Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
SetNode.php
001 <?php
002
003 /*
004 * This file is part of Twig.
005 *
006 * (c) Fabien Potencier
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Twig\Node;
013
014 use Twig\Compiler;
015 use Twig\Node\Expression\ConstantExpression;
016
017 /**
018 * Represents a set node.
019 *
020 * @author Fabien Potencier <fabien@symfony.com>
021 */
022 class SetNode extends Node implements NodeCaptureInterface
023 {
024 public function __construct(bool $capture, Node $names, Node $values, int $lineno, string $tag = null)
025 {
026 parent::__construct(['names' => $names, 'values' => $values], ['capture' => $capture, 'safe' => false], $lineno, $tag);
027
028 /*
029 * Optimizes the node when capture is used for a large block of text.
030 *
031 * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig\Markup("foo");
032 */
033 if ($this->getAttribute('capture')) {
034 $this->setAttribute('safe', true);
035
036 $values = $this->getNode('values');
037 if ($values instanceof TextNode) {
038 $this->setNode('values', new ConstantExpression($values->getAttribute('data'), $values->getTemplateLine()));
039 $this->setAttribute('capture', false);
040 }
041 }
042 }
043
044 public function compile(Compiler $compiler)
045 {
046 $compiler->addDebugInfo($this);
047
048 if (\count($this->getNode('names')) > 1) {
049 $compiler->write('list(');
050 foreach ($this->getNode('names') as $idx => $node) {
051 if ($idx) {
052 $compiler->raw(', ');
053 }
054
055 $compiler->subcompile($node);
056 }
057 $compiler->raw(')');
058 } else {
059 if ($this->getAttribute('capture')) {
060 if ($compiler->getEnvironment()->isDebug()) {
061 $compiler->write("ob_start();\n");
062 } else {
063 $compiler->write("ob_start(function () { return ''; });\n");
064 }
065 $compiler
066 ->subcompile($this->getNode('values'))
067 ;
068 }
069
070 $compiler->subcompile($this->getNode('names'), false);
071
072 if ($this->getAttribute('capture')) {
073 $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Markup(\$tmp, \$this->env->getCharset())");
074 }
075 }
076
077 if (!$this->getAttribute('capture')) {
078 $compiler->raw(' = ');
079
080 if (\count($this->getNode('names')) > 1) {
081 $compiler->write('[');
082 foreach ($this->getNode('values') as $idx => $value) {
083 if ($idx) {
084 $compiler->raw(', ');
085 }
086
087 $compiler->subcompile($value);
088 }
089 $compiler->raw(']');
090 } else {
091 if ($this->getAttribute('safe')) {
092 $compiler
093 ->raw("('' === \$tmp = ")
094 ->subcompile($this->getNode('values'))
095 ->raw(") ? '' : new Markup(\$tmp, \$this->env->getCharset())")
096 ;
097 } else {
098 $compiler->subcompile($this->getNode('values'));
099 }
100 }
101 }
102
103 $compiler->raw(";\n");
104 }
105 }
106
107 class_alias('Twig\Node\SetNode', 'Twig_Node_Set');
108