Просмотр исходного кода

Is there a theme already named like this?

Signed-off-by: Suki <[email protected]>
Suki 11 лет назад
Родитель
Сommit
442c83ebce
3 измененных файлов с 10 добавлено и 19 удалено
  1. 4 17
      Sources/Subs-Themes.php
  2. 5 2
      Sources/Themes.php
  3. 1 0
      Themes/default/languages/Themes.english.php

+ 4 - 17
Sources/Subs-Themes.php

@@ -182,28 +182,15 @@ function get_theme_info($path)
 function theme_install($to_install = array())
 {
 	global $sourcedir, $txt, $context, $boarddir, $boardurl;
-	global $themedir, $themeurl, $explicit_images;
+	global $themedir, $themeurl, $settings, $explicit_images;
 
 	// External use? no problem!
 	if ($to_install)
 		$context['to_install'] = $to_install;
 
-	// We kinda need this and it should have been previously set.
-	if (empty($context['to_install']))
-		return false;
-
 	// One last check.
 	if ($context['to_install']['dir'] != '' && basename($context['to_install']['dir']) != 'Themes')
-		return false;
-
-	// Defaults.
-	$context['to_install'] = array(
-		'theme_url' => $themeurl . '/' . basename($context['to_install']['dir']),
-	);
-
-	// This vars could have been set, it all depends from where are we coming.
-	if (empty($context['to_install']['images_url']))
-		$context['to_install']['images_url'] = $themeurl . '/' . basename($context['to_install']['dir']) . '/images';
+		fatal_lang_error('theme_install_invalid_dir', false);
 
 	// Perhaps they are trying to install a mod, lets tell them nicely this is the wrong function.
 	if (file_exists($context['to_install']['dir'] . '/package-info.xml'))
@@ -258,13 +245,13 @@ function theme_install($to_install = array())
 						)
 					);
 
-					// Do a redirect and set a nice updated message.
+					// Done with the update, tell the user about it.
 					return $to_update['id_theme'];
 					break; // Just for reference.
 			}
 	}
 
-	if (isset($context['to_install']['based_on']))
+	if (!empty($context['to_install']['based_on']))
 	{
 		// No need for elaborated stuff when the theme is based on the default one.
 		if ($context['to_install']['based_on'] == 'default')

+ 5 - 2
Sources/Themes.php

@@ -1337,6 +1337,10 @@ function InstallCopy()
 	// Get a cleaner version.
 	$name = preg_replace('~[^A-Za-z0-9_\- ]~', '', $_REQUEST['copy']);
 
+	// Is there a theme already named like this?
+	if (file_exists($themedir .'/'. $name))
+		fatal_lang_error('theme_install_already_dir', false);
+
 	// This is a brand new theme so set all possible values.
 	$context['to_install'] = array(
 		'dir' => $themedir . '/' . $name,
@@ -1344,8 +1348,7 @@ function InstallCopy()
 		'name' => $name,
 		'images_url' => $themeurl . '/' . $name . '/images',
 		'version' => '1.0',
-		'install_for' => '2.1 - 2.1.99, '. strtr($forum_version, array('SMF ' => '')) .'',
-		'based_on' => '',
+		'install_for' => '2.1 - 2.1.99, '. strtr($forum_version, array('SMF ' => '')),
 	);
 
 	// Create the specific dir.

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

@@ -34,6 +34,7 @@ $txt['theme_install_error_file_4'] = 'No file was uploaded.';
 $txt['theme_install_error_file_6'] = 'Missing a temporary upload folder.';
 $txt['theme_install_error_file_7'] = 'Failed to write file to disk.';
 $txt['theme_install_invalid_dir'] = 'You did not add a path for your actual theme, you cannot re-add the default theme';
+$txt['theme_install_already_dir'] = 'The name you specified is already been used by another theme, please try a different name.';
 
 $txt['theme_pick'] = 'Choose a theme...';
 $txt['theme_preview'] = 'Preview theme';