Changeset View
Changeset View
Standalone View
Standalone View
src/view/phui/PHUIObjectBoxView.php
<?php | <?php | ||||
final class PHUIObjectBoxView extends AphrontView { | final class PHUIObjectBoxView extends AphrontView { | ||||
private $headerText; | private $headerText; | ||||
private $headerColor; | private $color; | ||||
private $formErrors = null; | private $formErrors = null; | ||||
private $formSaved = false; | private $formSaved = false; | ||||
private $infoView; | private $infoView; | ||||
private $form; | private $form; | ||||
private $validationException; | private $validationException; | ||||
private $header; | private $header; | ||||
private $flush; | private $flush; | ||||
private $id; | private $id; | ||||
private $sigils = array(); | private $sigils = array(); | ||||
private $metadata; | private $metadata; | ||||
private $actionListID; | private $actionListID; | ||||
private $objectList; | private $objectList; | ||||
private $tabs = array(); | private $tabs = array(); | ||||
private $propertyLists = array(); | private $propertyLists = array(); | ||||
const COLOR_RED = 'red'; | |||||
const COLOR_BLUE = 'blue'; | |||||
const COLOR_GREEN = 'green'; | |||||
const COLOR_YELLOW = 'yellow'; | |||||
public function addSigil($sigil) { | public function addSigil($sigil) { | ||||
$this->sigils[] = $sigil; | $this->sigils[] = $sigil; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setMetadata(array $metadata) { | public function setMetadata(array $metadata) { | ||||
$this->metadata = $metadata; | $this->metadata = $metadata; | ||||
return $this; | return $this; | ||||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | public function addPropertyList( | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHeaderText($text) { | public function setHeaderText($text) { | ||||
$this->headerText = $text; | $this->headerText = $text; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setHeaderColor($color) { | public function setColor($color) { | ||||
$this->headerColor = $color; | $this->color = $color; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setFormErrors(array $errors, $title = null) { | public function setFormErrors(array $errors, $title = null) { | ||||
if ($errors) { | if ($errors) { | ||||
$this->formErrors = id(new PHUIInfoView()) | $this->formErrors = id(new PHUIInfoView()) | ||||
->setTitle($title) | ->setTitle($title) | ||||
->setErrors($errors); | ->setErrors($errors); | ||||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | public function setValidationException( | ||||
$this->validationException = $ex; | $this->validationException = $ex; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function render() { | public function render() { | ||||
require_celerity_resource('phui-object-box-css'); | require_celerity_resource('phui-object-box-css'); | ||||
$header_color = null; | |||||
if ($this->headerColor) { | |||||
$header_color = $this->headerColor; | |||||
} | |||||
$header = null; | |||||
if ($this->header) { | |||||
$header = $this->header; | $header = $this->header; | ||||
$header->setHeaderColor($header_color); | if ($this->headerText) { | ||||
} else if ($this->headerText) { | |||||
$header = id(new PHUIHeaderView()) | $header = id(new PHUIHeaderView()) | ||||
->setHeader($this->headerText) | ->setHeader($this->headerText); | ||||
->setHeaderColor($header_color); | |||||
} | } | ||||
if ($this->actionListID) { | if ($this->actionListID) { | ||||
$icon_id = celerity_generate_unique_node_id(); | $icon_id = celerity_generate_unique_node_id(); | ||||
$icon = id(new PHUIIconView()) | $icon = id(new PHUIIconView()) | ||||
->setIconFont('fa-bars'); | ->setIconFont('fa-bars'); | ||||
$meta = array( | $meta = array( | ||||
'map' => array( | 'map' => array( | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | $content = id(new PHUIBoxView()) | ||||
)) | )) | ||||
->setBorder(true) | ->setBorder(true) | ||||
->setID($this->id) | ->setID($this->id) | ||||
->addMargin(PHUI::MARGIN_LARGE_TOP) | ->addMargin(PHUI::MARGIN_LARGE_TOP) | ||||
->addMargin(PHUI::MARGIN_LARGE_LEFT) | ->addMargin(PHUI::MARGIN_LARGE_LEFT) | ||||
->addMargin(PHUI::MARGIN_LARGE_RIGHT) | ->addMargin(PHUI::MARGIN_LARGE_RIGHT) | ||||
->addClass('phui-object-box'); | ->addClass('phui-object-box'); | ||||
if ($this->color) { | |||||
$content->addClass('phui-object-box-'.$this->color); | |||||
} | |||||
if ($this->tabs) { | if ($this->tabs) { | ||||
$content->addSigil('phui-object-box'); | $content->addSigil('phui-object-box'); | ||||
$content->setMetadata( | $content->setMetadata( | ||||
array( | array( | ||||
'tabMap' => $tab_map, | 'tabMap' => $tab_map, | ||||
)); | )); | ||||
} | } | ||||
if ($this->flush) { | if ($this->flush) { | ||||
$content->addClass('phui-object-box-flush'); | $content->addClass('phui-object-box-flush'); | ||||
} | } | ||||
$content->addClass('phui-object-box-'.$header_color); | |||||
foreach ($this->sigils as $sigil) { | foreach ($this->sigils as $sigil) { | ||||
$content->addSigil($sigil); | $content->addSigil($sigil); | ||||
} | } | ||||
if ($this->metadata !== null) { | if ($this->metadata !== null) { | ||||
$content->setMetadata($this->metadata); | $content->setMetadata($this->metadata); | ||||
} | } | ||||
if ($this->objectList) { | if ($this->objectList) { | ||||
$content->appendChild($this->objectList); | $content->appendChild($this->objectList); | ||||
} | } | ||||
return $content; | return $content; | ||||
} | } | ||||
} | } |