2012-12-07 22:32:14 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorMenuItemView extends AphrontView {
|
|
|
|
|
|
|
|
const TYPE_LINK = 'type-link';
|
|
|
|
const TYPE_SPACER = 'type-spacer';
|
|
|
|
const TYPE_LABEL = 'type-label';
|
|
|
|
|
|
|
|
private $name;
|
|
|
|
private $href;
|
|
|
|
private $type = self::TYPE_LINK;
|
|
|
|
private $isExternal;
|
|
|
|
private $key;
|
|
|
|
private $classes = array();
|
2012-12-07 22:33:03 +01:00
|
|
|
private $workflow;
|
|
|
|
private $sortOrder = 1.0;
|
|
|
|
private $icon;
|
|
|
|
private $selected;
|
|
|
|
|
|
|
|
public function setSelected($selected) {
|
|
|
|
$this->selected = $selected;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSelected() {
|
|
|
|
return $this->selected;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIcon($icon) {
|
|
|
|
$this->icon = $icon;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIcon() {
|
|
|
|
return $this->icon;
|
|
|
|
}
|
2012-12-07 22:32:14 +01:00
|
|
|
|
|
|
|
public function setKey($key) {
|
|
|
|
$this->key = $key;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getKey() {
|
|
|
|
return $this->key;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setType($type) {
|
|
|
|
$this->type = $type;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getType() {
|
|
|
|
return $this->type;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHref($href) {
|
|
|
|
$this->href = $href;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHref() {
|
|
|
|
return $this->href;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setName($name) {
|
|
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName() {
|
|
|
|
return $this->name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setIsExternal($is_external) {
|
|
|
|
$this->isExternal = $is_external;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getIsExternal() {
|
|
|
|
return $this->isExternal;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function addClass($class) {
|
|
|
|
$this->classes[] = $class;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
public function setWorkflow($workflow) {
|
|
|
|
$this->workflow = $workflow;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSortOrder($order) {
|
|
|
|
$this->sortOrder = $order;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSortOrder() {
|
|
|
|
return $this->sortOrder;
|
2012-12-07 22:32:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
$classes = array(
|
|
|
|
'phabricator-menu-item-view',
|
|
|
|
'phabricator-menu-item-'.$this->type,
|
|
|
|
);
|
|
|
|
|
|
|
|
$classes = array_merge($classes, $this->classes);
|
|
|
|
|
2012-12-07 22:33:03 +01:00
|
|
|
$name = null;
|
|
|
|
if ($this->name) {
|
|
|
|
$external = null;
|
|
|
|
if ($this->isExternal) {
|
|
|
|
$external = " \xE2\x86\x97";
|
|
|
|
}
|
|
|
|
$name = phutil_render_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-menu-item-name',
|
|
|
|
),
|
|
|
|
phutil_escape_html($this->name.$external));
|
|
|
|
}
|
|
|
|
|
|
|
|
return javelin_render_tag(
|
2012-12-07 22:32:14 +01:00
|
|
|
$this->href ? 'a' : 'div',
|
|
|
|
array(
|
2012-12-07 22:33:03 +01:00
|
|
|
'class' => implode(' ', $classes),
|
|
|
|
'href' => $this->href,
|
|
|
|
'sigil' => $this->workflow ? 'workflow' : null,
|
2012-12-07 22:32:14 +01:00
|
|
|
),
|
2012-12-07 22:33:03 +01:00
|
|
|
$this->renderChildren().
|
|
|
|
$name);
|
2012-12-07 22:32:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|