Add IPackageInstallationPlugin::getDefaultFilename()
authorMatthias Schmidt <gravatronics@live.com>
Sat, 23 May 2015 09:27:39 +0000 (11:27 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 23 May 2015 09:27:39 +0000 (11:27 +0200)
17 files changed:
CHANGELOG.md
com.woltlab.wcf/package.xml
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/install/files/lib/system/package/plugin/ACLOptionPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPSearchProviderPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPTemplatePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/AbstractXMLPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/BBCodePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/FilePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/IPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/LanguagePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/PIPPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/SQLPackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/StylePackageInstallationPlugin.class.php
wcfsetup/install/files/lib/system/package/plugin/TemplatePackageInstallationPlugin.class.php

index 9fc7e2caa2fbf8481ca43a52ca065fec36dcab49..2212b488f90793bc3c52f6b3672c6cff13565f50 100644 (file)
@@ -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.
index dfa081cefb3860ff1f76e238c8f34067052f0a51..6474f08fc285f5ec2f8d8d411bff41619ca7d6db 100644 (file)
        </authorinformation>
        
        <instructions type="install">
-               <instruction type="packageInstallationPlugin">packageInstallationPlugin.xml</instruction>
-               <instruction type="acpMenu">acpMenu.xml</instruction>
-               <instruction type="userGroupOption">userGroupOption.xml</instruction>
-               <instruction type="option">option.xml</instruction>
-               <instruction type="template">templates.tar</instruction>
-               <instruction type="eventListener">eventListener.xml</instruction>
+               <instruction type="packageInstallationPlugin" />
+               <instruction type="acpMenu" />
+               <instruction type="userGroupOption" />
+               <instruction type="option" />
+               <instruction type="template" />
+               <instruction type="eventListener" />
                <instruction type="script">acp/install.php</instruction>
-               <instruction type="cronjob">cronjob.xml</instruction>
-               <instruction type="coreObject">coreObject.xml</instruction>
-               <instruction type="clipboardAction">clipboardAction.xml</instruction>
-               <instruction type="objectTypeDefinition">objectTypeDefinition.xml</instruction>
-               <instruction type="objectType">objectType.xml</instruction>
-               <instruction type="acpSearchProvider">acpSearchProvider.xml</instruction>
+               <instruction type="cronjob" />
+               <instruction type="coreObject" />
+               <instruction type="clipboardAction" />
+               <instruction type="objectTypeDefinition" />
+               <instruction type="objectType" />
+               <instruction type="acpSearchProvider" />
                <instruction type="style">blue-temptation-style.tgz</instruction>
                <instruction type="style">woltlab-basic-style.tgz</instruction>
-               <instruction type="userOption">userOption.xml</instruction>
-               <instruction type="bbcode">bbcode.xml</instruction>
-               <instruction type="smiley">smiley.xml</instruction>
-               <instruction type="pageMenu">pageMenu.xml</instruction>
-               <instruction type="sitemap">sitemap.xml</instruction>
-               <instruction type="dashboardBox">dashboardBox.xml</instruction>
-               <instruction type="userProfileMenu">userProfileMenu.xml</instruction>
-               <instruction type="userMenu">userMenu.xml</instruction>
-               <instruction type="userNotificationEvent">userNotificationEvent.xml</instruction>
-               <instruction type="aclOption">aclOption.xml</instruction>
+               <instruction type="userOption" />
+               <instruction type="bbcode" />
+               <instruction type="smiley" />
+               <instruction type="pageMenu" />
+               <instruction type="sitemap" />
+               <instruction type="dashboardBox" />
+               <instruction type="userProfileMenu" />
+               <instruction type="userMenu" />
+               <instruction type="userNotificationEvent" />
+               <instruction type="aclOption" />
                <instruction type="script">acp/post_install.php</instruction>
        </instructions>
 </package>
index c8ee70edd6a2032061f665db801d0c52b9de43fa..9e83703b1cd423c45088e42b3cd0649460b19b17 100644 (file)
@@ -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)) {
index 16ed6aea4be733379292f6340f8146f7d545be70..323c85d17b7ce883f5d1eeed548681dc62888569 100644 (file)
@@ -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';
+       }
 }
index 7351111de56da378c1daf6c99bad8cdeaa3fae13..2188ba78b9013dee00aa562fc2acc430cde4353c 100644 (file)
@@ -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';
+       }
 }
index e3a58c97e7166572dd85cbad9cee4cfb8e774092..88ea932adadd2b05aca5c23d4ad4f30e2a460054 100644 (file)
@@ -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';
+       }
 }
index a664b534ff2165333e4c9238aa645a74b201b25b..74979841d5691d159621687ec4ab623713e40a09 100644 (file)
@@ -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 {
index a202354465eb37e034928f97ad8847fcf460266f..8f9d188b638503e9af6837f1c86cf0e970ad979e 100644 (file)
@@ -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()
         */
index aa78b75af4af4e46c9e2a14dbdd8e50fdd27023e..1980c7c456b784a31b94ad9a966264e0ea4117c4 100644 (file)
@@ -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 {
index 2fe9d25a945c875d61f0a3011d3fb43919ee5bbf..a0a0e261bf6beea5900db31ef1644d4511e663b4 100644 (file)
@@ -185,4 +185,11 @@ class BBCodePackageInstallationPlugin extends AbstractXMLPackageInstallationPlug
                        }
                }
        }
+       
+       /**
+        * @see \wcf\system\package\plugin\IPackageInstallationPlugin::getDefaultFilename()
+        */
+       public static function getDefaultFilename() {
+               return 'bbcode.xml';
+       }
 }
index 93361ea9190abd38c640cbf6aa3cf95e6f21bdd5..73da12f5b8158faac867cf5dc42911e642ae44b1 100644 (file)
@@ -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 {
index 497f0ddbc3d587d9d8bce9966233b3e3c2da375c..62d533fe9da68bee8b02ff7210bf0144b0579d40 100644 (file)
@@ -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.
index 0ea8854d62ad7bdd5d1a105b35ff2cdef0ac2a50..6d449dbf5082d8e54d0f81bb27a6f927d546607a 100644 (file)
@@ -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()
         */
index 8c34005eb8f58465c120318c445fc50f86df144f..2895736f6b52bf01e47a6b659a39c9db52681cd8 100644 (file)
@@ -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()
         */
index 742ef1df8d62ac08cd9e846146878bf411a0f889..59093ebb345e281b5785973cd3a6c434f3b84094 100644 (file)
@@ -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 {
index 07ea7a90163091d0e98c990e3e8b6e9b71d18b2e..d745a679a48e5e2d00c11629cb9a45915c118a8a 100644 (file)
@@ -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() {
index e4f968c4fa2748fb2f39288ead7c7d704b4fb9f4..168dc0bdeba8f015195cfb6dacc31a85cca62ddc 100644 (file)
@@ -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 {