Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
index cdaa5f7c6c..3cbf202eb6 100644
--- a/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
+++ b/src/applications/diffusion/typeahead/DiffusionRepositoryDatasource.php
@@ -1,35 +1,34 @@
<?php
final class DiffusionRepositoryDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a repository name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationDiffusion';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$repos = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->execute();
foreach ($repos as $repo) {
$results[] = id(new PhabricatorTypeaheadResult())
->setName($repo->getMonogram().' '.$repo->getName())
->setURI('/diffusion/'.$repo->getCallsign().'/')
->setPHID($repo->getPHID())
- ->setPriorityString($repo->getMonogram())
- ->setIcon('fa-database bluegrey');
+ ->setPriorityString($repo->getMonogram());
}
return $results;
}
}
diff --git a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
index e266dca640..ccb527dfa0 100644
--- a/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
+++ b/src/applications/legalpad/typeahead/LegalpadDocumentDatasource.php
@@ -1,33 +1,32 @@
<?php
final class LegalpadDocumentDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a document name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationLegalpad';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$documents = id(new LegalpadDocumentQuery())
->setViewer($viewer)
->execute();
foreach ($documents as $document) {
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($document->getPHID())
- ->setIcon('fa-file-text-o')
->setName($document->getMonogram().' '.$document->getTitle());
}
return $results;
}
}
diff --git a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
index a6c84d9cce..6b7078b410 100644
--- a/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
+++ b/src/applications/macro/typeahead/PhabricatorMacroDatasource.php
@@ -1,35 +1,34 @@
<?php
final class PhabricatorMacroDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a macro name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationMacro';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$macros = id(new PhabricatorMacroQuery())
->setViewer($viewer)
->withStatus(PhabricatorMacroQuery::STATUS_ACTIVE)
->execute();
foreach ($macros as $macro) {
$results[] = id(new PhabricatorTypeaheadResult())
->setPHID($macro->getPHID())
- ->setName($macro->getName())
- ->setIcon('fa-meh-o bluegrey');
+ ->setName($macro->getName());
}
return $results;
}
}
diff --git a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
index df814dfa3a..3371d2cf0f 100644
--- a/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
+++ b/src/applications/mailinglists/phid/PhabricatorMailingListPHIDTypeList.php
@@ -1,71 +1,75 @@
<?php
final class PhabricatorMailingListPHIDTypeList extends PhabricatorPHIDType {
const TYPECONST = 'MLST';
public function getTypeConstant() {
return self::TYPECONST;
}
public function getTypeName() {
return pht('Mailing List');
}
+ public function getTypeIcon() {
+ return 'fa-envelope-o';
+ }
+
public function newObject() {
return new PhabricatorMetaMTAMailingList();
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new PhabricatorMailingListQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$list = $objects[$phid];
$handle->setName($list->getName());
$handle->setURI($list->getURI());
}
}
public function canLoadNamedObject($name) {
return preg_match('/^.+@.+/', $name);
}
public function loadNamedObjects(
PhabricatorObjectQuery $query,
array $names) {
$id_map = array();
foreach ($names as $name) {
// Maybe normalize these some day?
$id = $name;
$id_map[$id][] = $name;
}
$objects = id(new PhabricatorMailingListQuery())
->setViewer($query->getViewer())
->withEmails(array_keys($id_map))
->execute();
$results = array();
foreach ($objects as $id => $object) {
$email = $object->getEmail();
foreach (idx($id_map, $email, array()) as $name) {
$results[$name] = $object;
}
}
return $results;
}
}
diff --git a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
index b82b47a9ea..6aff840c22 100644
--- a/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
+++ b/src/applications/owners/phid/PhabricatorOwnersPHIDTypePackage.php
@@ -1,43 +1,47 @@
<?php
final class PhabricatorOwnersPHIDTypePackage extends PhabricatorPHIDType {
const TYPECONST = 'OPKG';
public function getTypeConstant() {
return self::TYPECONST;
}
public function getTypeName() {
return pht('Owners Package');
}
+ public function getTypeIcon() {
+ return 'fa-list-alt';
+ }
+
public function newObject() {
return new PhabricatorOwnersPackage();
}
protected function buildQueryForObjects(
PhabricatorObjectQuery $query,
array $phids) {
return id(new PhabricatorOwnersPackageQuery())
->withPHIDs($phids);
}
public function loadHandles(
PhabricatorHandleQuery $query,
array $handles,
array $objects) {
foreach ($handles as $phid => $handle) {
$package = $objects[$phid];
$name = $package->getName();
$id = $package->getID();
$handle->setName($name);
$handle->setURI("/owners/package/{$id}/");
}
}
}
diff --git a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
index edbcf758ce..7d681bc2cc 100644
--- a/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
+++ b/src/applications/owners/typeahead/PhabricatorOwnersPackageDatasource.php
@@ -1,35 +1,34 @@
<?php
final class PhabricatorOwnersPackageDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a package name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationOwners';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$packages = id(new PhabricatorOwnersPackageQuery())
->setViewer($viewer)
->execute();
foreach ($packages as $package) {
$results[] = id(new PhabricatorTypeaheadResult())
- ->setIcon('fa-list-alt bluegrey')
->setName($package->getName())
->setURI('/owners/package/'.$package->getID().'/')
->setPHID($package->getPHID());
}
return $results;
}
}
diff --git a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
index 5b1a91d953..d0f9aa2d18 100644
--- a/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
+++ b/src/applications/people/typeahead/PhabricatorPeopleDatasource.php
@@ -1,126 +1,125 @@
<?php
final class PhabricatorPeopleDatasource
extends PhabricatorTypeaheadDatasource {
private $enrichResults;
/**
* Controls enriched rendering, for global search. This is a bit hacky and
* should probably be handled in a more general way, but is fairly reasonable
* for now.
*/
public function setEnrichResults($enrich) {
$this->enrichResults = $enrich;
return $this;
}
public function getPlaceholderText() {
return pht('Type a username...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationPeople';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$users = array();
if (strlen($raw_query)) {
// This is an arbitrary limit which is just larger than any limit we
// actually use in the application.
// TODO: The datasource should pass this in the query.
$limit = 15;
$user_table = new PhabricatorUser();
$conn_r = $user_table->establishConnection('r');
$ids = queryfx_all(
$conn_r,
'SELECT id FROM %T WHERE username LIKE %>
ORDER BY username ASC LIMIT %d',
$user_table->getTableName(),
$raw_query,
$limit);
$ids = ipull($ids, 'id');
if (count($ids) < $limit) {
// If we didn't find enough username hits, look for real name hits.
// We need to pull the entire pagesize so that we end up with the
// right number of items if this query returns many duplicate IDs
// that we've already selected.
$realname_ids = queryfx_all(
$conn_r,
'SELECT DISTINCT userID FROM %T WHERE token LIKE %>
ORDER BY token ASC LIMIT %d',
PhabricatorUser::NAMETOKEN_TABLE,
$raw_query,
$limit);
$realname_ids = ipull($realname_ids, 'userID');
$ids = array_merge($ids, $realname_ids);
$ids = array_unique($ids);
$ids = array_slice($ids, 0, $limit);
}
// Always add the logged-in user because some tokenizers autosort them
// first. They'll be filtered out on the client side if they don't
// match the query.
if ($viewer->getID()) {
$ids[] = $viewer->getID();
}
if ($ids) {
$users = id(new PhabricatorPeopleQuery())
->setViewer($viewer)
->withIDs($ids)
->execute();
}
}
if ($this->enrichResults && $users) {
$phids = mpull($users, 'getPHID');
$handles = id(new PhabricatorHandleQuery())
->setViewer($viewer)
->withPHIDs($phids)
->execute();
}
foreach ($users as $user) {
$closed = null;
if ($user->getIsDisabled()) {
$closed = pht('Disabled');
} else if ($user->getIsSystemAgent()) {
$closed = pht('Bot/Script');
}
$result = id(new PhabricatorTypeaheadResult())
->setName($user->getFullName())
->setURI('/p/'.$user->getUsername())
->setPHID($user->getPHID())
->setPriorityString($user->getUsername())
- ->setIcon('fa-user bluegrey')
->setPriorityType('user')
->setClosed($closed);
if ($this->enrichResults) {
$display_type = 'User';
if ($user->getIsAdmin()) {
$display_type = 'Administrator';
}
$result->setDisplayType($display_type);
$result->setImageURI($handles[$user->getPHID()]->getImageURI());
}
$results[] = $result;
}
return $results;
}
}
diff --git a/src/applications/project/typeahead/PhabricatorProjectDatasource.php b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
index 8b2343132d..f9bba5c33f 100644
--- a/src/applications/project/typeahead/PhabricatorProjectDatasource.php
+++ b/src/applications/project/typeahead/PhabricatorProjectDatasource.php
@@ -1,47 +1,47 @@
<?php
final class PhabricatorProjectDatasource
extends PhabricatorTypeaheadDatasource {
public function getPlaceholderText() {
return pht('Type a project name...');
}
public function getDatasourceApplicationClass() {
return 'PhabricatorApplicationProject';
}
public function loadResults() {
$viewer = $this->getViewer();
$raw_query = $this->getRawQuery();
$results = array();
$projs = id(new PhabricatorProjectQuery())
->setViewer($viewer)
->needImages(true)
->execute();
foreach ($projs as $proj) {
$closed = null;
if ($proj->isArchived()) {
$closed = pht('Archived');
}
$proj_result = id(new PhabricatorTypeaheadResult())
->setName($proj->getName())
->setDisplayType('Project')
->setURI('/tag/'.$proj->getPrimarySlug().'/')
->setPHID($proj->getPHID())
- ->setIcon($proj->getIcon())
+ ->setIcon($proj->getIcon().' bluegrey')
->setPriorityType('proj')
->setClosed($closed);
$proj_result->setImageURI($proj->getProfileImageURI());
$results[] = $proj_result;
}
return $results;
}
}
diff --git a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
index ee4c8609fa..37aa314ce9 100644
--- a/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
+++ b/src/applications/typeahead/storage/PhabricatorTypeaheadResult.php
@@ -1,92 +1,120 @@
<?php
final class PhabricatorTypeaheadResult {
private $name;
private $uri;
private $phid;
private $priorityString;
private $displayName;
private $displayType;
private $imageURI;
private $priorityType;
private $imageSprite;
private $icon;
private $closed;
public function setIcon($icon) {
$this->icon = $icon;
return $this;
}
public function setName($name) {
$this->name = $name;
return $this;
}
public function setURI($uri) {
$this->uri = $uri;
return $this;
}
public function setPHID($phid) {
$this->phid = $phid;
return $this;
}
public function setPriorityString($priority_string) {
$this->priorityString = $priority_string;
return $this;
}
public function setDisplayName($display_name) {
$this->displayName = $display_name;
return $this;
}
public function setDisplayType($display_type) {
$this->displayType = $display_type;
return $this;
}
public function setImageURI($image_uri) {
$this->imageURI = $image_uri;
return $this;
}
public function setPriorityType($priority_type) {
$this->priorityType = $priority_type;
return $this;
}
public function setImageSprite($image_sprite) {
$this->imageSprite = $image_sprite;
return $this;
}
public function setClosed($closed) {
$this->closed = $closed;
return $this;
}
public function getWireFormat() {
$data = array(
$this->name,
$this->uri ? (string)$this->uri : null,
$this->phid,
$this->priorityString,
$this->displayName,
$this->displayType,
$this->imageURI ? (string)$this->imageURI : null,
$this->priorityType,
- $this->icon,
+ ($this->icon === null) ? $this->getDefaultIcon() : $this->icon,
$this->closed,
$this->imageSprite ? (string)$this->imageSprite : null,
);
while (end($data) === null) {
array_pop($data);
}
return $data;
}
+ /**
+ * If the datasource did not specify an icon explicitly, try to select a
+ * default based on PHID type.
+ */
+ private function getDefaultIcon() {
+ static $icon_map;
+ if ($icon_map === null) {
+ $types = PhabricatorPHIDType::getAllTypes();
+
+ $map = array();
+ foreach ($types as $type) {
+ $icon = $type->getTypeIcon();
+ if ($icon !== null) {
+ $map[$type->getTypeConstant()] = "{$icon} bluegrey";
+ }
+ }
+
+ $icon_map = $map;
+ }
+
+ $phid_type = phid_get_type($this->phid);
+ if (isset($icon_map[$phid_type])) {
+ return $icon_map[$phid_type];
+ }
+
+ return null;
+ }
+
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Feb 4, 6:53 AM (1 d, 11 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
738977
Default Alt Text
(16 KB)

Event Timeline