Browse Source

Move some things around

Signed-off-by: Suki <[email protected]>
Suki 11 years ago
parent
commit
e01a60668a
2 changed files with 108 additions and 124 deletions
  1. 21 41
      Sources/Themes.php
  2. 87 83
      Themes/default/Themes.template.php

+ 21 - 41
Sources/Themes.php

@@ -93,9 +93,10 @@ function ThemesMain()
 		);
 	}
 
-	// Follow the sa or just go to administration.
+	// Follow the sa or just go to settings page.
 	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
 		$subActions[$_GET['sa']]();
+
 	else
 		$subActions['list']();
 }
@@ -116,50 +117,23 @@ function ThemeAdmin()
 
 	loadLanguage('Admin');
 	isAllowedTo('admin_forum');
+	loadTemplate('Themes');
+	createToken('admin-tm');
 
-	// If we aren't submitting - that is, if we are about to...
-	if (!isset($_POST['save']))
-	{
-		loadTemplate('Themes');
+	// Can we create a new theme?
+	$context['can_create_new'] = is_writable($boarddir . '/Themes');
+	$context['new_theme_dir'] = substr(realpath($boarddir . '/Themes/default'), 0, -7);
 
-		// Make our known themes a little easier to work with.
-		$knownThemes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
+	// Look for a non existent theme directory. (ie theme87.)
+	$theme_dir = $boarddir . '/Themes/theme';
+	$i = 1;
+	while (file_exists($theme_dir . $i))
+		$i++;
 
-		// Load up all the themes.
-		$request = $smcFunc['db_query']('', '
-			SELECT id_theme, value AS name
-			FROM {db_prefix}themes
-			WHERE variable = {string:name}
-				AND id_member = {int:no_member}
-			ORDER BY id_theme',
-			array(
-				'no_member' => 0,
-				'name' => 'name',
-			)
-		);
-		$context['themes'] = array();
-		while ($row = $smcFunc['db_fetch_assoc']($request))
-			$context['themes'][] = array(
-				'id' => $row['id_theme'],
-				'name' => $row['name'],
-				'known' => in_array($row['id_theme'], $knownThemes),
-			);
-		$smcFunc['db_free_result']($request);
-
-		// Can we create a new theme?
-		$context['can_create_new'] = is_writable($boarddir . '/Themes');
-		$context['new_theme_dir'] = substr(realpath($boarddir . '/Themes/default'), 0, -7);
-
-		// Look for a non existent theme directory. (ie theme87.)
-		$theme_dir = $boarddir . '/Themes/theme';
-		$i = 1;
-		while (file_exists($theme_dir . $i))
-			$i++;
-		$context['new_theme_name'] = 'theme' . $i;
+	$context['new_theme_name'] = 'theme' . $i;
 
-		createToken('admin-tm');
-	}
-	else
+	// If we aren't submitting - that is, if we are about to...
+	if (isset($_POST['save']))
 	{
 		checkSession();
 		validateToken('admin-tm');
@@ -197,6 +171,7 @@ function ThemeList()
 	loadLanguage('Admin');
 	isAllowedTo('admin_forum');
 
+	// If there is a theme then go to its specific settings.
 	if (isset($_REQUEST['th']))
 		return SetThemeSettings();
 
@@ -260,6 +235,9 @@ function ThemeList()
 
 	loadTemplate('Themes');
 
+	// Make our known themes a little easier to work with.
+	$knownThemes = !empty($modSettings['knownThemes']) ? explode(',',$modSettings['knownThemes']) : array();
+
 	$request = $smcFunc['db_query']('', '
 		SELECT id_theme, variable, value
 		FROM {db_prefix}themes
@@ -279,6 +257,8 @@ function ThemeList()
 		if (!isset($context['themes'][$row['id_theme']]))
 			$context['themes'][$row['id_theme']] = array(
 				'id' => $row['id_theme'],
+				'name' => $row['value'],
+				'known' => in_array($row['id_theme'], $knownThemes),
 			);
 		$context['themes'][$row['id_theme']][$row['variable']] = $row['value'];
 	}

+ 87 - 83
Themes/default/Themes.template.php

@@ -17,88 +17,7 @@ function template_main()
 
 	echo '
 	<div id="admincenter">
-		<div class="cat_bar">
-			<h3 class="catbg">
-				<a href="', $scripturl, '?action=helpadmin;help=themes" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" class="icon" alt="', $txt['help'], '" /></a>
-				', $txt['themeadmin_title'], '
-			</h3>
-		</div>
-		<div class="information">
-			', $txt['themeadmin_explain'], '
-		</div>
-		<div id="admin_form_wrapper">
-			<form action="', $scripturl, '?action=admin;area=theme;sa=admin" method="post" accept-charset="', $context['character_set'], '">
-				<div class="cat_bar">
-					<h3 class="catbg">',
-						$txt['settings'], '
-					</h3>
-				</div>
-				<div class="windowbg2">
-					<div class="content">
-						<dl class="settings">
-							<dt>
-								<label for="options-theme_allow"> ', $txt['theme_allow'], '</label>
-							</dt>
-							<dd>
-								<input type="checkbox" name="options[theme_allow]" id="options-theme_allow" value="1"', !empty($modSettings['theme_allow']) ? ' checked="checked"' : '', ' class="input_check" />
-							</dd>
-							<dt>
-								<label for="known_themes_list">', $txt['themeadmin_selectable'], '</label>:
-							</dt>
-							<dd>
-								<div id="known_themes_list">';
-	foreach ($context['themes'] as $theme)
-		echo '
-									<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked="checked"' : '', ' class="input_check" /> ', $theme['name'], '</label><br />';
-
-		echo '
-								</div>
-								<a href="javascript:void(0);" onclick="document.getElementById(\'known_themes_list\').style.display=\'block\'; document.getElementById(\'known_themes_link\').style.display = \'none\'; return false; " id="known_themes_link" style="display: none;">[ ', $txt['themeadmin_themelist_link'], ' ]</a>
-								<script type="text/javascript"><!-- // --><![CDATA[
-									document.getElementById("known_themes_list").style.display = "none";
-									document.getElementById("known_themes_link").style.display = "";
-								// ]]></script>
-							</dd>
-							<dt>
-								<label for="theme_guests">', $txt['theme_guests'], ':</label>
-							</dt>
-							<dd>
-								<select name="options[theme_guests]" id="theme_guests">';
-
-	// Put an option for each theme in the select box.
-	foreach ($context['themes'] as $theme)
-		echo '
-									<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected="selected"' : '', '>', $theme['name'], '</option>';
-
-	echo '
-								</select>
-								<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=-1;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
-							</dd>
-							<dt>
-								<label for="theme_reset">', $txt['theme_reset'], '</label>:
-							</dt>
-							<dd>
-								<select name="theme_reset" id="theme_reset">
-									<option value="-1" selected="selected">', $txt['theme_nochange'], '</option>
-									<option value="0">', $txt['theme_forum_default'], '</option>';
-
-	// Same thing, this time for changing the theme of everyone.
-	foreach ($context['themes'] as $theme)
-		echo '
-									<option value="', $theme['id'], '">', $theme['name'], '</option>';
-
-	echo '
-								</select>
-								<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=0;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
-							</dd>
-						</dl>
-						<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />
-						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
-						<input type="hidden" name="', $context['admin-tm_token_var'], '" value="', $context['admin-tm_token'], '" />
-						<input type="hidden" value="0" name="options[theme_allow]" />
-					</div>
-				</div>
-			</form>';
+		<div id="admin_form_wrapper">';
 
 	// Link to simplemachines.org for latest themes and info!
 	echo '
@@ -192,10 +111,95 @@ function template_main()
 
 function template_list_themes()
 {
-	global $context, $settings, $options, $scripturl, $txt;
+	global $context, $settings, $options, $scripturl, $txt, $modSettings;
 
 	echo '
 	<div id="admincenter">
+		<div class="cat_bar">
+			<h3 class="catbg">
+				<a href="', $scripturl, '?action=helpadmin;help=themes" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" class="icon" alt="', $txt['help'], '" /></a>
+				', $txt['themeadmin_title'], '
+			</h3>
+		</div>
+		<div class="information">
+			', $txt['themeadmin_explain'], '
+		</div>
+		<div id="admin_form_wrapper">
+			<form action="', $scripturl, '?action=admin;area=theme;sa=admin" method="post" accept-charset="', $context['character_set'], '">
+				<div class="cat_bar">
+					<h3 class="catbg">',
+						$txt['settings'], '
+					</h3>
+				</div>
+				<div class="windowbg2">
+					<div class="content">
+						<dl class="settings">
+							<dt>
+								<label for="options-theme_allow"> ', $txt['theme_allow'], '</label>
+							</dt>
+							<dd>
+								<input type="checkbox" name="options[theme_allow]" id="options-theme_allow" value="1"', !empty($modSettings['theme_allow']) ? ' checked="checked"' : '', ' class="input_check" />
+							</dd>
+							<dt>
+								<label for="known_themes_list">', $txt['themeadmin_selectable'], '</label>:
+							</dt>
+							<dd>
+								<div id="known_themes_list">';
+	foreach ($context['themes'] as $theme)
+		echo '
+									<label for="options-known_themes_', $theme['id'], '"><input type="checkbox" name="options[known_themes][]" id="options-known_themes_', $theme['id'], '" value="', $theme['id'], '"', $theme['known'] ? ' checked="checked"' : '', ' class="input_check" /> ', $theme['name'], '</label><br />';
+
+		echo '
+								</div>
+								<a href="javascript:void(0);" onclick="document.getElementById(\'known_themes_list\').style.display=\'block\'; document.getElementById(\'known_themes_link\').style.display = \'none\'; return false; " id="known_themes_link" style="display: none;">[ ', $txt['themeadmin_themelist_link'], ' ]</a>
+								<script type="text/javascript"><!-- // --><![CDATA[
+									document.getElementById("known_themes_list").style.display = "none";
+									document.getElementById("known_themes_link").style.display = "";
+								// ]]></script>
+							</dd>
+							<dt>
+								<label for="theme_guests">', $txt['theme_guests'], ':</label>
+							</dt>
+							<dd>
+								<select name="options[theme_guests]" id="theme_guests">';
+
+	// Put an option for each theme in the select box.
+	foreach ($context['themes'] as $theme)
+		echo '
+									<option value="', $theme['id'], '"', $modSettings['theme_guests'] == $theme['id'] ? ' selected="selected"' : '', '>', $theme['name'], '</option>';
+
+	echo '
+								</select>
+								<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=-1;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
+							</dd>
+							<dt>
+								<label for="theme_reset">', $txt['theme_reset'], '</label>:
+							</dt>
+							<dd>
+								<select name="theme_reset" id="theme_reset">
+									<option value="-1" selected="selected">', $txt['theme_nochange'], '</option>
+									<option value="0">', $txt['theme_forum_default'], '</option>';
+
+	// Same thing, this time for changing the theme of everyone.
+	foreach ($context['themes'] as $theme)
+		echo '
+									<option value="', $theme['id'], '">', $theme['name'], '</option>';
+
+	echo '
+								</select>
+								<span class="smalltext pick_theme"><a href="', $scripturl, '?action=theme;sa=pick;u=0;', $context['session_var'], '=', $context['session_id'], '">', $txt['theme_select'], '</a></span>
+							</dd>
+						</dl>
+						<input type="submit" name="save" value="' . $txt['save'] . '" class="button_submit" />
+						<input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
+						<input type="hidden" name="', $context['admin-tm_token_var'], '" value="', $context['admin-tm_token'], '" />
+						<input type="hidden" value="0" name="options[theme_allow]" />
+					</div>
+				</div>
+			</form>';
+
+	// Theme list.
+	echo '
 		<div class="cat_bar">
 			<h3 class="catbg">', $txt['themeadmin_list_heading'], '</h3>
 		</div>