Register default values for `SharedTemplateEngine`
authorCyperghost <olaf_schmitz_1@t-online.de>
Thu, 25 Jan 2024 14:28:04 +0000 (15:28 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Thu, 25 Jan 2024 14:28:04 +0000 (15:28 +0100)
wcfsetup/install/files/lib/system/WCF.class.php

index 2489c54947da0a7fd2fcb046759b39f032955775..a4b7d70c50075ba825a5b0f53addda7116b1fda7 100644 (file)
@@ -31,6 +31,7 @@ use wcf\system\session\SessionFactory;
 use wcf\system\session\SessionHandler;
 use wcf\system\style\StyleHandler;
 use wcf\system\template\EmailTemplateEngine;
+use wcf\system\template\SharedTemplateEngine;
 use wcf\system\template\TemplateEngine;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\util\DirectoryUtil;
@@ -658,6 +659,7 @@ class WCF
                 static::getTPL()->addApplication($abbreviation, $packageDir . 'templates/');
             }
             EmailTemplateEngine::getInstance()->addApplication($abbreviation, $packageDir . 'templates/');
+            SharedTemplateEngine::getInstance()->addApplication($abbreviation, $packageDir . 'templates/');
 
             // init application and assign it as template variable
             self::$applicationObjects[$application->packageID] = \call_user_func([$className, 'getInstance']);
@@ -666,6 +668,10 @@ class WCF
                 '__' . $abbreviation,
                 self::$applicationObjects[$application->packageID]
             );
+            SharedTemplateEngine::getInstance()->assign(
+                '__' . $abbreviation,
+                self::$applicationObjects[$application->packageID]
+            );
         } else {
             unset(self::$autoloadDirectories[$abbreviation]);
             throw new SystemException("Unable to run '" . $package->package . "', '" . $className . "' is missing or does not implement '" . IApplication::class . "'.");
@@ -743,21 +749,24 @@ class WCF
         if (ENABLE_ENTERPRISE_MODE) {
             $wcf = new TemplateScriptingCore($wcf);
         }
-
-        self::getTPL()->registerPrefilter(['event', 'hascontent', 'lang', 'jsphrase', 'jslang', 'csrfToken', 'icon']);
-        self::getTPL()->assign([
-            '__wcf' => $wcf,
-        ]);
-
-        $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
-        // Execute background queue in this request, if it was requested and AJAX isn't used.
-        if (!$isAjax) {
-            if (self::getSession()->getVar('forceBackgroundQueuePerform')) {
-                self::getTPL()->assign([
-                    'forceBackgroundQueuePerform' => true,
-                ]);
-
-                self::getSession()->unregister('forceBackgroundQueuePerform');
+        $tplEngines = [self::getTPL(), SharedTemplateEngine::getInstance()];
+
+        foreach ($tplEngines as $tplEngine) {
+            $tplEngine->registerPrefilter(['event', 'hascontent', 'lang', 'jsphrase', 'jslang', 'csrfToken', 'icon']);
+            $tplEngine->assign([
+                '__wcf' => $wcf,
+            ]);
+
+            $isAjax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest');
+            // Execute background queue in this request, if it was requested and AJAX isn't used.
+            if (!$isAjax) {
+                if (self::getSession()->getVar('forceBackgroundQueuePerform')) {
+                    $tplEngine->assign([
+                        'forceBackgroundQueuePerform' => true,
+                    ]);
+
+                    self::getSession()->unregister('forceBackgroundQueuePerform');
+                }
             }
         }
 
@@ -807,6 +816,7 @@ class WCF
         if (self::$tplObj !== null) {
             self::getTPL()->setLanguageID(self::getLanguage()->languageID);
             EmailTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID);
+            SharedTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID);
         }
     }