Sfoglia il codice sorgente

Different route, same goal

Signed-off-by: Suki <[email protected]>
Suki 11 anni fa
parent
commit
53b252782c

+ 27 - 23
Sources/Themes.php

@@ -58,8 +58,8 @@ function ThemesMain()
 
 	// Theme administration, removal, choice, or installation...
 	$subActions = array(
-		'list' => 'ThemeList',
 		'admin' => 'ThemeAdmin',
+		'list' => 'ThemeList',
 		'reset' => 'SetThemeOptions',
 		'options' => 'SetThemeOptions',
 		'install' => 'ThemeInstall',
@@ -77,12 +77,12 @@ function ThemesMain()
 			'help' => 'themes',
 			'description' => $txt['themeadmin_description'],
 			'tabs' => array(
-				'list' => array(
-					'description' => $txt['themeadmin_list_desc'],
-				),
 				'admin' => array(
 					'description' => $txt['themeadmin_admin_desc'],
 				),
+				'list' => array(
+					'description' => $txt['themeadmin_list_desc'],
+				),
 				'reset' => array(
 					'description' => $txt['themeadmin_reset_desc'],
 				),
@@ -93,12 +93,11 @@ function ThemesMain()
 		);
 	}
 
-	// Follow the sa or just go to settings page.
+	// Follow the sa or just go to administration.
 	if (isset($_GET['sa']) && !empty($subActions[$_GET['sa']]))
 		$subActions[$_GET['sa']]();
-
 	else
-		$subActions['list']();
+		$subActions['admin']();
 }
 
 /**
@@ -117,23 +116,26 @@ function ThemeAdmin()
 
 	loadLanguage('Admin');
 	isAllowedTo('admin_forum');
-	loadTemplate('Themes');
-	createToken('admin-tm');
 
-	// 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);
+	// If we aren't submitting - that is, if we are about to...
+	if (!isset($_POST['save']))
+	{
+		loadTemplate('Themes');
 
-	// Look for a non existent theme directory. (ie theme87.)
-	$theme_dir = $boarddir . '/Themes/theme';
-	$i = 1;
-	while (file_exists($theme_dir . $i))
-		$i++;
+		// 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);
 
-	$context['new_theme_name'] = 'theme' . $i;
+		// 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;
 
-	// If we aren't submitting - that is, if we are about to...
-	if (isset($_POST['save']))
+		createToken('admin-tm');
+	}
+	else
 	{
 		checkSession();
 		validateToken('admin-tm');
@@ -171,7 +173,6 @@ function ThemeList()
 	loadLanguage('Admin');
 	isAllowedTo('admin_forum');
 
-	// If there is a theme then go to its specific settings.
 	if (isset($_REQUEST['th']))
 		return SetThemeSettings();
 
@@ -241,11 +242,12 @@ function ThemeList()
 	$request = $smcFunc['db_query']('', '
 		SELECT id_theme, variable, value
 		FROM {db_prefix}themes
-		WHERE variable IN ({string:name}, {string:theme_dir}, {string:theme_url}, {string:images_url})
+		WHERE variable IN ({string:name}, {string:version}, {string:theme_dir}, {string:theme_url}, {string:images_url})
 			AND id_member = {int:no_member}',
 		array(
 			'no_member' => 0,
 			'name' => 'name',
+			'version' => 'version',
 			'theme_dir' => 'theme_dir',
 			'theme_url' => 'theme_url',
 			'images_url' => 'images_url',
@@ -268,7 +270,8 @@ function ThemeList()
 	{
 		$context['themes'][$i]['theme_dir'] = realpath($context['themes'][$i]['theme_dir']);
 
-		if (file_exists($context['themes'][$i]['theme_dir'] . '/index.template.php'))
+		// Fetch the version if there isn't one stored on te DB.
+		if (empty($context['themes'][$i]['version']) && file_exists($context['themes'][$i]['theme_dir'] . '/index.template.php'))
 		{
 			// Fetch the header... a good 256 bytes should be more than enough.
 			$fp = fopen($context['themes'][$i]['theme_dir'] . '/index.template.php', 'rb');
@@ -287,6 +290,7 @@ function ThemeList()
 	$context['reset_url'] = $boardurl . '/Themes';
 
 	$context['sub_template'] = 'list_themes';
+	createToken('admin-ti');
 	createToken('admin-tl');
 	createToken('admin-tr', 'request');
 }

+ 75 - 76
Themes/default/Themes.template.php

@@ -17,6 +17,15 @@ 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">';
 
 	// Link to simplemachines.org for latest themes and info!
@@ -24,15 +33,11 @@ function template_main()
 			<br />
 			<div class="cat_bar">
 				<h3 class="catbg">
-					<a href="', $scripturl, '?action=helpadmin;help=latest_themes" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" class="icon" alt="', $txt['help'], '" /></a> ', $txt['theme_latest'], '
+					', $txt['theme_adding_title'], '
 				</h3>
 			</div>
-			<div class="windowbg">
-				<div class="content">
-					<div id="themeLatest">
-						', $txt['theme_latest_fetch'], '
-					</div>
-				</div>
+			<div class="windowbg2">
+				', $txt['theme_adding'], '
 			</div>
 			<br />';
 
@@ -84,7 +89,7 @@ function template_main()
 						</dl>
 						<input type="submit" name="save" value="', $txt['theme_install_go'], '" 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" name="', $context['admin-tl_token_var'], '" value="', $context['admin-tl_token'], '" />
 					</div>
 				</div>
 			</form>
@@ -111,94 +116,88 @@ function template_main()
 
 function template_list_themes()
 {
-	global $context, $settings, $options, $scripturl, $txt, $modSettings;
+	global $context, $settings, $options, $scripturl, $txt;
+	global $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">';
+	<div id="admincenter">';
+
+	echo '
+		<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 />';
+								<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">';
+							</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>';
+								<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>';
+							</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>';
+								<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>
+							</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-ti_token_var'], '" value="', $context['admin-ti_token'], '" />
+					<input type="hidden" value="0" name="options[theme_allow]" />
 				</div>
-			</form>';
+			</div>
+		</form>
+		<br />';
 
-	// Theme list.
 	echo '
 		<div class="cat_bar">
 			<h3 class="catbg">', $txt['themeadmin_list_heading'], '</h3>

+ 3 - 0
Themes/default/languages/Themes.english.php

@@ -95,6 +95,9 @@ $txt['hide_post_group_desc'] = 'Enabling this will not display a member\'s post
 
 $txt['subject_toggle'] = 'Show subjects in topics.';
 
+$txt['theme_adding_title'] = 'Obtaining Packages';
+$txt['theme_adding'] = 'You can always find new packages for your forum from the SMF modifications area - <strong><a href="http://custom.simplemachines.org/mods/" target="_blank">http://custom.simplemachines.org/mods/</a></strong>. You can browse them on the website, read the comments, and download them to your computer and then upload them to your forum from there.<br /><br />If you run into any questions with modifications, each modification published on simplemachines.org has a dedicated topic about it where support and comments should be directed to.';
+
 $txt['theme_options_defaults'] = 'These are the default values for some member specific settings.  Changing these will only affect new members and guests.';
 $txt['theme_options_title'] = 'Change or reset default options';