Parcourir la source

+ Provide a nice message for those that try to install a theme via the package manager

Spuds il y a 13 ans
Parent
commit
fa722f9d6c

+ 1 - 0
Sources/PackageGet.php

@@ -662,6 +662,7 @@ function PackageUpload()
 	{
 		@unlink($destination);
 		loadLanguage('Errors');
+		$txt[$context['package']] = str_replace('{MANAGETHEMEURL}', $scripturl . '?action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id'], $txt[$context['package']]);
 		fatal_lang_error('package_upload_error_broken', false, $txt[$context['package']]);
 	}
 	// Is it already uploaded, maybe?

+ 8 - 1
Sources/Subs-Package.php

@@ -457,7 +457,14 @@ function getPackageInfo($gzfilename)
 
 	// Nothing?
 	if (empty($packageInfo))
-		return 'package_get_error_is_zero';
+	{
+		// Perhaps they are trying to install a theme, lets tell them nicely this is the wrong function
+		$packageInfo = read_tgz_file($boarddir . '/Packages/' . $gzfilename, '*/theme_info.xml', true);
+		if (!empty($packageInfo))
+			return 'package_get_error_is_theme';
+		else
+			return 'package_get_error_is_zero';
+	}
 
 	// Parse package-info.xml into an xmlArray.
 	require_once($sourcedir . '/Class-Package.php');

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

@@ -284,6 +284,7 @@ $txt['package_get_error_not_found'] = 'The package you are trying to install can
 $txt['package_get_error_missing_xml'] = 'The package you are attempting to install is missing the package-info.xml that must be in the root package directory.';
 $txt['package_get_error_is_zero'] = 'Although the package was downloaded to the server it appears to be empty. Please check the Packages directory, and the &quot;temp&quot; sub-directory are both writable. If you continue to experience this problem you should try extracting the package on your PC and uploading the extracted files into a subdirectory in your Packages directory and try again. For example, if the package was called shout.tar.gz you should:<br />1) Download the package to your local PC and extract it into files.<br />2) Using an FTP client create a new directory in your &quot;Packages&quot; folder, in this example you may call it "shout".<br />3) Upload all the files from the extracted package to this directory.<br />4) Go back to the package manager browse page and the package will be automatically found by SMF.';
 $txt['package_get_error_packageinfo_corrupt'] = 'SMF was unable to find any valid information within the package-info.xml file included within the Package. There may be an error with the modification, or the package may be corrupt.';
+$txt['package_get_error_is_theme'] = 'You can\'t install a Theme from this section, please use the <a href="{MANAGETHEMEURL}">Themes and Layout</a> management page to upload it';
 
 $txt['no_membergroup_selected'] = 'No membergroup selected';
 $txt['membergroup_does_not_exist'] = 'The membergroup doesn\'t exist or is invalid.';