Suggest the app directory when installing through the ACP
authorAlexander Ebert <ebert@woltlab.com>
Thu, 31 Jan 2019 15:50:40 +0000 (16:50 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 31 Jan 2019 15:50:40 +0000 (16:50 +0100)
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php

index c6603db27098a3e6a9f7d368576d25ec0b82c905..19018f1a19448f2c9874d1871ebd0f406eff0869 100644 (file)
@@ -433,6 +433,9 @@ class PackageInstallationDispatcher {
                }
                unset($nodeData['requirements']);
                
+               $applicationDirectory = $nodeData['applicationDirectory'];
+               unset($nodeData['applicationDirectory']);
+               
                // update package
                if ($this->queue->packageID) {
                        $packageEditor = new PackageEditor(new Package($this->queue->packageID));
@@ -534,7 +537,7 @@ class PackageInstallationDispatcher {
                
                if ($this->getPackage()->isApplication && $this->getPackage()->package != 'com.woltlab.wcf' && $this->getAction() == 'install') {
                        if (empty($this->getPackage()->packageDir)) {
-                               $document = $this->promptPackageDir();
+                               $document = $this->promptPackageDir($applicationDirectory);
                                if ($document !== null && $document instanceof FormDocument) {
                                        $installationStep->setDocument($document);
                                }
@@ -799,9 +802,10 @@ class PackageInstallationDispatcher {
        /**
         * Prompts for a text input for package directory (applies for applications only)
         * 
+        * @param       string          $applicationDirectory
         * @return      FormDocument
         */
-       protected function promptPackageDir() {
+       protected function promptPackageDir($applicationDirectory) {
                // check for pre-defined directories originating from WCFSetup
                $directory = WCF::getSession()->getVar('__wcfSetup_directories');
                if ($directory !== null) {
@@ -841,7 +845,10 @@ class PackageInstallationDispatcher {
                        if ($isParent === false) {
                                $defaultPath = dirname(WCF_DIR);
                        }
-                       $defaultPath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($defaultPath)) . Package::getAbbreviation($this->getPackage()->package) . '/';
+                       if (!$applicationDirectory) {
+                               $applicationDirectory = Package::getAbbreviation($this->getPackage()->package);
+                       }
+                       $defaultPath = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($defaultPath)) . $applicationDirectory . '/';
                        
                        $packageDir->setValue($defaultPath);
                        $container->appendChild($packageDir);
index f838dc46510a64bebcc1c841ace10054f459491b..b21a3d6522375a3fa95966df232e4a76ac0ccefc 100644 (file)
@@ -12,7 +12,7 @@ use wcf\util\StringUtil;
  * Creates a logical node-based installation tree.
  * 
  * @author     Alexander Ebert
- * @copyright  2001-2018 WoltLab GmbH
+ * @copyright  2001-2019 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    WoltLabSuite\Core\System\Package
  */
@@ -27,7 +27,7 @@ class PackageInstallationNodeBuilder {
         * active package installation dispatcher
         * @var PackageInstallationDispatcher
         */
-       public $installation = null;
+       public $installation;
        
        /**
         * current installation node
@@ -396,7 +396,6 @@ class PackageInstallationNodeBuilder {
                
                $this->node = $this->getToken();
                
-               // calculate the number of instances of this package
                $sql = "INSERT INTO     wcf".WCF_N."_package_installation_node
                                        (queueID, processNo, sequenceNo, node, parentNode, nodeType, nodeData)
                        VALUES          (?, ?, ?, ?, ?, ?, ?)";
@@ -420,7 +419,8 @@ class PackageInstallationNodeBuilder {
                                'authorURL' => $this->installation->getArchive()->getAuthorInfo('authorURL') !== null ? $this->installation->getArchive()->getAuthorInfo('authorURL') : '',
                                'installDate' => TIME_NOW,
                                'updateDate' => TIME_NOW,
-                               'requirements' => $this->requirements
+                               'requirements' => $this->requirements,
+                               'applicationDirectory' => $this->installation->getArchive()->getPackageInfo('applicationDirectory') ?: '',
                        ])
                ]);
        }