</div>
</section>
-{sharedInclude file='formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
</div>
</section>
-{sharedInclude file='formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
{/if}
{/if}
- {sharedInclude file='formContainerChildren'}
+ {include file='shared_formContainerChildren'}
</section>
-{sharedInclude file='formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
<dd>
{@$field->getFieldHtml()}
- {sharedInclude file='formFieldErrors'}
- {sharedInclude file='formFieldDescription'}
- {sharedInclude file='formFieldDependencies'}
- {sharedInclude file='formFieldDataHandler'}
+ {include file='shared_formFieldErrors'}
+ {include file='shared_formFieldDescription'}
+ {include file='shared_formFieldDependencies'}
+ {include file='shared_formFieldDataHandler'}
</dd>
</dl>
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;
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']);
'__' . $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 . "'.");
if (ENABLE_ENTERPRISE_MODE) {
$wcf = new TemplateScriptingCore($wcf);
}
- $tplEngines = [self::getTPL(), SharedTemplateEngine::getInstance()];
- /** @var TemplateEngine[] $tplEngines */
- 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');
- }
+ 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');
}
}
if (self::$tplObj !== null) {
self::getTPL()->setLanguageID(self::getLanguage()->languageID);
EmailTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID);
- SharedTemplateEngine::getInstance()->setLanguageID(self::getLanguage()->languageID);
+ WCF::getTPL()->setLanguageID(self::getLanguage()->languageID);
}
}
use wcf\data\article\ViewableArticle;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
-use wcf\system\template\SharedTemplateEngine;
use wcf\system\WCF;
use wcf\util\StringUtil;
'message' => WCF::getLanguage()->getDynamicVariable('wcf.message.content.no.permission.title')
], true);
} elseif ($parser->getOutputType() == 'text/html') {
- return SharedTemplateEngine::getInstance()->fetch('shared_articleBBCode', 'wcf', [
+ return WCF::getTPL()->fetch('shared_articleBBCode', 'wcf', [
'article' => $article,
'articleID' => $article->articleID,
'titleHash' => \substr(StringUtil::getRandomID(), 0, 8),
use wcf\data\media\ViewableMedia;
use wcf\system\message\embedded\object\MessageEmbeddedObjectManager;
use wcf\system\request\LinkHandler;
-use wcf\system\template\SharedTemplateEngine;
use wcf\system\WCF;
use wcf\util\StringUtil;
$float = (!empty($openingTag['attributes'][2])) ? $openingTag['attributes'][2] : 'none';
$width = (!empty($openingTag['attributes'][3])) ? $openingTag['attributes'][3] : 'auto';
- return SharedTemplateEngine::getInstance()->fetch('shared_mediaBBCodeTag', 'wcf', [
+ return WCF::getTPL()->fetch('shared_mediaBBCodeTag', 'wcf', [
'mediaLink' => $this->getLink($media),
'removeLinks' => $removeLinks,
'thumbnailLink' => $thumbnailSize !== 'original' ? $this->getThumbnailLink(
'width' => $width,
]);
} elseif ($media->isVideo() || $media->isAudio()) {
- return SharedTemplateEngine::getInstance()->fetch('shared_mediaBBCodeTag', 'wcf', [
+ return WCF::getTPL()->fetch('shared_mediaBBCodeTag', 'wcf', [
'mediaLink' => $this->getLink($media),
'removeLinks' => $removeLinks,
'float' => 'none',
use wcf\system\form\builder\data\processor\DefaultFormDataProcessor;
use wcf\system\form\builder\field\IFileFormField;
use wcf\system\form\builder\field\IFormField;
-use wcf\system\template\SharedTemplateEngine;
use wcf\system\WCF;
/**
throw new \BadMethodCallException("The form document has to be built before it can be rendered.");
}
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
'shared_form',
'wcf',
\array_merge($this->getHtmlVariables(), ['form' => $this])
namespace wcf\system\form\builder;
use wcf\system\application\ApplicationHandler;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Form node that shows the contents of a specific template.
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
$this->getTemplateName(),
$this->getApplication(),
$this->getVariables(),
use wcf\system\form\builder\TFormChildNode;
use wcf\system\form\builder\TFormElement;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Default implementation of a form button.
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
$this->templateName,
'wcf',
[
use wcf\system\form\builder\TFormChildNode;
use wcf\system\form\builder\TFormElement;
use wcf\system\form\builder\TFormParentNode;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Represents a default container.
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
$this->templateName,
$this->templateApplication,
\array_merge($this->getHtmlVariables(), [
use wcf\system\form\builder\field\IFormField;
use wcf\system\form\builder\field\IImmutableFormField;
use wcf\system\form\builder\field\ISelectionFormField;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Represents a form field container for one main field with (optional) support for a suffix selection
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch('shared_suffixFormFieldContainer', 'wcf', [
+ return WCF::getTPL()->fetch('shared_suffixFormFieldContainer', 'wcf', [
'element' => $this,
]);
}
use wcf\system\form\builder\field\validation\IFormFieldValidator;
use wcf\system\form\builder\TFormChildNode;
use wcf\system\form\builder\TFormElement;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Abstract implementation of a form field.
throw new \LogicException("\$templateName property has not been set for class '" . static::class . "'.");
}
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
$this->templateName,
$this->templateApplication,
\array_merge($this->getHtmlVariables(), [
throw new \UnexpectedValueException("Form field '{$this->getPrefixedId()}' requires a label.");
}
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
'shared_formField',
'wcf',
['field' => $this],
namespace wcf\system\form\builder\field;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Implementation of a checkbox form field for boolean values.
throw new \UnexpectedValueException("Form field '{$this->getPrefixedId()}' requires a label.");
}
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
'shared_checkboxFormField',
'wcf',
[
/**
* @inheritDoc
*/
- protected $templateName = '__singleSelectionFormField';
+ protected $templateName = 'shared_singleSelectionFormField';
/**
* @inheritDoc
use wcf\system\application\ApplicationHandler;
use wcf\system\form\builder\field\IFormField;
use wcf\system\form\builder\IFormNode;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Abstract implementation of a form field dependency.
throw new \LogicException("Unknown application with abbreviation '{$this->templateNameApplication}'.");
}
- return SharedTemplateEngine::getInstance()->fetch($this->templateName, $this->templateNameApplication, [
+ return WCF::getTPL()->fetch($this->templateName, $this->templateNameApplication, [
'dependency' => $this,
], true);
}
use wcf\system\form\builder\field\AbstractFormField;
use wcf\system\form\builder\field\TDefaultIdFormField;
use wcf\system\form\builder\field\validation\FormFieldValidationError;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Form field implementation for the instructions of a devtools project.
$this->removeClass('formError');
- return SharedTemplateEngine::getInstance()->fetch(
+ return WCF::getTPL()->fetch(
$this->templateName,
'wcf',
[
namespace wcf\system\form\builder\field\validation;
-use wcf\system\template\SharedTemplateEngine;
use wcf\system\WCF;
/**
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch('shared_formFieldError', 'wcf', [
+ return WCF::getTPL()->fetch('shared_formFieldError', 'wcf', [
'error' => $this,
]);
}
use wcf\system\form\builder\IFormChildNode;
use wcf\system\form\builder\TFormChildNode;
use wcf\system\form\builder\TFormNode;
-use wcf\system\template\SharedTemplateEngine;
+use wcf\system\WCF;
/**
* Implementation of a form field for the list smilies of a certain category used by a wysiwyg
*/
public function getHtml()
{
- return SharedTemplateEngine::getInstance()->fetch('shared_wysiwygSmileyFormNode', 'wcf', [
+ return WCF::getTPL()->fetch('shared_wysiwygSmileyFormNode', 'wcf', [
'node' => $this,
]);
}
use wcf\system\exception\SystemException;
use wcf\system\Regex;
use wcf\system\SingletonFactory;
+use wcf\system\WCF;
use wcf\util\DirectoryUtil;
use wcf\util\HeaderUtil;
use wcf\util\StringUtil;
protected $tagStack = [];
+ private int $sharedTemplateGroupID = 0;
+
/**
* @inheritDoc
*/
$this->pluginNamespace = 'wcf\system\template\plugin\\';
$this->compileDir = WCF_DIR . 'templates/compiled/';
+ $sql = "SELECT templateGroupID
+ FROM wcf" . WCF_N . "_template_group
+ WHERE templateGroupFolderName = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(['_wcf_shared/']);
+
+ $this->sharedTemplateGroupID = $statement->fetchSingleColumn();
+
$this->loadTemplateGroupCache();
$this->assignSystemVariables();
}
*/
public function getSourceFilename($templateName, $application)
{
- if (\str_starts_with($templateName, 'shared_') && !($this instanceof SharedTemplateEngine)) {
- throw new \LogicException('Shared templates can only be used with SharedTemplateEngine');
+ if ($this->isSharedTemplate($templateName)) {
+ $sourceFilename = $this->getPath(TemplateEngine::getInstance()->templatePaths[$application], $templateName);
+ } else {
+ $sourceFilename = $this->getPath($this->templatePaths[$application], $templateName);
}
-
- $sourceFilename = $this->getPath($this->templatePaths[$application], $templateName);
if (!empty($sourceFilename)) {
return $sourceFilename;
}
{
if (!Template::isSystemCritical($templateName)) {
$templateGroupID = $this->getTemplateGroupID();
-
while ($templateGroupID != 0) {
$templateGroup = $this->templateGroupCache[$templateGroupID];
*/
public function getCompiledFilename($templateName, $application)
{
- return $this->compileDir . $this->getTemplateGroupID() . '_' . $application . '_' . $this->languageID . '_' . $templateName . '.php';
+ $path = $this->compileDir;
+ if ($this->isSharedTemplate($templateName)) {
+ $path .= $this->sharedTemplateGroupID;
+ } else {
+ $path .= $this->getTemplateGroupID();
+ }
+ return $path . '_' . $application . '_' . $this->languageID . '_' . $templateName . '.php';
}
/**
*/
public function getMetaDataFilename($templateName)
{
- return $this->compileDir . $this->getTemplateGroupID() . '_' . $templateName . '.meta.php';
+ $path = $this->compileDir;
+ if ($this->isSharedTemplate($templateName)) {
+ $path .= $this->sharedTemplateGroupID;
+ } else {
+ $path .= $this->getTemplateGroupID();
+ }
+ return $path . '_' . $templateName . '.meta.php';
}
/**
return $data;
}
+
+ protected function isSharedTemplate(string $templateName): bool
+ {
+ return \str_starts_with($templateName, 'shared_');
+ }
}
namespace wcf\system\template\plugin;
-use wcf\system\template\SharedTemplateEngine;
use wcf\system\template\TemplateEngine;
/**
unset($tagArgs['file'], $tagArgs['application'], $tagArgs['sandbox']);
- return SharedTemplateEngine::getInstance()->fetch($file, $application, $tagArgs, $sandbox);
+ return WCF::getTPL()->fetch($file, $application, $tagArgs, $sandbox);
}
}