@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 147 lines 3.7 kB view raw
1<?php 2 3abstract class DiffusionRepositoryManagementPanel 4 extends Phobject { 5 6 private $viewer; 7 private $repository; 8 private $controller; 9 10 final public function setViewer(PhabricatorUser $viewer) { 11 $this->viewer = $viewer; 12 return $this; 13 } 14 15 final public function getViewer() { 16 return $this->viewer; 17 } 18 19 final public function setRepository(PhabricatorRepository $repository) { 20 $this->repository = $repository; 21 return $this; 22 } 23 24 final public function getRepository() { 25 return $this->repository; 26 } 27 28 final public function getRequest() { 29 return $this->controller->getRequest(); 30 } 31 32 final public function setController(PhabricatorController $controller) { 33 $this->controller = $controller; 34 return $this; 35 } 36 37 final public function getManagementPanelKey() { 38 return $this->getPhobjectClassConstant('PANELKEY'); 39 } 40 41 abstract public function getManagementPanelLabel(); 42 abstract public function getManagementPanelOrder(); 43 abstract public function buildManagementPanelContent(); 44 public function buildManagementPanelCurtain() { return null; } 45 46 public function getManagementPanelIcon() { 47 return 'fa-pencil'; 48 } 49 50 public function getManagementPanelGroupKey() { 51 return DiffusionRepositoryManagementMainPanelGroup::PANELGROUPKEY; 52 } 53 54 public function shouldEnableForRepository( 55 PhabricatorRepository $repository) { 56 return true; 57 } 58 59 public static function getAllPanels() { 60 return id(new PhutilClassMapQuery()) 61 ->setAncestorClass(self::class) 62 ->setUniqueMethod('getManagementPanelKey') 63 ->setSortMethod('getManagementPanelOrder') 64 ->execute(); 65 } 66 67 final protected function newTimeline() { 68 return $this->controller->newTimeline($this->getRepository()); 69 } 70 71 final public function getPanelURI() { 72 $repository = $this->getRepository(); 73 $key = $this->getManagementPanelKey(); 74 return $repository->getPathURI("manage/{$key}/"); 75 } 76 77 final public function newEditEnginePage() { 78 $field_keys = $this->getEditEngineFieldKeys(); 79 if (!$field_keys) { 80 return null; 81 } 82 83 $key = $this->getManagementPanelKey(); 84 $label = $this->getManagementPanelLabel(); 85 $panel_uri = $this->getPanelURI(); 86 87 return id(new PhabricatorEditPage()) 88 ->setKey($key) 89 ->setLabel($label) 90 ->setViewURI($panel_uri) 91 ->setFieldKeys($field_keys); 92 } 93 94 protected function getEditEngineFieldKeys() { 95 return array(); 96 } 97 98 protected function getEditPageURI($page = null) { 99 if ($page === null) { 100 $page = $this->getManagementPanelKey(); 101 } 102 103 $repository = $this->getRepository(); 104 $id = $repository->getID(); 105 return "/diffusion/edit/{$id}/page/{$page}/"; 106 } 107 108 public function getPanelNavigationURI() { 109 return $this->getPanelURI(); 110 } 111 112 final protected function newActionList() { 113 $viewer = $this->getViewer(); 114 115 // Generating this ID allows to spawn the "Actions" menu 116 // on mobile on the header 117 $action_id = celerity_generate_unique_node_id(); 118 119 return id(new PhabricatorActionListView()) 120 ->setViewer($viewer) 121 ->setID($action_id); 122 } 123 124 final protected function newCurtainView() { 125 $viewer = $this->getViewer(); 126 127 return id(new PHUICurtainView()) 128 ->setViewer($viewer); 129 } 130 131 final protected function newBox($header_text, $body) { 132 $viewer = $this->getViewer(); 133 134 $header = id(new PHUIHeaderView()) 135 ->setViewer($viewer) 136 ->setHeader($header_text); 137 138 $view = id(new PHUIObjectBoxView()) 139 ->setViewer($viewer) 140 ->setHeader($header) 141 ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 142 ->appendChild($body); 143 144 return $view; 145 } 146 147}