From e1ff2cacda6181b13d021918a6d5ceecce7a45eb Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 31 Jan 2019 16:50:40 +0100 Subject: [PATCH] Suggest the app directory when installing through the ACP --- .../package/PackageInstallationDispatcher.class.php | 13 ++++++++++--- .../PackageInstallationNodeBuilder.class.php | 8 ++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index c6603db270..19018f1a19 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -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); diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php index f838dc4651..b21a3d6522 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationNodeBuilder.class.php @@ -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 * @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') ?: '', ]) ]); } -- 2.20.1