@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
at recaptime-dev/main 87 lines 1.9 kB view raw
1<?php 2 3/** 4 * Convenience class for rendering a list of handles. 5 * 6 * This class simplifies rendering a list of handles and improves loading and 7 * caching semantics in the rendering pipeline by delaying bulk loads until the 8 * last possible moment. 9 */ 10final class PHUIHandleListView 11 extends AphrontTagView { 12 13 private $handleList; 14 private $asInline; 15 private $asText; 16 private $glyphLimit; 17 18 public function setHandleList(PhabricatorHandleList $list) { 19 $this->handleList = $list; 20 return $this; 21 } 22 23 public function setAsInline($inline) { 24 $this->asInline = $inline; 25 return $this; 26 } 27 28 public function getAsInline() { 29 return $this->asInline; 30 } 31 32 public function setAsText($as_text) { 33 $this->asText = $as_text; 34 return $this; 35 } 36 37 public function getAsText() { 38 return $this->asText; 39 } 40 41 public function setGlyphLimit($glyph_limit) { 42 $this->glyphLimit = $glyph_limit; 43 return $this; 44 } 45 46 public function getGlyphLimit() { 47 return $this->glyphLimit; 48 } 49 50 protected function getTagName() { 51 if ($this->getAsText()) { 52 return null; 53 } else { 54 // TODO: It would be nice to render this with a proper <ul />, at least 55 // in block mode, but don't stir the waters up too much for now. 56 return 'span'; 57 } 58 } 59 60 protected function getTagContent() { 61 $list = $this->handleList; 62 63 $glyph_limit = $this->getGlyphLimit(); 64 65 $items = array(); 66 foreach ($list as $handle) { 67 $view = $list->renderHandle($handle->getPHID()) 68 ->setShowHovercard(true) 69 ->setAsText($this->getAsText()); 70 71 if ($glyph_limit) { 72 $view->setGlyphLimit($glyph_limit); 73 } 74 75 $items[] = $view; 76 } 77 78 if ($this->getAsInline()) { 79 $items = phutil_implode_html(', ', $items); 80 } else { 81 $items = phutil_implode_html(phutil_tag('br'), $items); 82 } 83 84 return $items; 85 } 86 87}