2013-10-02 22:13:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAppSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
2014-06-12 22:22:20 +02:00
|
|
|
public function getResultTypeDescription() {
|
|
|
|
return pht('Applications');
|
|
|
|
}
|
|
|
|
|
2014-05-09 21:25:52 +02:00
|
|
|
public function getApplicationClassName() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return 'PhabricatorApplicationsApplication';
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
public function getPageSize(PhabricatorSavedQuery $saved) {
|
|
|
|
return INF;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromRequest(AphrontRequest $request) {
|
|
|
|
$saved = new PhabricatorSavedQuery();
|
|
|
|
|
|
|
|
$saved->setParameter('name', $request->getStr('name'));
|
|
|
|
|
2013-10-07 02:10:29 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'installed',
|
|
|
|
$this->readBoolFromRequest($request, 'installed'));
|
|
|
|
$saved->setParameter(
|
|
|
|
'beta',
|
|
|
|
$this->readBoolFromRequest($request, 'beta'));
|
|
|
|
$saved->setParameter(
|
|
|
|
'firstParty',
|
|
|
|
$this->readBoolFromRequest($request, 'firstParty'));
|
2014-05-29 21:17:54 +02:00
|
|
|
$saved->setParameter(
|
|
|
|
'launchable',
|
|
|
|
$this->readBoolFromRequest($request, 'launchable'));
|
2013-10-02 22:13:07 +02:00
|
|
|
|
|
|
|
return $saved;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) {
|
2013-10-03 21:39:15 +02:00
|
|
|
$query = id(new PhabricatorApplicationQuery())
|
2013-10-04 15:46:47 +02:00
|
|
|
->setOrder(PhabricatorApplicationQuery::ORDER_NAME)
|
|
|
|
->withUnlisted(false);
|
2013-10-02 22:13:07 +02:00
|
|
|
|
|
|
|
$name = $saved->getParameter('name');
|
|
|
|
if (strlen($name)) {
|
|
|
|
$query->withNameContains($name);
|
|
|
|
}
|
|
|
|
|
|
|
|
$installed = $saved->getParameter('installed');
|
|
|
|
if ($installed !== null) {
|
|
|
|
$query->withInstalled($installed);
|
|
|
|
}
|
|
|
|
|
|
|
|
$beta = $saved->getParameter('beta');
|
|
|
|
if ($beta !== null) {
|
|
|
|
$query->withBeta($beta);
|
|
|
|
}
|
|
|
|
|
|
|
|
$first_party = $saved->getParameter('firstParty');
|
|
|
|
if ($first_party !== null) {
|
|
|
|
$query->withFirstParty($first_party);
|
|
|
|
}
|
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$launchable = $saved->getParameter('launchable');
|
|
|
|
if ($launchable !== null) {
|
|
|
|
$query->withLaunchable($launchable);
|
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSearchForm(
|
|
|
|
AphrontFormView $form,
|
|
|
|
PhabricatorSavedQuery $saved) {
|
|
|
|
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('Name Contains'))
|
|
|
|
->setName('name')
|
|
|
|
->setValue($saved->getParameter('name')))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Installed'))
|
|
|
|
->setName('installed')
|
2013-10-07 02:10:29 +02:00
|
|
|
->setValue($this->getBoolFromQuery($saved, 'installed'))
|
2013-10-02 22:13:07 +02:00
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'' => pht('Show All Applications'),
|
|
|
|
'true' => pht('Show Installed Applications'),
|
|
|
|
'false' => pht('Show Uninstalled Applications'),
|
|
|
|
)))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Beta'))
|
|
|
|
->setName('beta')
|
2013-10-07 02:10:29 +02:00
|
|
|
->setValue($this->getBoolFromQuery($saved, 'beta'))
|
2013-10-02 22:13:07 +02:00
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'' => pht('Show All Applications'),
|
|
|
|
'true' => pht('Show Beta Applications'),
|
|
|
|
'false' => pht('Show Released Applications'),
|
|
|
|
)))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Provenance'))
|
|
|
|
->setName('firstParty')
|
2013-10-07 02:10:29 +02:00
|
|
|
->setValue($this->getBoolFromQuery($saved, 'firstParty'))
|
2013-10-02 22:13:07 +02:00
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'' => pht('Show All Applications'),
|
|
|
|
'true' => pht('Show First-Party Applications'),
|
|
|
|
'false' => pht('Show Third-Party Applications'),
|
2014-05-29 21:17:54 +02:00
|
|
|
)))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSelectControl())
|
|
|
|
->setLabel(pht('Launchable'))
|
|
|
|
->setName('launchable')
|
|
|
|
->setValue($this->getBoolFromQuery($saved, 'launchable'))
|
|
|
|
->setOptions(
|
|
|
|
array(
|
|
|
|
'' => pht('Show All Applications'),
|
|
|
|
'true' => pht('Show Launchable Applications'),
|
|
|
|
'false' => pht('Show Non-Launchable Applications'),
|
2013-10-02 22:13:07 +02:00
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/applications/'.$path;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBuiltinQueryNames() {
|
2014-07-23 02:03:09 +02:00
|
|
|
return array(
|
2014-05-29 21:17:54 +02:00
|
|
|
'launcher' => pht('Launcher'),
|
2013-10-02 22:13:07 +02:00
|
|
|
'all' => pht('All Applications'),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
switch ($query_key) {
|
2014-05-29 21:17:54 +02:00
|
|
|
case 'launcher':
|
|
|
|
return $query
|
|
|
|
->setParameter('installed', true)
|
|
|
|
->setParameter('launchable', true);
|
2013-10-02 22:13:07 +02:00
|
|
|
case 'all':
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
2014-05-09 21:25:52 +02:00
|
|
|
protected function renderResultList(
|
2014-05-29 21:17:54 +02:00
|
|
|
array $all_applications,
|
2014-05-09 21:25:52 +02:00
|
|
|
PhabricatorSavedQuery $query,
|
|
|
|
array $handle) {
|
2014-05-29 21:17:54 +02:00
|
|
|
assert_instances_of($all_applications, 'PhabricatorApplication');
|
2014-05-09 21:25:52 +02:00
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$all_applications = msort($all_applications, 'getName');
|
2014-05-09 21:25:52 +02:00
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
if ($query->getQueryKey() == 'launcher') {
|
|
|
|
$groups = mgroup($all_applications, 'getApplicationGroup');
|
|
|
|
} else {
|
|
|
|
$groups = array($all_applications);
|
|
|
|
}
|
2014-05-09 21:25:52 +02:00
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$group_names = PhabricatorApplication::getApplicationGroups();
|
|
|
|
$groups = array_select_keys($groups, array_keys($group_names)) + $groups;
|
|
|
|
|
|
|
|
$results = array();
|
|
|
|
foreach ($groups as $group => $applications) {
|
|
|
|
if (count($groups) > 1) {
|
|
|
|
$results[] = phutil_tag(
|
|
|
|
'h1',
|
|
|
|
array(
|
|
|
|
'class' => 'launcher-header',
|
|
|
|
),
|
|
|
|
idx($group_names, $group, $group));
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$list = new PHUIObjectItemListView();
|
|
|
|
$list->addClass('phui-object-item-launcher-list');
|
|
|
|
|
|
|
|
foreach ($applications as $application) {
|
|
|
|
$icon = $application->getIconName();
|
|
|
|
if (!$icon) {
|
|
|
|
$icon = 'application';
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: This sheet doesn't work the same way other sheets do so it
|
|
|
|
// ends up with the wrong classes if we try to use PHUIIconView. This
|
|
|
|
// is probably all changing in the redesign anyway.
|
|
|
|
|
|
|
|
$icon_view = javelin_tag(
|
|
|
|
'span',
|
|
|
|
array(
|
|
|
|
'class' => 'phui-icon-view '.
|
|
|
|
'sprite-apps-large apps-'.$icon.'-dark-large',
|
|
|
|
'aural' => false,
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$description = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'style' => 'white-space: nowrap; '.
|
|
|
|
'overflow: hidden; '.
|
|
|
|
'text-overflow: ellipsis;',
|
|
|
|
),
|
|
|
|
$application->getShortDescription());
|
|
|
|
|
|
|
|
$item = id(new PHUIObjectItemView())
|
|
|
|
->setHeader($application->getName())
|
|
|
|
->setImageIcon($icon_view)
|
|
|
|
->addAttribute($description)
|
|
|
|
->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('Help/Options'))
|
|
|
|
->setIcon('fa-cog')
|
|
|
|
->setHref('/applications/view/'.get_class($application).'/'));
|
|
|
|
|
|
|
|
if ($application->getBaseURI()) {
|
|
|
|
$item->setHref($application->getBaseURI());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$application->isInstalled()) {
|
(Redesign) Clean up older "Tile" code
Summary:
This does some backend cleanup of the tile stuff, and some general cleanup of other application things:
- Users who haven't customized preferences get a small, specific set of pinned applications: Differential, Maniphest, Diffusion, Audit, Phriction, Projects (and, for administrators, Auth, Config and People).
- Old tile size methods are replaced with `isPinnnedByDefault()`.
- Shortened some short descriptions.
- `shouldAppearInLaunchView()` replaced by less ambiguous `isLaunchable()`.
- Added a marker for third-party / extension applications.
Test Plan: Faked away my preferences and viewed the home page, saw a smaller set of default pins.
Reviewers: chad
Reviewed By: chad
Subscribers: epriestley
Differential Revision: https://secure.phabricator.com/D9358
2014-06-04 00:47:27 +02:00
|
|
|
$item->addIcon('fa-times', pht('Uninstalled'));
|
2014-05-29 21:17:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($application->isBeta()) {
|
|
|
|
$item->addIcon('fa-star-half-o grey', pht('Beta'));
|
|
|
|
}
|
|
|
|
|
(Redesign) Clean up older "Tile" code
Summary:
This does some backend cleanup of the tile stuff, and some general cleanup of other application things:
- Users who haven't customized preferences get a small, specific set of pinned applications: Differential, Maniphest, Diffusion, Audit, Phriction, Projects (and, for administrators, Auth, Config and People).
- Old tile size methods are replaced with `isPinnnedByDefault()`.
- Shortened some short descriptions.
- `shouldAppearInLaunchView()` replaced by less ambiguous `isLaunchable()`.
- Added a marker for third-party / extension applications.
Test Plan: Faked away my preferences and viewed the home page, saw a smaller set of default pins.
Reviewers: chad
Reviewed By: chad
Subscribers: epriestley
Differential Revision: https://secure.phabricator.com/D9358
2014-06-04 00:47:27 +02:00
|
|
|
if (!$application->isFirstParty()) {
|
|
|
|
$item->addIcon('fa-puzzle-piece', pht('Extension'));
|
|
|
|
}
|
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$list->addItem($item);
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
$results[] = $list;
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2014-05-29 21:17:54 +02:00
|
|
|
return $results;
|
2014-05-09 21:25:52 +02:00
|
|
|
}
|
|
|
|
|
2013-10-02 22:13:07 +02:00
|
|
|
}
|