Ver código fonte

! Of course, logging the stylesheets in use is only any good if you actually attempt to log the ones you're actually using.

Signed-off-by: Peter Spicer <[email protected]>
Peter Spicer 10 anos atrás
pai
commit
5f6f1b14f7
2 arquivos alterados com 38 adições e 42 exclusões
  1. 32 18
      Sources/Load.php
  2. 6 24
      Themes/default/index.template.php

+ 32 - 18
Sources/Load.php

@@ -1756,6 +1756,15 @@ function loadTheme($id_theme = 0, $initialize = true)
 	// Initialize the theme.
 	// Initialize the theme.
 	loadSubTemplate('init', 'ignore');
 	loadSubTemplate('init', 'ignore');
 
 
+	// Allow overriding the board wide time/number formats.
+	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
+		$user_info['time_format'] = $txt['time_format'];
+
+	// Set the character set from the template.
+	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
+	$context['utf8'] = $context['character_set'] === 'UTF-8';
+	$context['right_to_left'] = !empty($txt['lang_rtl']);
+
 	// Guests may still need a name.
 	// Guests may still need a name.
 	if ($context['user']['is_guest'] && empty($context['user']['name']))
 	if ($context['user']['is_guest'] && empty($context['user']['name']))
 		$context['user']['name'] = $txt['guest_title'];
 		$context['user']['name'] = $txt['guest_title'];
@@ -1764,6 +1773,22 @@ function loadTheme($id_theme = 0, $initialize = true)
 	if (!empty($settings['require_theme_strings']))
 	if (!empty($settings['require_theme_strings']))
 		loadLanguage('ThemeStrings', '', false);
 		loadLanguage('ThemeStrings', '', false);
 
 
+	// Sort out some themes.
+	if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always')
+	{
+		$settings['theme_url'] = $settings['default_theme_url'];
+		$settings['images_url'] = $settings['default_images_url'];
+		$settings['theme_dir'] = $settings['default_theme_dir'];
+	}
+	// Make a special URL for the language.
+	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
+
+	// And of course, let's load the default CSS file.
+	loadCSSFile('index.css');
+
+	if ($context['right_to_left'])
+		loadCSSFile('rtl.css');
+
 	// We allow theme variants, because we're cool.
 	// We allow theme variants, because we're cool.
 	$context['theme_variant'] = '';
 	$context['theme_variant'] = '';
 	$context['theme_variant_url'] = '';
 	$context['theme_variant_url'] = '';
@@ -1782,30 +1807,19 @@ function loadTheme($id_theme = 0, $initialize = true)
 		// Do this to keep things easier in the templates.
 		// Do this to keep things easier in the templates.
 		$context['theme_variant'] = '_' . $context['theme_variant'];
 		$context['theme_variant'] = '_' . $context['theme_variant'];
 		$context['theme_variant_url'] = $context['theme_variant'] . '/';
 		$context['theme_variant_url'] = $context['theme_variant'] . '/';
+
+		if (!empty($context['theme_variant']))
+		{
+			loadCSSFile('index' . $context['theme_variant'] . '.css');
+			if ($context['right_to_left'])
+				loadCSSFile('rtl' . $context['theme_variant'] . '.css');
+		}
 	}
 	}
 
 
 	// Let's be compatible with old themes!
 	// Let's be compatible with old themes!
 	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
 	if (!function_exists('template_html_above') && in_array('html', $context['template_layers']))
 		$context['template_layers'] = array('main');
 		$context['template_layers'] = array('main');
 
 
-	// Allow overriding the board wide time/number formats.
-	if (empty($user_settings['time_format']) && !empty($txt['time_format']))
-		$user_info['time_format'] = $txt['time_format'];
-
-	if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'always')
-	{
-		$settings['theme_url'] = $settings['default_theme_url'];
-		$settings['images_url'] = $settings['default_images_url'];
-		$settings['theme_dir'] = $settings['default_theme_dir'];
-	}
-	// Make a special URL for the language.
-	$settings['lang_images_url'] = $settings['images_url'] . '/' . (!empty($txt['image_lang']) ? $txt['image_lang'] : $user_info['language']);
-
-	// Set the character set from the template.
-	$context['character_set'] = empty($modSettings['global_character_set']) ? $txt['lang_character_set'] : $modSettings['global_character_set'];
-	$context['utf8'] = $context['character_set'] === 'UTF-8';
-	$context['right_to_left'] = !empty($txt['lang_rtl']);
-
 	$context['tabindex'] = 1;
 	$context['tabindex'] = 1;
 
 
 	// Compatibility.
 	// Compatibility.

+ 6 - 24
Themes/default/index.template.php

@@ -78,41 +78,23 @@ function template_html_above()
 <html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
 <html', $context['right_to_left'] ? ' dir="rtl"' : '', '>
 <head>';
 <head>';
 
 
-	// The ?alp21 part of this link is just here to make sure browsers don't cache it wrongly.
-	echo '
-	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index.css?alp21" />';
+	// You don't need to manually load index.css, this will be set up for you. You can, of course, add
+	// any other files you want, after template_css() has been run. Note that RTL will also be loaded for you.
 
 
 	// The most efficient way of writing multi themes is to use a master index.css plus variant.css files.
 	// The most efficient way of writing multi themes is to use a master index.css plus variant.css files.
-	if (!empty($context['theme_variant']))
-		echo '
-	<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />';
+	// If you've set them up properly (through $settings['theme_variants'], loadCSSFile will load the variant files for you.
+
+	// load in any css from mods or themes so they can overwrite if wanted
+	template_css();
 
 
 	// Save some database hits, if a width for multiple wrappers is set in admin.
 	// Save some database hits, if a width for multiple wrappers is set in admin.
 	if (!empty($settings['forum_width']))
 	if (!empty($settings['forum_width']))
 		echo '
 		echo '
 	<style type="text/css">#wrapper, .frame {width: ', $settings['forum_width'], ';}</style>';
 	<style type="text/css">#wrapper, .frame {width: ', $settings['forum_width'], ';}</style>';
 
 
-	// Quick and dirty testing of RTL horrors. Remove before production build.
-	//echo '
-	//<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css?alp21" />';
-
-	// load in any css from mods or themes so they can overwrite if wanted
-	template_css();
-
 	// load in any javascript files from mods and themes
 	// load in any javascript files from mods and themes
 	template_javascript();
 	template_javascript();
 
 
-	// RTL languages require an additional stylesheet.
-	if ($context['right_to_left'])
-	{
-		echo '
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl.css?alp21" />';
-
-	if (!empty($context['theme_variant']))
-		echo '
-		<link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/rtl', $context['theme_variant'], '.css?alp21" />';
-	}
-
 	echo '
 	echo '
 	<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 	<meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
 	<meta name="description" content="', !empty($context['meta_description']) ? $context['meta_description'] : $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '
 	<meta name="description" content="', !empty($context['meta_description']) ? $context['meta_description'] : $context['page_title_html_safe'], '" />', !empty($context['meta_keywords']) ? '