diff --git a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php --- a/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanQuery.php @@ -28,55 +28,46 @@ return $this; } + public function newResultObject() { + return new HarbormasterBuildPlan(); + } + 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); + return $this->loadStandardPage($this->newResultObject()); } - protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { - $where = array(); + protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { + $where = parent::buildWhereClauseParts($conn); - if ($this->ids) { + 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 --- a/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php +++ b/src/applications/harbormaster/query/HarbormasterBuildPlanSearchEngine.php @@ -11,57 +11,34 @@ return 'PhabricatorHarbormasterApplication'; } - public function buildSavedQueryFromRequest(AphrontRequest $request) { - $saved = new PhabricatorSavedQuery(); - - $saved->setParameter( - 'status', - $this->readListFromRequest($request, 'status')); - - $this->saveQueryOrder($saved, $request); + public function newQuery() { + return new HarbormasterBuildPlanQuery(); + } - return $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'), + )), + ); } - public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { - $query = id(new HarbormasterBuildPlanQuery()); - $this->setQueryOrder($query, $saved); + public function buildQueryFromParameters(array $map) { + $query = $this->newQuery(); - $status = $saved->getParameter('status', array()); - if ($status) { - $query->withStatuses($status); + 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 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -891,20 +891,6 @@ /* -( 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. */