Path: blob/master/src/infrastructure/graph/ManiphestTaskGraph.php
12241 views
<?php12final class ManiphestTaskGraph3extends PhabricatorObjectGraph {45private $seedMaps = array();6private $isStandalone;78protected function getEdgeTypes() {9return array(10ManiphestTaskDependedOnByTaskEdgeType::EDGECONST,11ManiphestTaskDependsOnTaskEdgeType::EDGECONST,12);13}1415protected function getParentEdgeType() {16return ManiphestTaskDependsOnTaskEdgeType::EDGECONST;17}1819protected function newQuery() {20return new ManiphestTaskQuery();21}2223protected function isClosed($object) {24return $object->isClosed();25}2627public function setIsStandalone($is_standalone) {28$this->isStandalone = $is_standalone;29return $this;30}3132public function getIsStandalone() {33return $this->isStandalone;34}3536protected function newTableRow($phid, $object, $trace) {37$viewer = $this->getViewer();3839Javelin::initBehavior('phui-hovercards');4041if ($object) {42$status = $object->getStatus();43$priority = $object->getPriority();44$status_icon = ManiphestTaskStatus::getStatusIcon($status);45$status_name = ManiphestTaskStatus::getTaskStatusName($status);4647$priority_color = ManiphestTaskPriority::getTaskPriorityColor($priority);48if ($object->isClosed()) {49$priority_color = 'grey';50}5152$status = array(53id(new PHUIIconView())->setIcon($status_icon, $priority_color),54' ',55$status_name,56);5758$owner_phid = $object->getOwnerPHID();59if ($owner_phid) {60$assigned = $viewer->renderHandle($owner_phid);61} else {62$assigned = phutil_tag('em', array(), pht('None'));63}6465$link = javelin_tag(66'a',67array(68'href' => $object->getURI(),69'sigil' => 'hovercard',70'meta' => array(71'hovercardSpec' => array(72'objectPHID' => $object->getPHID(),73),74),75),76$object->getTitle());7778$link = array(79phutil_tag(80'span',81array(82'class' => 'object-name',83),84$object->getMonogram()),85' ',86$link,87);8889$subtype_tag = null;9091$subtype = $object->newSubtypeObject();92if ($subtype && $subtype->hasTagView()) {93$subtype_tag = $subtype->newTagView()94->setSlimShady(true);95}96} else {97$status = null;98$assigned = null;99$subtype_tag = null;100$link = $viewer->renderHandle($phid);101}102103if ($this->isParentTask($phid)) {104$marker = 'fa-chevron-circle-up bluegrey';105$marker_tip = pht('Direct Parent');106} else if ($this->isChildTask($phid)) {107$marker = 'fa-chevron-circle-down bluegrey';108$marker_tip = pht('Direct Subtask');109} else {110$marker = null;111}112113if ($marker) {114$marker = id(new PHUIIconView())115->setIcon($marker)116->addSigil('has-tooltip')117->setMetadata(118array(119'tip' => $marker_tip,120'align' => 'E',121));122}123124return array(125$marker,126$trace,127$status,128$subtype_tag,129$assigned,130$link,131);132}133134protected function newTable(AphrontTableView $table) {135$subtype_map = id(new ManiphestTask())->newEditEngineSubtypeMap();136$has_subtypes = ($subtype_map->getCount() > 1);137138return $table139->setHeaders(140array(141null,142null,143pht('Status'),144pht('Subtype'),145pht('Assigned'),146pht('Task'),147))148->setColumnClasses(149array(150'nudgeright',151'threads',152'graph-status',153null,154null,155'wide pri object-link',156))157->setColumnVisibility(158array(159true,160!$this->getRenderOnlyAdjacentNodes(),161true,162$has_subtypes,163))164->setDeviceVisibility(165array(166true,167168// On mobile, we only show the actual graph drawing if we're on the169// standalone page, since it can take over the screen otherwise.170$this->getIsStandalone(),171true,172173// On mobile, don't show subtypes since they're relatively less174// important and we're more pressured for space.175false,176));177}178179private function isParentTask($task_phid) {180$map = $this->getSeedMap(ManiphestTaskDependedOnByTaskEdgeType::EDGECONST);181return isset($map[$task_phid]);182}183184private function isChildTask($task_phid) {185$map = $this->getSeedMap(ManiphestTaskDependsOnTaskEdgeType::EDGECONST);186return isset($map[$task_phid]);187}188189private function getSeedMap($type) {190if (!isset($this->seedMaps[$type])) {191$maps = $this->getEdges($type);192$phids = idx($maps, $this->getSeedPHID(), array());193$phids = array_fuse($phids);194$this->seedMaps[$type] = $phids;195}196197return $this->seedMaps[$type];198}199200protected function newEllipsisRow() {201return array(202null,203null,204null,205null,206null,207pht("\xC2\xB7 \xC2\xB7 \xC2\xB7"),208);209}210211212}213214215