diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php index 4123941665..9caf01f54e 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php @@ -28,55 +28,46 @@ final class HarbormasterBuildPlanQuery return $this; } - protected function loadPage() { - $table = new HarbormasterBuildPlan(); - $conn_r = $table->establishConnection('r'); - - $data = queryfx_all( - $conn_r, - 'SELECT * FROM %T %Q %Q %Q', - $table->getTableName(), - $this->buildWhereClause($conn_r), - $this->buildOrderClause($conn_r), - $this->buildLimitClause($conn_r)); - - return $table->loadAllFromArray($data); + public function newResultObject() { + return new HarbormasterBuildPlan(); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - $where = array(); + protected function loadPage() { + return $this->loadStandardPage($this->newResultObject()); + } - if ($this->ids) { + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); + + if ($this->ids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'id IN (%Ld)', $this->ids); } - if ($this->phids) { + if ($this->phids !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'phid IN (%Ls)', $this->phids); } - if ($this->statuses) { + if ($this->statuses !== null) { $where[] = qsprintf( - $conn_r, + $conn, 'planStatus IN (%Ls)', $this->statuses); } if (strlen($this->datasourceQuery)) { $where[] = qsprintf( - $conn_r, + $conn, 'name LIKE %>', $this->datasourceQuery); } - $where[] = $this->buildPagingClause($conn_r); - - return $this->formatWhereClause($where); + return $where; } public function getQueryApplicationClass() { diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php index 0ab920a905..6d2fe319ae 100644 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php @@ -11,57 +11,34 @@ final class HarbormasterBuildPlanSearchEngine return 'PhabricatorHarbormasterApplication'; } - public function buildSavedQueryFromRequest(AphrontRequest $request) { - $saved = new PhabricatorSavedQuery(); - - $saved->setParameter( - 'status', - $this->readListFromRequest($request, 'status')); - - $this->saveQueryOrder($saved, $request); - - return $saved; + public function newQuery() { + return new HarbormasterBuildPlanQuery(); } - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { - $query = id(new HarbormasterBuildPlanQuery()); - $this->setQueryOrder($query, $saved); + protected function buildCustomSearchFields() { + return array( + id(new PhabricatorSearchCheckboxesField()) + ->setLabel(pht('Status')) + ->setKey('status') + ->setAliases(array('statuses')) + ->setOptions( + array( + HarbormasterBuildPlan::STATUS_ACTIVE => pht('Active'), + HarbormasterBuildPlan::STATUS_DISABLED => pht('Disabled'), + )), + ); + } - $status = $saved->getParameter('status', array()); - if ($status) { - $query->withStatuses($status); + public function buildQueryFromParameters(array $map) { + $query = $this->newQuery(); + + if ($map['status']) { + $query->withStatuses($map['status']); } return $query; } - public function buildSearchForm( - AphrontFormView $form, - PhabricatorSavedQuery $saved) { - - $status = $saved->getParameter('status', array()); - - $form - ->appendChild( - id(new AphrontFormCheckboxControl()) - ->setLabel('Status') - ->addCheckbox( - 'status[]', - HarbormasterBuildPlan::STATUS_ACTIVE, - pht('Active'), - in_array(HarbormasterBuildPlan::STATUS_ACTIVE, $status)) - ->addCheckbox( - 'status[]', - HarbormasterBuildPlan::STATUS_DISABLED, - pht('Disabled'), - in_array(HarbormasterBuildPlan::STATUS_DISABLED, $status))); - - $this->appendOrderFieldsToForm( - $form, - $saved, - new HarbormasterBuildPlanQuery()); - } - protected function getURI($path) { return '/harbormaster/plan/'.$path; } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index 11e562b43f..e1e094a8ff 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -891,20 +891,6 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { /* -( Result Ordering )---------------------------------------------------- */ - - /** - * Save order selection to a @{class:PhabricatorSavedQuery}. - */ - protected function saveQueryOrder( - PhabricatorSavedQuery $saved, - AphrontRequest $request) { - - $saved->setParameter('order', $request->getStr('order')); - - return $this; - } - - /** * Set query ordering from a saved value. */