Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php b/src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php
index d2d1f9ab82..ef8964463f 100644
--- a/src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php
+++ b/src/applications/project/engineextension/PhabricatorProjectHovercardEngineExtension.php
@@ -1,55 +1,75 @@
<?php
final class PhabricatorProjectHovercardEngineExtension
extends PhabricatorHovercardEngineExtension {
const EXTENSIONKEY = 'project.card';
public function isExtensionEnabled() {
return true;
}
public function getExtensionName() {
return pht('Project Card');
}
public function canRenderObjectHovercard($object) {
return ($object instanceof PhabricatorProject);
}
public function willRenderHovercards(array $objects) {
$viewer = $this->getViewer();
$phids = mpull($objects, 'getPHID');
$projects = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->withPHIDs($phids)
->needImages(true)
->execute();
$projects = mpull($projects, null, 'getPHID');
+ $custom_fields = array();
+ foreach ($projects as $project) {
+ $field = PhabricatorCustomField::getObjectField(
+ $project,
+ PhabricatorCustomField::ROLE_VIEW,
+ 'std:project:internal:description');
+ if ($field === null) {
+ // This means the field is disabled, it would always be null.
+ break;
+ }
+ $field
+ ->setViewer($viewer)
+ ->readValueFromObject($project);
+ $custom_fields[] = $field;
+ }
+
+ id(new PhabricatorCustomFieldStorageQuery())
+ ->addFields($custom_fields)
+ ->execute();
+
return array(
'projects' => $projects,
);
}
public function renderHovercard(
PHUIHovercardView $hovercard,
PhabricatorObjectHandle $handle,
$object,
$data) {
$viewer = $this->getViewer();
$project = idx($data['projects'], $object->getPHID());
if (!$project) {
return;
}
$project_card = id(new PhabricatorProjectCardView())
->setProject($project)
->setViewer($viewer);
$hovercard->appendChild($project_card);
}
}
diff --git a/src/applications/project/view/PhabricatorProjectCardView.php b/src/applications/project/view/PhabricatorProjectCardView.php
index a56697ba7e..03d342b666 100644
--- a/src/applications/project/view/PhabricatorProjectCardView.php
+++ b/src/applications/project/view/PhabricatorProjectCardView.php
@@ -1,84 +1,106 @@
<?php
final class PhabricatorProjectCardView extends AphrontTagView {
private $project;
private $viewer;
private $tag;
public function setProject(PhabricatorProject $project) {
$this->project = $project;
return $this;
}
public function setViewer(PhabricatorUser $viewer) {
$this->viewer = $viewer;
return $this;
}
public function setTag($tag) {
$this->tag = $tag;
return $this;
}
protected function getTagName() {
if ($this->tag) {
return $this->tag;
}
return 'div';
}
protected function getTagAttributes() {
$classes = array();
$classes[] = 'project-card-view';
$color = $this->project->getColor();
$classes[] = 'project-card-'.$color;
return array(
'class' => implode(' ', $classes),
);
}
protected function getTagContent() {
$project = $this->project;
$viewer = $this->viewer;
require_celerity_resource('project-card-view-css');
$icon = $project->getDisplayIconIcon();
$icon_name = $project->getDisplayIconName();
$tag = id(new PHUITagView())
->setIcon($icon)
->setName($icon_name)
->addClass('project-view-header-tag')
->setType(PHUITagView::TYPE_SHADE);
$header = id(new PHUIHeaderView())
->setHeader(array($project->getDisplayName(), $tag))
->setUser($viewer)
->setPolicyObject($project)
->setImage($project->getProfileImageURI());
if ($project->getStatus() == PhabricatorProjectStatus::STATUS_ACTIVE) {
$header->setStatus('fa-check', 'bluegrey', pht('Active'));
} else {
$header->setStatus('fa-ban', 'red', pht('Archived'));
}
$description = null;
+ // This getProxy() feels hacky - see also PhabricatorProjectDatasource:67
+ $description_field = PhabricatorCustomField::getObjectField(
+ $project,
+ PhabricatorCustomField::ROLE_VIEW,
+ 'std:project:internal:description');
+
+ if ($description_field !== null) {
+ $description_field = $description_field->getProxy();
+
+ $description = $description_field->getFieldValue();
+ if (phutil_nonempty_string($description)) {
+ $description = PhabricatorMarkupEngine::summarizeSentence($description);
+ $description = id(new PHUIRemarkupView($viewer, $description))
+ ->setContextObject($project);
+
+ $description = phutil_tag(
+ 'div',
+ array('class' => 'project-card-body phui-header-shell'),
+ $description);
+ }
+ }
+
$card = phutil_tag(
'div',
array(
'class' => 'project-card-inner',
),
array(
$header,
$description,
));
return $card;
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Apr 30, 11:47 AM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108697
Default Alt Text
(5 KB)

Event Timeline