private function renderSearch()
 {
     $user = $this->user;
     $result = null;
     $keyboard_config = array('helpURI' => '/help/keyboardshortcut/');
     if ($user->isLoggedIn()) {
         $show_search = $user->isUserActivated();
     } else {
         $show_search = PhabricatorEnv::getEnvConfig('policy.allow-public');
     }
     if ($show_search) {
         $search = new PhabricatorMainMenuSearchView();
         $search->setUser($user);
         $application = null;
         $controller = $this->getController();
         if ($controller) {
             $application = $controller->getCurrentApplication();
         }
         if ($application) {
             $search->setApplication($application);
         }
         $result = $search;
         $pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
         if ($user->loadPreferences()->getPreference($pref_shortcut, true)) {
             $keyboard_config['searchID'] = $search->getID();
         }
     }
     Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config);
     if ($result) {
         $result = id(new PHUIListItemView())->addClass('phabricator-main-menu-search')->appendChild($result);
     }
     return $result;
 }
 private function renderMainMenu()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $menu = new PhabricatorMainMenuView();
     $menu->setUser($user);
     $keyboard_config = array('helpURI' => '/help/keyboardshortcut/');
     if ($user->isLoggedIn()) {
         $search = new PhabricatorMainMenuSearchView();
         $search->setUser($user);
         $search->setScope($this->getSearchDefaultScope());
         $menu->appendChild($search);
         $pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
         if ($user->loadPreferences()->getPreference($pref_shortcut, true)) {
             $keyboard_config['searchID'] = $search->getID();
         }
     }
     Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config);
     $applications = PhabricatorApplication::getAllInstalledApplications();
     $icon_views = array();
     foreach ($applications as $application) {
         $icon_views[] = $application->buildMainMenuItems($this->getRequest()->getUser(), $this->getController());
     }
     $icon_views = array_mergev($icon_views);
     $icon_views = msort($icon_views, 'getSortOrder');
     $menu->appendChild($icon_views);
     return $menu->render();
 }
 private function renderSearch()
 {
     $viewer = $this->getViewer();
     $result = null;
     $keyboard_config = array('helpURI' => '/help/keyboardshortcut/');
     if ($viewer->isLoggedIn()) {
         $show_search = $viewer->isUserActivated();
     } else {
         $show_search = PhabricatorEnv::getEnvConfig('policy.allow-public');
     }
     if ($show_search) {
         $search = new PhabricatorMainMenuSearchView();
         $search->setViewer($viewer);
         $application = null;
         $controller = $this->getController();
         if ($controller) {
             $application = $controller->getCurrentApplication();
         }
         if ($application) {
             $search->setApplication($application);
         }
         $result = $search;
         $keyboard_config['searchID'] = $search->getID();
     }
     $keyboard_config['pht'] = array('/' => pht('Give keyboard focus to the search box.'), '?' => pht('Show keyboard shortcut help for the current page.'));
     Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config);
     if ($result) {
         $result = id(new PHUIListItemView())->addClass('phabricator-main-menu-search')->appendChild($result);
     }
     return $result;
 }
 private function renderMainMenu()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $menu = new PhabricatorMainMenuView();
     $menu->setUser($user);
     $keyboard_config = array('helpURI' => '/help/keyboardshortcut/');
     if ($user->isLoggedIn()) {
         $search = new PhabricatorMainMenuSearchView();
         $search->setUser($user);
         $search->setScope($this->getSearchDefaultScope());
         $menu->appendChild($search);
         $pref_shortcut = PhabricatorUserPreferences::PREFERENCE_SEARCH_SHORTCUT;
         if ($user->loadPreferences()->getPreference($pref_shortcut, true)) {
             $keyboard_config['searchID'] = $search->getID();
         }
     }
     Javelin::initBehavior('phabricator-keyboard-shortcuts', $keyboard_config);
     if ($user->isLoggedIn()) {
         require_celerity_resource('phabricator-glyph-css');
         $item = new PhabricatorMainMenuIconView();
         $item->setName($user->getUsername());
         $item->addClass('glyph glyph-profile');
         $item->setHref('/p/' . $user->getUsername() . '/');
         $menu->appendChild($item);
         $item = new PhabricatorMainMenuIconView();
         $item->setName(pht('Settings'));
         $item->addClass('glyph glyph-settings');
         $item->setHref('/settings/');
         $menu->appendChild($item);
         $item = new PhabricatorMainMenuIconView();
         $item->setName(pht('Log Out'));
         $item->addClass('glyph glyph-logout');
         $item->setHref('/logout/');
         $menu->appendChild($item);
     }
     return $menu->render();
 }