Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUIHeaderView.php
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | if ($this->image) { | ||||
'class' => 'phui-header-image', | 'class' => 'phui-header-image', | ||||
'style' => 'background-image: url('.$this->image.')', | 'style' => 'background-image: url('.$this->image.')', | ||||
), | ), | ||||
' '); | ' '); | ||||
} | } | ||||
$header = array(); | $header = array(); | ||||
$header[] = $this->renderObjectSpaceInformation(); | |||||
if ($this->objectName) { | |||||
$header[] = array( | |||||
phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => '/'.$this->objectName, | |||||
), | |||||
$this->objectName), | |||||
' ', | |||||
); | |||||
} | |||||
if ($this->actionLinks) { | if ($this->actionLinks) { | ||||
$actions = array(); | $actions = array(); | ||||
foreach ($this->actionLinks as $button) { | foreach ($this->actionLinks as $button) { | ||||
$button->setColor(PHUIButtonView::SIMPLE); | $button->setColor(PHUIButtonView::SIMPLE); | ||||
$button->addClass(PHUI::MARGIN_SMALL_LEFT); | $button->addClass(PHUI::MARGIN_SMALL_LEFT); | ||||
$button->addClass('phui-header-action-link'); | $button->addClass('phui-header-action-link'); | ||||
$actions[] = $button; | $actions[] = $button; | ||||
} | } | ||||
Show All 10 Lines | if ($this->buttonBar) { | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phui-header-action-links', | 'class' => 'phui-header-action-links', | ||||
), | ), | ||||
$this->buttonBar); | $this->buttonBar); | ||||
} | } | ||||
$header[] = $this->header; | $header[] = $this->header; | ||||
if ($this->objectName) { | |||||
array_unshift( | |||||
$header, | |||||
phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => '/'.$this->objectName, | |||||
), | |||||
$this->objectName), | |||||
' '); | |||||
} | |||||
if ($this->tags) { | if ($this->tags) { | ||||
$header[] = ' '; | $header[] = ' '; | ||||
$header[] = phutil_tag( | $header[] = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'phui-header-tags', | 'class' => 'phui-header-tags', | ||||
), | ), | ||||
array_interleave(' ', $this->tags)); | array_interleave(' ', $this->tags)); | ||||
Show All 40 Lines | return array( | ||||
array( | array( | ||||
'class' => 'phui-header-view grouped', | 'class' => 'phui-header-view grouped', | ||||
), | ), | ||||
$header), | $header), | ||||
); | ); | ||||
} | } | ||||
private function renderPolicyProperty(PhabricatorPolicyInterface $object) { | private function renderPolicyProperty(PhabricatorPolicyInterface $object) { | ||||
$policies = PhabricatorPolicyQuery::loadPolicies( | $viewer = $this->getUser(); | ||||
$this->getUser(), | |||||
$object); | $policies = PhabricatorPolicyQuery::loadPolicies($viewer, $object); | ||||
$view_capability = PhabricatorPolicyCapability::CAN_VIEW; | $view_capability = PhabricatorPolicyCapability::CAN_VIEW; | ||||
$policy = idx($policies, $view_capability); | $policy = idx($policies, $view_capability); | ||||
if (!$policy) { | if (!$policy) { | ||||
return null; | return null; | ||||
} | } | ||||
$phid = $object->getPHID(); | $phid = $object->getPHID(); | ||||
$icon = id(new PHUIIconView()) | $icon = id(new PHUIIconView()) | ||||
->setIconFont($policy->getIcon().' bluegrey'); | ->setIconFont($policy->getIcon().' bluegrey'); | ||||
$link = javelin_tag( | $link = javelin_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => 'policy-link', | 'class' => 'policy-link', | ||||
'href' => '/policy/explain/'.$phid.'/'.$view_capability.'/', | 'href' => '/policy/explain/'.$phid.'/'.$view_capability.'/', | ||||
'sigil' => 'workflow', | 'sigil' => 'workflow', | ||||
), | ), | ||||
$policy->getShortName()); | $policy->getShortName()); | ||||
return array($icon, $link); | return array($icon, $link); | ||||
} | } | ||||
private function renderObjectSpaceInformation() { | |||||
$viewer = $this->getUser(); | |||||
$object = $this->policyObject; | |||||
if (!$object) { | |||||
return; | |||||
} | |||||
if (!($object instanceof PhabricatorSpacesInterface)) { | |||||
return; | |||||
} | |||||
$space_phid = $object->getSpacePHID(); | |||||
if ($space_phid === null) { | |||||
$default_space = PhabricatorSpacesNamespaceQuery::getDefaultSpace(); | |||||
if ($default_space) { | |||||
$space_phid = $default_space->getPHID(); | |||||
} | |||||
} | |||||
if ($space_phid === null) { | |||||
return; | |||||
} | |||||
return phutil_tag( | |||||
'span', | |||||
array( | |||||
'class' => 'spaces-name', | |||||
), | |||||
array( | |||||
$viewer->renderHandle($space_phid), | |||||
' | ', | |||||
)); | |||||
} | |||||
} | } |