コード例 #1
0
    private function buildQueriesBox(PhabricatorApplicationSearchEngine $engine)
    {
        $viewer = $this->getViewer();
        $info = pht(<<<EOTEXT
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`,
the query will start with no constraints.

For example, many applications have builtin queries like `"active"` or
`"open"` to find only active or enabled results. To use a `queryKey`, specify
it like this:

```lang=json, name="Selecting a Builtin Query"
{
  ...
  "queryKey": "active",
  ...
}
```

The table below shows the keys to use to select builtin queries and your
saved queries, but you can also use **any** query you run via the web UI as a
starting point. You can find the key for a query by examining the URI after
running a normal search.

You can use these keys to select builtin queries and your configured saved
queries:
EOTEXT
);
        $named_queries = $engine->loadAllNamedQueries();
        $rows = array();
        foreach ($named_queries as $named_query) {
            $builtin = $named_query->getIsBuiltin() ? pht('Builtin') : pht('Custom');
            $rows[] = array($named_query->getQueryKey(), $named_query->getQueryName(), $builtin);
        }
        $table = id(new AphrontTableView($rows))->setHeaders(array(pht('Query Key'), pht('Name'), pht('Builtin')))->setColumnClasses(array('prewrap', 'pri wide', null));
        return id(new PHUIObjectBoxView())->setHeaderText(pht('Builtin and Saved Queries'))->setCollapsed(true)->appendChild($this->buildRemarkup($info))->appendChild($table);
    }