Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / settings / query / PhabricatorUserPreferencesSearchEngine.php
bloba677ed0e66e309ad494940b33e888d2bfdfa8e71
1 <?php
3 final class PhabricatorUserPreferencesSearchEngine
4 extends PhabricatorApplicationSearchEngine {
6 public function getResultTypeDescription() {
7 return pht('User Preferences');
10 public function getApplicationClassName() {
11 return 'PhabricatorSettingApplication';
14 public function newQuery() {
15 return id(new PhabricatorUserPreferencesQuery())
16 ->withHasUserPHID(false);
19 protected function buildQueryFromParameters(array $map) {
20 $query = $this->newQuery();
22 return $query;
25 protected function buildCustomSearchFields() {
26 return array();
29 protected function getURI($path) {
30 return '/settings/'.$path;
33 protected function getBuiltinQueryNames() {
34 $names = array(
35 'all' => pht('All Settings'),
38 return $names;
41 public function buildSavedQueryFromBuiltin($query_key) {
42 $query = $this->newSavedQuery();
43 $query->setQueryKey($query_key);
45 switch ($query_key) {
46 case 'all':
47 return $query;
50 return parent::buildSavedQueryFromBuiltin($query_key);
53 protected function renderResultList(
54 array $settings,
55 PhabricatorSavedQuery $query,
56 array $handles) {
57 assert_instances_of($settings, 'PhabricatorUserPreferences');
59 $viewer = $this->requireViewer();
61 $list = id(new PHUIObjectItemListView())
62 ->setViewer($viewer);
63 foreach ($settings as $setting) {
65 $icon = id(new PHUIIconView())
66 ->setIcon('fa-globe')
67 ->setBackground('bg-sky');
69 $item = id(new PHUIObjectItemView())
70 ->setHeader($setting->getDisplayName())
71 ->setHref($setting->getEditURI())
72 ->setImageIcon($icon)
73 ->addAttribute(pht('Edit global default settings for all users.'));
75 $list->addItem($item);
78 $list->addItem(
79 id(new PHUIObjectItemView())
80 ->setHeader(pht('Personal Account Settings'))
81 ->addAttribute(pht('Edit settings for your personal account.'))
82 ->setImageURI($viewer->getProfileImageURI())
83 ->setHref('/settings/user/'.$viewer->getUsername().'/'));
85 return id(new PhabricatorApplicationSearchResultView())
86 ->setObjectList($list);