Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/engine/PhabricatorSearchEngineAPIMethod.php
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | abstract class PhabricatorSearchEngineAPIMethod | ||||
final public function getMethodDescription() { | final public function getMethodDescription() { | ||||
return pht( | return pht( | ||||
'This is a standard **ApplicationSearch** method which will let you '. | 'This is a standard **ApplicationSearch** method which will let you '. | ||||
'list, query, or search for objects. For documentation on these '. | 'list, query, or search for objects. For documentation on these '. | ||||
'endpoints, see **[[ %s | Conduit API: Using Search Endpoints ]]**.', | 'endpoints, see **[[ %s | Conduit API: Using Search Endpoints ]]**.', | ||||
PhabricatorEnv::getDoclink('Conduit API: Using Search Endpoints')); | PhabricatorEnv::getDoclink('Conduit API: Using Search Endpoints')); | ||||
} | } | ||||
final public function getMethodDocumentation() { | final protected function newDocumentationPages(PhabricatorUser $viewer) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$engine = $this->newSearchEngine() | $engine = $this->newSearchEngine() | ||||
->setViewer($viewer); | ->setViewer($viewer); | ||||
$query = $engine->newQuery(); | $query = $engine->newQuery(); | ||||
$out = array(); | $out = array(); | ||||
$out[] = $this->buildQueriesBox($engine); | $out[] = $this->buildQueriesDocumentationPage($viewer, $engine); | ||||
$out[] = $this->buildConstraintsBox($engine); | $out[] = $this->buildConstraintsDocumentationPage($viewer, $engine); | ||||
$out[] = $this->buildOrderBox($engine, $query); | $out[] = $this->buildOrderDocumentationPage($viewer, $engine, $query); | ||||
$out[] = $this->buildFieldsBox($engine); | $out[] = $this->buildFieldsDocumentationPage($viewer, $engine); | ||||
$out[] = $this->buildAttachmentsBox($engine); | $out[] = $this->buildAttachmentsDocumentationPage($viewer, $engine); | ||||
$out[] = $this->buildPagingBox($engine); | $out[] = $this->buildPagingDocumentationPage($viewer, $engine); | ||||
return $out; | return $out; | ||||
} | } | ||||
private function buildQueriesBox( | private function buildQueriesDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine) { | PhabricatorApplicationSearchEngine $engine) { | ||||
$viewer = $this->getViewer(); | $viewer = $this->getViewer(); | ||||
$info = pht(<<<EOTEXT | $info = pht(<<<EOTEXT | ||||
You can choose a builtin or saved query as a starting point for filtering | You can choose a builtin or saved query as a starting point for filtering | ||||
results by selecting it with `queryKey`. If you don't specify a `queryKey`, | results by selecting it with `queryKey`. If you don't specify a `queryKey`, | ||||
the query will start with no constraints. | the query will start with no constraints. | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | $table = id(new AphrontTableView($rows)) | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'prewrap', | 'prewrap', | ||||
'pri wide', | 'pri wide', | ||||
null, | null, | ||||
)); | )); | ||||
return id(new PHUIObjectBoxView()) | $title = pht('Prebuilt Queries'); | ||||
->setHeaderText(pht('Builtin and Saved Queries')) | $content = array( | ||||
->setCollapsed(true) | $this->newRemarkupDocumentationView($info), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $table, | ||||
->appendChild($this->newRemarkupDocumentationView($info)) | ); | ||||
->appendChild($table); | |||||
return $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('queries'); | |||||
} | } | ||||
private function buildConstraintsBox( | private function buildConstraintsDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine) { | PhabricatorApplicationSearchEngine $engine) { | ||||
$info = pht(<<<EOTEXT | $info = pht(<<<EOTEXT | ||||
You can apply custom constraints by passing a dictionary in `constraints`. | You can apply custom constraints by passing a dictionary in `constraints`. | ||||
This will let you search for specific sets of results (for example, you may | This will let you search for specific sets of results (for example, you may | ||||
want show only results with a certain state, status, or owner). | want show only results with a certain state, status, or owner). | ||||
▲ Show 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | $table = id(new AphrontTableView($rows)) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'prewrap', | 'prewrap', | ||||
'pri', | 'pri', | ||||
'prewrap', | 'prewrap', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
return id(new PHUIObjectBoxView()) | |||||
->setHeaderText(pht('Custom Query Constraints')) | $title = pht('Constraints'); | ||||
->setCollapsed(true) | $content = array( | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $this->newRemarkupDocumentationView($info), | ||||
->appendChild($this->newRemarkupDocumentationView($info)) | $table, | ||||
->appendChild($table) | $constant_lists, | ||||
->appendChild($constant_lists); | ); | ||||
return $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('constraints') | |||||
->setIconIcon('fa-filter'); | |||||
} | } | ||||
private function buildOrderBox( | private function buildOrderDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine, | PhabricatorApplicationSearchEngine $engine, | ||||
$query) { | $query) { | ||||
$orders_info = pht(<<<EOTEXT | $orders_info = pht(<<<EOTEXT | ||||
Use `order` to choose an ordering for the results. | Use `order` to choose an ordering for the results. | ||||
Either specify a single key from the builtin orders (these are a set of | Either specify a single key from the builtin orders (these are a set of | ||||
meaningful, high-level, human-readable orders) or specify a custom list of | meaningful, high-level, human-readable orders) or specify a custom list of | ||||
▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | $columns_table = id(new AphrontTableView($rows)) | ||||
pht('Unique'), | pht('Unique'), | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'pri', | 'pri', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
$title = pht('Result Ordering'); | |||||
$content = array( | |||||
$this->newRemarkupDocumentationView($orders_info), | |||||
$orders_table, | |||||
$this->newRemarkupDocumentationView($columns_info), | |||||
$columns_table, | |||||
); | |||||
return id(new PHUIObjectBoxView()) | return $this->newDocumentationBoxPage($viewer, $title, $content) | ||||
->setHeaderText(pht('Result Ordering')) | ->setAnchor('ordering') | ||||
->setCollapsed(true) | ->setIconIcon('fa-sort-numeric-asc'); | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->appendChild($this->newRemarkupDocumentationView($orders_info)) | |||||
->appendChild($orders_table) | |||||
->appendChild($this->newRemarkupDocumentationView($columns_info)) | |||||
->appendChild($columns_table); | |||||
} | } | ||||
private function buildFieldsBox( | private function buildFieldsDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine) { | PhabricatorApplicationSearchEngine $engine) { | ||||
$info = pht(<<<EOTEXT | $info = pht(<<<EOTEXT | ||||
Objects matching your query are returned as a list of dictionaries in the | Objects matching your query are returned as a list of dictionaries in the | ||||
`data` property of the results. Each dictionary has some metadata and a | `data` property of the results. Each dictionary has some metadata and a | ||||
`fields` key, which contains the information about the object that most callers | `fields` key, which contains the information about the object that most callers | ||||
will be interested in. | will be interested in. | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | $table = id(new AphrontTableView($rows)) | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'pri', | 'pri', | ||||
'mono', | 'mono', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
return id(new PHUIObjectBoxView()) | $title = pht('Object Fields'); | ||||
->setHeaderText(pht('Object Fields')) | $content = array( | ||||
->setCollapsed(true) | $this->newRemarkupDocumentationView($info), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $table, | ||||
->appendChild($this->newRemarkupDocumentationView($info)) | ); | ||||
->appendChild($table); | |||||
return $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('fields') | |||||
->setIconIcon('fa-cube'); | |||||
} | } | ||||
private function buildAttachmentsBox( | private function buildAttachmentsDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine) { | PhabricatorApplicationSearchEngine $engine) { | ||||
$info = pht(<<<EOTEXT | $info = pht(<<<EOTEXT | ||||
By default, only basic information about objects is returned. If you want | By default, only basic information about objects is returned. If you want | ||||
more extensive information, you can use available `attachments` to get more | more extensive information, you can use available `attachments` to get more | ||||
information in the results (like subscribers and projects). | information in the results (like subscribers and projects). | ||||
Generally, requesting more information means the query executes more slowly | Generally, requesting more information means the query executes more slowly | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | $table = id(new AphrontTableView($rows)) | ||||
)) | )) | ||||
->setColumnClasses( | ->setColumnClasses( | ||||
array( | array( | ||||
'prewrap', | 'prewrap', | ||||
'pri', | 'pri', | ||||
'wide', | 'wide', | ||||
)); | )); | ||||
return id(new PHUIObjectBoxView()) | $title = pht('Attachments'); | ||||
->setHeaderText(pht('Attachments')) | $content = array( | ||||
->setCollapsed(true) | $this->newRemarkupDocumentationView($info), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | $table, | ||||
->appendChild($this->newRemarkupDocumentationView($info)) | ); | ||||
->appendChild($table); | |||||
return $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('attachments') | |||||
->setIconIcon('fa-cubes'); | |||||
} | } | ||||
private function buildPagingBox( | private function buildPagingDocumentationPage( | ||||
PhabricatorUser $viewer, | |||||
PhabricatorApplicationSearchEngine $engine) { | PhabricatorApplicationSearchEngine $engine) { | ||||
$info = pht(<<<EOTEXT | $info = pht(<<<EOTEXT | ||||
Queries are limited to returning 100 results at a time. If you want fewer | Queries are limited to returning 100 results at a time. If you want fewer | ||||
results than this, you can use `limit` to specify a smaller limit. | results than this, you can use `limit` to specify a smaller limit. | ||||
If you want more results, you'll need to make additional queries to retrieve | If you want more results, you'll need to make additional queries to retrieve | ||||
more pages of results. | more pages of results. | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
might be useful if you are rendering a web UI for a user and want to provide | might be useful if you are rendering a web UI for a user and want to provide | ||||
"Next Page" and "Previous Page" links. | "Next Page" and "Previous Page" links. | ||||
If `after` is `null`, there is no next page of results available. Likewise, | If `after` is `null`, there is no next page of results available. Likewise, | ||||
if `before` is `null`, there are no previous results available. | if `before` is `null`, there are no previous results available. | ||||
EOTEXT | EOTEXT | ||||
); | ); | ||||
return id(new PHUIObjectBoxView()) | $title = pht('Paging and Limits'); | ||||
->setHeaderText(pht('Paging and Limits')) | $content = array( | ||||
->setCollapsed(true) | $this->newRemarkupDocumentationView($info), | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | ); | ||||
->appendChild($this->newRemarkupDocumentationView($info)); | |||||
return $this->newDocumentationBoxPage($viewer, $title, $content) | |||||
->setAnchor('paging') | |||||
->setIconIcon('fa-clone'); | |||||
} | } | ||||
} | } |