Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / project / engineextension / PhabricatorProjectsCurtainExtension.php
blob7251323415cf827bbe56657a4135faf5581260fa
1 <?php
3 final class PhabricatorProjectsCurtainExtension
4 extends PHUICurtainExtension {
6 const EXTENSIONKEY = 'projects.projects';
8 public function shouldEnableForObject($object) {
9 return ($object instanceof PhabricatorProjectInterface);
12 public function getExtensionApplication() {
13 return new PhabricatorProjectApplication();
16 public function buildCurtainPanel($object) {
17 $viewer = $this->getViewer();
19 $project_phids = PhabricatorEdgeQuery::loadDestinationPHIDs(
20 $object->getPHID(),
21 PhabricatorProjectObjectHasProjectEdgeType::EDGECONST);
23 $has_projects = (bool)$project_phids;
24 $project_phids = array_reverse($project_phids);
25 $handles = $viewer->loadHandles($project_phids);
27 // If this object can appear on boards, build the workboard annotations.
28 // Some day, this might be a generic interface. For now, only tasks can
29 // appear on boards.
30 $can_appear_on_boards = ($object instanceof ManiphestTask);
32 $annotations = array();
33 if ($has_projects && $can_appear_on_boards) {
34 $engine = id(new PhabricatorBoardLayoutEngine())
35 ->setViewer($viewer)
36 ->setBoardPHIDs($project_phids)
37 ->setObjectPHIDs(array($object->getPHID()))
38 ->executeLayout();
40 // TDOO: Generalize this UI and move it out of Maniphest.
41 require_celerity_resource('maniphest-task-summary-css');
43 foreach ($project_phids as $project_phid) {
44 $handle = $handles[$project_phid];
46 $columns = $engine->getObjectColumns(
47 $project_phid,
48 $object->getPHID());
50 $annotation = array();
51 foreach ($columns as $column) {
52 $project_id = $column->getProject()->getID();
54 $column_name = pht('(%s)', $column->getDisplayName());
55 $column_link = phutil_tag(
56 'a',
57 array(
58 'href' => $column->getWorkboardURI(),
59 'class' => 'maniphest-board-link',
61 $column_name);
63 $annotation[] = $column_link;
66 if ($annotation) {
67 $annotations[$project_phid] = array(
68 ' ',
69 phutil_implode_html(', ', $annotation),
76 if ($has_projects) {
77 $list = id(new PHUIHandleTagListView())
78 ->setHandles($handles)
79 ->setAnnotations($annotations)
80 ->setShowHovercards(true);
81 } else {
82 $list = phutil_tag('em', array(), pht('None'));
85 return $this->newPanel()
86 ->setHeaderText(pht('Tags'))
87 ->setOrder(10000)
88 ->appendChild($list);