Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
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 |
Set.php
001 <?php
002
003 /*
004 * This file is part of Twig.
005 *
006 * (c) 2010 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 /**
013 * Represents a set node.
014 *
015 * @author Fabien Potencier <fabien@symfony.com>
016 */
017 class Twig_Node_Set extends Twig_Node
018 {
019 public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null)
020 {
021 parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag);
022
023 /*
024 * Optimizes the node when capture is used for a large block of text.
025 *
026 * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo");
027 */
028 if ($this->getAttribute('capture')) {
029 $this->setAttribute('safe', true);
030
031 $values = $this->getNode('values');
032 if ($values instanceof Twig_Node_Text) {
033 $this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getLine()));
034 $this->setAttribute('capture', false);
035 }
036 }
037 }
038
039 /**
040 * Compiles the node to PHP.
041 *
042 * @param Twig_Compiler A Twig_Compiler instance
043 */
044 public function compile(Twig_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 $compiler
061 ->write("ob_start();\n")
062 ->subcompile($this->getNode('values'))
063 ;
064 }
065
066 $compiler->subcompile($this->getNode('names'), false);
067
068 if ($this->getAttribute('capture')) {
069 $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())");
070 }
071 }
072
073 if (!$this->getAttribute('capture')) {
074 $compiler->raw(' = ');
075
076 if (count($this->getNode('names')) > 1) {
077 $compiler->write('array(');
078 foreach ($this->getNode('values') as $idx => $value) {
079 if ($idx) {
080 $compiler->raw(', ');
081 }
082
083 $compiler->subcompile($value);
084 }
085 $compiler->raw(')');
086 } else {
087 if ($this->getAttribute('safe')) {
088 $compiler
089 ->raw("('' === \$tmp = ")
090 ->subcompile($this->getNode('values'))
091 ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())")
092 ;
093 } else {
094 $compiler->subcompile($this->getNode('values'));
095 }
096 }
097 }
098
099 $compiler->raw(";\n");
100 }
101 }
102