2013-10-02 22:13:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class PhabricatorAppSearchEngine
|
|
|
|
extends PhabricatorApplicationSearchEngine {
|
|
|
|
|
|
|
|
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'));
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
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'),
|
|
|
|
)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getURI($path) {
|
|
|
|
return '/applications/'.$path;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getBuiltinQueryNames() {
|
|
|
|
$names = array(
|
|
|
|
'all' => pht('All Applications'),
|
|
|
|
);
|
|
|
|
|
|
|
|
return $names;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function buildSavedQueryFromBuiltin($query_key) {
|
|
|
|
|
|
|
|
$query = $this->newSavedQuery();
|
|
|
|
$query->setQueryKey($query_key);
|
|
|
|
|
|
|
|
switch ($query_key) {
|
|
|
|
case 'all':
|
|
|
|
return $query;
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::buildSavedQueryFromBuiltin($query_key);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|