Application directories are now prompted on setup
authorAlexander Ebert <ebert@woltlab.com>
Wed, 9 Dec 2015 17:49:47 +0000 (18:49 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 9 Dec 2015 17:49:47 +0000 (18:49 +0100)
wcfsetup/install/files/lib/system/WCFSetup.class.php
wcfsetup/install/files/lib/system/package/PackageArchive.class.php
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php
wcfsetup/setup/lang/setup_de.xml
wcfsetup/setup/lang/setup_en.xml
wcfsetup/setup/template/stepConfigureDB.tpl
wcfsetup/setup/template/stepConfigureDirectories.tpl [new file with mode: 0644]
wcfsetup/setup/template/stepCreateUser.tpl
wcfsetup/setup/template/stepNext.tpl
wcfsetup/setup/template/stepSearchWcfDir.tpl [deleted file]
wcfsetup/setup/template/stepSelectLanguages.tpl

index 8880721ba66943556dad274a064383a69a94112e..2834a832e409a08f38023776ee9232d9efcb3849 100644 (file)
@@ -3,6 +3,7 @@ namespace wcf\system;
 use wcf\data\language\LanguageEditor;
 use wcf\data\language\SetupLanguage;
 use wcf\data\package\installation\queue\PackageInstallationQueueEditor;
+use wcf\data\package\Package;
 use wcf\data\user\User;
 use wcf\data\user\UserAction;
 use wcf\system\cache\builder\LanguageCacheBuilder;
@@ -47,9 +48,15 @@ define('ENABLE_BENCHMARK', 0);
 class WCFSetup extends WCF {
        /**
         * list of available languages
-        * @var array
+        * @var string[]
         */
-       protected static $availableLanguages = array();
+       protected static $availableLanguages = [];
+       
+       /**
+        * installation directories
+        * @var string[]
+        */
+       protected static $directories = [];
        
        /**
         * language code of selected installation language
@@ -59,21 +66,15 @@ class WCFSetup extends WCF {
        
        /**
         * selected languages to be installed
-        * @var array
+        * @var string[]
         */
-       protected static $selectedLanguages = array();
-       
-       /**
-        * directory of the framework
-        * @var string
-        */
-       protected static $wcfDir = '';
+       protected static $selectedLanguages = [];
        
        /**
         * list of installed files
-        * @var array
+        * @var string[]
         */
-       protected static $installedFiles = array();
+       protected static $installedFiles = [];
        
        /**
         * name of installed primary application
@@ -89,12 +90,12 @@ class WCFSetup extends WCF {
        
        /**
         * supported databases
-        * @var array<array>
+        * @var string[][]
         */
-       protected static $dbClasses = array(
-               'MySQLDatabase' => array('class' => 'wcf\system\database\MySQLDatabase', 'minversion' => '5.1.17')//,           // MySQL 5.1.17+
-               //'PostgreSQLDatabase' => array('class' => 'wcf\system\database\PostgreSQLDatabase', 'minversion' => '8.2.0')   // PostgreSQL 8.2.0+
-       );
+       protected static $dbClasses = [
+               'MySQLDatabase' => ['class' => 'wcf\system\database\MySQLDatabase', 'minversion' => '5.1.17']//,                // MySQL 5.1.17+
+               //'PostgreSQLDatabase' => ['class' => 'wcf\system\database\PostgreSQLDatabase', 'minversion' => '8.2.0']        // PostgreSQL 8.2.0+
+       ];
        
        /**
         * Calls all init functions of the WCFSetup class and starts the setup process.
@@ -104,7 +105,7 @@ class WCFSetup extends WCF {
                
                $this->getDeveloperMode();
                $this->getLanguageSelection();
-               $this->getWCFDir();
+               $this->getInstallationDirectories();
                $this->initLanguage();
                $this->initTPL();
                self::getLanguage()->loadLanguage();
@@ -143,12 +144,12 @@ class WCFSetup extends WCF {
        /**
         * Gets the available database classes.
         * 
-        * @return      array
+        * @return      string[]
         */
        protected static function getAvailableDBClasses() {
-               $availableDBClasses = array();
+               $availableDBClasses = [];
                foreach (self::$dbClasses as $class => $data) {
-                       if (call_user_func(array($data['class'], 'isSupported'))) {
+                       if (call_user_func([$data['class'], 'isSupported'])) {
                                $availableDBClasses[$class] = $data;
                        }
                }
@@ -159,19 +160,23 @@ class WCFSetup extends WCF {
        /**
         * Gets the selected wcf dir from request.
         */
-       protected static function getWCFDir() {
+       protected static function getInstallationDirectories() {
                if (self::$developerMode && isset($_ENV['WCFSETUP_USEDEFAULTWCFDIR'])) {
-                       $_REQUEST['wcfDir'] = FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR).'wcf/';
+                       if (!is_array($_REQUEST['directories'])) $_REQUEST['directories'] = [];
+                       $_REQUEST['directories']['wcf'] = FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR).'wcf/';
                }
                
-               if (isset($_REQUEST['wcfDir']) && $_REQUEST['wcfDir'] != '') {
-                       self::$wcfDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator($_REQUEST['wcfDir']));
-                       if (@file_exists(self::$wcfDir)) {
-                               define('RELATIVE_WCF_DIR', FileUtil::getRelativePath(INSTALL_SCRIPT_DIR, self::$wcfDir));
+               if (!empty($_REQUEST['directories']) && is_array($_REQUEST['directories'])) {
+                       foreach ($_REQUEST['directories'] as $application => $directory) {
+                               self::$directories[$application] = $directory;
+                               
+                               if ($application === 'wcf' && @file_exists(self::$directories['wcf'])) {
+                                       define('RELATIVE_WCF_DIR', FileUtil::getRelativePath(INSTALL_SCRIPT_DIR, self::$directories['wcf']));   
+                               }
                        }
                }
                
-               define('WCF_DIR', self::$wcfDir);
+               define('WCF_DIR', (isset(self::$directories['wcf']) ? self::$directories['wcf'] : ''));
        }
        
        /**
@@ -184,9 +189,7 @@ class WCFSetup extends WCF {
                mb_language('uni');
                
                // init setup language
-               self::$languageObj = new SetupLanguage(null, array(
-                       'languageCode' => self::$selectedLanguageCode
-               ));
+               self::$languageObj = new SetupLanguage(null, ['languageCode' => self::$selectedLanguageCode]);
        }
        
        /**
@@ -196,22 +199,22 @@ class WCFSetup extends WCF {
                self::$tplObj = SetupTemplateEngine::getInstance();
                self::getTPL()->setLanguageID((self::$selectedLanguageCode == 'en' ? 0 : 1));
                self::getTPL()->setCompileDir(TMP_DIR);
-               self::getTPL()->addApplication('wcf', PACKAGE_ID, TMP_DIR);
-               self::getTPL()->registerPrefilter(array('lang'));
-               self::getTPL()->assign(array(
+               self::getTPL()->addApplication('wcf', TMP_DIR);
+               self::getTPL()->registerPrefilter(['lang']);
+               self::getTPL()->assign([
                        '__wcf' => $this,
                        'tmpFilePrefix' => TMP_FILE_PREFIX,
                        'languageCode' => self::$selectedLanguageCode,
                        'selectedLanguages' => self::$selectedLanguages,
-                       'wcfDir' => self::$wcfDir,
+                       'directories' => self::$directories,
                        'developerMode' => self::$developerMode
-               ));
+               ]);
        }
        
        /**
         * Returns all languages from WCFSetup.tar.gz.
         * 
-        * @return      array
+        * @return      string[]
         */
        protected static function getAvailableLanguages() {
                $languages = $match = [];
@@ -238,7 +241,7 @@ class WCFSetup extends WCF {
        protected function calcProgress($currentStep) {
                // calculate progress
                $progress = round((100 / 18) * ++$currentStep, 0);
-               self::getTPL()->assign(array('progress' => $progress));
+               self::getTPL()->assign(['progress' => $progress]);
        }
        
        /**
@@ -251,6 +254,7 @@ class WCFSetup extends WCF {
                
                // execute current step
                switch ($step) {
+                       /** @noinspection PhpMissingBreakStatementInspection */
                        case 'selectSetupLanguage':
                                if (!self::$developerMode) {
                                        $this->calcProgress(0);
@@ -258,6 +262,7 @@ class WCFSetup extends WCF {
                                        break;
                                }
                        
+                       /** @noinspection PhpMissingBreakStatementInspection */
                        case 'showLicense':
                                if (!self::$developerMode) {
                                        $this->calcProgress(1);
@@ -265,6 +270,7 @@ class WCFSetup extends WCF {
                                        break;
                                }
                        
+                       /** @noinspection PhpMissingBreakStatementInspection */
                        case 'showSystemRequirements':
                                if (!self::$developerMode) {
                                        $this->calcProgress(2);
@@ -272,10 +278,11 @@ class WCFSetup extends WCF {
                                        break;
                                }
                        
-                       case 'searchWcfDir':
+                       /** @noinspection PhpMissingBreakStatementInspection */
+                       case 'configureDirectories':
                                if (!self::$developerMode || !isset($_ENV['WCFSETUP_USEDEFAULTWCFDIR'])) {
                                        $this->calcProgress(3);
-                                       $this->searchWcfDir();
+                                       $this->configureDirectories();
                                        break;
                                }
                        
@@ -330,10 +337,10 @@ class WCFSetup extends WCF {
         * Shows the first setup page.
         */
        protected function selectSetupLanguage() {
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'availableLanguages' => self::$availableLanguages,
                        'nextStep' => 'showLicense'
-               ));
+               ]);
                WCF::getTPL()->display('stepSelectSetupLanguage');
        }
        
@@ -347,7 +354,7 @@ class WCFSetup extends WCF {
                                exit;
                        }
                        else {
-                               WCF::getTPL()->assign(array('missingAcception' => true));
+                               WCF::getTPL()->assign(['missingAcception' => true]);
                        }
                
                }
@@ -359,10 +366,10 @@ class WCFSetup extends WCF {
                        $license = file_get_contents(TMP_DIR.'setup/license/license_en.txt');
                }
                
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'license' => $license,
                        'nextStep' => 'showLicense'
-               ));
+               ]);
                WCF::getTPL()->display('stepShowLicense');
        }
        
@@ -370,7 +377,7 @@ class WCFSetup extends WCF {
         * Shows the system requirements.
         */
        protected function showSystemRequirements() {
-               $system = array();
+               $system = [];
                
                // php version
                $system['phpVersion']['value'] = phpversion();
@@ -389,7 +396,7 @@ class WCFSetup extends WCF {
                $system['gdLib']['value'] = '0.0.0';
                if (function_exists('gd_info')) {
                        $temp = gd_info();
-                       $match = array();
+                       $match = [];
                        if (preg_match('!([0-9]+\.[0-9]+(?:\.[0-9]+)?)!', $temp['GD Version'], $match)) {
                                if (preg_match('/^[0-9]+\.[0-9]+$/', $match[1])) $match[1] .= '.0';
                                $system['gdLib']['value'] = $match[1];
@@ -401,10 +408,10 @@ class WCFSetup extends WCF {
                $system['memoryLimit']['value'] = ini_get('memory_limit');
                $system['memoryLimit']['result'] = $this->compareMemoryLimit();
                
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'system' => $system,
-                       'nextStep' => 'searchWcfDir'
-               ));
+                       'nextStep' => 'configureDirectories'
+               ]);
                WCF::getTPL()->display('stepShowSystemRequirements');
        }
        
@@ -451,38 +458,105 @@ class WCFSetup extends WCF {
        /**
         * Searches the wcf dir.
         */
-       protected function searchWcfDir() {
-               if (self::$wcfDir) {
-                       $wcfDir = self::$wcfDir;
+       protected function configureDirectories() {
+               // get available packages
+               $applications = $packages = [];
+               foreach (glob(TMP_DIR . 'install/packages/*') as $file) {
+                       $filename = basename($file);
+                       if (preg_match('~\.(?:tar|tar\.gz|tgz)$~', $filename)) {
+                               $package = new PackageArchive($file);
+                               $package->openArchive();
+                               
+                               $application = Package::getAbbreviation($package->getPackageInfo('name'));
+                               
+                               $applications[] = $application;
+                               $packages[$application] = [
+                                       'directory' => ($package->getPackageInfo('applicationDirectory') ?: $application),
+                                       'packageDescription' => $package->getLocalizedPackageInfo('packageDescription'),
+                                       'packageName' => $package->getLocalizedPackageInfo('packageName')
+                               ];
+                               
+                       }
                }
-               else {
-                       $wcfDir = FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR).'wcf/';
+               
+               uasort($packages, function($a, $b) {
+                       return strcmp($a['packageName'], $b['packageName']);
+               });
+               
+               // force cms being shown first
+               $showOrder = ['wcf'];
+               foreach (array_keys($packages) as $application) {
+                       if ($application !== 'wcf') $showOrder[] = $application;
                }
                
-               $invalidDirectory = false;
-               if (@is_file($wcfDir.'lib/system/WCF.class.php')) {
-                       $invalidDirectory = true;
+               $documentRoot = FileUtil::unifyDirSeparator($_SERVER['DOCUMENT_ROOT']);
+               $errors = [];
+               if (!empty(self::$directories)) {
+                       $applicationPaths = $knownPaths = [];
+                       
+                       // use $showOrder instead of $applications to ensure that the error message for
+                       // duplicate directories will trigger in display order rather than the random
+                       // sort order returned by glob() above
+                       foreach ($showOrder as $application) {
+                               $path = FileUtil::getRealPath($documentRoot . '/' . FileUtil::addTrailingSlash(FileUtil::removeLeadingSlash(self::$directories[$application])));
+                               if (strpos($path, $documentRoot) !== 0) {
+                                       // verify that given path is still within the current document root
+                                       $errors[$application] = 'outsideDocumentRoot';
+                               }
+                               else if (in_array($path, $knownPaths)) {
+                                       // prevent the same path for two or more applications
+                                       $errors[$application] = 'duplicate';
+                               }
+                               else if (@is_file($path . 'global.php')) {
+                                       // check if directory is empty (dotfiles are okay)
+                                       $errors[$application] = 'notEmpty';
+                               }
+                               else {
+                                       // try to create directory if it does not exist
+                                       if (!is_dir($path) && !FileUtil::makePath($path)) {
+                                               $errors[$application] = 'makePath';
+                                       }
+                                       
+                                       try {
+                                               FileUtil::makeWritable($path);
+                                       }
+                                       catch (SystemException $e) {
+                                               $errors[$application] = 'makeWritable';
+                                       }
+                               }
+                               
+                               $applicationPaths[$application] = $path;
+                               $knownPaths[] = $path;
+                       }
+                       
+                       if (empty($errors)) {
+                               // copy over the actual paths
+                               self::$directories = array_merge(self::$directories, $applicationPaths);
+                               WCF::getTPL()->assign(['directories' => self::$directories]);
+                               
+                               $this->unzipFiles();
+                               return;
+                       }
+               }
+               else {
+                       // resolve path relative to document root
+                       $relativePath = str_replace(FileUtil::unifyDirSeparator($_SERVER['DOCUMENT_ROOT']), '', FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR));
+                       foreach ($packages as $application => $packageData) {
+                               self::$directories[$application] = $relativePath . ($application === 'wcf' ? '' : $packageData['directory'] . '/');
+                       }
                }
                
-               // domain
-               $domainName = '';
-               if (!empty($_SERVER['SERVER_NAME'])) $domainName = 'http://' . $_SERVER['SERVER_NAME'];
-               // port
-               if (!empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) $domainName .= ':' . $_SERVER['SERVER_PORT'];
-               // script url
-               $installScriptUrl = '';
-               if (!empty($_SERVER['REQUEST_URI'])) $installScriptUrl = FileUtil::removeLeadingSlash(FileUtil::removeTrailingSlash(FileUtil::unifyDirSeparator(dirname($_SERVER['REQUEST_URI']))));
-               
-               WCF::getTPL()->assign(array(
-                       'nextStep' => 'unzipFiles',
-                       'invalidDirectory' => $invalidDirectory,
-                       'wcfDir' => $wcfDir,
-                       'domainName' => $domainName,
-                       'installScriptUrl' => $installScriptUrl,
-                       'installScriptDir' => FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR)
-               ));
-               
-               WCF::getTPL()->display('stepSearchWcfDir');
+               WCF::getTPL()->assign([
+                       'directories' => self::$directories,
+                       'documentRoot' => $documentRoot,
+                       'errors' => $errors,
+                       'installScriptDir' => FileUtil::unifyDirSeparator(INSTALL_SCRIPT_DIR),
+                       'nextStep' => 'configureDirectories', // call this step again to validate paths
+                       'packages' => $packages,
+                       'showOrder' => $showOrder
+               ]);
+               
+               WCF::getTPL()->display('stepConfigureDirectories');
        }
        
        /**
@@ -490,20 +564,12 @@ class WCFSetup extends WCF {
         */
        protected function unzipFiles() {
                // WCF seems to be installed, abort
-               if (@is_file(self::$wcfDir.'lib/system/WCF.class.php')) {
+               if (@is_file(self::$directories['wcf'].'lib/system/WCF.class.php')) {
                        throw new SystemException('Target directory seems to be an existing installation of WCF, unable to continue.');
-                       exit;
                }
                // WCF not yet installed, install files first
                else {
-                       try {
-                               $this->installFiles();
-                       }
-                       catch (\Exception $e) {
-                               WCF::getTPL()->assign(array('exception' => $e));
-                               $this->searchWcfDir();
-                               return;
-                       }
+                       $this->installFiles();
                        
                        $this->gotoNextStep('selectLanguages');
                }
@@ -518,12 +584,12 @@ class WCFSetup extends WCF {
                // skip step in developer mode
                // select all available languages automatically
                if (self::$developerMode) {
-                       self::$selectedLanguages = array();
+                       self::$selectedLanguages = [];
                        foreach (self::$availableLanguages as $languageCode => $language) {
                                self::$selectedLanguages[] = $languageCode;
                        }
                        
-                       self::getTPL()->assign(array('selectedLanguages' => self::$selectedLanguages));
+                       self::getTPL()->assign(['selectedLanguages' => self::$selectedLanguages]);
                        $this->gotoNextStep('configureDB');
                        exit;
                }
@@ -555,15 +621,15 @@ class WCFSetup extends WCF {
                }
                else {
                        self::$selectedLanguages[] = self::$selectedLanguageCode;
-                       WCF::getTPL()->assign(array('selectedLanguages' => self::$selectedLanguages));
+                       WCF::getTPL()->assign(['selectedLanguages' => self::$selectedLanguages]);
                }
                
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'errorField' => $errorField,
                        'errorType' => $errorType,
                        'availableLanguages' => self::$availableLanguages,
                        'nextStep' => 'selectLanguages'
-               ));
+               ]);
                WCF::getTPL()->display('stepSelectLanguages');
        }
        
@@ -572,6 +638,7 @@ class WCFSetup extends WCF {
         */
        protected function configureDB() {
                $availableDBClasses = self::getAvailableDBClasses();
+               $dbClass = '';
                if (self::$developerMode && isset($_ENV['WCFSETUP_DBHOST'])) {
                        $dbHost = $_ENV['WCFSETUP_DBHOST'];
                        $dbUser = $_ENV['WCFSETUP_DBUSER'];
@@ -585,7 +652,6 @@ class WCFSetup extends WCF {
                        $dbPassword = '';
                        $dbName = 'wcf';
                        $dbNumber = 1;
-                       $dbClass = '';
                }
                
                // set $dbClass to first item in $availableDBClasses
@@ -627,6 +693,7 @@ class WCFSetup extends WCF {
                                }
                                
                                // check connection data
+                               /** @var \wcf\system\database\Database $db */
                                $db = new $dbClass($dbHost, $dbUser, $dbPassword, $dbName, $dbPort, true);
                                $db->connect();
                                
@@ -644,7 +711,7 @@ class WCFSetup extends WCF {
                                        $statement->execute();
                                        $hasInnoDB = false;
                                        while ($row = $statement->fetchArray()) {
-                                               if ($row['Engine'] == 'InnoDB' && in_array($row['Support'], array('DEFAULT', 'YES'))) {
+                                               if ($row['Engine'] == 'InnoDB' && in_array($row['Support'], ['DEFAULT', 'YES'])) {
                                                        $hasInnoDB = true;
                                                        break;
                                                }
@@ -679,14 +746,14 @@ class WCFSetup extends WCF {
                                }
                                // show configure template again
                                else {
-                                       WCF::getTPL()->assign(array('conflictedTables' => $conflictedTables));
+                                       WCF::getTPL()->assign(['conflictedTables' => $conflictedTables]);
                                }
                        }
                        catch (SystemException $e) {
-                               WCF::getTPL()->assign(array('exception' => $e));
+                               WCF::getTPL()->assign(['exception' => $e]);
                        }
                }
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'dbHost' => $dbHost,
                        'dbUser' => $dbUser,
                        'dbPassword' => $dbPassword,
@@ -695,7 +762,7 @@ class WCFSetup extends WCF {
                        'dbClass' => $dbClass,
                        'availableDBClasses' => $availableDBClasses,
                        'nextStep' => 'configureDB'
-               ));
+               ]);
                WCF::getTPL()->display('stepConfigureDB');
        }
        
@@ -705,6 +772,7 @@ class WCFSetup extends WCF {
         * 
         * @param       \wcf\system\database\Database   $db
         * @param       integer                         $dbNumber
+        * @return      string[]        list of already existing tables
         */
        protected function getConflictedTables($db, $dbNumber) {
                // get content of the sql structure file
@@ -720,7 +788,7 @@ class WCFSetup extends WCF {
                $existingTables = $db->getEditor()->getTableNames();
                
                // check if existing tables are in conflict with wcf tables
-               $conflictedTables = array();
+               $conflictedTables = [];
                foreach ($existingTables as $existingTableName) {
                        foreach ($matches[1] as $wcfTableName) {
                                if ($existingTableName == $wcfTableName) {
@@ -764,16 +832,16 @@ class WCFSetup extends WCF {
                                VALUES          (?)";
                        $statement = self::getDB()->prepareStatement($sql);
                        foreach ($matches[1] as $tableName) {
-                               $statement->execute(array($tableName));
+                               $statement->execute([$tableName]);
                        }
                }
                
                if ($offset < (count($sqlData) - 1)) {
-                       WCF::getTPL()->assign(array(
-                               '__additionalParameters' => array(
+                       WCF::getTPL()->assign([
+                               '__additionalParameters' => [
                                        'offset' => $offset + 1
-                               )
-                       ));
+                               ]
+                       ]);
                        
                        $this->gotoNextStep('createDB');
                }
@@ -786,11 +854,11 @@ class WCFSetup extends WCF {
                                                (pluginName, priority, className)
                                VALUES          (?, ?, ?)";
                        $statement = self::getDB()->prepareStatement($sql);
-                       $statement->execute(array(
+                       $statement->execute([
                                'packageInstallationPlugin',
                                1,
                                'wcf\system\package\plugin\PIPPackageInstallationPlugin'
-                       ));
+                       ]);
                        
                        $this->gotoNextStep('logFiles');
                }
@@ -803,9 +871,9 @@ class WCFSetup extends WCF {
                $this->initDB();
                
                $this->getInstalledFiles(WCF_DIR);
-               $acpTemplateInserts = $fileInserts = array();
+               $acpTemplateInserts = $fileInserts = [];
                foreach (self::$installedFiles as $file) {
-                       $match = array();
+                       $match = [];
                        if (preg_match('!/acp/templates/([^/]+)\.tpl$!', $file, $match)) {
                                // acp template
                                $acpTemplateInserts[] = $match[1];
@@ -825,7 +893,7 @@ class WCFSetup extends WCF {
                        
                        self::getDB()->beginTransaction();
                        foreach ($acpTemplateInserts as $acpTemplate) {
-                               $statement->execute(array($acpTemplate, 'wcf'));
+                               $statement->execute([$acpTemplate, 'wcf']);
                        }
                        self::getDB()->commitTransaction();
                }
@@ -839,7 +907,7 @@ class WCFSetup extends WCF {
                        
                        self::getDB()->beginTransaction();
                        foreach ($fileInserts as $file) {
-                               $statement->execute(array($file, 'wcf'));
+                               $statement->execute([$file, 'wcf']);
                        }
                        self::getDB()->commitTransaction();
                }
@@ -965,7 +1033,7 @@ class WCFSetup extends WCF {
                                        FROM    wcf".WCF_N."_language
                                        WHERE   languageCode = ?";
                                $statement = self::getDB()->prepareStatement($sql);
-                               $statement->execute(array(self::$selectedLanguageCode));
+                               $statement->execute([self::$selectedLanguageCode]);
                                $row = $statement->fetchArray();
                                if (isset($row['languageID'])) $languageID = $row['languageID'];
                                
@@ -974,24 +1042,24 @@ class WCFSetup extends WCF {
                                }
                                
                                // create user
-                               $data = array(
-                                       'data' => array(
+                               $data = [
+                                       'data' => [
                                                'email' => $email,
                                                'languageID' => $languageID,
                                                'password' => $password,
                                                'username' => $username
-                                       ),
-                                       'groups' => array(
+                                       ],
+                                       'groups' => [
                                                1,
                                                3,
                                                4
-                                       ),
-                                       'languages' => array(
+                                       ],
+                                       'languages' => [
                                                $languageID
-                                       )
-                               );
+                                       ]
+                               ];
                                
-                               $userAction = new UserAction(array(), 'create', $data);
+                               $userAction = new UserAction([], 'create', $data);
                                $userAction->executeAction();
                                
                                // go to next step
@@ -1004,7 +1072,7 @@ class WCFSetup extends WCF {
                        }
                }
                
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'errorField' => $errorField,
                        'errorType' => $errorType,
                        'username' => $username,
@@ -1013,7 +1081,7 @@ class WCFSetup extends WCF {
                        'password' => $password,
                        'confirmPassword' => $confirmPassword,
                        'nextStep' => 'createUser'
-               ));
+               ]);
                WCF::getTPL()->display('stepCreateUser');
        }
        
@@ -1029,7 +1097,7 @@ class WCFSetup extends WCF {
                
                // get delivered packages
                $wcfPackageFile = '';
-               $otherPackages = array();
+               $otherPackages = [];
                $tar = new Tar(SETUP_FILE);
                foreach ($tar->getContentList() as $file) {
                        if ($file['type'] != 'folder' && mb_strpos($file['filename'], 'install/packages/') === 0) {
@@ -1081,14 +1149,14 @@ class WCFSetup extends WCF {
                        }
                        
                        // register essential wcf package
-                       $queue = PackageInstallationQueueEditor::create(array(
+                       $queue = PackageInstallationQueueEditor::create([
                                'processNo' => $processNo,
                                'userID' => $admin->userID,
                                'package' => 'com.woltlab.wcf',
                                'packageName' => 'WoltLab Community Framework',
                                'archive' => TMP_DIR.'install/packages/'.$wcfPackageFile,
                                'isApplication' => 1
-                       ));
+                       ]);
                }
                
                // register all other delivered packages
@@ -1105,12 +1173,12 @@ class WCFSetup extends WCF {
                                        FROM    wcf".WCF_N."_package_installation_queue";
                                $statement = WCF::getDB()->prepareStatement($sql);
                                $statement->execute();
-                               $queues = array();
+                               $queues = [];
                                while ($row = $statement->fetchArray()) {
                                        $queues[$row['queueID']] = $row['parentQueueID'];
                                }
                                
-                               $queueIDs = array();
+                               $queueIDs = [];
                                $queueID = $queue->queueID;
                                while ($queueID) {
                                        $queueIDs[] = $queueID;
@@ -1125,7 +1193,7 @@ class WCFSetup extends WCF {
                                        $statement = WCF::getDB()->prepareStatement($sql);
                                        WCF::getDB()->beginTransaction();
                                        foreach ($queueIDs as $queueID) {
-                                               $statement->execute(array($queueID));
+                                               $statement->execute([$queueID]);
                                        }
                                        WCF::getDB()->commitTransaction();
                                }
@@ -1140,7 +1208,7 @@ class WCFSetup extends WCF {
                                throw new SystemException('', 0, '', $e);
                        }
                        
-                       $queue = PackageInstallationQueueEditor::create(array(
+                       $queue = PackageInstallationQueueEditor::create([
                                'parentQueueID' => $queue->queueID,
                                'processNo' => $processNo,
                                'userID' => $admin->userID,
@@ -1148,7 +1216,7 @@ class WCFSetup extends WCF {
                                'packageName' => $archive->getLocalizedPackageInfo('packageName'),
                                'archive' => TMP_DIR.'install/packages/'.$packageFile,
                                'isApplication' => 1
-                       ));
+                       ]);
                }
                
                // login as admin
@@ -1158,6 +1226,7 @@ class WCFSetup extends WCF {
                SessionHandler::getInstance()->changeUser($admin);
                SessionHandler::getInstance()->register('masterPassword', 1);
                SessionHandler::getInstance()->register('__wcfSetup_developerMode', self::$developerMode);
+               SessionHandler::getInstance()->register('__wcfSetup_directories', self::$directories);
                SessionHandler::getInstance()->update();
                
                $installPhpDeleted = @unlink('./install.php');
@@ -1165,10 +1234,10 @@ class WCFSetup extends WCF {
                $wcfSetupTarDeleted = @unlink('./WCFSetup.tar.gz');
                
                // print page
-               WCF::getTPL()->assign(array(
+               WCF::getTPL()->assign([
                        'installPhpDeleted' => $installPhpDeleted,
                        'wcfSetupTarDeleted' => $wcfSetupTarDeleted
-               ));
+               ]);
                WCF::getTPL()->display('stepInstallPackages');
                
                // delete tmp files
@@ -1182,7 +1251,7 @@ class WCFSetup extends WCF {
         * @param       string          $nextStep
         */
        protected function gotoNextStep($nextStep) {
-               WCF::getTPL()->assign(array('nextStep' => $nextStep));
+               WCF::getTPL()->assign(['nextStep' => $nextStep]);
                WCF::getTPL()->display('stepNext');
        }
        
@@ -1190,7 +1259,7 @@ class WCFSetup extends WCF {
         * Installs the files of the tar archive.
         */
        protected static function installFiles() {
-               new Installer(self::$wcfDir, SETUP_FILE, null, 'install/files/');
+               new Installer(self::$directories['wcf'], SETUP_FILE, null, 'install/files/');
        }
        
        /**
@@ -1219,6 +1288,6 @@ class WCFSetup extends WCF {
                $tar->close();
                
                // assign package name
-               WCF::getTPL()->assign(array('setupPackageName' => self::$setupPackageName));
+               WCF::getTPL()->assign(['setupPackageName' => self::$setupPackageName]);
        }
 }
index 6c85b649c7aa6cc84af963b52cf3eb1add22918d..774359e6cd9f1ef25aa5331f4e601eabc128ab7f 100644 (file)
@@ -164,6 +164,7 @@ class PackageArchive {
                
                // parse xml
                $xpath = $xml->xpath();
+               /** @var \DOMElement $package */
                $package = $xpath->query('/ns:package')->item(0);
                
                // package name
@@ -178,6 +179,7 @@ class PackageArchive {
                // get package information
                $packageInformation = $xpath->query('./ns:packageinformation', $package)->item(0);
                $elements = $xpath->query('child::*', $packageInformation);
+               /** @var \DOMElement $element */
                foreach ($elements as $element) {
                        switch ($element->tagName) {
                                case 'packagename':
@@ -203,6 +205,12 @@ class PackageArchive {
                                        $this->packageInfo['isApplication'] = intval($element->nodeValue);
                                break;
                                
+                               case 'applicationdirectory':
+                                       if (preg_match('~^[a-z0-9\-\_]+$~', $element->nodeValue)) {
+                                               $this->packageInfo['applicationDirectory'] = $element->nodeValue;
+                                       }
+                               break;
+                               
                                case 'packageurl':
                                        $this->packageInfo['packageURL'] = $element->nodeValue;
                                break;
@@ -287,6 +295,7 @@ class PackageArchive {
                foreach ($elements as $element) {
                        $instructionData = array();
                        $instructions = $xpath->query('./ns:instruction', $element);
+                       /** @var \DOMElement $instruction */
                        foreach ($instructions as $instruction) {
                                $data = array();
                                $attributes = $xpath->query('attribute::*', $instruction);
index 61a0c84116abb6fe2e76e7948f48f9b0ad97f342..e9fe7b17dcbf5e5f47f7b3ac8f7103663a9d5dd0 100644 (file)
@@ -686,8 +686,14 @@ class PackageInstallationDispatcher {
         * @return      \wcf\system\form\FormDocument
         */
        protected function promptPackageDir() {
-               if (!PackageInstallationFormManager::findForm($this->queue, 'packageDir')) {
-                       
+               // check for pre-defined directories originating from WCFSetup
+               $directory = WCF::getSession()->getVar('__wcfSetup_directories');
+               if ($directory !== null) {
+                       $abbreviation = Package::getAbbreviation($this->getPackage()->package);
+                       $directory = (isset($directory[$abbreviation])) ? $directory[$abbreviation] : null;
+               }
+               
+               if ($directory === null && !PackageInstallationFormManager::findForm($this->queue, 'packageDir')) {
                        $container = new GroupFormElementContainer();
                        $packageDir = new TextInputFormElement($container);
                        $packageDir->setName('packageDir');
@@ -716,14 +722,20 @@ class PackageInstallationDispatcher {
                        return $document;
                }
                else {
-                       $document = PackageInstallationFormManager::getForm($this->queue, 'packageDir');
-                       $document->handleRequest();
-                       $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(FileUtil::unifyDirSeparator($document->getValue('packageDir'))));
-                       if ($packageDir === '/') $packageDir = '';
+                       if ($directory !== null) {
+                               $document = null;
+                               $packageDir = $directory;
+                       }
+                       else {
+                               $document = PackageInstallationFormManager::getForm($this->queue, 'packageDir');
+                               $document->handleRequest();
+                               $packageDir = FileUtil::addTrailingSlash(FileUtil::getRealPath(FileUtil::unifyDirSeparator($document->getValue('packageDir'))));
+                               if ($packageDir === '/') $packageDir = '';
+                       }
                        
                        if ($packageDir !== null) {
                                // validate package dir
-                               if (file_exists($packageDir . 'global.php')) {
+                               if ($document !== null && file_exists($packageDir . 'global.php')) {
                                        $document->setError('packageDir', WCF::getLanguage()->get('wcf.acp.package.packageDir.notAvailable'));
                                        return $document;
                                }
index e791ff63b54d433829b33c7f733ae948a689d8da..8a9c042b3498e0571216a5557c6a231d17fba788 100644 (file)
                <item name="wcf.global.systemRequirements.notActive"><![CDATA[nicht aktiviert]]></item>
                <item name="wcf.global.systemRequirements.memoryLimit"><![CDATA[Zur Verfügung stehender Arbeitsspeicher]]></item>
                <item name="wcf.global.systemRequirements.memoryLimit.description"><![CDATA[Der PHP-Skripten zur Verfügung stehende Arbeitsspeicher ist für einen einwandfreien Betrieb der Software zu gering.]]></item>
-               <item name="wcf.global.wcfDir"><![CDATA[Installationsverzeichnis wählen]]></item>
-               <item name="wcf.global.wcfDir.description"><![CDATA[In das Installationsverzeichnis werden alle Dateien von <b>WoltLab Community Framework</b> entpackt.]]></item>
-               <item name="wcf.global.wcfDir.dir"><![CDATA[Installationsverzeichnis]]></item>
-               <item name="wcf.global.wcfDir.dir.description"><![CDATA[Wenn Sie unsicher sind, belassen sie den vom System vorgegebenen Namen und führen die Standard-Installation durch.]]></item>
-               <item name="wcf.global.wcfDir.dir.info"><![CDATA[Dies ist <u>nicht</u> das Installationsverzeichnis von {$setupPackageName}! Es wird empfohlen den vorgeschlagenen Pfad beizubehalten.]]></item>
-               <item name="wcf.global.wcfDir.error.invalid"><![CDATA[Das eingegebene Verzeichnis ist ungültig.]]></item>
-               <item name="wcf.global.wcfDir.error.invalidDirectory"><![CDATA[Die Installation vermutet eine bereits vorhandene Installation von <b>WoltLab Community Framework</b> im Verzeichnis „{$wcfDir}“.<br />Bitte definieren Sie ein anderes Installationsverzeichnis um die Installation fortzusetzen.]]></item>
-               <item name="wcf.global.wcfDir.url"><![CDATA[Installationsadresse (URL)]]></item>
-               <item name="wcf.global.wcfDir.url.description"><![CDATA[Nach der Installation in das angegebene Installationsverzeichnis ist <b>WoltLab Community Framework</b> über diese Adresse (URL) erreichbar.]]></item>
                <item name="wcf.global.next"><![CDATA[Lade nächsten Schritt …]]></item>
                <item name="wcf.global.next.description"><![CDATA[Die Installation lädt im Moment den nächsten Schritt. Bitte haben Sie einen Augenblick Geduld.]]></item>
                <item name="wcf.global.languages"><![CDATA[Sprachen wählen]]></item>
                Bitte kontrollieren Sie, ob das Zielverzeichnis existiert und beschreibbar ist.]]></item>
                <item name="wcf.global.scrollDown"><![CDATA[Zum Seitenende]]></item>
                <item name="wcf.global.scrollUp"><![CDATA[Zum Seitenanfang]]></item>
+               <item name="wcf.global.applicationDirectory"><![CDATA[Installationsverzeichnisse]]></item>
+               <item name="wcf.global.applicationDirectory.description"><![CDATA[Geben Sie die Verzeichnisse an die für die Installation der aufgeführten Anwendungen verwendet werden sollen.]]></item>
+               <item name="wcf.global.applicationDirectory.error"><![CDATA[Die Eingaben für die Installationsverzeichnisse sind ungültig. Bitte überprüfen Sie die markierten Felder.]]></item>
+               <item name="wcf.global.applicationDirectory.error.duplicate"><![CDATA[Dieses Verzeichnis wurde bereits für eine andere Anwendung angegeben.]]></item>
+               <item name="wcf.global.applicationDirectory.error.makePath"><![CDATA[Das angegebene Verzeichnis kann auf Grund unzureichender Berechtigungen nicht erstellt werden.]]></item>
+               <item name="wcf.global.applicationDirectory.error.makeWritable"><![CDATA[Das angegebene Verzeichnis ist für PHP nicht beschreibbar, bitte überprüfen Sie die Berechtigungen.]]></item>
+               <item name="wcf.global.applicationDirectory.error.notEmpty"><![CDATA[In diesem Verzeichnis befindet sich bereits eine Anwendung.]]></item>
+               <item name="wcf.global.applicationDirectory.error.outsideDocumentRoot"><![CDATA[Das Verzeichnis befindet sich außerhalb des Hauptverzeichnis der Website.]]></item>
+               <item name="wcf.global.applicationDirectory.path"><![CDATA[Installationsverzeichnisse]]></item>
+               <item name="wcf.global.applicationDirectory.path.description"><![CDATA[Die Eingabe der Verzeichnisse erfolgt relativ zum Hauptverzeichnis der Website („{$documentRoot}“).]]></item>
+               <item name="wcf.global.applicationDirectory.url"><![CDATA[Endgültige URL für Anwendungen]]></item>
+               <item name="wcf.global.applicationDirectory.url.description"><![CDATA[Nach der Installation werden die Anwendungen unter den folgenden URLs erreichbar sein.]]></item>
        </category>
 </language>
index 41ab4a8ed1521f4fe6be0c76e7d738d46f436e2e..d8c7a11c2f619d26ce6395255556e15365c6ea5c 100644 (file)
                <item name="wcf.global.systemRequirements.notActive"><![CDATA[Not enabled]]></item>
                <item name="wcf.global.systemRequirements.memoryLimit"><![CDATA[PHP memory limit]]></item>
                <item name="wcf.global.systemRequirements.memoryLimit.description"><![CDATA[The maximum available memory of PHP scripts is too low to properly run the software.]]></item>
-               <item name="wcf.global.wcfDir"><![CDATA[Choose the installation-folder]]></item>
-               <item name="wcf.global.wcfDir.description"><![CDATA[All files of <b>WoltLab Community Framework</b> will be extracted into the installation-folder.]]></item>
-               <item name="wcf.global.wcfDir.dir"><![CDATA[Installation Directory]]></item>
-               <item name="wcf.global.wcfDir.dir.description"><![CDATA[If you are unsure, keep the name which the system suggests and run the standard installation.]]></item>
-               <item name="wcf.global.wcfDir.dir.info"><![CDATA[This is <u>not</u> the installation directory for {$setupPackageName}! It is recommended to keep the suggested path.]]></item>
-               <item name="wcf.global.wcfDir.error.invalid"><![CDATA[The given directory is not valid.]]></item>
-               <item name="wcf.global.wcfDir.error.invalidDirectory"><![CDATA[The installer has found a previous installation of <b>WoltLab Community Framework</b> in the “{$wcfDir}” directory.<br />Please enter an alternative installation directory to continue installation.]]></item>
-               <item name="wcf.global.wcfDir.url"><![CDATA[Installation Address (URL)]]></item>
-               <item name="wcf.global.wcfDir.url.description"><![CDATA[After the installation into the given directory you will be able to access <b>WoltLab Community Framework</b> through this address (URL).]]></item>
                <item name="wcf.global.next"><![CDATA[Loading next step …]]></item>
                <item name="wcf.global.next.description"><![CDATA[The installation is currently loading the next step, please wait.]]></item>
                <item name="wcf.global.languages"><![CDATA[Choose languages to install]]></item>
                Please make sure that the destination folder exists and can be written to.]]></item>
                <item name="wcf.global.scrollDown"><![CDATA[Go to Page Bottom]]></item>
                <item name="wcf.global.scrollUp"><![CDATA[Go to Page End]]></item>
+               <item name="wcf.global.applicationDirectory"><![CDATA[Configure Directories]]></item>
+               <item name="wcf.global.applicationDirectory.description"><![CDATA[Set up the installation directories for each application.]]></item>
+               <item name="wcf.global.applicationDirectory.error"><![CDATA[The provided directories are invalid, please checked the marked fields for errors.]]></item>
+               <item name="wcf.global.applicationDirectory.error.duplicate"><![CDATA[This directory has already been provided for a different application.]]></item>
+               <item name="wcf.global.applicationDirectory.error.makePath"><![CDATA[This directory cannot be created due to insufficient permissions.]]></item>
+               <item name="wcf.global.applicationDirectory.error.makeWritable"><![CDATA[The directory is not writable by PHP, please review the permissions.]]></item>
+               <item name="wcf.global.applicationDirectory.error.notEmpty"><![CDATA[There is already an application inside this directory.]]></item>
+               <item name="wcf.global.applicationDirectory.error.outsideDocumentRoot"><![CDATA[The directory is outside the website’s document root.]]></item>
+               <item name="wcf.global.applicationDirectory.path"><![CDATA[Directories]]></item>
+               <item name="wcf.global.applicationDirectory.path.description"><![CDATA[Directories are evaluated relative to the website’s document root (“{$documentRoot}”).]]></item>
+               <item name="wcf.global.applicationDirectory.url"><![CDATA[Application URLs]]></item>
+               <item name="wcf.global.applicationDirectory.url.description"><![CDATA[Applications will be accessible through these URLs after setup has completed.]]></item>
        </category>
 </language>
index 0101b0b49da41fd3663fd5375408059cd7563970..c3889ffa2b08d05433440f3e4be19903d3236f0e 100644 (file)
                <input type="hidden" name="step" value="{@$nextStep}" />
                <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
                <input type="hidden" name="languageCode" value="{@$languageCode}" />
-               <input type="hidden" name="wcfDir" value="{$wcfDir}" />
                <input type="hidden" name="dev" value="{@$developerMode}" />
+               {foreach from=$directories key=application item=directory}
+                       <input type="hidden" name="directories[{$application}]" value="{$directory}">
+               {/foreach}
                {foreach from=$selectedLanguages item=language}
                        <input type="hidden" name="selectedLanguages[]" value="{$language}" />
                {/foreach}
diff --git a/wcfsetup/setup/template/stepConfigureDirectories.tpl b/wcfsetup/setup/template/stepConfigureDirectories.tpl
new file mode 100644 (file)
index 0000000..9598f5a
--- /dev/null
@@ -0,0 +1,83 @@
+{include file='header'}
+
+<header class="boxHeadline boxSubHeadline">
+       <h2>{lang}wcf.global.applicationDirectory{/lang}</h2>
+       <p>{lang}wcf.global.applicationDirectory.description{/lang}</p>
+</header>
+
+{if !$errors|empty}
+       <p class="error">{lang}wcf.global.applicationDirectory.error{/lang}</p>
+{/if}
+
+<form method="post" action="install.php">
+       <div class="container containerPadding marginTop">
+               <fieldset>
+                       <legend>{lang}wcf.global.applicationDirectory.path{/lang}</legend>
+                       <small>{lang}wcf.global.applicationDirectory.path.description{/lang}</small>
+                       
+                       {foreach from=$showOrder item=$application}
+                               <dl{if $errors[$application]|isset} class="formError"{/if}>
+                                       <dt>
+                                               <label for="application_{$application}">{$packages[$application][packageName]}</label>
+                                       </dt>
+                                       <dd>
+                                               <input type="text" id="application_{$application}" class="long jsApplicationDirectory" name="directories[{$application}]" value="{$directories[$application]}">
+                                               {if $errors[$application]|isset}<small class="innerError">{lang}wcf.global.applicationDirectory.error.{@$errors[$application]}{/lang}</small>{/if}
+                                               <small>{$packages[$application][packageDescription]}</small>
+                                       </dd>
+                               </dl>
+                       {/foreach}
+               </fieldset>
+               
+               <fieldset>
+                       <legend>{lang}wcf.global.applicationDirectory.url{/lang}</legend>
+                       <small>{lang}wcf.global.applicationDirectory.url.description{/lang}</small>
+                       
+                       {foreach from=$showOrder item=$application}
+                               <dl>
+                                       <dt>
+                                               <label for="application_{$application}">{$packages[$application][packageName]}</label>
+                                       </dt>
+                                       <dd>
+                                               <span id="application_{$application}_url"></span>
+                                       </dd>
+                               </dl>
+                       {/foreach}
+               </fieldset>
+       </div>
+       
+       <div class="formSubmit">
+               <input type="submit" value="{lang}wcf.global.button.next{/lang}" accesskey="s" />
+               <input type="hidden" name="step" value="{@$nextStep}" />
+               <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
+               <input type="hidden" name="languageCode" value="{@$languageCode}" />
+               <input type="hidden" name="dev" value="{@$developerMode}" />
+       </div>
+</form>
+
+<script data-relocate="true">
+       (function() {
+               function updateUrl(event, directory) {
+                       directory = (directory) ? directory : event.currentTarget;
+                       
+                       var urlElement = document.getElementById(directory.id + '_url');
+                       var value = directory.value.trim();
+                       if (value.slice(-1) !== '/') value += '/';
+                       if (value.substr(0, 1) !== '/') value = '/' + value;
+                       
+                       urlElement.textContent = window.location.protocol + '//' + window.location.host + value;
+               }
+               
+               var directory, directories = document.getElementsByClassName('jsApplicationDirectory');
+               for (var i = 0, length = directories.length; i < length; i++) {
+                       directory = directories[i];
+                       
+                       updateUrl(undefined, directory);
+                       
+                       directory.addEventListener('keyup', updateUrl);
+                       directory.addEventListener('blur', updateUrl);
+               }
+       })();
+</script>
+
+{include file='footer'}
index 96fd3f9fc121aa8ccc78deee51502dd9193c65f9..89062fa606be8822d08daa23948a07b6759ab40f 100644 (file)
                <input type="hidden" name="step" value="{@$nextStep}" />
                <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
                <input type="hidden" name="languageCode" value="{@$languageCode}" />
-               <input type="hidden" name="wcfDir" value="{$wcfDir}" />
                <input type="hidden" name="dev" value="{@$developerMode}" />
+               {foreach from=$directories key=application item=directory}
+                       <input type="hidden" name="directories[{$application}]" value="{$directory}">
+               {/foreach}
        </div>
 </form>
 
index 4dcef26eb225d1a5600a4bc2063057483d6c0172..6fe859e99ee27b239186d64c4cd4312632782aca 100644 (file)
@@ -9,8 +9,10 @@
        <div class="formSubmit">
                <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
                <input type="hidden" name="languageCode" value="{@$languageCode}" />
-               <input type="hidden" name="wcfDir" value="{$wcfDir}" />
                <input type="hidden" name="dev" value="{@$developerMode}" />
+               {foreach from=$directories key=application item=directory}
+                       <input type="hidden" name="directories[{$application}]" value="{$directory}">
+               {/foreach}
                {foreach from=$selectedLanguages item=language}
                        <input type="hidden" name="selectedLanguages[]" value="{$language}" />
                {/foreach}
diff --git a/wcfsetup/setup/template/stepSearchWcfDir.tpl b/wcfsetup/setup/template/stepSearchWcfDir.tpl
deleted file mode 100644 (file)
index 51c5633..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-{include file='header'}
-
-<header class="boxHeadline boxSubHeadline">
-       <h2>{lang}wcf.global.wcfDir{/lang}</h2>
-       <p>{lang}wcf.global.wcfDir.description{/lang}</p>
-</header>
-
-{if $invalidDirectory}
-       <p class="error">{lang}wcf.global.wcfDir.error.invalidDirectory{/lang}</p>
-{/if}
-
-{if $exception|isset}
-       <p class="error">{lang}wcf.global.wcfDir.error{/lang}</p>
-{/if}
-
-<form method="post" action="install.php">
-       <div class="container containerPadding marginTop">
-               <fieldset>
-                       <legend>{lang}wcf.global.wcfDir.dir{/lang}</legend>
-                       <small>{lang}wcf.global.wcfDir.dir.info{/lang}</small>
-                       
-                       <dl>
-                               <dt><label for="wcfDir">{lang}wcf.global.wcfDir.dir{/lang}</label></dt>
-                               <dd>
-                                       <input type="text" id="wcfDir" name="wcfDir" value="{$wcfDir}" class="long" />
-                                       <small>{lang}wcf.global.wcfDir.dir.description{/lang}</small>
-                               </dd>
-                       </dl>
-                       <dl id="wcfUrlContainer" style="display: none;">
-                               <dt><label for="wcfUrl">{lang}wcf.global.wcfDir.url{/lang}</label></dt>
-                               <dd>
-                                       <p id="wcfUrl"></p>
-                                       <small>{lang}wcf.global.wcfDir.url.description{/lang}</small>
-                               </dd>
-                       </dl>
-               </fieldset>
-       </div>
-       
-       <div class="formSubmit">
-               <input type="submit" value="{lang}wcf.global.button.next{/lang}" accesskey="s" />
-               <input type="hidden" name="step" value="{@$nextStep}" />
-               <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
-               <input type="hidden" name="languageCode" value="{@$languageCode}" />
-               <input type="hidden" name="dev" value="{@$developerMode}" />
-       </div>
-</form>
-
-<script data-relocate="true">
-       document.getElementById('wcfUrlContainer').style.removeProperty('display');
-       
-       // data
-       var DOMAIN_NAME = '{@$domainName|encodeJS}';
-       var INSTALL_SCRIPT_DIR = '{@$installScriptDir|encodeJS}';
-       var INSTALL_SCRIPT_URL = '{@$installScriptUrl|encodeJS}';
-       var INVALID_ERROR_MESSAGE = '{lang}wcf.global.wcfDir.error.invalid{/lang}';
-       var wcfDir = document.getElementById('wcfDir');
-       var wcfUrl = document.getElementById('wcfUrl');
-       
-       function removeEmptyDirParts(dir) {
-               for (var i = dir.length; i >= 0; i--) {
-                       if (dir[i] == '' || dir[i] == '.') {
-                               dir.splice(i, 1);
-                       }
-               }
-               
-               return dir;
-       }
-       
-       function updateWcfUrl() {
-               // split paths and remove empty parts
-               var installScriptDirs = removeEmptyDirParts(INSTALL_SCRIPT_DIR.split('/'));
-               var wcfDirs = removeEmptyDirParts(wcfDir.value.split('/'));
-               var installScriptUrlDirs = removeEmptyDirParts(INSTALL_SCRIPT_URL.split('/'));
-               
-               // get relative path
-               var relativePathDirs = [];
-               var max = (wcfDirs.length > installScriptDirs.length) ? wcfDirs.length : installScriptDirs.length;
-               for (var i = 0; i < max; i++) {
-                       if (i < installScriptDirs.length && i < wcfDirs.length) {
-                               if (installScriptDirs[i] !== wcfDirs[i]) {
-                                       wcfDirs.splice(0, i);
-                                       
-                                       for (var j = 0, length = installScriptDirs.length - i; j < length; j++) {
-                                               $relativePathDirs.push('..');
-                                       }
-                                       
-                                       relativePathDirs = relativePathDirs.concat(wcfDirs);
-                                       break;
-                               }
-                       }
-                       // go up one level
-                       else if (i < installScriptDirs.length && i >= wcfDirs.length) {
-                               relativePathDirs.push('..');
-                       }
-                       else {
-                               relativePathDirs.push(wcfDirs[i]);
-                       }
-               }
-               
-               // loop dirs
-               for (var i = 0; i < relativePathDirs.length; i++) {
-                       if (relativePathDirs[i] == '..') {
-                               if (installScriptUrlDirs.length < 1) {
-                                       wcfUrl.textContent = INVALID_ERROR_MESSAGE;
-                                       return;
-                               }
-                               
-                               installScriptUrlDirs.pop();
-                       }
-                       else {
-                               installScriptUrlDirs.push(relativePathDirs[i]);
-                       }
-               }
-               
-               wcfUrl.textContent = DOMAIN_NAME + (installScriptUrlDirs.length ? '/' : '') + installScriptUrlDirs.join('/');
-       }
-       
-       wcfDir.addEventListener('keyup', updateWcfUrl);
-       wcfDir.addEventListener('blur', updateWcfUrl);
-       
-       updateWcfUrl();
-</script>
-
-{include file='footer'}
index 15ec080e60d048b7253c26c8cad7c9685e6829ac..709d2098a13f29d171d2fb91c15cf5418ece3480 100644 (file)
                <input type="hidden" name="step" value="{@$nextStep}" />
                <input type="hidden" name="tmpFilePrefix" value="{@$tmpFilePrefix}" />
                <input type="hidden" name="languageCode" value="{@$languageCode}" />
-               <input type="hidden" name="wcfDir" value="{$wcfDir}" />
                <input type="hidden" name="dev" value="{@$developerMode}" />
+               {foreach from=$directories key=application item=directory}
+                       <input type="hidden" name="directories[{$application}]" value="{$directory}">
+               {/foreach}
        </div>
 </form>