Browse Source

! Add the ability to show the registration agreement all the time, as linked in the footer. More shockingly, bring the help link down to the footer next to it... and remove it from the main menu like everyone wants to do anyway.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 years ago
parent
commit
5ed5dd99d9

+ 50 - 2
Sources/Help.php

@@ -24,14 +24,27 @@ if (!defined('SMF'))
  */
 function ShowHelp()
 {
-	global $scripturl, $context, $txt;
-
 	loadTemplate('Help');
 	loadLanguage('Manual');
 
+	$subActions = array(
+		'index' => 'HelpIndex',
+		'rules' => 'HelpRules',
+	);
+
+	$sa = isset($_GET['sa'], $subActions[$_GET['sa']]) ? $_GET['sa'] : 'index';
+	$subActions[$sa]();
+}
+
+function HelpIndex()
+{
+	global $scripturl, $context, $txt;
+
 	// We need to know where our wiki is.
 	$context['wiki_url'] = 'http://wiki.simplemachines.org/smf';
 
+	$context['canonical_url'] = $scripturl . '?action=help';
+
 	// Sections were are going to link...
 	$context['manual_sections'] = array(
 		'registering' => 'Registering',
@@ -57,6 +70,41 @@ function ShowHelp()
 	$context['sub_template'] = 'manual';
 }
 
+function HelpRules()
+{
+	global $context, $txt, $boarddir, $user_info, $scripturl;
+
+	// Build the link tree.
+	$context['linktree'][] = array(
+		'url' => $scripturl . '?action=help',
+		'name' => $txt['help'],
+	);
+	$context['linktree'][] = array(
+		'url' => $scripturl . '?action=help;sa=rules',
+		'name' => $txt['terms_and_rules'],
+	);
+
+	// Have we got a localized one?
+	if (file_exists($boarddir . '/agreement.' . $user_info['language'] . '.txt'))
+		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.' . $user_info['language'] . '.txt'), true, 'agreement_' . $user_info['language']);
+	elseif (file_exists($boarddir . '/agreement.txt'))
+		$context['agreement'] = parse_bbc(file_get_contents($boarddir . '/agreement.txt'), true, 'agreement');
+	else
+		$context['agreement'] = '';
+
+	// Nothing to show, so let's get out of here
+	if (empty($context['agreement']))
+	{
+		// No file found or a blank file! Just leave...
+		redirectexit();
+	}
+
+	$context['canonical_url'] = $scripturl . '?action=help;sa=rules';
+
+	$context['page_title'] = $txt['terms_and_rules'];
+	$context['sub_template'] = 'terms';
+}
+
 /**
  * Show some of the more detailed help to give the admin an idea...
  * It shows a popup for administrative or user help.

+ 0 - 7
Sources/Subs.php

@@ -3730,13 +3730,6 @@ function setupMenuContext()
 				),
 				'is_last' => $context['right_to_left'],
 			),
-			'help' => array(
-				'title' => $txt['help'],
-				'href' => $scripturl . '?action=help',
-				'show' => true,
-				'sub_buttons' => array(
-				),
-			),
 			'search' => array(
 				'title' => $txt['search'],
 				'href' => $scripturl . '?action=search',

+ 15 - 0
Themes/default/Help.template.php

@@ -171,4 +171,19 @@ function template_manual()
 			</div>';
 }
 
+function template_terms()
+{
+	global $txt, $context;
+
+	echo '
+		<div class="cat_bar">
+			<h3 class="catbg">
+				', $txt['terms_and_rules'], ' - ', $context['forum_name'], '
+			</h3>
+		</div>
+		<div class="roundframe">
+			', $context['agreement'], '
+		</div>';
+}
+
 ?>

+ 4 - 1
Themes/default/index.template.php

@@ -330,7 +330,7 @@ function template_body_above()
 
 function template_body_below()
 {
-	global $context, $txt;
+	global $context, $txt, $scripturl;
 
 	echo '
 			</div>
@@ -346,6 +346,9 @@ function template_body_below()
 	// There is now a global "Go to top" link at the right.
 		echo '
 			<a href="#top_section" id="bot" class="go_up">', $txt['go_up'], '</a>
+			<ul class="floatright">
+				<li><a href="', $scripturl, '?action=help">', $txt['help'], '</a> | <a href="', $scripturl, '?action=help;sa=rules">', $txt['terms_and_rules'], '</a></li>
+			</ul>
 			<ul class="reset">
 				<li class="copyright">', theme_copyright(), '</li>
 			</ul>';

+ 1 - 0
Themes/default/languages/index.english.php

@@ -122,6 +122,7 @@ $txt['admin_login'] = 'Administration Login';
 // Use numeric entities in the below string.
 $txt['topic'] = 'Topic';
 $txt['help'] = 'Help';
+$txt['terms_and_rules'] = 'Terms and Rules';
 $txt['notify'] = 'Notify';
 $txt['unnotify'] = 'Unnotify';
 $txt['notify_request'] = 'Do you want a notification email if someone replies to this topic?';