</div>
</section>
-{include file='__formContainerDependencies'}
+{sharedInclude file='formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
</div>
</section>
-{include file='__formContainerDependencies'}
+{sharedInclude file='formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
<h2 class="sectionTitle">{@$container->getLabel()}{if $container->markAsRequired()} <span class="formFieldRequired">*</span>{/if}</h2>
{/if}
{/if}
-
- {include file='__formContainerChildren'}
+
+ {sharedInclude file='formContainerChildren'}
</section>
-{include file='__formContainerDependencies'}
+{sharedInclude file='formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
<dd>
{@$field->getFieldHtml()}
- {include file='shared_formFieldErrors'}
- {include file='shared_formFieldDescription'}
- {include file='shared_formFieldDependencies'}
- {include file='shared_formFieldDataHandler'}
+ {sharedInclude file='formFieldErrors'}
+ {sharedInclude file='formFieldDescription'}
+ {sharedInclude file='formFieldDependencies'}
+ {sharedInclude file='formFieldDataHandler'}
</dd>
</dl>
*}{foreach from=$container->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{*
*}{if !$container->checkDependencies()} style="display: none;"{/if}{*
*}>
- {include file='__formContainerChildren'}
+ {include file='shared_formContainerChildren'}
</div>
-{include file='__formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
</dd>
</dl>
-{include file='__formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Default'], function(DefaultContainerDependency) {
*}{foreach from=$container->getAttributes() key='attributeName' item='attributeValue'} {$attributeName}="{$attributeValue}"{/foreach}{*
*}{if !$container->checkDependencies()} style="display: none;"{/if}{*
*}>
- {include file='__formContainerChildren'}
+ {include file='shared_formContainerChildren'}
</div>
-{include file='__formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/Tab'], function(TabContainerDependency) {
{/foreach}
</ul>
</nav>
-
- {include file='__formContainerChildren'}
+
+ {include file='shared_formContainerChildren'}
</div>
-{include file='__formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
<script data-relocate="true">
require(['WoltLabSuite/Core/Form/Builder/Field/Dependency/Container/TabMenu'], function(TabMenuContainerDependency) {
{/foreach}
</ul>
</nav>
-
- {include file='__formContainerChildren'}
+
+ {include file='shared_formContainerChildren'}
</div>
-{include file='__formContainerDependencies'}
+{include file='shared_formContainerDependencies'}
* @author Olaf Braun
* @copyright 2001-2014 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
*/
-class SharedTemplateEngine extends TemplateEngine
+final class SharedTemplateEngine extends TemplateEngine
{
/**
* @inheritDoc
*/
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');
+ }
+
$sourceFilename = $this->getPath($this->templatePaths[$application], $templateName);
if (!empty($sourceFilename)) {
return $sourceFilename;
--- /dev/null
+<?php
+
+namespace wcf\system\template\plugin;
+
+use wcf\system\template\SharedTemplateEngine;
+use wcf\system\template\TemplateEngine;
+
+/**
+ * Usage:
+ * {sharedInclude file="test" application="wcf"}
+ * {sharedInclude file="test" application="wcf" var=$variable …}
+ *
+ * @author Olaf Braun
+ * @copyright 2001-2024 WoltLab GmbH
+ * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @since 6.1
+ */
+final class SharedIncludeFunctionTemplatePlugin implements IFunctionTemplatePlugin
+{
+ #[\Override]
+ public function execute($tagArgs, TemplateEngine $tplObj)
+ {
+ if (!isset($tagArgs['file'])) {
+ throw new \InvalidArgumentException("missing 'file' argument in sharedInclude tag");
+ }
+ $file = 'shared_' . $tagArgs['file'];
+ $application = $tagArgs['application'] ?? 'wcf';
+ $sandbox = $tagArgs['sandbox'] ?? false;
+
+ unset($tagArgs['file'], $tagArgs['application'], $tagArgs['sandbox']);
+
+ return SharedTemplateEngine::getInstance()->fetch($file, $application, $tagArgs, $sandbox);
+ }
+}