Browse Source

Merge pull request #862 from Arantor/release-2.1

! Several exciting things at once: instead of using [1] in menu items, u...
Arantor 11 years ago
parent
commit
653dcd69cc
3 changed files with 85 additions and 49 deletions
  1. 38 26
      Sources/Subs.php
  2. 19 15
      Themes/default/css/index.css
  3. 28 8
      Themes/default/index.template.php

+ 38 - 26
Sources/Subs.php

@@ -3790,7 +3790,7 @@ function setupMenuContext()
 	// Set up the menu privileges.
 	$context['allow_search'] = !empty($modSettings['allow_guestAccess']) ? allowedTo('search_posts') : (!$user_info['is_guest'] && allowedTo('search_posts'));
 	$context['allow_admin'] = allowedTo(array('admin_forum', 'manage_boards', 'manage_permissions', 'moderate_forum', 'manage_membergroups', 'manage_bans', 'send_mail', 'edit_news', 'manage_attachments', 'manage_smileys'));
-	$context['allow_edit_profile'] = !$user_info['is_guest'];
+
 	$context['allow_memberlist'] = allowedTo('view_mlist');
 	$context['allow_calendar'] = allowedTo('calendar_view') && !empty($modSettings['cal_enabled']);
 	$context['allow_moderation_center'] = $context['user']['can_mod'];
@@ -3798,6 +3798,34 @@ function setupMenuContext()
 
 	$cacheTime = $modSettings['lastActive'] * 60;
 
+	// This is for showing the nice profile menu up top. Sub-menus are not supported.
+	$profile_menu = array(
+		'account' => array(
+			'title' => $txt['account'],
+			'href' => $scripturl . '?action=profile;area=account',
+			'show' => allowedTo(array('profile_forum_any', 'profile_forum_own')),
+		),
+		'profile' => array(
+			'title' => $txt['forumprofile'],
+			'href' => $scripturl . '?action=profile;area=forumprofile',
+			'show' => allowedTo(array('profile_forum_any', 'profile_forum_own')),
+		),
+		'theme' => array(
+			'title' => $txt['theme'],
+			'href' => $scripturl . '?action=profile;area=theme',
+			'show' => allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_extra_any')),
+		),
+	);
+	call_integration_hook('integrate_profile_buttons', array(&$profile_menu));
+	foreach ($profile_menu as $item => $details)
+	{
+		if ((isset($details['enabled']) && empty($details['enabled'])) || empty($details['show']))
+			unset ($profile_menu[$item]);
+		// OK, so the item's good. Let's push this into $context but save a little memory as we do.
+		unset ($details['show']);
+		$context['profile_menu'][$item] = $details;
+	}
+
 	// All the buttons we can possible want and then some, try pulling the final list of buttons from cache first.
 	if (($menu_buttons = cache_get_data('menu_buttons-' . implode('_', $user_info['groups']) . '-' . $user_info['language'], $cacheTime)) === null || time() - $cacheTime <= $modSettings['settings_updated'])
 	{
@@ -3848,6 +3876,11 @@ function setupMenuContext()
 						'title' => $txt['edit_permissions'],
 						'href' => $scripturl . '?action=admin;area=permissions',
 						'show' => allowedTo('manage_permissions'),
+					),
+					'memberapprove' => array(
+						'title' => $txt['approve_members_waiting'],
+						'href' => $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve',
+						'show' => !empty($context['unapproved_members']),
 						'is_last' => true,
 					),
 				),
@@ -3880,29 +3913,6 @@ function setupMenuContext()
 					),
 				),
 			),
-			'profile' => array(
-				'title' => $txt['profile'],
-				'href' => $scripturl . '?action=profile',
-				'show' => $context['allow_edit_profile'],
-				'sub_buttons' => array(
-					'account' => array(
-						'title' => $txt['account'],
-						'href' => $scripturl . '?action=profile;area=account',
-						'show' => allowedTo(array('profile_identity_any', 'profile_identity_own', 'manage_membergroups')),
-					),
-					'profile' => array(
-						'title' => $txt['forumprofile'],
-						'href' => $scripturl . '?action=profile;area=forumprofile',
-						'show' => allowedTo(array('profile_forum_any', 'profile_forum_own')),
-						'is_last' => true,
-					),
-					'theme' => array(
-						'title' => $txt['theme'],
-						'href' => $scripturl . '?action=profile;area=theme',
-						'show' => allowedTo(array('profile_extra_any', 'profile_extra_own', 'profile_extra_any')),
-					),
-				),
-			),
 			'pm' => array(
 				'title' => $txt['pm_short'],
 				'href' => $scripturl . '?action=pm',
@@ -4060,13 +4070,15 @@ function setupMenuContext()
 		$context['menu_buttons'][$current_action]['active_button'] = true;
 
 	if (!empty($user_info['mod_cache']) && $user_info['mod_cache']['bq'] != '0=1' && $context['open_mod_reports'] > 0)
-		$context['menu_buttons']['moderate']['title'] .= ' [<strong>' .$context['open_mod_reports'] . '</strong>]';
+		$context['menu_buttons']['moderate']['title'] .= ' <span class="amt">' . $context['open_mod_reports'] . '</span>';
 
+	if (!empty($context['unapproved_members']))
+		$context['menu_buttons']['admin']['sub_buttons']['memberapprove']['title'] .= ' <span class="amt">' . $context['unapproved_members'] . '</span>';
 
 	if (!$user_info['is_guest'] && $context['user']['unread_messages'] > 0 && isset($context['menu_buttons']['pm']))
 	{
 		$context['menu_buttons']['pm']['alttitle'] = $context['menu_buttons']['pm']['title'] . ' [' . $context['user']['unread_messages'] . ']';
-		$context['menu_buttons']['pm']['title'] .= ' [<strong>' . $context['user']['unread_messages'] . '</strong>]';
+		$context['menu_buttons']['pm']['title'] .= ' <span class="amt">' . $context['user']['unread_messages'] . '</span>';
 	}
 }
 

