Commit | Line | Data |
---|---|---|
5daa425d AE |
1 | <?php |
2 | namespace wcf\system\template; | |
3 | ||
4 | /** | |
5 | * Compiles template source into valid PHP code. | |
6 | * | |
7 | * @author Alexander Ebert | |
7d739af0 | 8 | * @copyright 2001-2016 WoltLab GmbH |
5daa425d AE |
9 | * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php> |
10 | * @package com.woltlab.wcf | |
11 | * @subpackage system.template | |
12 | * @category Community Framework | |
13 | */ | |
14 | class SetupTemplateCompiler extends TemplateCompiler { | |
15 | /** | |
0fcfe5f6 | 16 | * @inheritDoc |
5daa425d AE |
17 | */ |
18 | protected function compileOutputTag($tag) { | |
19 | $encodeHTML = false; | |
20 | $formatNumeric = false; | |
21 | if ($tag[0] == '@') { | |
22 | $tag = mb_substr($tag, 1); | |
23 | } | |
24 | else if ($tag[0] == '#') { | |
25 | $tag = mb_substr($tag, 1); | |
26 | $formatNumeric = true; | |
27 | } | |
28 | else { | |
29 | $encodeHTML = true; | |
30 | } | |
31 | ||
32 | $parsedTag = $this->compileVariableTag($tag); | |
33 | ||
34 | // the @ operator at the beginning of an output avoids | |
35 | // the default call of StringUtil::encodeHTML() | |
36 | if ($encodeHTML) { | |
37 | $parsedTag = 'wcf\util\StringUtil::encodeHTML('.$parsedTag.')'; | |
38 | } | |
39 | // the # operator at the beginning of an output instructs | |
40 | // the complier to call the StringUtil::formatNumeric() method | |
41 | else if ($formatNumeric) { | |
42 | $parsedTag = 'wcf\util\StringUtil::formatNumeric('.$parsedTag.')'; | |
43 | } | |
44 | ||
45 | return '<?php echo '.$parsedTag.'; ?>'; | |
46 | } | |
47 | } |