1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-04-04 08:28:22 +02:00
phorge-phorge/src/applications/help/application/PhabricatorHelpApplication.php
epriestley ae192e5328 Always render extra menu nodes, even when logged out
Summary:
Fixes T7915. This code is a little janky, but make it work for now.

Currently, we render "extra" nodes (dropdowns, etc) only if the user is logged in.

Instead, always render them.

Test Plan:
  - No more "phabricator-help-menu" error in console when logged out.
  - Search selector now works when logged out.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7915

Differential Revision: https://secure.phabricator.com/D12572
2015-04-27 08:15:51 -07:00

108 lines
2.5 KiB
PHP

<?php
final class PhabricatorHelpApplication extends PhabricatorApplication {
public function getName() {
return pht('Help');
}
public function canUninstall() {
return false;
}
public function isUnlisted() {
return true;
}
public function getRoutes() {
return array(
'/help/' => array(
'keyboardshortcut/' => 'PhabricatorHelpKeyboardShortcutController',
'editorprotocol/' => 'PhabricatorHelpEditorProtocolController',
'documentation/(?P<application>\w+)/'
=> 'PhabricatorHelpDocumentationController',
),
);
}
public function buildMainMenuItems(
PhabricatorUser $user,
PhabricatorController $controller = null) {
$application = null;
if ($controller) {
$application = $controller->getCurrentApplication();
}
$items = array();
$help_id = celerity_generate_unique_node_id();
Javelin::initBehavior(
'aphlict-dropdown',
array(
'bubbleID' => $help_id,
'dropdownID' => 'phabricator-help-menu',
'applicationClass' => 'PhabricatorHelpApplication',
'local' => true,
'desktop' => true,
'right' => true,
));
$item = id(new PHUIListItemView())
->setIcon('fa-life-ring')
->addClass('core-menu-item')
->setID($help_id)
->setOrder(200);
$hide = true;
if ($application) {
$help_name = pht('%s Help', $application->getName());
$item
->setName($help_name)
->setHref('/help/documentation/'.get_class($application).'/')
->setAural($help_name);
$help_items = $application->getHelpMenuItems($user);
if ($help_items) {
$hide = false;
}
}
if ($hide) {
$item->setStyle('display: none');
}
$items[] = $item;
return $items;
}
public function buildMainMenuExtraNodes(
PhabricatorUser $viewer,
PhabricatorController $controller = null) {
$application = null;
if ($controller) {
$application = $controller->getCurrentApplication();
}
$view = null;
if ($application) {
$help_items = $application->getHelpMenuItems($viewer);
if ($help_items) {
$view = new PHUIListView();
foreach ($help_items as $item) {
$view->addMenuItem($item);
}
}
}
return phutil_tag(
'div',
array(
'id' => 'phabricator-help-menu',
'class' => 'phabricator-main-menu-dropdown phui-list-sidenav',
'style' => 'display: none',
),
$view);
}
}