From: Matthias Schmidt Date: Sat, 23 May 2015 09:27:39 +0000 (+0200) Subject: Add IPackageInstallationPlugin::getDefaultFilename() X-Git-Tag: 3.0.0_Beta_1~2336^2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dcd8ab369ed85cefff87a606dc241e08f3665175;p=GitHub%2FWoltLab%2FWCF.git Add IPackageInstallationPlugin::getDefaultFilename() --- diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fc7e2caa2..2212b488f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### 2.2.0 Alpha 1 (XXXX-YY-ZZ) +* instruction file name for most PIPs has default value now. * `options` support for cronjobs. * `name` attribute for cronjob PIP (`cronjobName` for cronjob objects). * `permissions` and `options` support for event listeners. diff --git a/com.woltlab.wcf/package.xml b/com.woltlab.wcf/package.xml index dfa081cefb..6474f08fc2 100644 --- a/com.woltlab.wcf/package.xml +++ b/com.woltlab.wcf/package.xml @@ -15,31 +15,31 @@ - packageInstallationPlugin.xml - acpMenu.xml - userGroupOption.xml - option.xml - templates.tar - eventListener.xml + + + + + + acp/install.php - cronjob.xml - coreObject.xml - clipboardAction.xml - objectTypeDefinition.xml - objectType.xml - acpSearchProvider.xml + + + + + + blue-temptation-style.tgz woltlab-basic-style.tgz - userOption.xml - bbcode.xml - smiley.xml - pageMenu.xml - sitemap.xml - dashboardBox.xml - userProfileMenu.xml - userMenu.xml - userNotificationEvent.xml - aclOption.xml + + + + + + + + + + acp/post_install.php diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index c8ee70edd6..9e83703b1c 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -555,6 +555,14 @@ class PackageInstallationDispatcher { throw new SystemException("unable to find class '".$className."'"); } + // set default value + if (empty($nodeData['value'])) { + $defaultValue = call_user_func(array($className, 'getDefaultFilename')); + if ($defaultValue) { + $nodeData['value'] = $defaultValue; + } + } + $plugin = new $className($this, $nodeData); if (!($plugin instanceof IPackageInstallationPlugin)) { diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php index 16ed6aea4b..323c85d17b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php @@ -199,4 +199,11 @@ class ACLOptionPackageInstallationPlugin extends AbstractOptionPackageInstallati return $this->optionTypeIDs[$optionType]; } + + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'aclOption.xml'; + } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php index 7351111de5..2188ba78b9 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -16,4 +16,11 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::$className */ public $className = 'wcf\data\acp\menu\item\ACPMenuItemEditor'; + + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'acpMenu.xml'; + } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php index e3a58c97e7..88ea932ada 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php @@ -78,4 +78,11 @@ class ACPSearchProviderPackageInstallationPlugin extends AbstractXMLPackageInsta protected function cleanup() { ACPSearchProviderCacheBuilder::getInstance()->reset(); } + + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'acpSearchProvider.xml'; + } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php index a664b534ff..74979841d5 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php @@ -80,10 +80,21 @@ class ACPTemplatePackageInstallationPlugin extends AbstractPackageInstallationPl } } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'acptemplates.tar'; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ public static function isValid(PackageArchive $archive, $instruction) { + if (!$instruction) { + $defaultFilename = static::getDefaultFilename(); + } + if (preg_match('~\.(tar(\.gz)?|tgz)$~', $instruction)) { // check if file actually exists try { diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php index a202354465..8f9d188b63 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php @@ -44,7 +44,7 @@ abstract class AbstractPackageInstallationPlugin implements IPackageInstallation * Creates a new AbstractPackageInstallationPlugin object. * * @param \wcf\system\package\PackageInstallationDispatcher $installation - * @param array $instruction + * @param array $instruction */ public function __construct(PackageInstallationDispatcher $installation, $instruction = array()) { $this->installation = $installation; @@ -101,6 +101,13 @@ abstract class AbstractPackageInstallationPlugin implements IPackageInstallation $statement->execute(array($this->installation->getPackageID())); } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return null; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ diff --git a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php index aa78b75af4..1980c7c456 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php @@ -346,10 +346,26 @@ abstract class AbstractXMLPackageInstallationPlugin extends AbstractPackageInsta } } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + $classParts = explode('\\', get_called_class()); + + return lcfirst(str_replace('PackageInstallationPlugin', '', array_pop($classParts))).'.xml'; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ public static function isValid(PackageArchive $archive, $instruction) { + if (!$instruction) { + $defaultFilename = static::getDefaultFilename(); + if ($defaultFilename) { + $instruction = $defaultFilename; + } + } + if (preg_match('~\.xml$~', $instruction)) { // check if file actually exists try { diff --git a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php index 2fe9d25a94..a0a0e261bf 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php @@ -185,4 +185,11 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug } } } + + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'bbcode.xml'; + } } diff --git a/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php index 93361ea919..73da12f5b8 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php @@ -108,10 +108,21 @@ class FilePackageInstallationPlugin extends AbstractPackageInstallationPlugin { } } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'files.tar'; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ public static function isValid(PackageArchive $archive, $instruction) { + if (!$instruction) { + $defaultFilename = static::getDefaultFilename(); + } + if (preg_match('~\.(tar(\.gz)?|tgz)$~', $instruction)) { // check if file actually exists try { diff --git a/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php index 497f0ddbc3..62d533fe9d 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php @@ -36,6 +36,14 @@ interface IPackageInstallationPlugin { */ public function uninstall(); + /** + * Returns the default file name containing the instructions. If no default + * file name is supported, null is returned. + * + * @return string + */ + public static function getDefaultFilename(); + /** * Validates if the passed instruction is valid for this package installation plugin. If anything is * wrong with it, this method should return false. diff --git a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php index 0ea8854d62..6d449dbf50 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php @@ -253,6 +253,12 @@ class LanguagePackageInstallationPlugin extends AbstractXMLPackageInstallationPl */ protected function findExistingItem(array $data) { } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'language/*.xml'; + } /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ diff --git a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php index 8c34005eb8..2895736f6b 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php @@ -50,6 +50,13 @@ class PIPPackageInstallationPlugin extends AbstractXMLPackageInstallationPlugin ); } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'packageInstallationPlugin.xml'; + } + /** * @see \wcf\system\package\plugin\AbstractXMLPackageInstallationPlugin::findExistingItem() */ diff --git a/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php index 742ef1df8d..59093ebb34 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php @@ -152,10 +152,21 @@ class SQLPackageInstallationPlugin extends AbstractPackageInstallationPlugin { return $this->installation->getArchive()->getTar()->extractToString($fileindex); } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'install.sql'; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ public static function isValid(PackageArchive $archive, $instruction) { + if (!$instruction) { + $defaultFilename = static::getDefaultFilename(); + } + if (preg_match('~\.sql$~', $instruction)) { // check if file actually exists try { diff --git a/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php index 07ea7a9016..d745a679a4 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php @@ -20,7 +20,7 @@ class StylePackageInstallationPlugin extends AbstractPackageInstallationPlugin { */ public $className = 'wcf\data\style\StyleEditor'; - /** + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::install() */ public function install() { @@ -41,7 +41,7 @@ class StylePackageInstallationPlugin extends AbstractPackageInstallationPlugin { @unlink($filename); } - /** + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::uninstall() */ public function uninstall() { diff --git a/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php index e4f968c4fa..168dc0bdeb 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php @@ -82,10 +82,21 @@ class TemplatePackageInstallationPlugin extends AbstractPackageInstallationPlugi } } + /** + * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename() + */ + public static function getDefaultFilename() { + return 'templates.tar'; + } + /** * @see \wcf\system\package\plugin\IPackageInstallationPlugin::isValid() */ public static function isValid(PackageArchive $archive, $instruction) { + if (!$instruction) { + $defaultFilename = static::getDefaultFilename(); + } + if (preg_match('~\.(tar(\.gz)?|tgz)$~', $instruction)) { // check if file actually exists try {