Changeset View
Changeset View
Standalone View
Standalone View
src/view/page/menu/PhabricatorMainMenuSearchView.php
Show First 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | $form = phabricator_form( | ||||
$selector, | $selector, | ||||
$primary_input, | $primary_input, | ||||
$target, | $target, | ||||
))); | ))); | ||||
return $form; | return $form; | ||||
} | } | ||||
private function buildModeSelector($selector_id, $application_id) { | public static function getGlobalSearchScopeItems( | ||||
$viewer = $this->getViewer(); | PhabricatorUser $viewer, | ||||
PhabricatorApplication $application) { | |||||
$items = array(); | $items = array(); | ||||
$items[] = array( | $items[] = array( | ||||
'name' => pht('Search'), | 'name' => pht('Search'), | ||||
); | ); | ||||
$items[] = array( | $items[] = array( | ||||
'icon' => 'fa-globe', | 'icon' => 'fa-globe', | ||||
'name' => pht('All Documents'), | 'name' => pht('All Documents'), | ||||
'value' => 'all', | 'value' => 'all', | ||||
); | ); | ||||
$application_value = null; | $application_value = null; | ||||
$application_icon = self::DEFAULT_APPLICATION_ICON; | $application_icon = self::DEFAULT_APPLICATION_ICON; | ||||
$application = $this->getApplication(); | |||||
if ($application) { | if ($application) { | ||||
$application_value = get_class($application); | $application_value = get_class($application); | ||||
if ($application->getApplicationSearchDocumentTypes()) { | if ($application->getApplicationSearchDocumentTypes()) { | ||||
$application_icon = $application->getIcon(); | $application_icon = $application->getIcon(); | ||||
} | } | ||||
} | } | ||||
$items[] = array( | $items[] = array( | ||||
Show All 36 Lines | public static function getGlobalSearchScopeItems( | ||||
); | ); | ||||
$items[] = array( | $items[] = array( | ||||
'icon' => 'fa-book', | 'icon' => 'fa-book', | ||||
'name' => pht('User Guide: Search'), | 'name' => pht('User Guide: Search'), | ||||
'href' => PhabricatorEnv::getDoclink('Search User Guide'), | 'href' => PhabricatorEnv::getDoclink('Search User Guide'), | ||||
); | ); | ||||
return $items; | |||||
} | |||||
private function buildModeSelector($selector_id, $application_id) { | |||||
$viewer = $this->getViewer(); | |||||
$items = self::getGlobalSearchScopeItems($viewer, $this->getApplication()); | |||||
$scope_key = PhabricatorSearchScopeSetting::SETTINGKEY; | $scope_key = PhabricatorSearchScopeSetting::SETTINGKEY; | ||||
$current_value = $viewer->getUserSetting($scope_key); | $current_value = $viewer->getUserSetting($scope_key); | ||||
$current_icon = 'fa-globe'; | $current_icon = 'fa-globe'; | ||||
foreach ($items as $item) { | foreach ($items as $item) { | ||||
if (idx($item, 'value') == $current_value) { | if (idx($item, 'value') == $current_value) { | ||||
$current_icon = $item['icon']; | $current_icon = $item['icon']; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
$application = $this->getApplication(); | |||||
$application_value = null; | |||||
if ($application) { | |||||
$application_value = get_class($application); | |||||
} | |||||
$selector = id(new PHUIButtonView()) | $selector = id(new PHUIButtonView()) | ||||
->setID($selector_id) | ->setID($selector_id) | ||||
->addClass('phabricator-main-menu-search-dropdown') | ->addClass('phabricator-main-menu-search-dropdown') | ||||
->addSigil('global-search-dropdown') | ->addSigil('global-search-dropdown') | ||||
->setMetadata( | ->setMetadata( | ||||
array( | array( | ||||
'items' => $items, | 'items' => $items, | ||||
'icon' => $current_icon, | 'icon' => $current_icon, | ||||
Show All 32 Lines |