Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
PHP
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340<?php
final class PHUIObjectBoxView extends AphrontTagView {
private $headerText; private $color; private $background; private $tabGroups = array(); private $formErrors = null; private $infoView; private $form; private $validationException; private $header; private $flush; private $actionListID; private $objectList; private $table; private $collapsed = false; private $anchor; private $pager;
private $showAction; private $hideAction; private $showHideHref; private $showHideContent; private $showHideOpen;
private $propertyLists = array(); private $tailButtons = array();
const COLOR_RED = 'red'; const COLOR_BLUE = 'blue'; const COLOR_GREEN = 'green'; const COLOR_YELLOW = 'yellow';
const BLUE = 'phui-box-blue'; const BLUE_PROPERTY = 'phui-box-blue-property'; const WHITE_CONFIG = 'phui-box-white-config'; const GREY = 'phui-box-grey';
public function addPropertyList(PHUIPropertyListView $property_list) { $this->propertyLists[] = $property_list;
$action_list = $property_list->getActionList(); if ($action_list) { $this->actionListID = celerity_generate_unique_node_id(); $action_list->setId($this->actionListID); }
return $this; }
public function setHeaderText($text) { $this->headerText = $text; return $this; }
public function setColor($color) { $this->color = $color; return $this; }
public function setBackground($color) { $this->background = $color; return $this; }
public function setFormErrors(array $errors, $title = null) { if ($errors) { $this->formErrors = id(new PHUIInfoView()) ->setTitle($title) ->setErrors($errors); } return $this; }
public function addTabGroup(PHUITabGroupView $view) { $this->tabGroups[] = $view; return $this; }
public function setInfoView(PHUIInfoView $view) { $this->infoView = $view; return $this; }
public function setForm($form) { $this->form = $form; return $this; }
public function setHeader($header) { $this->header = $header; return $this; }
public function setFlush($flush) { $this->flush = $flush; return $this; }
public function setObjectList($list) { $this->objectList = $list; return $this; }
public function setTable($table) { $this->collapsed = true; $this->table = $table; return $this; }
public function setCollapsed($collapsed) { $this->collapsed = $collapsed; return $this; }
public function setPager(PHUIPagerView $pager) { $this->pager = $pager; return $this; }
public function setAnchor(PhabricatorAnchorView $anchor) { $this->anchor = $anchor; return $this; }
public function setShowHide($show, $hide, $content, $href, $open = false) { $this->showAction = $show; $this->hideAction = $hide; $this->showHideContent = $content; $this->showHideHref = $href; $this->showHideOpen = $open; return $this; }
public function setValidationException( ?PhabricatorApplicationTransactionValidationException $ex = null) { $this->validationException = $ex; return $this; }
public function newTailButton() { $button = id(new PHUIButtonView()) ->setTag('a') ->setColor(PHUIButtonView::GREY);
$this->tailButtons[] = $button;
return $button; }
protected function getTagAttributes() { $classes = array(); $classes[] = 'phui-box'; $classes[] = 'phui-box-border'; $classes[] = 'phui-object-box'; $classes[] = 'mlt mll mlr';
if ($this->color) { $classes[] = 'phui-object-box-'.$this->color; }
if ($this->collapsed) { $classes[] = 'phui-object-box-collapsed'; }
if ($this->flush) { $classes[] = 'phui-object-box-flush'; }
if ($this->background) { $classes[] = $this->background; }
return array( 'class' => implode(' ', $classes), ); }
protected function getTagContent() { require_celerity_resource('phui-box-css'); require_celerity_resource('phui-object-box-css');
$header = $this->header;
if ($this->headerText) { $header = id(new PHUIHeaderView()) ->setHeader($this->headerText); }
$showhide = null; if ($this->showAction !== null) { if (!$header) { $header = new PHUIHeaderView(); }
Javelin::initBehavior('phabricator-reveal-content');
$hide_action_id = celerity_generate_unique_node_id(); $show_action_id = celerity_generate_unique_node_id(); $content_id = celerity_generate_unique_node_id();
$hide_style = ($this->showHideOpen ? 'display: none;': null); $show_style = ($this->showHideOpen ? null : 'display: none;'); $hide_action = id(new PHUIButtonView()) ->setTag('a') ->addSigil('reveal-content') ->setID($hide_action_id) ->setStyle($hide_style) ->setIcon('fa-search') ->setHref($this->showHideHref) ->setMetaData( array( 'hideIDs' => array($hide_action_id), 'showIDs' => array($content_id, $show_action_id), )) ->setText($this->showAction);
$show_action = id(new PHUIButtonView()) ->setTag('a') ->addSigil('reveal-content') ->setStyle($show_style) ->setIcon('fa-search') ->setHref('#') ->setID($show_action_id) ->setMetaData( array( 'hideIDs' => array($content_id, $show_action_id), 'showIDs' => array($hide_action_id), )) ->setText($this->hideAction);
$header->addActionLink($hide_action); $header->addActionLink($show_action);
$showhide = array( phutil_tag( 'div', array( 'class' => 'phui-object-box-hidden-content', 'id' => $content_id, 'style' => $show_style, ), $this->showHideContent), ); }
if ($this->actionListID) { $icon_id = celerity_generate_unique_node_id(); $icon = id(new PHUIIconView()) ->setIcon('fa-bars'); $meta = array( 'map' => array( $this->actionListID => 'phabricator-action-list-toggle', $icon_id => 'phuix-dropdown-open', ), ); $mobile_menu = id(new PHUIButtonView()) ->setTag('a') ->setText(pht('Actions')) ->setHref('#') ->setIcon($icon) ->addClass('phui-mobile-menu') ->setID($icon_id) ->addSigil('jx-toggle-class') ->setMetadata($meta); $header->addActionLink($mobile_menu); }
$ex = $this->validationException; $exception_errors = null; if ($ex) { $messages = array(); foreach ($ex->getErrors() as $error) { $messages[] = $error->getMessage(); } if ($messages) { $exception_errors = id(new PHUIInfoView()) ->setErrors($messages); } }
if ($this->propertyLists) { $lists = new PHUIPropertyGroupView();
$ii = 0; foreach ($this->propertyLists as $list) { if ($ii > 0 || $this->tabGroups) { $list->addClass('phui-property-list-section-noninitial'); }
$lists->addPropertyList($list); $ii++; } } else { $lists = null; }
$pager = null; if ($this->pager) { if ($this->pager->willShowPagingControls()) { $pager = phutil_tag_div('phui-object-box-pager', $this->pager); } }
$content = array( ($this->showHideOpen == false ? $this->anchor : null), $header, $this->infoView, $exception_errors, $this->form, $this->tabGroups, $showhide, ($this->showHideOpen == true ? $this->anchor : null), $lists, $this->table, $pager, $this->formErrors, $this->renderChildren(), );
if ($this->objectList) { $content[] = $this->objectList; }
if ($this->tailButtons) { $content[] = phutil_tag( 'div', array( 'class' => 'phui-object-box-tail-buttons', ), $this->tailButtons); }
return $content; }}