Changeset View
Changeset View
Standalone View
Standalone View
src/view/page/menu/PhabricatorMainMenuView.php
Show All 28 Lines | public function render() { | ||||
require_celerity_resource('phabricator-main-menu-view'); | require_celerity_resource('phabricator-main-menu-view'); | ||||
require_celerity_resource('sprite-main-header-css'); | require_celerity_resource('sprite-main-header-css'); | ||||
$header_id = celerity_generate_unique_node_id(); | $header_id = celerity_generate_unique_node_id(); | ||||
$menus = array(); | $menus = array(); | ||||
$alerts = array(); | $alerts = array(); | ||||
$search_button = ''; | $search_button = ''; | ||||
$app_button = ''; | $app_button = ''; | ||||
$aural = null; | |||||
if ($user->isLoggedIn() && $user->isUserActivated()) { | if ($user->isLoggedIn() && $user->isUserActivated()) { | ||||
list($menu, $dropdowns) = $this->renderNotificationMenu(); | list($menu, $dropdowns, $aural) = $this->renderNotificationMenu(); | ||||
$alerts[] = $menu; | $alerts[] = $menu; | ||||
$menus = array_merge($menus, $dropdowns); | $menus = array_merge($menus, $dropdowns); | ||||
$app_button = $this->renderApplicationMenuButton($header_id); | $app_button = $this->renderApplicationMenuButton($header_id); | ||||
$search_button = $this->renderSearchMenuButton($header_id); | $search_button = $this->renderSearchMenuButton($header_id); | ||||
} else { | } else { | ||||
$app_button = $this->renderApplicationMenuButton($header_id); | $app_button = $this->renderApplicationMenuButton($header_id); | ||||
if (PhabricatorEnv::getEnvConfig('policy.allow-public')) { | if (PhabricatorEnv::getEnvConfig('policy.allow-public')) { | ||||
$search_button = $this->renderSearchMenuButton($header_id); | $search_button = $this->renderSearchMenuButton($header_id); | ||||
} | } | ||||
} | } | ||||
$search_menu = $this->renderPhabricatorSearchMenu(); | $search_menu = $this->renderPhabricatorSearchMenu(); | ||||
if ($alerts) { | if ($alerts) { | ||||
$alerts = phutil_tag( | $alerts = javelin_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => 'phabricator-main-menu-alerts', | 'class' => 'phabricator-main-menu-alerts', | ||||
'aural' => false, | |||||
), | ), | ||||
$alerts); | $alerts); | ||||
} | } | ||||
if ($aural) { | |||||
$aural = javelin_tag( | |||||
'span', | |||||
array( | |||||
'aural' => true, | |||||
), | |||||
phutil_implode_html(' ', $aural)); | |||||
} | |||||
$application_menu = $this->renderApplicationMenu(); | $application_menu = $this->renderApplicationMenu(); | ||||
$classes = array(); | $classes = array(); | ||||
$classes[] = 'phabricator-main-menu'; | $classes[] = 'phabricator-main-menu'; | ||||
$classes[] = 'sprite-main-header'; | $classes[] = 'sprite-main-header'; | ||||
$classes[] = 'main-header-'.PhabricatorEnv::getEnvConfig('ui.header-color'); | $classes[] = 'main-header-'.PhabricatorEnv::getEnvConfig('ui.header-color'); | ||||
return phutil_tag( | return phutil_tag( | ||||
'div', | 'div', | ||||
array( | array( | ||||
'class' => implode(' ', $classes), | 'class' => implode(' ', $classes), | ||||
'id' => $header_id, | 'id' => $header_id, | ||||
), | ), | ||||
array( | array( | ||||
$app_button, | $app_button, | ||||
$search_button, | $search_button, | ||||
$this->renderPhabricatorLogo(), | $this->renderPhabricatorLogo(), | ||||
$alerts, | $alerts, | ||||
$aural, | |||||
$application_menu, | $application_menu, | ||||
$search_menu, | $search_menu, | ||||
$menus, | $menus, | ||||
)); | )); | ||||
} | } | ||||
private function renderSearch() { | private function renderSearch() { | ||||
$user = $this->user; | $user = $this->user; | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | private function renderPhabricatorLogo() { | ||||
$class = 'phabricator-main-menu-logo-image'; | $class = 'phabricator-main-menu-logo-image'; | ||||
return phutil_tag( | return phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => 'phabricator-main-menu-logo', | 'class' => 'phabricator-main-menu-logo', | ||||
'href' => '/', | 'href' => '/', | ||||
), | ), | ||||
array( | |||||
javelin_tag( | |||||
'span', | |||||
array( | |||||
'aural' => true, | |||||
), | |||||
pht('Home')), | |||||
phutil_tag( | phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'sprite-menu menu-logo-image '.$class, | 'class' => 'sprite-menu menu-logo-image '.$class, | ||||
), | ), | ||||
'')); | ''), | ||||
)); | |||||
} | } | ||||
private function renderNotificationMenu() { | private function renderNotificationMenu() { | ||||
$user = $this->user; | $user = $this->user; | ||||
require_celerity_resource('phabricator-notification-css'); | require_celerity_resource('phabricator-notification-css'); | ||||
require_celerity_resource('phabricator-notification-menu-css'); | require_celerity_resource('phabricator-notification-menu-css'); | ||||
require_celerity_resource('sprite-menu-css'); | require_celerity_resource('sprite-menu-css'); | ||||
$container_classes = array( | $container_classes = array( | ||||
'sprite-menu', | 'sprite-menu', | ||||
'alert-notifications', | 'alert-notifications', | ||||
); | ); | ||||
$aural = array(); | |||||
$message_tag = ''; | $message_tag = ''; | ||||
$message_notification_dropdown = ''; | $message_notification_dropdown = ''; | ||||
$conpherence = 'PhabricatorApplicationConpherence'; | $conpherence = 'PhabricatorApplicationConpherence'; | ||||
if (PhabricatorApplication::isClassInstalled($conpherence)) { | if (PhabricatorApplication::isClassInstalled($conpherence)) { | ||||
$message_id = celerity_generate_unique_node_id(); | $message_id = celerity_generate_unique_node_id(); | ||||
$message_count_id = celerity_generate_unique_node_id(); | $message_count_id = celerity_generate_unique_node_id(); | ||||
$message_dropdown_id = celerity_generate_unique_node_id(); | $message_dropdown_id = celerity_generate_unique_node_id(); | ||||
$unread_status = ConpherenceParticipationStatus::BEHIND; | $unread_status = ConpherenceParticipationStatus::BEHIND; | ||||
$unread = id(new ConpherenceParticipantCountQuery()) | $unread = id(new ConpherenceParticipantCountQuery()) | ||||
->withParticipantPHIDs(array($user->getPHID())) | ->withParticipantPHIDs(array($user->getPHID())) | ||||
->withParticipationStatus($unread_status) | ->withParticipationStatus($unread_status) | ||||
->execute(); | ->execute(); | ||||
$message_count_number = idx($unread, $user->getPHID(), 0); | $message_count_number = idx($unread, $user->getPHID(), 0); | ||||
if ($message_count_number) { | |||||
$aural[] = phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => '/conpherence/', | |||||
), | |||||
pht( | |||||
'%s unread messages.', | |||||
new PhutilNumber($message_count_number))); | |||||
} else { | |||||
$aural[] = pht('No messages.'); | |||||
} | |||||
if ($message_count_number > 999) { | if ($message_count_number > 999) { | ||||
$message_count_number = "\xE2\x88\x9E"; | $message_count_number = "\xE2\x88\x9E"; | ||||
} | } | ||||
$message_count_tag = phutil_tag( | $message_count_tag = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'id' => $message_count_id, | 'id' => $message_count_id, | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | private function renderNotificationMenu() { | ||||
$count_id = celerity_generate_unique_node_id(); | $count_id = celerity_generate_unique_node_id(); | ||||
$dropdown_id = celerity_generate_unique_node_id(); | $dropdown_id = celerity_generate_unique_node_id(); | ||||
$bubble_id = celerity_generate_unique_node_id(); | $bubble_id = celerity_generate_unique_node_id(); | ||||
$count_number = id(new PhabricatorFeedStoryNotification()) | $count_number = id(new PhabricatorFeedStoryNotification()) | ||||
->countUnread($user); | ->countUnread($user); | ||||
if ($count_number) { | |||||
$aural[] = phutil_tag( | |||||
'a', | |||||
array( | |||||
'href' => '/notification/', | |||||
), | |||||
pht( | |||||
'%s unread notifications.', | |||||
new PhutilNumber($count_number))); | |||||
} else { | |||||
$aural[] = pht('No notifications.'); | |||||
} | |||||
if ($count_number > 999) { | if ($count_number > 999) { | ||||
$count_number = "\xE2\x88\x9E"; | $count_number = "\xE2\x88\x9E"; | ||||
} | } | ||||
$count_tag = phutil_tag( | $count_tag = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'id' => $count_id, | 'id' => $count_id, | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | private function renderNotificationMenu() { | ||||
$applications = PhabricatorApplication::getAllInstalledApplications(); | $applications = PhabricatorApplication::getAllInstalledApplications(); | ||||
foreach ($applications as $application) { | foreach ($applications as $application) { | ||||
$dropdowns[] = $application->buildMainMenuExtraNodes( | $dropdowns[] = $application->buildMainMenuExtraNodes( | ||||
$this->getUser(), | $this->getUser(), | ||||
$this->getController()); | $this->getController()); | ||||
} | } | ||||
return array( | return array( | ||||
hsprintf('%s%s', $bubble_tag, $message_tag), | array( | ||||
$dropdowns | $bubble_tag, | ||||
$message_tag, | |||||
), | |||||
$dropdowns, | |||||
$aural, | |||||
); | ); | ||||
} | } | ||||
private function renderMenuIcon($name) { | private function renderMenuIcon($name) { | ||||
return phutil_tag( | return phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'phabricator-core-menu-icon '. | 'class' => 'phabricator-core-menu-icon '. | ||||
'sprite-apps-large apps-'.$name, | 'sprite-apps-large apps-'.$name, | ||||
), | ), | ||||
''); | ''); | ||||
} | } | ||||
} | } |