@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 71 lines 1.7 kB view raw
1<?php 2 3final class PhabricatorProjectBuiltinsExample extends PhabricatorUIExample { 4 5 public function getName() { 6 return pht('Project Builtin Images'); 7 } 8 9 public function getDescription() { 10 return pht('Builtin Project Images.'); 11 } 12 13 public function getCategory() { 14 return pht('Catalogs'); 15 } 16 17 public function renderExample() { 18 $viewer = $this->getRequest()->getUser(); 19 20 $root = dirname(phutil_get_library_root('phabricator')); 21 $root = $root.'/resources/builtin/projects/v3/'; 22 23 Javelin::initBehavior('phabricator-tooltips', array()); 24 25 $map = array(); 26 $builtin_map = id(new FileFinder($root)) 27 ->withType('f') 28 ->withFollowSymlinks(true) 29 ->find(); 30 31 $images = array(); 32 foreach ($builtin_map as $image) { 33 $file = PhabricatorFile::loadBuiltin($viewer, 'projects/v3/'.$image); 34 $images[$file->getPHID()] = array( 35 'uri' => $file->getBestURI(), 36 'tip' => 'v3/'.$image, 37 ); 38 } 39 40 $buttons = array(); 41 foreach ($images as $phid => $spec) { 42 $button = javelin_tag( 43 'img', 44 array( 45 'height' => 100, 46 'width' => 100, 47 'src' => $spec['uri'], 48 'style' => 'float: left; padding: 4px;', 49 'sigil' => 'has-tooltip', 50 'meta' => array( 51 'tip' => $spec['tip'], 52 'size' => 300, 53 ), 54 )); 55 56 $buttons[] = $button; 57 } 58 59 $wrap1 = id(new PHUIObjectBoxView()) 60 ->setHeaderText(pht('Images')) 61 ->appendChild($buttons) 62 ->addClass('grouped'); 63 64 return phutil_tag( 65 'div', 66 array(), 67 array( 68 $wrap1, 69 )); 70 } 71}