Apply PSR-12 code style (#3886)
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / system / template / plugin / LangCompilerTemplatePlugin.class.php
CommitLineData
158bd3ca 1<?php
a9229942 2
158bd3ca 3namespace wcf\system\template\plugin;
a9229942 4
158bd3ca 5use wcf\system\template\TemplateScriptingCompiler;
158bd3ca
TD
6
7/**
a17de04e 8 * Template compiler plugin which compiles dynamic language variables.
a9229942 9 *
158bd3ca 10 * Usage:
a9229942
TD
11 * {lang}$blah{/lang}
12 * {lang var=$x}foo{/lang}
13 *
14 * @author Marcel Werk
15 * @copyright 2001-2019 WoltLab GmbH
16 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
17 * @package WoltLabSuite\Core\System\Template\Plugin
158bd3ca 18 */
a9229942
TD
19class LangCompilerTemplatePlugin implements ICompilerTemplatePlugin
20{
21 /**
22 * @inheritDoc
23 */
24 public function executeStart($tagArgs, TemplateScriptingCompiler $compiler)
25 {
26 $compiler->pushTag('lang');
27
28 $tagArgs = $compiler::makeArgString($tagArgs);
29
30 return "<?php
31 \$this->tagStack[] = ['lang', array_merge(\$this->v, [{$tagArgs}])];
23e43ac5
MW
32 ob_start();
33 ?>";
a9229942
TD
34 }
35
36 /**
37 * @inheritDoc
38 */
39 public function executeEnd(TemplateScriptingCompiler $compiler)
40 {
41 $compiler->popTag('lang');
42
43 return "<?php
44 echo wcf\\system\\WCF::getLanguage()->tplGet(ob_get_clean(), \$this->tagStack[count(\$this->tagStack) - 1][1]);
23e43ac5 45 array_pop(\$this->tagStack); ?>";
a9229942 46 }
dcb3a44c 47}