@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 upstream/main 152 lines 3.0 kB view raw
1<?php 2 3final class PHUIPolicySectionView 4 extends AphrontTagView { 5 6 private $icon; 7 private $header; 8 private $documentationLink; 9 10 public function setHeader($header) { 11 $this->header = $header; 12 return $this; 13 } 14 15 public function getHeader() { 16 return $this->header; 17 } 18 19 public function setIcon($icon) { 20 $this->icon = $icon; 21 return $this; 22 } 23 24 public function getIcon() { 25 return $this->icon; 26 } 27 28 public function setDocumentationLink($name, $href) { 29 $link = phutil_tag( 30 'a', 31 array( 32 'href' => $href, 33 'target' => '_blank', 34 ), 35 $name); 36 37 $this->documentationLink = phutil_tag( 38 'div', 39 array( 40 'class' => 'phui-policy-section-view-link', 41 ), 42 array( 43 id(new PHUIIconView())->setIcon('fa-book'), 44 $link, 45 )); 46 47 return $this; 48 } 49 50 public function getDocumentationLink() { 51 return $this->documentationLink; 52 } 53 54 public function appendList(array $items) { 55 foreach ($items as $key => $item) { 56 $items[$key] = phutil_tag( 57 'li', 58 array( 59 'class' => 'remarkup-list-item', 60 ), 61 $item); 62 } 63 64 $list = phutil_tag( 65 'ul', 66 array( 67 'class' => 'remarkup-list', 68 ), 69 $items); 70 71 return $this->appendChild($list); 72 } 73 74 public function appendHint($content) { 75 $hint = phutil_tag( 76 'p', 77 array( 78 'class' => 'phui-policy-section-view-hint', 79 ), 80 array( 81 id(new PHUIIconView()) 82 ->setIcon('fa-sticky-note bluegrey'), 83 ' ', 84 pht('Note:'), 85 ' ', 86 $content, 87 )); 88 89 return $this->appendChild($hint); 90 } 91 92 public function appendParagraph($content) { 93 return $this->appendChild(phutil_tag('p', array(), $content)); 94 } 95 96 public function appendRulesView(PhabricatorPolicyRulesView $rules_view) { 97 return $this->appendChild( 98 phutil_tag( 99 'div', 100 array( 101 'class' => 'phui-policy-section-view-rules', 102 ), 103 $rules_view)); 104 } 105 106 protected function getTagAttributes() { 107 return array( 108 'class' => 'phui-policy-section-view', 109 ); 110 } 111 112 protected function getTagContent() { 113 require_celerity_resource('phui-policy-section-view-css'); 114 115 $icon_view = null; 116 $icon = $this->getIcon(); 117 if ($icon !== null) { 118 $icon_view = id(new PHUIIconView()) 119 ->setIcon($icon); 120 } 121 122 $header_view = phutil_tag( 123 'span', 124 array( 125 'class' => 'phui-policy-section-view-header-text', 126 ), 127 $this->getHeader()); 128 129 $header = phutil_tag( 130 'div', 131 array( 132 'class' => 'phui-policy-section-view-header', 133 ), 134 array( 135 $icon_view, 136 $header_view, 137 $this->getDocumentationLink(), 138 )); 139 140 return array( 141 $header, 142 phutil_tag( 143 'div', 144 array( 145 'class' => 'phui-policy-section-view-body', 146 ), 147 $this->renderChildren()), 148 ); 149 } 150 151 152}