@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 105 lines 2.6 kB view raw
1<?php 2 3final class PhabricatorProjectCardView extends AphrontTagView { 4 5 private $project; 6 private $viewer; 7 private $tag; 8 9 public function setProject(PhabricatorProject $project) { 10 $this->project = $project; 11 return $this; 12 } 13 14 public function setViewer(PhabricatorUser $viewer) { 15 $this->viewer = $viewer; 16 return $this; 17 } 18 19 public function setTag($tag) { 20 $this->tag = $tag; 21 return $this; 22 } 23 24 protected function getTagName() { 25 if ($this->tag) { 26 return $this->tag; 27 } 28 return 'div'; 29 } 30 31 protected function getTagAttributes() { 32 $classes = array(); 33 $classes[] = 'project-card-view'; 34 35 $color = $this->project->getColor(); 36 $classes[] = 'project-card-'.$color; 37 38 return array( 39 'class' => implode(' ', $classes), 40 ); 41 } 42 43 protected function getTagContent() { 44 45 $project = $this->project; 46 $viewer = $this->viewer; 47 require_celerity_resource('project-card-view-css'); 48 49 $icon = $project->getDisplayIconIcon(); 50 $icon_name = $project->getDisplayIconName(); 51 $tag = id(new PHUITagView()) 52 ->setIcon($icon) 53 ->setName($icon_name) 54 ->addClass('project-view-header-tag') 55 ->setType(PHUITagView::TYPE_SHADE); 56 57 $header = id(new PHUIHeaderView()) 58 ->setHeader(array($project->getDisplayName(), $tag)) 59 ->setUser($viewer) 60 ->setPolicyObject($project) 61 ->setImage($project->getProfileImageURI()); 62 63 if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) { 64 $header->setStatus('fa-check', 'bluegrey', pht('Active')); 65 } else { 66 $header->setStatus('fa-ban', 'red', pht('Archived')); 67 } 68 69 $description = null; 70 71 // This getProxy() feels hacky - see also PhabricatorProjectDatasource:67 72 $description_field = PhabricatorCustomField::getObjectField( 73 $project, 74 PhabricatorCustomField::ROLE_VIEW, 75 'std:project:internal:description'); 76 77 if ($description_field !== null) { 78 $description_field = $description_field->getProxy(); 79 80 $description = $description_field->getFieldValue(); 81 if (phutil_nonempty_string($description)) { 82 $description = PhabricatorMarkupEngine::summarizeSentence($description); 83 $description = new PHUIRemarkupView($viewer, $description); 84 85 $description = phutil_tag( 86 'div', 87 array('class' => 'project-card-body phui-header-shell'), 88 $description); 89 } 90 } 91 92 $card = phutil_tag( 93 'div', 94 array( 95 'class' => 'project-card-inner', 96 ), 97 array( 98 $header, 99 $description, 100 )); 101 102 return $card; 103 } 104 105}