Path: blob/master/src/view/phui/PHUICurtainObjectRefView.php
12249 views
<?php12final class PHUICurtainObjectRefView3extends AphrontTagView {45private $handle;6private $epoch;7private $highlighted;8private $exiled;9private $exileNote = false;1011public function setHandle(PhabricatorObjectHandle $handle) {12$this->handle = $handle;13return $this;14}1516public function setEpoch($epoch) {17$this->epoch = $epoch;18return $this;19}2021public function setHighlighted($highlighted) {22$this->highlighted = $highlighted;23return $this;24}2526public function setExiled($is_exiled, $note = false) {27$this->exiled = $is_exiled;28$this->exileNote = $note;29return $this;30}3132protected function getTagAttributes() {33$classes = array();34$classes[] = 'phui-curtain-object-ref-view';3536if ($this->highlighted) {37$classes[] = 'phui-curtain-object-ref-view-highlighted';38}3940if ($this->exiled) {41$classes[] = 'phui-curtain-object-ref-view-exiled';42}4344$classes = implode(' ', $classes);4546return array(47'class' => $classes,48);49}5051protected function getTagContent() {52require_celerity_resource('phui-curtain-object-ref-view-css');5354$viewer = $this->getViewer();55$handle = $this->handle;5657$more_rows = array();5859$epoch = $this->epoch;60if ($epoch !== null) {61$epoch_view = phabricator_dual_datetime($epoch, $viewer);6263$epoch_cells = array();6465$epoch_cells[] = phutil_tag(66'td',67array(68'class' => 'phui-curtain-object-ref-view-epoch-cell',69),70$epoch_view);7172$more_rows[] = phutil_tag('tr', array(), $epoch_cells);73}7475if ($this->exiled) {76if ($this->exileNote !== false) {77$exile_note = $this->exileNote;78} else {79$exile_note = pht('No View Permission');80}8182$exiled_view = array(83id(new PHUIIconView())->setIcon('fa-eye-slash red'),84' ',85$exile_note,86);8788$exiled_cells = array();89$exiled_cells[] = phutil_tag(90'td',91array(92'class' => 'phui-curtain-object-ref-view-exiled-cell',93),94$exiled_view);9596$more_rows[] = phutil_tag('tr', array(), $exiled_cells);97}9899$header_cells = array();100101$image_view = $this->newImage();102103if ($more_rows) {104$row_count = 1 + count($more_rows);105} else {106$row_count = null;107}108109$header_cells[] = phutil_tag(110'td',111array(112'rowspan' => $row_count,113'class' => 'phui-curtain-object-ref-view-image-cell',114),115$image_view);116117$title_view = $this->newTitle();118119$header_cells[] = phutil_tag(120'td',121array(122'class' => 'phui-curtain-object-ref-view-title-cell',123),124$title_view);125126$rows = array();127128if (!$more_rows) {129$title_row_class = 'phui-curtain-object-ref-view-without-content';130} else {131$title_row_class = 'phui-curtain-object-ref-view-with-content';132}133134$rows[] = phutil_tag(135'tr',136array(137'class' => $title_row_class,138),139$header_cells);140141$body = phutil_tag(142'tbody',143array(),144array(145$rows,146$more_rows,147));148149return phutil_tag('table', array(), $body);150}151152private function newTitle() {153$title_view = null;154$handle = $this->handle;155156if ($handle) {157$title_view = $handle->renderLink();158}159160return $title_view;161}162163private function newImage() {164$image_uri = $this->getImageURI();165$target_uri = $this->getTargetURI();166167$icon_view = null;168if ($image_uri == null) {169$icon_view = $this->newIconView();170}171172if ($image_uri !== null) {173$image_view = javelin_tag(174'a',175array(176'style' => sprintf('background-image: url(%s)', $image_uri),177'href' => $target_uri,178'aural' => false,179));180} else if ($icon_view !== null) {181$image_view = javelin_tag(182'a',183array(184'href' => $target_uri,185'class' => 'phui-curtain-object-ref-view-icon-image',186'aural' => false,187),188$icon_view);189} else {190$image_view = null;191}192193return $image_view;194}195196private function getTargetURI() {197$target_uri = null;198$handle = $this->handle;199200if ($handle) {201$target_uri = $handle->getURI();202}203204return $target_uri;205}206207private function getImageURI() {208$image_uri = null;209$handle = $this->handle;210211if ($handle) {212$image_uri = $handle->getImageURI();213}214215return $image_uri;216}217218private function newIconView() {219$handle = $this->handle;220221if ($handle) {222$icon_view = id(new PHUIIconView())223->setIcon($handle->getIcon());224}225226return $icon_view;227}228229230}231232233