+ 19 - 15
Themes/default/css/index.css

@@ -1086,6 +1086,19 @@ img.sort, .sort {
 	line-height: 1.9em;
 	position: relative;
 }
+/* For cases where we want to spotlight something specific to an item, e.g. an amount */
+.dropmenu li .amt
+{
+	padding: 0 4px;
+	color: white;
+	background: #6d90ad;
+	border-radius: 4px;
+}
+.dropmenu li .active .amt
+{
+	background: none;
+	color: inherit;
+}
 /* Needed for new PM notifications. */
 .dropmenu li strong {
 	color: #333;
@@ -1393,32 +1406,23 @@ img.sort, .sort {
 	display: block;
 	clear: both;
 }
-#top_section ul {
+#top_info {
 	margin: 0;
-	padding: 9px 9px 7px 9px;
+	padding: 5px 9px 4px 9px;
 	line-height: 1.3em;
+	width: 50%;
 }
-#top_section ul li {
+/*#top_section ul li {
 	margin-bottom: 2px;
 	margin-right: 7px;
 	display: inline;
 	font-size: 0.9em;
-}
+}*/
 .notice
 {
  font-weight: bold;
 }
-.modnotice
-{
-	padding: 4px;
-}
-.modnotice .amt
-{
-	padding: 0 4px;
-	color: white;
-	background: #6d90ad;
-	border-radius: 4px;
-}
+
 #search_form {
 	padding: 4px 0 0 0;
 	text-align: right;

+ 28 - 8
Themes/default/index.template.php

@@ -178,29 +178,49 @@ function template_body_above()
 	// Wrapper div now echoes permanently for better layout options. h1 a is now target for "Go up" links.
 	echo '
 	<div id="top_section">
-		<div class="frame">
-			<ul class="floatleft">';
+		<div class="frame">';
 
 	// If the user is logged in, display some things that might be useful.
 	if ($context['user']['is_logged'])
 	{
-		// @todo There needs to be something else here.
+		// Firstly, the user's menu
+		$is_current_user = $context['current_action'] == 'profile' && !empty($context['user']['is_owner']);
+		echo '
+			<ul class="floatleft dropmenu" id="top_info">
+				<li>
+					<a href="', $scripturl, '?action=profile"', $is_current_user ? ' class="active"' : '', '>', $context['user']['name'], !empty($context['profile_menu']) ? ' &#9660;' : '', '</a>';
+		if (!empty($context['profile_menu']))
+		{
+			echo '
+					<ul>';
+			foreach ($context['profile_menu'] as $key => $item)
+				echo '
+						<li>', !empty($item['href']) ? '<a href="' . $item['href'] . '">' . $item['title'] . '</a>' : $item['title'], '</li>';
+			echo '
+					</ul>';
+		}
+
+		echo '
+				</li>';
 
+		// This will only apply if we're powerful and can actually see reports.
 		if (!empty($context['open_mod_reports']) && $context['show_open_reports'])
 			echo '
-				<li class="modnotice"><a href="', $scripturl, '?action=moderate;area=reports">', $txt['mod_reports_waiting'], '</a>: <span class="amt">', $context['open_mod_reports'], '</span></li>';
+				<li class="modnotice"><a href="', $scripturl, '?action=moderate;area=reports">', $txt['mod_reports_waiting'], ' <span class="amt">', $context['open_mod_reports'], '</span></a></li>';
 
 		// Are there any members waiting for approval?
 		if (!empty($context['unapproved_members']))
 			echo '
-				<li class="modnotice"><a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $txt['approve_members_waiting'], '</a>: <span class="amt">', $context['unapproved_members'], '</span></li>';
+				<li class="modnotice"><a href="', $scripturl, '?action=admin;area=viewmembers;sa=browse;type=approve">', $txt['approve_members_waiting'], ' <span class="amt">', $context['unapproved_members'], '</span></a></li>';
+
+		echo '
+			</ul>';
 	}
 	// Otherwise they're a guest. Ask them to either register or login.
 	else
 		echo '
-				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login'), '</li>';
-
-	echo '
+			<ul class="floatleft" id="top_info">
+				<li>', sprintf($txt[$context['can_register'] ? 'welcome_guest_register' : 'welcome_guest'], $txt['guest_title'], $scripturl . '?action=login'), '</li>
 			</ul>';
 
 	if ($context['allow_search'])