Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/differential/phid/DifferentialRevisionPHIDType.php b/src/applications/differential/phid/DifferentialRevisionPHIDType.php
index a117690d66..a7d3c9f4a7 100644
--- a/src/applications/differential/phid/DifferentialRevisionPHIDType.php
+++ b/src/applications/differential/phid/DifferentialRevisionPHIDType.php
@@ -1,88 +1,79 @@
<?php
final class DifferentialRevisionPHIDType extends PhabricatorPHIDType {
const TYPECONST = 'DREV';
public function getTypeName() {
return pht('Differential Revision');
}
public function newObject() {
return new DifferentialRevision();
}
public function getPHIDTypeApplicationClass() {
return 'PhabricatorDifferentialApplication';
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new DifferentialRevisionQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$revision = $objects[$phid];
$title = $revision->getTitle();
$monogram = $revision->getMonogram();
$uri = $revision->getURI();
$handle
->setName($monogram)
->setURI($uri)
->setFullName("{$monogram}: {$title}");
if ($revision->isClosed()) {
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
}
-
- $icon = $revision->getStatusIcon();
- $color = $revision->getStatusIconColor();
- $name = $revision->getStatusDisplayName();
-
- $handle
- ->setStateIcon($icon)
- ->setStateColor($color)
- ->setStateName($name);
}
}
public function canLoadNamedObject($name) {
return preg_match('/^D[1-9]\d*$/i', $name);
}
public function loadNamedObjects(
PhabricatorObjectQuery $query,
array $names) {
$id_map = array();
foreach ($names as $name) {
$id = (int)substr($name, 1);
$id_map[$id][] = $name;
}
$objects = id(new DifferentialRevisionQuery())
->setViewer($query->getViewer())
->withIDs(array_keys($id_map))
->execute();
$results = array();
foreach ($objects as $id => $object) {
foreach (idx($id_map, $id, array()) as $name) {
$results[$name] = $object;
}
}
return $results;
}
}
diff --git a/src/applications/maniphest/controller/ManiphestTaskDetailController.php b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
index c5dba7d3b5..00b884d610 100644
--- a/src/applications/maniphest/controller/ManiphestTaskDetailController.php
+++ b/src/applications/maniphest/controller/ManiphestTaskDetailController.php
@@ -1,600 +1,598 @@
<?php
final class ManiphestTaskDetailController extends ManiphestController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $this->getViewer();
$id = $request->getURIData('id');
$task = id(new ManiphestTaskQuery())
->setViewer($viewer)
->withIDs(array($id))
->needSubscriberPHIDs(true)
->executeOne();
if (!$task) {
return new Aphront404Response();
}
$field_list = PhabricatorCustomField::getObjectFields(
$task,
PhabricatorCustomField::ROLE_VIEW);
$field_list
->setViewer($viewer)
->readFieldsFromStorage($task);
$edit_engine = id(new ManiphestEditEngine())
->setViewer($viewer)
->setTargetObject($task);
$edge_types = array(
ManiphestTaskHasCommitEdgeType::EDGECONST,
ManiphestTaskHasRevisionEdgeType::EDGECONST,
ManiphestTaskHasMockEdgeType::EDGECONST,
PhabricatorObjectMentionedByObjectEdgeType::EDGECONST,
PhabricatorObjectMentionsObjectEdgeType::EDGECONST,
ManiphestTaskHasDuplicateTaskEdgeType::EDGECONST,
);
$phid = $task->getPHID();
$query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(array($phid))
->withEdgeTypes($edge_types);
$edges = idx($query->execute(), $phid);
$phids = array_fill_keys($query->getDestinationPHIDs(), true);
if ($task->getOwnerPHID()) {
$phids[$task->getOwnerPHID()] = true;
}
$phids[$task->getAuthorPHID()] = true;
$phids = array_keys($phids);
$handles = $viewer->loadHandles($phids);
$timeline = $this->buildTransactionTimeline(
$task,
new ManiphestTransactionQuery());
$monogram = $task->getMonogram();
$crumbs = $this->buildApplicationCrumbs()
->addTextCrumb($monogram)
->setBorder(true);
$header = $this->buildHeaderView($task);
$details = $this->buildPropertyView($task, $field_list, $edges, $handles);
$description = $this->buildDescriptionView($task);
$curtain = $this->buildCurtain($task, $edit_engine);
$title = pht('%s %s', $monogram, $task->getTitle());
$comment_view = $edit_engine
->buildEditEngineCommentView($task);
$timeline->setQuoteRef($monogram);
$comment_view->setTransactionTimeline($timeline);
$related_tabs = array();
$graph_menu = null;
$graph_limit = 200;
$overflow_message = null;
$task_graph = id(new ManiphestTaskGraph())
->setViewer($viewer)
->setSeedPHID($task->getPHID())
->setLimit($graph_limit)
->loadGraph();
if (!$task_graph->isEmpty()) {
$parent_type = ManiphestTaskDependedOnByTaskEdgeType::EDGECONST;
$subtask_type = ManiphestTaskDependsOnTaskEdgeType::EDGECONST;
$parent_map = $task_graph->getEdges($parent_type);
$subtask_map = $task_graph->getEdges($subtask_type);
$parent_list = idx($parent_map, $task->getPHID(), array());
$subtask_list = idx($subtask_map, $task->getPHID(), array());
$has_parents = (bool)$parent_list;
$has_subtasks = (bool)$subtask_list;
// First, get a count of direct parent tasks and subtasks. If there
// are too many of these, we just don't draw anything. You can use
// the search button to browse tasks with the search UI instead.
$direct_count = count($parent_list) + count($subtask_list);
if ($direct_count > $graph_limit) {
$overflow_message = pht(
'This task is directly connected to more than %s other tasks. '.
'Use %s to browse parents or subtasks, or %s to show more of the '.
'graph.',
new PhutilNumber($graph_limit),
phutil_tag('strong', array(), pht('Search...')),
phutil_tag('strong', array(), pht('View Standalone Graph')));
$graph_table = null;
} else {
// If there aren't too many direct tasks, but there are too many total
// tasks, we'll only render directly connected tasks.
if ($task_graph->isOverLimit()) {
$task_graph->setRenderOnlyAdjacentNodes(true);
$overflow_message = pht(
'This task is connected to more than %s other tasks. '.
'Only direct parents and subtasks are shown here. Use '.
'%s to show more of the graph.',
new PhutilNumber($graph_limit),
phutil_tag('strong', array(), pht('View Standalone Graph')));
}
$graph_table = $task_graph->newGraphTable();
}
if ($overflow_message) {
$overflow_view = $this->newTaskGraphOverflowView(
$task,
$overflow_message,
true);
$graph_table = array(
$overflow_view,
$graph_table,
);
}
$graph_menu = $this->newTaskGraphDropdownMenu(
$task,
$has_parents,
$has_subtasks,
true);
$related_tabs[] = id(new PHUITabView())
->setName(pht('Task Graph'))
->setKey('graph')
->appendChild($graph_table);
}
$related_tabs[] = $this->newMocksTab($task, $query);
$related_tabs[] = $this->newMentionsTab($task, $query);
$related_tabs[] = $this->newDuplicatesTab($task, $query);
$tab_view = null;
$related_tabs = array_filter($related_tabs);
if ($related_tabs) {
$tab_group = new PHUITabGroupView();
foreach ($related_tabs as $tab) {
$tab_group->addTab($tab);
}
$related_header = id(new PHUIHeaderView())
->setHeader(pht('Related Objects'));
if ($graph_menu) {
$related_header->addActionLink($graph_menu);
}
$tab_view = id(new PHUIObjectBoxView())
->setHeader($related_header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->addTabGroup($tab_group);
}
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(
array(
$tab_view,
$timeline,
$comment_view,
))
->addPropertySection(pht('Description'), $description)
->addPropertySection(pht('Details'), $details);
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(
array(
$task->getPHID(),
))
->appendChild($view);
}
private function buildHeaderView(ManiphestTask $task) {
$view = id(new PHUIHeaderView())
->setHeader($task->getTitle())
->setUser($this->getRequest()->getUser())
->setPolicyObject($task);
$priority_name = ManiphestTaskPriority::getTaskPriorityName(
$task->getPriority());
$priority_color = ManiphestTaskPriority::getTaskPriorityColor(
$task->getPriority());
$status = $task->getStatus();
$status_name = ManiphestTaskStatus::renderFullDescription(
$status, $priority_name);
$view->addProperty(PHUIHeaderView::PROPERTY_STATUS, $status_name);
$view->setHeaderIcon(ManiphestTaskStatus::getStatusIcon(
$task->getStatus()).' '.$priority_color);
if (ManiphestTaskPoints::getIsEnabled()) {
$points = $task->getPoints();
if ($points !== null) {
$points_name = pht('%s %s',
$task->getPoints(),
ManiphestTaskPoints::getPointsLabel());
$tag = id(new PHUITagView())
->setName($points_name)
->setColor(PHUITagView::COLOR_BLUE)
->setType(PHUITagView::TYPE_SHADE);
$view->addTag($tag);
}
}
$subtype = $task->newSubtypeObject();
if ($subtype && $subtype->hasTagView()) {
$subtype_tag = $subtype->newTagView();
$view->addTag($subtype_tag);
}
return $view;
}
private function buildCurtain(
ManiphestTask $task,
PhabricatorEditEngine $edit_engine) {
$viewer = $this->getViewer();
$id = $task->getID();
$phid = $task->getPHID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$task,
PhabricatorPolicyCapability::CAN_EDIT);
$can_interact = PhabricatorPolicyFilter::canInteract($viewer, $task);
// We expect a policy dialog if you can't edit the task, and expect a
// lock override dialog if you can't interact with it.
$workflow_edit = (!$can_edit || !$can_interact);
$curtain = $this->newCurtainView($task);
$curtain->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Task'))
->setIcon('fa-pencil')
->setHref($this->getApplicationURI("/task/edit/{$id}/"))
->setDisabled(!$can_edit)
->setWorkflow($workflow_edit));
$subtype_map = $task->newEditEngineSubtypeMap();
$subtask_options = $subtype_map->getCreateFormsForSubtype(
$edit_engine,
$task);
// If no forms are available, we want to show the user an error.
// If one form is available, we take them user directly to the form.
// If two or more forms are available, we give the user a choice.
// The "subtask" controller handles the first case (no forms) and the
// third case (more than one form). In the case of one form, we link
// directly to the form.
$subtask_uri = "/task/subtask/{$id}/";
$subtask_workflow = true;
if (count($subtask_options) == 1) {
$subtask_form = head($subtask_options);
$form_key = $subtask_form->getIdentifier();
$subtask_uri = id(new PhutilURI("/task/edit/form/{$form_key}/"))
->replaceQueryParam('parent', $id)
->replaceQueryParam('template', $id)
->replaceQueryParam('status', ManiphestTaskStatus::getDefaultStatus());
$subtask_workflow = false;
}
$subtask_uri = $this->getApplicationURI($subtask_uri);
$subtask_item = id(new PhabricatorActionView())
->setName(pht('Create Subtask'))
->setHref($subtask_uri)
->setIcon('fa-level-down')
->setDisabled(!$subtask_options)
->setWorkflow($subtask_workflow);
$relationship_list = PhabricatorObjectRelationshipList::newForObject(
$viewer,
$task);
$submenu_actions = array(
$subtask_item,
ManiphestTaskHasParentRelationship::RELATIONSHIPKEY,
ManiphestTaskHasSubtaskRelationship::RELATIONSHIPKEY,
ManiphestTaskMergeInRelationship::RELATIONSHIPKEY,
ManiphestTaskCloseAsDuplicateRelationship::RELATIONSHIPKEY,
);
$task_submenu = $relationship_list->newActionSubmenu($submenu_actions)
->setName(pht('Edit Related Tasks...'))
->setIcon('fa-anchor');
$curtain->addAction($task_submenu);
$relationship_submenu = $relationship_list->newActionMenu();
if ($relationship_submenu) {
$curtain->addAction($relationship_submenu);
}
$owner_phid = $task->getOwnerPHID();
$author_phid = $task->getAuthorPHID();
$handles = $viewer->loadHandles(array($owner_phid, $author_phid));
if ($owner_phid) {
$image_uri = $handles[$owner_phid]->getImageURI();
$image_href = $handles[$owner_phid]->getURI();
$owner = $viewer->renderHandle($owner_phid)->render();
$content = phutil_tag('strong', array(), $owner);
$assigned_to = id(new PHUIHeadThingView())
->setImage($image_uri)
->setImageHref($image_href)
->setContent($content);
} else {
$assigned_to = phutil_tag('em', array(), pht('None'));
}
$curtain->newPanel()
->setHeaderText(pht('Assigned To'))
->appendChild($assigned_to);
$author_uri = $handles[$author_phid]->getImageURI();
$author_href = $handles[$author_phid]->getURI();
$author = $viewer->renderHandle($author_phid)->render();
$content = phutil_tag('strong', array(), $author);
$date = phabricator_date($task->getDateCreated(), $viewer);
$content = pht('%s, %s', $content, $date);
$authored_by = id(new PHUIHeadThingView())
->setImage($author_uri)
->setImageHref($author_href)
->setContent($content);
$curtain->newPanel()
->setHeaderText(pht('Authored By'))
->appendChild($authored_by);
return $curtain;
}
private function buildPropertyView(
ManiphestTask $task,
PhabricatorCustomFieldList $field_list,
array $edges,
$handles) {
$viewer = $this->getRequest()->getUser();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
$source = $task->getOriginalEmailSource();
if ($source) {
$subject = '[T'.$task->getID().'] '.$task->getTitle();
$view->addProperty(
pht('From Email'),
phutil_tag(
'a',
array(
'href' => 'mailto:'.$source.'?subject='.$subject,
),
$source));
}
$edge_types = array(
ManiphestTaskHasRevisionEdgeType::EDGECONST
=> pht('Differential Revisions'),
);
$revisions_commits = array();
$commit_phids = array_keys(
$edges[ManiphestTaskHasCommitEdgeType::EDGECONST]);
if ($commit_phids) {
$commit_drev = DiffusionCommitHasRevisionEdgeType::EDGECONST;
$drev_edges = id(new PhabricatorEdgeQuery())
->withSourcePHIDs($commit_phids)
->withEdgeTypes(array($commit_drev))
->execute();
foreach ($commit_phids as $phid) {
$revisions_commits[$phid] = $handles->renderHandle($phid)
- ->setShowHovercard(true)
- ->setShowStateIcon(true);
+ ->setShowHovercard(true);
$revision_phid = key($drev_edges[$phid][$commit_drev]);
$revision_handle = $handles->getHandleIfExists($revision_phid);
if ($revision_handle) {
$task_drev = ManiphestTaskHasRevisionEdgeType::EDGECONST;
unset($edges[$task_drev][$revision_phid]);
$revisions_commits[$phid] = hsprintf(
'%s / %s',
$revision_handle->renderHovercardLink($revision_handle->getName()),
$revisions_commits[$phid]);
}
}
}
foreach ($edge_types as $edge_type => $edge_name) {
if (!$edges[$edge_type]) {
continue;
}
$edge_handles = $viewer->loadHandles(array_keys($edges[$edge_type]));
- $edge_list = $edge_handles->renderList()
- ->setShowStateIcons(true);
+ $edge_list = $edge_handles->renderList();
$view->addProperty($edge_name, $edge_list);
}
if ($revisions_commits) {
$view->addProperty(
pht('Commits'),
phutil_implode_html(phutil_tag('br'), $revisions_commits));
}
$field_list->appendFieldsToPropertyList(
$task,
$viewer,
$view);
if ($view->hasAnyProperties()) {
return $view;
}
return null;
}
private function buildDescriptionView(ManiphestTask $task) {
$viewer = $this->getViewer();
$section = null;
$description = $task->getDescription();
if (strlen($description)) {
$section = new PHUIPropertyListView();
$section->addTextContent(
phutil_tag(
'div',
array(
'class' => 'phabricator-remarkup',
),
id(new PHUIRemarkupView($viewer, $description))
->setContextObject($task)));
}
return $section;
}
private function newMocksTab(
ManiphestTask $task,
PhabricatorEdgeQuery $edge_query) {
$mock_type = ManiphestTaskHasMockEdgeType::EDGECONST;
$mock_phids = $edge_query->getDestinationPHIDs(array(), array($mock_type));
if (!$mock_phids) {
return null;
}
$viewer = $this->getViewer();
$handles = $viewer->loadHandles($mock_phids);
// TODO: It would be nice to render this as pinboard-style thumbnails,
// similar to "{M123}", instead of a list of links.
$view = id(new PHUIPropertyListView())
->addProperty(pht('Mocks'), $handles->renderList());
return id(new PHUITabView())
->setName(pht('Mocks'))
->setKey('mocks')
->appendChild($view);
}
private function newMentionsTab(
ManiphestTask $task,
PhabricatorEdgeQuery $edge_query) {
$in_type = PhabricatorObjectMentionedByObjectEdgeType::EDGECONST;
$out_type = PhabricatorObjectMentionsObjectEdgeType::EDGECONST;
$in_phids = $edge_query->getDestinationPHIDs(array(), array($in_type));
$out_phids = $edge_query->getDestinationPHIDs(array(), array($out_type));
// Filter out any mentioned users from the list. These are not generally
// very interesting to show in a relationship summary since they usually
// end up as subscribers anyway.
$user_type = PhabricatorPeopleUserPHIDType::TYPECONST;
foreach ($out_phids as $key => $out_phid) {
if (phid_get_type($out_phid) == $user_type) {
unset($out_phids[$key]);
}
}
if (!$in_phids && !$out_phids) {
return null;
}
$viewer = $this->getViewer();
$in_handles = $viewer->loadHandles($in_phids);
$out_handles = $viewer->loadHandles($out_phids);
$in_handles = $this->getCompleteHandles($in_handles);
$out_handles = $this->getCompleteHandles($out_handles);
if (!count($in_handles) && !count($out_handles)) {
return null;
}
$view = new PHUIPropertyListView();
if (count($in_handles)) {
$view->addProperty(pht('Mentioned In'), $in_handles->renderList());
}
if (count($out_handles)) {
$view->addProperty(pht('Mentioned Here'), $out_handles->renderList());
}
return id(new PHUITabView())
->setName(pht('Mentions'))
->setKey('mentions')
->appendChild($view);
}
private function newDuplicatesTab(
ManiphestTask $task,
PhabricatorEdgeQuery $edge_query) {
$in_type = ManiphestTaskHasDuplicateTaskEdgeType::EDGECONST;
$in_phids = $edge_query->getDestinationPHIDs(array(), array($in_type));
$viewer = $this->getViewer();
$in_handles = $viewer->loadHandles($in_phids);
$in_handles = $this->getCompleteHandles($in_handles);
$view = new PHUIPropertyListView();
if (!count($in_handles)) {
return null;
}
$view->addProperty(
pht('Duplicates Merged Here'), $in_handles->renderList());
return id(new PHUITabView())
->setName(pht('Duplicates'))
->setKey('duplicates')
->appendChild($view);
}
private function getCompleteHandles(PhabricatorHandleList $handles) {
$phids = array();
foreach ($handles as $phid => $handle) {
if (!$handle->isComplete()) {
continue;
}
$phids[] = $phid;
}
return $handles->newSublist($phids);
}
}
diff --git a/src/applications/phid/PhabricatorObjectHandle.php b/src/applications/phid/PhabricatorObjectHandle.php
index ba93dbcead..86f0f848c0 100644
--- a/src/applications/phid/PhabricatorObjectHandle.php
+++ b/src/applications/phid/PhabricatorObjectHandle.php
@@ -1,468 +1,415 @@
<?php
final class PhabricatorObjectHandle
extends Phobject
implements PhabricatorPolicyInterface {
const AVAILABILITY_FULL = 'full';
const AVAILABILITY_NONE = 'none';
const AVAILABILITY_NOEMAIL = 'no-email';
const AVAILABILITY_PARTIAL = 'partial';
const AVAILABILITY_DISABLED = 'disabled';
const STATUS_OPEN = 'open';
const STATUS_CLOSED = 'closed';
private $uri;
private $phid;
private $type;
private $name;
private $fullName;
private $title;
private $imageURI;
private $icon;
private $tagColor;
private $timestamp;
private $status = self::STATUS_OPEN;
private $availability = self::AVAILABILITY_FULL;
private $complete;
private $objectName;
private $policyFiltered;
private $subtitle;
private $tokenIcon;
private $commandLineObjectName;
private $mailStampName;
- private $stateIcon;
- private $stateColor;
- private $stateName;
-
public function setIcon($icon) {
$this->icon = $icon;
return $this;
}
public function getIcon() {
if ($this->getPolicyFiltered()) {
return 'fa-lock';
}
if ($this->icon) {
return $this->icon;
}
return $this->getTypeIcon();
}
public function setSubtitle($subtitle) {
$this->subtitle = $subtitle;
return $this;
}
public function getSubtitle() {
return $this->subtitle;
}
public function setTagColor($color) {
static $colors;
if (!$colors) {
$colors = array_fuse(array_keys(PHUITagView::getShadeMap()));
}
if (isset($colors[$color])) {
$this->tagColor = $color;
}
return $this;
}
public function getTagColor() {
if ($this->getPolicyFiltered()) {
return 'disabled';
}
if ($this->tagColor) {
return $this->tagColor;
}
return 'blue';
}
public function getIconColor() {
if ($this->tagColor) {
return $this->tagColor;
}
return null;
}
public function setTokenIcon($icon) {
$this->tokenIcon = $icon;
return $this;
}
public function getTokenIcon() {
if ($this->tokenIcon !== null) {
return $this->tokenIcon;
}
return $this->getIcon();
}
public function getTypeIcon() {
if ($this->getPHIDType()) {
return $this->getPHIDType()->getTypeIcon();
}
return null;
}
public function setPolicyFiltered($policy_filered) {
$this->policyFiltered = $policy_filered;
return $this;
}
public function getPolicyFiltered() {
return $this->policyFiltered;
}
public function setObjectName($object_name) {
$this->objectName = $object_name;
return $this;
}
public function getObjectName() {
if (!$this->objectName) {
return $this->getName();
}
return $this->objectName;
}
public function setMailStampName($mail_stamp_name) {
$this->mailStampName = $mail_stamp_name;
return $this;
}
public function getMailStampName() {
return $this->mailStampName;
}
public function setURI($uri) {
$this->uri = $uri;
return $this;
}
public function getURI() {
return $this->uri;
}
public function setPHID($phid) {
$this->phid = $phid;
return $this;
}
public function getPHID() {
return $this->phid;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function getName() {
if ($this->name === null) {
if ($this->getPolicyFiltered()) {
return pht('Restricted %s', $this->getTypeName());
} else {
return pht('Unknown Object (%s)', $this->getTypeName());
}
}
return $this->name;
}
public function setAvailability($availability) {
$this->availability = $availability;
return $this;
}
public function getAvailability() {
return $this->availability;
}
public function isDisabled() {
return ($this->getAvailability() == self::AVAILABILITY_DISABLED);
}
public function setStatus($status) {
$this->status = $status;
return $this;
}
public function getStatus() {
return $this->status;
}
public function setFullName($full_name) {
$this->fullName = $full_name;
return $this;
}
public function getFullName() {
if ($this->fullName !== null) {
return $this->fullName;
}
return $this->getName();
}
public function setCommandLineObjectName($command_line_object_name) {
$this->commandLineObjectName = $command_line_object_name;
return $this;
}
public function getCommandLineObjectName() {
if ($this->commandLineObjectName !== null) {
return $this->commandLineObjectName;
}
return $this->getObjectName();
}
public function setTitle($title) {
$this->title = $title;
return $this;
}
public function getTitle() {
return $this->title;
}
public function setType($type) {
$this->type = $type;
return $this;
}
public function getType() {
return $this->type;
}
public function setImageURI($uri) {
$this->imageURI = $uri;
return $this;
}
public function getImageURI() {
return $this->imageURI;
}
public function setTimestamp($timestamp) {
$this->timestamp = $timestamp;
return $this;
}
public function getTimestamp() {
return $this->timestamp;
}
public function getTypeName() {
if ($this->getPHIDType()) {
return $this->getPHIDType()->getTypeName();
}
return $this->getType();
}
/**
* Set whether or not the underlying object is complete. See
* @{method:isComplete} for an explanation of what it means to be complete.
*
* @param bool True if the handle represents a complete object.
* @return this
*/
public function setComplete($complete) {
$this->complete = $complete;
return $this;
}
/**
* Determine if the handle represents an object which was completely loaded
* (i.e., the underlying object exists) vs an object which could not be
* completely loaded (e.g., the type or data for the PHID could not be
* identified or located).
*
* Basically, @{class:PhabricatorHandleQuery} gives you back a handle for
* any PHID you give it, but it gives you a complete handle only for valid
* PHIDs.
*
* @return bool True if the handle represents a complete object.
*/
public function isComplete() {
return $this->complete;
}
- public function setStateIcon($state_icon) {
- $this->stateIcon = $state_icon;
- return $this;
- }
-
- public function getStateIcon() {
- return $this->stateIcon;
- }
-
- public function setStateColor($state_color) {
- $this->stateColor = $state_color;
- return $this;
- }
-
- public function getStateColor() {
- return $this->stateColor;
- }
-
- public function setStateName($state_name) {
- $this->stateName = $state_name;
- return $this;
- }
-
- public function getStateName() {
- return $this->stateName;
- }
-
- public function renderStateIcon() {
- $icon = $this->getStateIcon();
- if ($icon === null) {
- $icon = 'fa-question-circle-o';
- }
-
- $color = $this->getStateColor();
-
- $name = $this->getStateName();
- if ($name === null) {
- $name = pht('Unknown');
- }
-
- return id(new PHUIIconView())
- ->setIcon($icon, $color)
- ->addSigil('has-tooltip')
- ->setMetadata(
- array(
- 'tip' => $name,
- ));
- }
-
public function renderLink($name = null) {
return $this->renderLinkWithAttributes($name, array());
}
public function renderHovercardLink($name = null) {
Javelin::initBehavior('phui-hovercards');
$attributes = array(
'sigil' => 'hovercard',
'meta' => array(
'hoverPHID' => $this->getPHID(),
),
);
return $this->renderLinkWithAttributes($name, $attributes);
}
private function renderLinkWithAttributes($name, array $attributes) {
if ($name === null) {
$name = $this->getLinkName();
}
$classes = array();
$classes[] = 'phui-handle';
$title = $this->title;
if ($this->status != self::STATUS_OPEN) {
$classes[] = 'handle-status-'.$this->status;
}
$circle = null;
if ($this->availability != self::AVAILABILITY_FULL) {
$classes[] = 'handle-availability-'.$this->availability;
$circle = array(
phutil_tag(
'span',
array(
'class' => 'perfect-circle',
),
"\xE2\x80\xA2"),
' ',
);
}
if ($this->getType() == PhabricatorPeopleUserPHIDType::TYPECONST) {
$classes[] = 'phui-link-person';
}
$uri = $this->getURI();
$icon = null;
if ($this->getPolicyFiltered()) {
$icon = id(new PHUIIconView())
->setIcon('fa-lock lightgreytext');
}
$attributes = $attributes + array(
'href' => $uri,
'class' => implode(' ', $classes),
'title' => $title,
);
return javelin_tag(
$uri ? 'a' : 'span',
$attributes,
array($circle, $icon, $name));
}
public function renderTag() {
return id(new PHUITagView())
->setType(PHUITagView::TYPE_SHADE)
->setColor($this->getTagColor())
->setIcon($this->getIcon())
->setHref($this->getURI())
->setName($this->getLinkName());
}
public function getLinkName() {
switch ($this->getType()) {
case PhabricatorPeopleUserPHIDType::TYPECONST:
$name = $this->getName();
break;
default:
$name = $this->getFullName();
break;
}
return $name;
}
protected function getPHIDType() {
$types = PhabricatorPHIDType::getAllTypes();
return idx($types, $this->getType());
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
);
}
public function getPolicy($capability) {
return PhabricatorPolicies::POLICY_PUBLIC;
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
// NOTE: Handles are always visible, they just don't get populated with
// data if the user can't see the underlying object.
return true;
}
public function describeAutomaticCapability($capability) {
return null;
}
}
diff --git a/src/applications/phid/view/PHUIHandleListView.php b/src/applications/phid/view/PHUIHandleListView.php
index 24104fe76d..c5b2f19784 100644
--- a/src/applications/phid/view/PHUIHandleListView.php
+++ b/src/applications/phid/view/PHUIHandleListView.php
@@ -1,102 +1,87 @@
<?php
/**
* Convenience class for rendering a list of handles.
*
* This class simplifies rendering a list of handles and improves loading and
* caching semantics in the rendering pipeline by delaying bulk loads until the
* last possible moment.
*/
final class PHUIHandleListView
extends AphrontTagView {
private $handleList;
private $asInline;
private $asText;
- private $showStateIcons;
private $glyphLimit;
public function setHandleList(PhabricatorHandleList $list) {
$this->handleList = $list;
return $this;
}
public function setAsInline($inline) {
$this->asInline = $inline;
return $this;
}
public function getAsInline() {
return $this->asInline;
}
public function setAsText($as_text) {
$this->asText = $as_text;
return $this;
}
public function getAsText() {
return $this->asText;
}
- public function setShowStateIcons($show_state_icons) {
- $this->showStateIcons = $show_state_icons;
- return $this;
- }
-
- public function getShowStateIcons() {
- return $this->showStateIcons;
- }
-
public function setGlyphLimit($glyph_limit) {
$this->glyphLimit = $glyph_limit;
return $this;
}
public function getGlyphLimit() {
return $this->glyphLimit;
}
protected function getTagName() {
if ($this->getAsText()) {
return null;
} else {
// TODO: It would be nice to render this with a proper <ul />, at least
// in block mode, but don't stir the waters up too much for now.
return 'span';
}
}
protected function getTagContent() {
$list = $this->handleList;
- $show_state_icons = $this->getShowStateIcons();
$glyph_limit = $this->getGlyphLimit();
$items = array();
foreach ($list as $handle) {
$view = $list->renderHandle($handle->getPHID())
->setShowHovercard(true)
->setAsText($this->getAsText());
- if ($show_state_icons) {
- $view->setShowStateIcon(true);
- }
-
if ($glyph_limit) {
$view->setGlyphLimit($glyph_limit);
}
$items[] = $view;
}
if ($this->getAsInline()) {
$items = phutil_implode_html(', ', $items);
} else {
$items = phutil_implode_html(phutil_tag('br'), $items);
}
return $items;
}
}
diff --git a/src/applications/phid/view/PHUIHandleView.php b/src/applications/phid/view/PHUIHandleView.php
index fe3c62a9ac..6cdf84f391 100644
--- a/src/applications/phid/view/PHUIHandleView.php
+++ b/src/applications/phid/view/PHUIHandleView.php
@@ -1,115 +1,100 @@
<?php
/**
* Convenience class for rendering a single handle.
*
* This class simplifies rendering a single handle, and improves loading and
* caching semantics in the rendering pipeline by loading data at the last
* moment.
*/
final class PHUIHandleView
extends AphrontView {
private $handleList;
private $handlePHID;
private $asTag;
private $asText;
private $useShortName;
private $showHovercard;
- private $showStateIcon;
private $glyphLimit;
public function setHandleList(PhabricatorHandleList $list) {
$this->handleList = $list;
return $this;
}
public function setHandlePHID($phid) {
$this->handlePHID = $phid;
return $this;
}
public function setAsTag($tag) {
$this->asTag = $tag;
return $this;
}
public function setAsText($as_text) {
$this->asText = $as_text;
return $this;
}
public function setUseShortName($short) {
$this->useShortName = $short;
return $this;
}
public function setShowHovercard($hovercard) {
$this->showHovercard = $hovercard;
return $this;
}
- public function setShowStateIcon($show_state_icon) {
- $this->showStateIcon = $show_state_icon;
- return $this;
- }
-
- public function getShowStateIcon() {
- return $this->showStateIcon;
- }
-
public function setGlyphLimit($glyph_limit) {
$this->glyphLimit = $glyph_limit;
return $this;
}
public function getGlyphLimit() {
return $this->glyphLimit;
}
public function render() {
$handle = $this->handleList[$this->handlePHID];
if ($this->asTag) {
$tag = $handle->renderTag();
if ($this->showHovercard) {
$tag->setPHID($handle->getPHID());
}
return $tag;
}
if ($this->asText) {
return $handle->getLinkName();
}
if ($this->useShortName) {
$name = $handle->getName();
} else {
$name = $handle->getLinkName();
}
$glyph_limit = $this->getGlyphLimit();
if ($glyph_limit) {
$name = id(new PhutilUTF8StringTruncator())
->setMaximumGlyphs($glyph_limit)
->truncateString($name);
}
if ($this->showHovercard) {
$link = $handle->renderHovercardLink($name);
} else {
$link = $handle->renderLink($name);
}
- if ($this->showStateIcon) {
- $icon = $handle->renderStateIcon();
- $link = array($icon, ' ', $link);
- }
-
return $link;
}
}
diff --git a/src/applications/repository/phid/PhabricatorRepositoryCommitPHIDType.php b/src/applications/repository/phid/PhabricatorRepositoryCommitPHIDType.php
index c37bdc04f9..df84f2dcfd 100644
--- a/src/applications/repository/phid/PhabricatorRepositoryCommitPHIDType.php
+++ b/src/applications/repository/phid/PhabricatorRepositoryCommitPHIDType.php
@@ -1,127 +1,117 @@
<?php
final class PhabricatorRepositoryCommitPHIDType extends PhabricatorPHIDType {
const TYPECONST = 'CMIT';
public function getTypeName() {
return pht('Diffusion Commit');
}
public function newObject() {
return new PhabricatorRepositoryCommit();
}
public function getPHIDTypeApplicationClass() {
return 'PhabricatorDiffusionApplication';
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new DiffusionCommitQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
$unreachable = array();
foreach ($handles as $phid => $handle) {
$commit = $objects[$phid];
if ($commit->isUnreachable()) {
$unreachable[$phid] = $commit;
}
}
if ($unreachable) {
$query = id(new DiffusionCommitHintQuery())
->setViewer($query->getViewer())
->withCommits($unreachable);
$query->execute();
$hints = $query->getCommitMap();
} else {
$hints = array();
}
foreach ($handles as $phid => $handle) {
$commit = $objects[$phid];
$repository = $commit->getRepository();
$commit_identifier = $commit->getCommitIdentifier();
$name = $repository->formatCommitName($commit_identifier);
if ($commit->isUnreachable()) {
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
// If we have a hint about this commit being rewritten, add the
// rewrite target to the handle name. This reduces the chance users
// will be caught offguard by the rewrite.
$hint = idx($hints, $phid);
if ($hint && $hint->isRewritten()) {
$new_name = $hint->getNewCommitIdentifier();
$new_name = $repository->formatCommitName($new_name);
$name = pht("%s \xE2\x99\xBB %s", $name, $new_name);
}
}
$summary = $commit->getSummary();
if (strlen($summary)) {
$full_name = $name.': '.$summary;
} else {
$full_name = $name;
}
$handle->setName($name);
$handle->setFullName($full_name);
$handle->setURI($commit->getURI());
$handle->setTimestamp($commit->getEpoch());
-
- $status = $commit->getAuditStatusObject();
- $icon = $status->getIcon();
- $color = $status->getColor();
- $name = $status->getName();
-
- $handle
- ->setStateIcon($icon)
- ->setStateColor($color)
- ->setStateName($name);
}
}
public static function getCommitObjectNamePattern() {
$min_unqualified = PhabricatorRepository::MINIMUM_UNQUALIFIED_HASH;
$min_qualified = PhabricatorRepository::MINIMUM_QUALIFIED_HASH;
return
'(?:r[A-Z]+:?|R[0-9]+:)[1-9]\d*'.
'|'.
'(?:r[A-Z]+:?|R[0-9]+:)[a-f0-9]{'.$min_qualified.',40}'.
'|'.
'[a-f0-9]{'.$min_unqualified.',40}';
}
public function canLoadNamedObject($name) {
$pattern = self::getCommitObjectNamePattern();
return preg_match('(^'.$pattern.'$)', $name);
}
public function loadNamedObjects(
PhabricatorObjectQuery $query,
array $names) {
$query = id(new DiffusionCommitQuery())
->setViewer($query->getViewer())
->withIdentifiers($names);
$query->execute();
return $query->getIdentifierMap();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Thu, Jul 3, 5:14 PM (17 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
166075
Default Alt Text
(40 KB)

Event Timeline