From: Alexander Ebert Date: Thu, 25 Jul 2019 14:33:34 +0000 (+0200) Subject: Reworked the rewrite rule generator X-Git-Tag: 5.2.0_Alpha_3~11 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b6ee3a6f3e324b5d4af012976a73203869652f01;p=GitHub%2FWoltLab%2FWCF.git Reworked the rewrite rule generator See #2903 --- diff --git a/wcfsetup/install/files/acp/templates/__optionRewriteRulesOutput.tpl b/wcfsetup/install/files/acp/templates/__optionRewriteRulesOutput.tpl new file mode 100644 index 0000000000..38236b8464 --- /dev/null +++ b/wcfsetup/install/files/acp/templates/__optionRewriteRulesOutput.tpl @@ -0,0 +1,13 @@ +{foreach from=$rewriteRules key=$webserver item=$rules} +
+

{lang}wcf.acp.rewrite.{$webserver}{/lang}

+ + {foreach from=$rules key=$path item=content} +

+ {$path} +

+
{$content}
+ {/foreach} +
+{/foreach} + diff --git a/wcfsetup/install/files/lib/data/option/OptionAction.class.php b/wcfsetup/install/files/lib/data/option/OptionAction.class.php index bb4573661d..d847b9cbe6 100644 --- a/wcfsetup/install/files/lib/data/option/OptionAction.class.php +++ b/wcfsetup/install/files/lib/data/option/OptionAction.class.php @@ -115,16 +115,8 @@ class OptionAction extends AbstractDatabaseObjectAction { return ['validationResult' => $smtp->testConnection()]; } - /** - * Validates the "generateRewriteRules" action - * @throws \wcf\system\exception\AJAXException - */ public function validateGenerateRewriteRules() { WCF::getSession()->checkPermissions(['admin.configuration.canEditOption']); - - if (!FileUtil::isApacheModule()) { - throw new AJAXException(WCF::getLanguage()->get('wcf.acp.rewrite.error.notApache')); - } } /** @@ -134,28 +126,22 @@ class OptionAction extends AbstractDatabaseObjectAction { * @return string */ public function generateRewriteRules() { - $output = ''; - - foreach ($this->fetchRewriteRules() as $path => $content) { - $output .= <<{$path} -
{$content}
-
-SNIPPET; - - } - - return $output; + return WCF::getTPL()->fetch('__optionRewriteRulesOutput', 'wcf', [ + 'rewriteRules' => $this->fetchRewriteRules(), + ]); } /** * Returns an array with rewrite rules per necessary directory/file * Applications in sub-directories of another application will be mapped to the top one * - * @return string[] + * @return string[][] */ protected function fetchRewriteRules() { - $dirs = $rules = []; + $dirs = []; + $rules = [ + 'apache' => [], + ]; foreach (ApplicationHandler::getInstance()->getApplications() as $app) { $test = $app->getPackage()->getAbsolutePackageDir(); $insert = true; @@ -187,13 +173,15 @@ SNIPPET; krsort($domainPaths); foreach ($domainPaths as $domainPath => $value) { - $path = FileUtil::removeTrailingSlash(substr($value, strlen($dir))); - $snippet = << - + + - diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 231c2d4597..5461a5e019 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -2542,10 +2542,10 @@ If you have already bought the licenses for the listed apps, th - + + -