├── .gitignore ├── README.md ├── config ├── autoload.php └── twiggy.php ├── helpers └── twiggy_helper.php ├── libraries └── Twiggy.php ├── spark.info └── vendor └── Twig ├── AUTHORS ├── CHANGELOG ├── LICENSE ├── README.markdown └── lib └── Twig ├── Autoloader.php ├── Compiler.php ├── CompilerInterface.php ├── Environment.php ├── Error.php ├── Error ├── Loader.php ├── Runtime.php └── Syntax.php ├── ExpressionParser.php ├── Extension.php ├── Extension ├── Core.php ├── Debug.php ├── Escaper.php ├── Optimizer.php └── Sandbox.php ├── ExtensionInterface.php ├── Filter.php ├── Filter ├── Function.php ├── Method.php └── Node.php ├── FilterInterface.php ├── Function.php ├── Function ├── Function.php ├── Method.php └── Node.php ├── FunctionInterface.php ├── Lexer.php ├── LexerInterface.php ├── Loader ├── Array.php ├── Chain.php ├── Filesystem.php └── String.php ├── LoaderInterface.php ├── Markup.php ├── Node.php ├── Node ├── AutoEscape.php ├── Block.php ├── BlockReference.php ├── Body.php ├── Do.php ├── Expression.php ├── Expression │ ├── Array.php │ ├── AssignName.php │ ├── Binary.php │ ├── Binary │ │ ├── Add.php │ │ ├── And.php │ │ ├── BitwiseAnd.php │ │ ├── BitwiseOr.php │ │ ├── BitwiseXor.php │ │ ├── Concat.php │ │ ├── Div.php │ │ ├── Equal.php │ │ ├── FloorDiv.php │ │ ├── Greater.php │ │ ├── GreaterEqual.php │ │ ├── In.php │ │ ├── Less.php │ │ ├── LessEqual.php │ │ ├── Mod.php │ │ ├── Mul.php │ │ ├── NotEqual.php │ │ ├── NotIn.php │ │ ├── Or.php │ │ ├── Power.php │ │ ├── Range.php │ │ └── Sub.php │ ├── BlockReference.php │ ├── Conditional.php │ ├── Constant.php │ ├── ExtensionReference.php │ ├── Filter.php │ ├── Filter │ │ └── Default.php │ ├── Function.php │ ├── GetAttr.php │ ├── MethodCall.php │ ├── Name.php │ ├── Parent.php │ ├── TempName.php │ ├── Test.php │ ├── Test │ │ ├── Constant.php │ │ ├── Defined.php │ │ ├── Divisibleby.php │ │ ├── Even.php │ │ ├── Null.php │ │ ├── Odd.php │ │ └── Sameas.php │ ├── Unary.php │ └── Unary │ │ ├── Neg.php │ │ ├── Not.php │ │ └── Pos.php ├── Flush.php ├── For.php ├── ForLoop.php ├── If.php ├── Import.php ├── Include.php ├── Macro.php ├── Module.php ├── Print.php ├── Sandbox.php ├── SandboxedModule.php ├── SandboxedPrint.php ├── Set.php ├── SetTemp.php ├── Spaceless.php └── Text.php ├── NodeInterface.php ├── NodeOutputInterface.php ├── NodeTraverser.php ├── NodeVisitor ├── Escaper.php ├── Optimizer.php ├── SafeAnalysis.php └── Sandbox.php ├── NodeVisitorInterface.php ├── Parser.php ├── ParserInterface.php ├── Sandbox ├── SecurityError.php ├── SecurityPolicy.php └── SecurityPolicyInterface.php ├── Template.php ├── TemplateInterface.php ├── Test ├── Function.php ├── Method.php └── Node.php ├── TestInterface.php ├── Token.php ├── TokenParser.php ├── TokenParser ├── AutoEscape.php ├── Block.php ├── Do.php ├── Extends.php ├── Filter.php ├── Flush.php ├── For.php ├── From.php ├── If.php ├── Import.php ├── Include.php ├── Macro.php ├── Sandbox.php ├── Set.php ├── Spaceless.php └── Use.php ├── TokenParserBroker.php ├── TokenParserBrokerInterface.php ├── TokenParserInterface.php └── TokenStream.php /.gitignore: -------------------------------------------------------------------------------- 1 | *.log 2 | .DS_Store 3 | *.tmproj 4 | *.sublime-project 5 | *.sublime-workspace -------------------------------------------------------------------------------- /config/autoload.php: -------------------------------------------------------------------------------- 1 | 7 | * @license http://www.opensource.org/licenses/MIT 8 | */ 9 | 10 | $autoload['libraries'] = array('twiggy'); 11 | $autoload['config'] = array('twiggy'); 12 | $autoload['helper'] = array(); -------------------------------------------------------------------------------- /helpers/twiggy_helper.php: -------------------------------------------------------------------------------- 1 | 6 | 7 | Project Founder: 8 | 9 | - Armin Ronacher 10 | -------------------------------------------------------------------------------- /vendor/Twig/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 by the Twig Team, see AUTHORS for more details. 2 | 3 | Some rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * The names of the contributors may not be used to endorse or 18 | promote products derived from this software without specific 19 | prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 22 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 23 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 24 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 25 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 26 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 27 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 28 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 29 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /vendor/Twig/README.markdown: -------------------------------------------------------------------------------- 1 | Twig, the flexible, fast, and secure template language for PHP 2 | ============================================================== 3 | 4 | Twig is a template language for PHP, released under the new BSD license (code 5 | and documentation). 6 | 7 | Twig uses a syntax similar to the Django and Jinja template languages which 8 | inspired the Twig runtime environment. 9 | 10 | More Information 11 | ---------------- 12 | 13 | Read the [documentation][1] for more information. 14 | 15 | [1]: http://twig.sensiolabs.org/documentation -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Autoloader.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Autoloader 19 | { 20 | /** 21 | * Registers Twig_Autoloader as an SPL autoloader. 22 | */ 23 | static public function register() 24 | { 25 | ini_set('unserialize_callback_func', 'spl_autoload_call'); 26 | spl_autoload_register(array(new self, 'autoload')); 27 | } 28 | 29 | /** 30 | * Handles autoloading of classes. 31 | * 32 | * @param string $class A class name. 33 | * 34 | * @return boolean Returns true if the class has been loaded 35 | */ 36 | static public function autoload($class) 37 | { 38 | if (0 !== strpos($class, 'Twig')) { 39 | return; 40 | } 41 | 42 | if (is_file($file = dirname(__FILE__).'/../'.str_replace(array('_', "\0"), array('/', ''), $class).'.php')) { 43 | require $file; 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Compiler.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Compiler implements Twig_CompilerInterface 20 | { 21 | protected $lastLine; 22 | protected $source; 23 | protected $indentation; 24 | protected $env; 25 | 26 | /** 27 | * Constructor. 28 | * 29 | * @param Twig_Environment $env The twig environment instance 30 | */ 31 | public function __construct(Twig_Environment $env) 32 | { 33 | $this->env = $env; 34 | } 35 | 36 | /** 37 | * Returns the environment instance related to this compiler. 38 | * 39 | * @return Twig_Environment The environment instance 40 | */ 41 | public function getEnvironment() 42 | { 43 | return $this->env; 44 | } 45 | 46 | /** 47 | * Gets the current PHP code after compilation. 48 | * 49 | * @return string The PHP code 50 | */ 51 | public function getSource() 52 | { 53 | return $this->source; 54 | } 55 | 56 | /** 57 | * Compiles a node. 58 | * 59 | * @param Twig_NodeInterface $node The node to compile 60 | * @param integer $indentation The current indentation 61 | * 62 | * @return Twig_Compiler The current compiler instance 63 | */ 64 | public function compile(Twig_NodeInterface $node, $indentation = 0) 65 | { 66 | $this->lastLine = null; 67 | $this->source = ''; 68 | $this->indentation = $indentation; 69 | 70 | $node->compile($this); 71 | 72 | return $this; 73 | } 74 | 75 | public function subcompile(Twig_NodeInterface $node, $raw = true) 76 | { 77 | if (false === $raw) { 78 | $this->addIndentation(); 79 | } 80 | 81 | $node->compile($this); 82 | 83 | return $this; 84 | } 85 | 86 | /** 87 | * Adds a raw string to the compiled code. 88 | * 89 | * @param string $string The string 90 | * 91 | * @return Twig_Compiler The current compiler instance 92 | */ 93 | public function raw($string) 94 | { 95 | $this->source .= $string; 96 | 97 | return $this; 98 | } 99 | 100 | /** 101 | * Writes a string to the compiled code by adding indentation. 102 | * 103 | * @return Twig_Compiler The current compiler instance 104 | */ 105 | public function write() 106 | { 107 | $strings = func_get_args(); 108 | foreach ($strings as $string) { 109 | $this->addIndentation(); 110 | $this->source .= $string; 111 | } 112 | 113 | return $this; 114 | } 115 | 116 | public function addIndentation() 117 | { 118 | $this->source .= str_repeat(' ', $this->indentation * 4); 119 | 120 | return $this; 121 | } 122 | 123 | /** 124 | * Adds a quoted string to the compiled code. 125 | * 126 | * @param string $value The string 127 | * 128 | * @return Twig_Compiler The current compiler instance 129 | */ 130 | public function string($value) 131 | { 132 | $this->source .= sprintf('"%s"', addcslashes($value, "\0\t\"\$\\")); 133 | 134 | return $this; 135 | } 136 | 137 | /** 138 | * Returns a PHP representation of a given value. 139 | * 140 | * @param mixed $value The value to convert 141 | * 142 | * @return Twig_Compiler The current compiler instance 143 | */ 144 | public function repr($value) 145 | { 146 | if (is_int($value) || is_float($value)) { 147 | $this->raw($value); 148 | } elseif (null === $value) { 149 | $this->raw('null'); 150 | } elseif (is_bool($value)) { 151 | $this->raw($value ? 'true' : 'false'); 152 | } elseif (is_array($value)) { 153 | $this->raw('array('); 154 | $i = 0; 155 | foreach ($value as $key => $value) { 156 | if ($i++) { 157 | $this->raw(', '); 158 | } 159 | $this->repr($key); 160 | $this->raw(' => '); 161 | $this->repr($value); 162 | } 163 | $this->raw(')'); 164 | } else { 165 | $this->string($value); 166 | } 167 | 168 | return $this; 169 | } 170 | 171 | /** 172 | * Adds debugging information. 173 | * 174 | * @param Twig_NodeInterface $node The related twig node 175 | * 176 | * @return Twig_Compiler The current compiler instance 177 | */ 178 | public function addDebugInfo(Twig_NodeInterface $node) 179 | { 180 | if ($node->getLine() != $this->lastLine) { 181 | $this->lastLine = $node->getLine(); 182 | $this->write("// line {$node->getLine()}\n"); 183 | } 184 | 185 | return $this; 186 | } 187 | 188 | /** 189 | * Indents the generated code. 190 | * 191 | * @param integer $step The number of indentation to add 192 | * 193 | * @return Twig_Compiler The current compiler instance 194 | */ 195 | public function indent($step = 1) 196 | { 197 | $this->indentation += $step; 198 | 199 | return $this; 200 | } 201 | 202 | /** 203 | * Outdents the generated code. 204 | * 205 | * @param integer $step The number of indentation to remove 206 | * 207 | * @return Twig_Compiler The current compiler instance 208 | */ 209 | public function outdent($step = 1) 210 | { 211 | $this->indentation -= $step; 212 | 213 | if ($this->indentation < 0) { 214 | throw new Twig_Error('Unable to call outdent() as the indentation would become negative'); 215 | } 216 | 217 | return $this; 218 | } 219 | } 220 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/CompilerInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_CompilerInterface 19 | { 20 | /** 21 | * Compiles a node. 22 | * 23 | * @param Twig_NodeInterface $node The node to compile 24 | * 25 | * @return Twig_CompilerInterface The current compiler instance 26 | */ 27 | function compile(Twig_NodeInterface $node); 28 | 29 | /** 30 | * Gets the current PHP code after compilation. 31 | * 32 | * @return string The PHP code 33 | */ 34 | function getSource(); 35 | } 36 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Error/Loader.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Error_Loader extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Error/Runtime.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Error_Runtime extends Twig_Error 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Error/Syntax.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Error_Syntax extends Twig_Error 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Extension.php: -------------------------------------------------------------------------------- 1 | new Twig_Function_Function('twig_var_dump', array('is_safe' => $isDumpOutputHtmlSafe ? array('html') : array(), 'needs_context' => true, 'needs_environment' => true)), 25 | ); 26 | } 27 | 28 | /** 29 | * Returns the name of the extension. 30 | * 31 | * @return string The extension name 32 | */ 33 | public function getName() 34 | { 35 | return 'debug'; 36 | } 37 | } 38 | 39 | function twig_var_dump(Twig_Environment $env, $context) 40 | { 41 | if (!$env->isDebug()) { 42 | return; 43 | } 44 | 45 | ob_start(); 46 | 47 | $count = func_num_args(); 48 | if (2 === $count) { 49 | $vars = array(); 50 | foreach ($context as $key => $value) { 51 | if (!$value instanceof Twig_Template) { 52 | $vars[$key] = $value; 53 | } 54 | } 55 | 56 | var_dump($vars); 57 | } else { 58 | for ($i = 2; $i < $count; $i++) { 59 | var_dump(func_get_arg($i)); 60 | } 61 | } 62 | 63 | return ob_get_clean(); 64 | } 65 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Extension/Escaper.php: -------------------------------------------------------------------------------- 1 | autoescape = $autoescape; 18 | } 19 | 20 | /** 21 | * Returns the token parser instances to add to the existing list. 22 | * 23 | * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances 24 | */ 25 | public function getTokenParsers() 26 | { 27 | return array(new Twig_TokenParser_AutoEscape()); 28 | } 29 | 30 | /** 31 | * Returns the node visitor instances to add to the existing list. 32 | * 33 | * @return array An array of Twig_NodeVisitorInterface instances 34 | */ 35 | public function getNodeVisitors() 36 | { 37 | return array(new Twig_NodeVisitor_Escaper()); 38 | } 39 | 40 | /** 41 | * Returns a list of filters to add to the existing list. 42 | * 43 | * @return array An array of filters 44 | */ 45 | public function getFilters() 46 | { 47 | return array( 48 | 'raw' => new Twig_Filter_Function('twig_raw_filter', array('is_safe' => array('all'))), 49 | ); 50 | } 51 | 52 | public function isGlobal() 53 | { 54 | return $this->autoescape; 55 | } 56 | 57 | /** 58 | * Returns the name of the extension. 59 | * 60 | * @return string The extension name 61 | */ 62 | public function getName() 63 | { 64 | return 'escaper'; 65 | } 66 | } 67 | 68 | /** 69 | * Marks a variable as being safe. 70 | * 71 | * @param string $string A PHP variable 72 | */ 73 | function twig_raw_filter($string) 74 | { 75 | return $string; 76 | } 77 | 78 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Extension/Optimizer.php: -------------------------------------------------------------------------------- 1 | optimizers = $optimizers; 18 | } 19 | 20 | /** 21 | * {@inheritdoc} 22 | */ 23 | public function getNodeVisitors() 24 | { 25 | return array(new Twig_NodeVisitor_Optimizer($this->optimizers)); 26 | } 27 | 28 | /** 29 | * {@inheritdoc} 30 | */ 31 | public function getName() 32 | { 33 | return 'optimizer'; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Extension/Sandbox.php: -------------------------------------------------------------------------------- 1 | policy = $policy; 20 | $this->sandboxedGlobally = $sandboxed; 21 | } 22 | 23 | /** 24 | * Returns the token parser instances to add to the existing list. 25 | * 26 | * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances 27 | */ 28 | public function getTokenParsers() 29 | { 30 | return array(new Twig_TokenParser_Sandbox()); 31 | } 32 | 33 | /** 34 | * Returns the node visitor instances to add to the existing list. 35 | * 36 | * @return array An array of Twig_NodeVisitorInterface instances 37 | */ 38 | public function getNodeVisitors() 39 | { 40 | return array(new Twig_NodeVisitor_Sandbox()); 41 | } 42 | 43 | public function enableSandbox() 44 | { 45 | $this->sandboxed = true; 46 | } 47 | 48 | public function disableSandbox() 49 | { 50 | $this->sandboxed = false; 51 | } 52 | 53 | public function isSandboxed() 54 | { 55 | return $this->sandboxedGlobally || $this->sandboxed; 56 | } 57 | 58 | public function isSandboxedGlobally() 59 | { 60 | return $this->sandboxedGlobally; 61 | } 62 | 63 | public function setSecurityPolicy(Twig_Sandbox_SecurityPolicyInterface $policy) 64 | { 65 | $this->policy = $policy; 66 | } 67 | 68 | public function getSecurityPolicy() 69 | { 70 | return $this->policy; 71 | } 72 | 73 | public function checkSecurity($tags, $filters, $functions) 74 | { 75 | if ($this->isSandboxed()) { 76 | $this->policy->checkSecurity($tags, $filters, $functions); 77 | } 78 | } 79 | 80 | public function checkMethodAllowed($obj, $method) 81 | { 82 | if ($this->isSandboxed()) { 83 | $this->policy->checkMethodAllowed($obj, $method); 84 | } 85 | } 86 | 87 | public function checkPropertyAllowed($obj, $method) 88 | { 89 | if ($this->isSandboxed()) { 90 | $this->policy->checkPropertyAllowed($obj, $method); 91 | } 92 | } 93 | 94 | public function ensureToStringAllowed($obj) 95 | { 96 | if (is_object($obj)) { 97 | $this->policy->checkMethodAllowed($obj, '__toString'); 98 | } 99 | 100 | return $obj; 101 | } 102 | 103 | /** 104 | * Returns the name of the extension. 105 | * 106 | * @return string The extension name 107 | */ 108 | public function getName() 109 | { 110 | return 'sandbox'; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/ExtensionInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_ExtensionInterface 19 | { 20 | /** 21 | * Initializes the runtime environment. 22 | * 23 | * This is where you can load some file that contains filter functions for instance. 24 | * 25 | * @param Twig_Environment $environment The current Twig_Environment instance 26 | */ 27 | function initRuntime(Twig_Environment $environment); 28 | 29 | /** 30 | * Returns the token parser instances to add to the existing list. 31 | * 32 | * @return array An array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances 33 | */ 34 | function getTokenParsers(); 35 | 36 | /** 37 | * Returns the node visitor instances to add to the existing list. 38 | * 39 | * @return array An array of Twig_NodeVisitorInterface instances 40 | */ 41 | function getNodeVisitors(); 42 | 43 | /** 44 | * Returns a list of filters to add to the existing list. 45 | * 46 | * @return array An array of filters 47 | */ 48 | function getFilters(); 49 | 50 | /** 51 | * Returns a list of tests to add to the existing list. 52 | * 53 | * @return array An array of tests 54 | */ 55 | function getTests(); 56 | 57 | /** 58 | * Returns a list of functions to add to the existing list. 59 | * 60 | * @return array An array of functions 61 | */ 62 | function getFunctions(); 63 | 64 | /** 65 | * Returns a list of operators to add to the existing list. 66 | * 67 | * @return array An array of operators 68 | */ 69 | function getOperators(); 70 | 71 | /** 72 | * Returns a list of global variables to add to the existing list. 73 | * 74 | * @return array An array of global variables 75 | */ 76 | function getGlobals(); 77 | 78 | /** 79 | * Returns the name of the extension. 80 | * 81 | * @return string The extension name 82 | */ 83 | function getName(); 84 | } 85 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Filter.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | abstract class Twig_Filter implements Twig_FilterInterface 19 | { 20 | protected $options; 21 | protected $arguments = array(); 22 | 23 | public function __construct(array $options = array()) 24 | { 25 | $this->options = array_merge(array( 26 | 'needs_environment' => false, 27 | 'needs_context' => false, 28 | 'pre_escape' => null, 29 | ), $options); 30 | } 31 | 32 | public function setArguments($arguments) 33 | { 34 | $this->arguments = $arguments; 35 | } 36 | 37 | public function getArguments() 38 | { 39 | return $this->arguments; 40 | } 41 | 42 | public function needsEnvironment() 43 | { 44 | return $this->options['needs_environment']; 45 | } 46 | 47 | public function needsContext() 48 | { 49 | return $this->options['needs_context']; 50 | } 51 | 52 | public function getSafe(Twig_Node $filterArgs) 53 | { 54 | if (isset($this->options['is_safe'])) { 55 | return $this->options['is_safe']; 56 | } 57 | 58 | if (isset($this->options['is_safe_callback'])) { 59 | return call_user_func($this->options['is_safe_callback'], $filterArgs); 60 | } 61 | 62 | return array(); 63 | } 64 | 65 | public function getPreEscape() 66 | { 67 | return $this->options['pre_escape']; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Filter/Function.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Filter_Function extends Twig_Filter 19 | { 20 | protected $function; 21 | 22 | public function __construct($function, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->function = $function; 27 | } 28 | 29 | public function compile() 30 | { 31 | return $this->function; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Filter/Method.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Filter_Method extends Twig_Filter 19 | { 20 | protected $extension, $method; 21 | 22 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->extension = $extension; 27 | $this->method = $method; 28 | } 29 | 30 | public function compile() 31 | { 32 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Filter/Node.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Filter_Node extends Twig_Filter 19 | { 20 | protected $class; 21 | 22 | public function __construct($class, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->class = $class; 27 | } 28 | 29 | public function getClass() 30 | { 31 | return $this->class; 32 | } 33 | 34 | public function compile() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/FilterInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_FilterInterface 19 | { 20 | /** 21 | * Compiles a filter. 22 | * 23 | * @return string The PHP code for the filter 24 | */ 25 | function compile(); 26 | 27 | function needsEnvironment(); 28 | 29 | function needsContext(); 30 | 31 | function getSafe(Twig_Node $filterArgs); 32 | 33 | function getPreEscape(); 34 | 35 | function setArguments($arguments); 36 | 37 | function getArguments(); 38 | } 39 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Function.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | abstract class Twig_Function implements Twig_FunctionInterface 19 | { 20 | protected $options; 21 | protected $arguments = array(); 22 | 23 | public function __construct(array $options = array()) 24 | { 25 | $this->options = array_merge(array( 26 | 'needs_environment' => false, 27 | 'needs_context' => false, 28 | ), $options); 29 | } 30 | 31 | public function setArguments($arguments) 32 | { 33 | $this->arguments = $arguments; 34 | } 35 | 36 | public function getArguments() 37 | { 38 | return $this->arguments; 39 | } 40 | 41 | public function needsEnvironment() 42 | { 43 | return $this->options['needs_environment']; 44 | } 45 | 46 | public function needsContext() 47 | { 48 | return $this->options['needs_context']; 49 | } 50 | 51 | public function getSafe(Twig_Node $functionArgs) 52 | { 53 | if (isset($this->options['is_safe'])) { 54 | return $this->options['is_safe']; 55 | } 56 | 57 | if (isset($this->options['is_safe_callback'])) { 58 | return call_user_func($this->options['is_safe_callback'], $functionArgs); 59 | } 60 | 61 | return array(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Function/Function.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Function_Function extends Twig_Function 20 | { 21 | protected $function; 22 | 23 | public function __construct($function, array $options = array()) 24 | { 25 | parent::__construct($options); 26 | 27 | $this->function = $function; 28 | } 29 | 30 | public function compile() 31 | { 32 | return $this->function; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Function/Method.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Function_Method extends Twig_Function 20 | { 21 | protected $extension, $method; 22 | 23 | public function __construct(Twig_ExtensionInterface $extension, $method, array $options = array()) 24 | { 25 | parent::__construct($options); 26 | 27 | $this->extension = $extension; 28 | $this->method = $method; 29 | } 30 | 31 | public function compile() 32 | { 33 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Function/Node.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Function_Node extends Twig_Filter 19 | { 20 | protected $class; 21 | 22 | public function __construct($class, array $options = array()) 23 | { 24 | parent::__construct($options); 25 | 26 | $this->class = $class; 27 | } 28 | 29 | public function getClass() 30 | { 31 | return $this->class; 32 | } 33 | 34 | public function compile() 35 | { 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/FunctionInterface.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | interface Twig_FunctionInterface 20 | { 21 | /** 22 | * Compiles a function. 23 | * 24 | * @return string The PHP code for the function 25 | */ 26 | function compile(); 27 | 28 | function needsEnvironment(); 29 | 30 | function needsContext(); 31 | 32 | function getSafe(Twig_Node $filterArgs); 33 | 34 | function setArguments($arguments); 35 | 36 | function getArguments(); 37 | } 38 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/LexerInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_LexerInterface 19 | { 20 | /** 21 | * Tokenizes a source code. 22 | * 23 | * @param string $code The source code 24 | * @param string $filename A unique identifier for the source code 25 | * 26 | * @return Twig_TokenStream A token stream instance 27 | */ 28 | function tokenize($code, $filename = null); 29 | } 30 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Loader/Array.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_Loader_Array implements Twig_LoaderInterface 24 | { 25 | protected $templates; 26 | 27 | /** 28 | * Constructor. 29 | * 30 | * @param array $templates An array of templates (keys are the names, and values are the source code) 31 | * 32 | * @see Twig_Loader 33 | */ 34 | public function __construct(array $templates) 35 | { 36 | $this->templates = array(); 37 | foreach ($templates as $name => $template) { 38 | $this->templates[$name] = $template; 39 | } 40 | } 41 | 42 | /** 43 | * Adds or overrides a template. 44 | * 45 | * @param string $name The template name 46 | * @param string $template The template source 47 | */ 48 | public function setTemplate($name, $template) 49 | { 50 | $this->templates[(string) $name] = $template; 51 | } 52 | 53 | /** 54 | * Gets the source code of a template, given its name. 55 | * 56 | * @param string $name The name of the template to load 57 | * 58 | * @return string The template source code 59 | */ 60 | public function getSource($name) 61 | { 62 | $name = (string) $name; 63 | if (!isset($this->templates[$name])) { 64 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 65 | } 66 | 67 | return $this->templates[$name]; 68 | } 69 | 70 | /** 71 | * Gets the cache key to use for the cache for a given template name. 72 | * 73 | * @param string $name The name of the template to load 74 | * 75 | * @return string The cache key 76 | */ 77 | public function getCacheKey($name) 78 | { 79 | $name = (string) $name; 80 | if (!isset($this->templates[$name])) { 81 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 82 | } 83 | 84 | return $this->templates[$name]; 85 | } 86 | 87 | /** 88 | * Returns true if the template is still fresh. 89 | * 90 | * @param string $name The template name 91 | * @param timestamp $time The last modification time of the cached template 92 | */ 93 | public function isFresh($name, $time) 94 | { 95 | $name = (string) $name; 96 | if (!isset($this->templates[$name])) { 97 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 98 | } 99 | 100 | return true; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Loader/Chain.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Loader_Chain implements Twig_LoaderInterface 19 | { 20 | protected $loaders; 21 | 22 | /** 23 | * Constructor. 24 | * 25 | * @param Twig_LoaderInterface[] $loaders An array of loader instances 26 | */ 27 | public function __construct(array $loaders = array()) 28 | { 29 | $this->loaders = array(); 30 | foreach ($loaders as $loader) { 31 | $this->addLoader($loader); 32 | } 33 | } 34 | 35 | /** 36 | * Adds a loader instance. 37 | * 38 | * @param Twig_LoaderInterface $loader A Loader instance 39 | */ 40 | public function addLoader(Twig_LoaderInterface $loader) 41 | { 42 | $this->loaders[] = $loader; 43 | } 44 | 45 | /** 46 | * Gets the source code of a template, given its name. 47 | * 48 | * @param string $name The name of the template to load 49 | * 50 | * @return string The template source code 51 | */ 52 | public function getSource($name) 53 | { 54 | foreach ($this->loaders as $loader) { 55 | try { 56 | return $loader->getSource($name); 57 | } catch (Twig_Error_Loader $e) { 58 | } 59 | } 60 | 61 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 62 | } 63 | 64 | /** 65 | * Gets the cache key to use for the cache for a given template name. 66 | * 67 | * @param string $name The name of the template to load 68 | * 69 | * @return string The cache key 70 | */ 71 | public function getCacheKey($name) 72 | { 73 | foreach ($this->loaders as $loader) { 74 | try { 75 | return $loader->getCacheKey($name); 76 | } catch (Twig_Error_Loader $e) { 77 | } 78 | } 79 | 80 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 81 | } 82 | 83 | /** 84 | * Returns true if the template is still fresh. 85 | * 86 | * @param string $name The template name 87 | * @param timestamp $time The last modification time of the cached template 88 | */ 89 | public function isFresh($name, $time) 90 | { 91 | foreach ($this->loaders as $loader) { 92 | try { 93 | return $loader->isFresh($name, $time); 94 | } catch (Twig_Error_Loader $e) { 95 | } 96 | } 97 | 98 | throw new Twig_Error_Loader(sprintf('Template "%s" is not defined.', $name)); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Loader/Filesystem.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Loader_Filesystem implements Twig_LoaderInterface 19 | { 20 | protected $paths; 21 | protected $cache; 22 | 23 | /** 24 | * Constructor. 25 | * 26 | * @param string|array $paths A path or an array of paths where to look for templates 27 | */ 28 | public function __construct($paths) 29 | { 30 | $this->setPaths($paths); 31 | } 32 | 33 | /** 34 | * Returns the paths to the templates. 35 | * 36 | * @return array The array of paths where to look for templates 37 | */ 38 | public function getPaths() 39 | { 40 | return $this->paths; 41 | } 42 | 43 | /** 44 | * Sets the paths where templates are stored. 45 | * 46 | * @param string|array $paths A path or an array of paths where to look for templates 47 | */ 48 | public function setPaths($paths) 49 | { 50 | if (!is_array($paths)) { 51 | $paths = array($paths); 52 | } 53 | 54 | $this->paths = array(); 55 | foreach ($paths as $path) { 56 | $this->addPath($path); 57 | } 58 | } 59 | 60 | /** 61 | * Adds a path where templates are stored. 62 | * 63 | * @param string $path A path where to look for templates 64 | */ 65 | public function addPath($path) 66 | { 67 | // invalidate the cache 68 | $this->cache = array(); 69 | 70 | if (!is_dir($path)) { 71 | throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); 72 | } 73 | 74 | $this->paths[] = $path; 75 | } 76 | 77 | /** 78 | * Gets the source code of a template, given its name. 79 | * 80 | * @param string $name The name of the template to load 81 | * 82 | * @return string The template source code 83 | */ 84 | public function getSource($name) 85 | { 86 | return file_get_contents($this->findTemplate($name)); 87 | } 88 | 89 | /** 90 | * Gets the cache key to use for the cache for a given template name. 91 | * 92 | * @param string $name The name of the template to load 93 | * 94 | * @return string The cache key 95 | */ 96 | public function getCacheKey($name) 97 | { 98 | return $this->findTemplate($name); 99 | } 100 | 101 | /** 102 | * Returns true if the template is still fresh. 103 | * 104 | * @param string $name The template name 105 | * @param timestamp $time The last modification time of the cached template 106 | */ 107 | public function isFresh($name, $time) 108 | { 109 | return filemtime($this->findTemplate($name)) < $time; 110 | } 111 | 112 | protected function findTemplate($name) 113 | { 114 | // normalize name 115 | $name = preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')); 116 | 117 | if (isset($this->cache[$name])) { 118 | return $this->cache[$name]; 119 | } 120 | 121 | $this->validateName($name); 122 | 123 | foreach ($this->paths as $path) { 124 | if (is_file($path.'/'.$name)) { 125 | return $this->cache[$name] = $path.'/'.$name; 126 | } 127 | } 128 | 129 | throw new Twig_Error_Loader(sprintf('Unable to find template "%s" (looked into: %s).', $name, implode(', ', $this->paths))); 130 | } 131 | 132 | protected function validateName($name) 133 | { 134 | if (false !== strpos($name, "\0")) { 135 | throw new Twig_Error_Loader('A template name cannot contain NUL bytes.'); 136 | } 137 | 138 | $parts = explode('/', $name); 139 | $level = 0; 140 | foreach ($parts as $part) { 141 | if ('..' === $part) { 142 | --$level; 143 | } elseif ('.' !== $part) { 144 | ++$level; 145 | } 146 | 147 | if ($level < 0) { 148 | throw new Twig_Error_Loader(sprintf('Looks like you try to load a template outside configured directories (%s).', $name)); 149 | } 150 | } 151 | } 152 | } 153 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Loader/String.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_Loader_String implements Twig_LoaderInterface 24 | { 25 | /** 26 | * Gets the source code of a template, given its name. 27 | * 28 | * @param string $name The name of the template to load 29 | * 30 | * @return string The template source code 31 | */ 32 | public function getSource($name) 33 | { 34 | return $name; 35 | } 36 | 37 | /** 38 | * Gets the cache key to use for the cache for a given template name. 39 | * 40 | * @param string $name The name of the template to load 41 | * 42 | * @return string The cache key 43 | */ 44 | public function getCacheKey($name) 45 | { 46 | return $name; 47 | } 48 | 49 | /** 50 | * Returns true if the template is still fresh. 51 | * 52 | * @param string $name The template name 53 | * @param timestamp $time The last modification time of the cached template 54 | */ 55 | public function isFresh($name, $time) 56 | { 57 | return true; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/LoaderInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_LoaderInterface 19 | { 20 | /** 21 | * Gets the source code of a template, given its name. 22 | * 23 | * @param string $name The name of the template to load 24 | * 25 | * @return string The template source code 26 | */ 27 | function getSource($name); 28 | 29 | /** 30 | * Gets the cache key to use for the cache for a given template name. 31 | * 32 | * @param string $name The name of the template to load 33 | * 34 | * @return string The cache key 35 | */ 36 | function getCacheKey($name); 37 | 38 | /** 39 | * Returns true if the template is still fresh. 40 | * 41 | * @param string $name The template name 42 | * @param timestamp $time The last modification time of the cached template 43 | */ 44 | function isFresh($name, $time); 45 | } 46 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Markup.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Markup implements Countable 19 | { 20 | protected $content; 21 | protected $charset; 22 | 23 | public function __construct($content, $charset) 24 | { 25 | $this->content = (string) $content; 26 | $this->charset = $charset; 27 | } 28 | 29 | public function __toString() 30 | { 31 | return $this->content; 32 | } 33 | 34 | public function count() 35 | { 36 | return function_exists('mb_get_info') ? mb_strlen($this->content, $this->charset) : strlen($this->content); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/AutoEscape.php: -------------------------------------------------------------------------------- 1 | 23 | */ 24 | class Twig_Node_AutoEscape extends Twig_Node 25 | { 26 | public function __construct($value, Twig_NodeInterface $body, $lineno, $tag = 'autoescape') 27 | { 28 | parent::__construct(array('body' => $body), array('value' => $value), $lineno, $tag); 29 | } 30 | 31 | /** 32 | * Compiles the node to PHP. 33 | * 34 | * @param Twig_Compiler A Twig_Compiler instance 35 | */ 36 | public function compile(Twig_Compiler $compiler) 37 | { 38 | $compiler->subcompile($this->getNode('body')); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Block.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Block extends Twig_Node 20 | { 21 | public function __construct($name, Twig_NodeInterface $body, $lineno, $tag = null) 22 | { 23 | parent::__construct(array('body' => $body), array('name' => $name), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write(sprintf("public function block_%s(\$context, array \$blocks = array())\n", $this->getAttribute('name')), "{\n") 36 | ->indent() 37 | ; 38 | 39 | $compiler 40 | ->subcompile($this->getNode('body')) 41 | ->outdent() 42 | ->write("}\n\n") 43 | ; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/BlockReference.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_BlockReference extends Twig_Node implements Twig_NodeOutputInterface 20 | { 21 | public function __construct($name, $lineno, $tag = null) 22 | { 23 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write(sprintf("\$this->displayBlock('%s', \$context, \$blocks);\n", $this->getAttribute('name'))) 36 | ; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Body.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Body extends Twig_Node 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Do.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Do extends Twig_Node 19 | { 20 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('') 35 | ->subcompile($this->getNode('expr')) 36 | ->raw(";\n") 37 | ; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | abstract class Twig_Node_Expression extends Twig_Node 20 | { 21 | } 22 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Array.php: -------------------------------------------------------------------------------- 1 | index = -1; 20 | foreach ($this->getKeyValuePairs() as $pair) { 21 | if ($pair['key'] instanceof Twig_Node_Expression_Constant && ctype_digit((string) $pair['key']->getAttribute('value')) && $pair['key']->getAttribute('value') > $this->index) { 22 | $this->index = $pair['key']->getAttribute('value'); 23 | } 24 | } 25 | } 26 | 27 | public function getKeyValuePairs() 28 | { 29 | $pairs = array(); 30 | 31 | foreach (array_chunk($this->nodes, 2) as $pair) { 32 | $pairs[] = array( 33 | 'key' => $pair[0], 34 | 'value' => $pair[1], 35 | ); 36 | } 37 | 38 | return $pairs; 39 | } 40 | 41 | public function hasElement(Twig_Node_Expression $key) 42 | { 43 | foreach ($this->getKeyValuePairs() as $pair) { 44 | // we compare the string representation of the keys 45 | // to avoid comparing the line numbers which are not relevant here. 46 | if ((string) $key == (string) $pair['key']) { 47 | return true; 48 | } 49 | } 50 | 51 | return false; 52 | } 53 | 54 | public function addElement(Twig_Node_Expression $value, Twig_Node_Expression $key = null) 55 | { 56 | if (null === $key) { 57 | $key = new Twig_Node_Expression_Constant(++$this->index, $value->getLine()); 58 | } 59 | 60 | array_push($this->nodes, $key, $value); 61 | } 62 | 63 | /** 64 | * Compiles the node to PHP. 65 | * 66 | * @param Twig_Compiler A Twig_Compiler instance 67 | */ 68 | public function compile(Twig_Compiler $compiler) 69 | { 70 | $compiler->raw('array('); 71 | $first = true; 72 | foreach ($this->getKeyValuePairs() as $pair) { 73 | if (!$first) { 74 | $compiler->raw(', '); 75 | } 76 | $first = false; 77 | 78 | $compiler 79 | ->subcompile($pair['key']) 80 | ->raw(' => ') 81 | ->subcompile($pair['value']) 82 | ; 83 | } 84 | $compiler->raw(')'); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/AssignName.php: -------------------------------------------------------------------------------- 1 | raw('$context[') 24 | ->string($this->getAttribute('name')) 25 | ->raw(']') 26 | ; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary.php: -------------------------------------------------------------------------------- 1 | $left, 'right' => $right), array(), $lineno); 17 | } 18 | 19 | /** 20 | * Compiles the node to PHP. 21 | * 22 | * @param Twig_Compiler A Twig_Compiler instance 23 | */ 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(') 28 | ->subcompile($this->getNode('left')) 29 | ->raw(' ') 30 | ; 31 | $this->operator($compiler); 32 | $compiler 33 | ->raw(' ') 34 | ->subcompile($this->getNode('right')) 35 | ->raw(')') 36 | ; 37 | } 38 | 39 | abstract public function operator(Twig_Compiler $compiler); 40 | } 41 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Add.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/And.php: -------------------------------------------------------------------------------- 1 | raw('&&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/BitwiseAnd.php: -------------------------------------------------------------------------------- 1 | raw('&'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/BitwiseOr.php: -------------------------------------------------------------------------------- 1 | raw('|'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/BitwiseXor.php: -------------------------------------------------------------------------------- 1 | raw('^'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Concat.php: -------------------------------------------------------------------------------- 1 | raw('.'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Div.php: -------------------------------------------------------------------------------- 1 | raw('/'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Equal.php: -------------------------------------------------------------------------------- 1 | raw('=='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/FloorDiv.php: -------------------------------------------------------------------------------- 1 | raw('intval(floor('); 21 | parent::compile($compiler); 22 | $compiler->raw('))'); 23 | } 24 | 25 | public function operator(Twig_Compiler $compiler) 26 | { 27 | return $compiler->raw('/'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Greater.php: -------------------------------------------------------------------------------- 1 | raw('>'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/GreaterEqual.php: -------------------------------------------------------------------------------- 1 | raw('>='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/In.php: -------------------------------------------------------------------------------- 1 | raw('twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Less.php: -------------------------------------------------------------------------------- 1 | raw('<'); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/LessEqual.php: -------------------------------------------------------------------------------- 1 | raw('<='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Mod.php: -------------------------------------------------------------------------------- 1 | raw('%'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Mul.php: -------------------------------------------------------------------------------- 1 | raw('*'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/NotEqual.php: -------------------------------------------------------------------------------- 1 | raw('!='); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/NotIn.php: -------------------------------------------------------------------------------- 1 | raw('!twig_in_filter(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('not in'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Or.php: -------------------------------------------------------------------------------- 1 | raw('||'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Power.php: -------------------------------------------------------------------------------- 1 | raw('pow(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('**'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Range.php: -------------------------------------------------------------------------------- 1 | raw('range(') 22 | ->subcompile($this->getNode('left')) 23 | ->raw(', ') 24 | ->subcompile($this->getNode('right')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | public function operator(Twig_Compiler $compiler) 30 | { 31 | return $compiler->raw('..'); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Binary/Sub.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/BlockReference.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Expression_BlockReference extends Twig_Node_Expression 20 | { 21 | public function __construct(Twig_NodeInterface $name, $asString = false, $lineno, $tag = null) 22 | { 23 | parent::__construct(array('name' => $name), array('as_string' => $asString, 'output' => false), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | if ($this->getAttribute('as_string')) { 34 | $compiler->raw('(string) '); 35 | } 36 | 37 | if ($this->getAttribute('output')) { 38 | $compiler 39 | ->addDebugInfo($this) 40 | ->write("\$this->displayBlock(") 41 | ->subcompile($this->getNode('name')) 42 | ->raw(", \$context, \$blocks);\n") 43 | ; 44 | } else { 45 | $compiler 46 | ->raw("\$this->renderBlock(") 47 | ->subcompile($this->getNode('name')) 48 | ->raw(", \$context, \$blocks)") 49 | ; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Conditional.php: -------------------------------------------------------------------------------- 1 | $expr1, 'expr2' => $expr2, 'expr3' => $expr3), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler 22 | ->raw('((') 23 | ->subcompile($this->getNode('expr1')) 24 | ->raw(') ? (') 25 | ->subcompile($this->getNode('expr2')) 26 | ->raw(') : (') 27 | ->subcompile($this->getNode('expr3')) 28 | ->raw('))') 29 | ; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Constant.php: -------------------------------------------------------------------------------- 1 | $value), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->repr($this->getAttribute('value')); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/ExtensionReference.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_ExtensionReference extends Twig_Node_Expression 19 | { 20 | public function __construct($name, $lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler->raw(sprintf("\$this->env->getExtension('%s')", $this->getAttribute('name'))); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Filter.php: -------------------------------------------------------------------------------- 1 | $node, 'filter' => $filterName, 'arguments' => $arguments), array(), $lineno, $tag); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getNode('filter')->getAttribute('value'); 22 | 23 | if (false === $filter = $compiler->getEnvironment()->getFilter($name)) { 24 | $message = sprintf('The filter "%s" does not exist', $name); 25 | if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFilters()))) { 26 | $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); 27 | } 28 | 29 | throw new Twig_Error_Syntax($message, $this->getLine()); 30 | } 31 | 32 | $this->compileFilter($compiler, $filter); 33 | } 34 | 35 | protected function compileFilter(Twig_Compiler $compiler, Twig_FilterInterface $filter) 36 | { 37 | $compiler 38 | ->raw($filter->compile().'(') 39 | ->raw($filter->needsEnvironment() ? '$this->env, ' : '') 40 | ->raw($filter->needsContext() ? '$context, ' : '') 41 | ; 42 | 43 | foreach ($filter->getArguments() as $argument) { 44 | $compiler 45 | ->string($argument) 46 | ->raw(', ') 47 | ; 48 | } 49 | 50 | $compiler->subcompile($this->getNode('node')); 51 | 52 | foreach ($this->getNode('arguments') as $node) { 53 | $compiler 54 | ->raw(', ') 55 | ->subcompile($node) 56 | ; 57 | } 58 | 59 | $compiler->raw(')'); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Filter/Default.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var.foo|default('foo item on var is not defined') }} 17 | * 18 | * 19 | * @package twig 20 | * @author Fabien Potencier 21 | */ 22 | class Twig_Node_Expression_Filter_Default extends Twig_Node_Expression_Filter 23 | { 24 | public function __construct(Twig_NodeInterface $node, Twig_Node_Expression_Constant $filterName, Twig_NodeInterface $arguments, $lineno, $tag = null) 25 | { 26 | $default = new Twig_Node_Expression_Filter($node, new Twig_Node_Expression_Constant('_default', $node->getLine()), $arguments, $node->getLine()); 27 | 28 | if ('default' === $filterName->getAttribute('value') && ($node instanceof Twig_Node_Expression_Name || $node instanceof Twig_Node_Expression_GetAttr)) { 29 | $test = new Twig_Node_Expression_Test_Defined(clone $node, 'defined', new Twig_Node(), $node->getLine()); 30 | $false = count($arguments) ? $arguments->getNode(0) : new Twig_Node_Expression_Constant('', $node->getLine()); 31 | 32 | $node = new Twig_Node_Expression_Conditional($test, $default, $false, $node->getLine()); 33 | } else { 34 | $node = $default; 35 | } 36 | 37 | parent::__construct($node, $filterName, $arguments, $lineno, $tag); 38 | } 39 | 40 | public function compile(Twig_Compiler $compiler) 41 | { 42 | $compiler->subcompile($this->getNode('node')); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Function.php: -------------------------------------------------------------------------------- 1 | $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | 22 | if (false === $function = $compiler->getEnvironment()->getFunction($name)) { 23 | $message = sprintf('The function "%s" does not exist', $name); 24 | if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getFunctions()))) { 25 | $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); 26 | } 27 | 28 | throw new Twig_Error_Syntax($message, $this->getLine()); 29 | } 30 | 31 | $compiler->raw($function->compile().'('); 32 | 33 | $first = true; 34 | 35 | if ($function->needsEnvironment()) { 36 | $compiler->raw('$this->env'); 37 | $first = false; 38 | } 39 | 40 | if ($function->needsContext()) { 41 | if (!$first) { 42 | $compiler->raw(', '); 43 | } 44 | $compiler->raw('$context'); 45 | $first = false; 46 | } 47 | 48 | foreach ($function->getArguments() as $argument) { 49 | if (!$first) { 50 | $compiler->raw(', '); 51 | } 52 | $compiler->string($argument); 53 | $first = false; 54 | } 55 | 56 | foreach ($this->getNode('arguments') as $node) { 57 | if (!$first) { 58 | $compiler->raw(', '); 59 | } 60 | $compiler->subcompile($node); 61 | $first = false; 62 | } 63 | 64 | $compiler->raw(')'); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/GetAttr.php: -------------------------------------------------------------------------------- 1 | $node, 'attribute' => $attribute, 'arguments' => $arguments), array('type' => $type, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | if (function_exists('twig_template_get_attributes')) { 22 | $compiler->raw('twig_template_get_attributes($this, '); 23 | } else { 24 | $compiler->raw('$this->getAttribute('); 25 | } 26 | 27 | if ($this->getAttribute('ignore_strict_check')) { 28 | $this->getNode('node')->setAttribute('ignore_strict_check', true); 29 | } 30 | 31 | $compiler->subcompile($this->getNode('node')); 32 | 33 | $compiler->raw(', ')->subcompile($this->getNode('attribute')); 34 | 35 | if (count($this->getNode('arguments')) || Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { 36 | $compiler->raw(', ')->subcompile($this->getNode('arguments')); 37 | 38 | if (Twig_TemplateInterface::ANY_CALL !== $this->getAttribute('type') || $this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { 39 | $compiler->raw(', ')->repr($this->getAttribute('type')); 40 | } 41 | 42 | if ($this->getAttribute('is_defined_test') || $this->getAttribute('ignore_strict_check')) { 43 | $compiler->raw(', '.($this->getAttribute('is_defined_test') ? 'true' : 'false')); 44 | } 45 | 46 | if ($this->getAttribute('ignore_strict_check')) { 47 | $compiler->raw(', '.($this->getAttribute('ignore_strict_check') ? 'true' : 'false')); 48 | } 49 | } 50 | 51 | $compiler->raw(')'); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/MethodCall.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('method' => $method, 'safe' => false), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $compiler 21 | ->subcompile($this->getNode('node')) 22 | ->raw('->') 23 | ->raw($this->getAttribute('method')) 24 | ->raw('(') 25 | ; 26 | $first = true; 27 | foreach ($this->getNode('arguments')->getKeyValuePairs() as $pair) { 28 | if (!$first) { 29 | $compiler->raw(', '); 30 | } 31 | $first = false; 32 | 33 | $compiler->subcompile($pair['value']); 34 | } 35 | $compiler->raw(')'); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Name.php: -------------------------------------------------------------------------------- 1 | '$this', 16 | '_context' => '$context', 17 | '_charset' => '$this->env->getCharset()', 18 | ); 19 | 20 | public function __construct($name, $lineno) 21 | { 22 | parent::__construct(array(), array('name' => $name, 'is_defined_test' => false, 'ignore_strict_check' => false), $lineno); 23 | } 24 | 25 | public function compile(Twig_Compiler $compiler) 26 | { 27 | $name = $this->getAttribute('name'); 28 | 29 | if ($this->getAttribute('is_defined_test')) { 30 | if ($this->isSpecial()) { 31 | $compiler->repr(true); 32 | } else { 33 | $compiler->raw('array_key_exists(')->repr($name)->raw(', $context)'); 34 | } 35 | } elseif ($this->isSpecial()) { 36 | $compiler->raw($this->specialVars[$name]); 37 | } else { 38 | // remove the non-PHP 5.4 version when PHP 5.3 support is dropped 39 | // as the non-optimized version is just a workaround for slow ternary operator 40 | // when the context has a lot of variables 41 | if (version_compare(phpversion(), '5.4.0RC1', '>=') && ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables())) { 42 | // PHP 5.4 ternary operator performance was optimized 43 | $compiler 44 | ->raw('(isset($context[') 45 | ->string($name) 46 | ->raw(']) ? $context[') 47 | ->string($name) 48 | ->raw('] : null)') 49 | ; 50 | } else { 51 | $compiler 52 | ->raw('$this->getContext($context, ') 53 | ->string($name) 54 | ; 55 | 56 | if ($this->getAttribute('ignore_strict_check')) { 57 | $compiler->raw(', true'); 58 | } 59 | 60 | $compiler 61 | ->raw(')') 62 | ; 63 | } 64 | } 65 | } 66 | 67 | public function isSpecial() 68 | { 69 | return isset($this->specialVars[$this->getAttribute('name')]); 70 | } 71 | 72 | public function isSimple() 73 | { 74 | return !$this->isSpecial() && !$this->getAttribute('is_defined_test'); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Parent.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Expression_Parent extends Twig_Node_Expression 20 | { 21 | public function __construct($name, $lineno, $tag = null) 22 | { 23 | parent::__construct(array(), array('output' => false, 'name' => $name), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | if ($this->getAttribute('output')) { 34 | $compiler 35 | ->addDebugInfo($this) 36 | ->write("\$this->displayParentBlock(") 37 | ->string($this->getAttribute('name')) 38 | ->raw(", \$context, \$blocks);\n") 39 | ; 40 | } else { 41 | $compiler 42 | ->raw("\$this->renderParentBlock(") 43 | ->string($this->getAttribute('name')) 44 | ->raw(", \$context, \$blocks)") 45 | ; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/TempName.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $compiler->raw('$_')->raw($this->getAttribute('name'))->raw('_'); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test.php: -------------------------------------------------------------------------------- 1 | $node, 'arguments' => $arguments), array('name' => $name), $lineno); 16 | } 17 | 18 | public function compile(Twig_Compiler $compiler) 19 | { 20 | $name = $this->getAttribute('name'); 21 | $testMap = $compiler->getEnvironment()->getTests(); 22 | if (!isset($testMap[$name])) { 23 | $message = sprintf('The test "%s" does not exist', $name); 24 | if ($alternatives = $compiler->getEnvironment()->computeAlternatives($name, array_keys($compiler->getEnvironment()->getTests()))) { 25 | $message = sprintf('%s. Did you mean "%s"', $message, implode('", "', $alternatives)); 26 | } 27 | 28 | throw new Twig_Error_Syntax($message, $this->getLine()); 29 | } 30 | 31 | $name = $this->getAttribute('name'); 32 | $node = $this->getNode('node'); 33 | 34 | $compiler 35 | ->raw($testMap[$name]->compile().'(') 36 | ->subcompile($node) 37 | ; 38 | 39 | if (null !== $this->getNode('arguments')) { 40 | $compiler->raw(', '); 41 | 42 | $max = count($this->getNode('arguments')) - 1; 43 | foreach ($this->getNode('arguments') as $i => $arg) { 44 | $compiler->subcompile($arg); 45 | 46 | if ($i != $max) { 47 | $compiler->raw(', '); 48 | } 49 | } 50 | } 51 | 52 | $compiler->raw(')'); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Constant.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if post.status is constant('Post::PUBLISHED') %} 17 | * the status attribute is exactly the same as Post::PUBLISHED 18 | * {% endif %} 19 | * 20 | * 21 | * @package twig 22 | * @author Fabien Potencier 23 | */ 24 | class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test 25 | { 26 | public function compile(Twig_Compiler $compiler) 27 | { 28 | $compiler 29 | ->raw('(') 30 | ->subcompile($this->getNode('node')) 31 | ->raw(' === constant(') 32 | ->subcompile($this->getNode('arguments')->getNode(0)) 33 | ->raw('))') 34 | ; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Defined.php: -------------------------------------------------------------------------------- 1 | 16 | * {# defined works with variable names and variable attributes #} 17 | * {% if foo is defined %} 18 | * {# ... #} 19 | * {% endif %} 20 | * 21 | * 22 | * @package twig 23 | * @author Fabien Potencier 24 | */ 25 | class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test 26 | { 27 | public function __construct(Twig_NodeInterface $node, $name, Twig_NodeInterface $arguments = null, $lineno) 28 | { 29 | parent::__construct($node, $name, $arguments, $lineno); 30 | 31 | if ($node instanceof Twig_Node_Expression_Name) { 32 | $node->setAttribute('is_defined_test', true); 33 | } elseif ($node instanceof Twig_Node_Expression_GetAttr) { 34 | $node->setAttribute('is_defined_test', true); 35 | 36 | $this->changeIgnoreStrictCheck($node); 37 | } else { 38 | throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine()); 39 | } 40 | } 41 | 42 | protected function changeIgnoreStrictCheck(Twig_Node_Expression_GetAttr $node) 43 | { 44 | $node->setAttribute('ignore_strict_check', true); 45 | 46 | if ($node->getNode('node') instanceof Twig_Node_Expression_GetAttr) { 47 | $this->changeIgnoreStrictCheck($node->getNode('node')); 48 | } 49 | } 50 | 51 | public function compile(Twig_Compiler $compiler) 52 | { 53 | $compiler->subcompile($this->getNode('node')); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Divisibleby.php: -------------------------------------------------------------------------------- 1 | 16 | * {% if loop.index is divisibleby(3) %} 17 | * 18 | * 19 | * @package twig 20 | * @author Fabien Potencier 21 | */ 22 | class Twig_Node_Expression_Test_Divisibleby extends Twig_Node_Expression_Test 23 | { 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(0 == ') 28 | ->subcompile($this->getNode('node')) 29 | ->raw(' % ') 30 | ->subcompile($this->getNode('arguments')->getNode(0)) 31 | ->raw(')') 32 | ; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Even.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is even }} 17 | * 18 | * 19 | * @package twig 20 | * @author Fabien Potencier 21 | */ 22 | class Twig_Node_Expression_Test_Even extends Twig_Node_Expression_Test 23 | { 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(') 28 | ->subcompile($this->getNode('node')) 29 | ->raw(' % 2 == 0') 30 | ->raw(')') 31 | ; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Null.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is none }} 17 | * 18 | * 19 | * @package twig 20 | * @author Fabien Potencier 21 | */ 22 | class Twig_Node_Expression_Test_Null extends Twig_Node_Expression_Test 23 | { 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(null === ') 28 | ->subcompile($this->getNode('node')) 29 | ->raw(')') 30 | ; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Odd.php: -------------------------------------------------------------------------------- 1 | 16 | * {{ var is odd }} 17 | * 18 | * 19 | * @package twig 20 | * @author Fabien Potencier 21 | */ 22 | class Twig_Node_Expression_Test_Odd extends Twig_Node_Expression_Test 23 | { 24 | public function compile(Twig_Compiler $compiler) 25 | { 26 | $compiler 27 | ->raw('(') 28 | ->subcompile($this->getNode('node')) 29 | ->raw(' % 2 == 1') 30 | ->raw(')') 31 | ; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Test/Sameas.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Expression_Test_Sameas extends Twig_Node_Expression_Test 19 | { 20 | public function compile(Twig_Compiler $compiler) 21 | { 22 | $compiler 23 | ->raw('(') 24 | ->subcompile($this->getNode('node')) 25 | ->raw(' === ') 26 | ->subcompile($this->getNode('arguments')->getNode(0)) 27 | ->raw(')') 28 | ; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Unary.php: -------------------------------------------------------------------------------- 1 | $node), array(), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $compiler->raw('('); 22 | $this->operator($compiler); 23 | $compiler 24 | ->subcompile($this->getNode('node')) 25 | ->raw(')') 26 | ; 27 | } 28 | 29 | abstract public function operator(Twig_Compiler $compiler); 30 | } 31 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Unary/Neg.php: -------------------------------------------------------------------------------- 1 | raw('-'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Unary/Not.php: -------------------------------------------------------------------------------- 1 | raw('!'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Expression/Unary/Pos.php: -------------------------------------------------------------------------------- 1 | raw('+'); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Flush.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Flush extends Twig_Node 19 | { 20 | public function __construct($lineno, $tag) 21 | { 22 | parent::__construct(array(), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write("flush();\n") 35 | ; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/For.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_For extends Twig_Node 20 | { 21 | protected $loop; 22 | 23 | public function __construct(Twig_Node_Expression_AssignName $keyTarget, Twig_Node_Expression_AssignName $valueTarget, Twig_Node_Expression $seq, Twig_Node_Expression $ifexpr = null, Twig_NodeInterface $body, Twig_NodeInterface $else = null, $lineno, $tag = null) 24 | { 25 | $body = new Twig_Node(array($body, $this->loop = new Twig_Node_ForLoop($lineno, $tag))); 26 | 27 | if (null !== $ifexpr) { 28 | $body = new Twig_Node_If(new Twig_Node(array($ifexpr, $body)), null, $lineno, $tag); 29 | } 30 | 31 | parent::__construct(array('key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body, 'else' => $else), array('with_loop' => true, 'ifexpr' => null !== $ifexpr), $lineno, $tag); 32 | } 33 | 34 | /** 35 | * Compiles the node to PHP. 36 | * 37 | * @param Twig_Compiler A Twig_Compiler instance 38 | */ 39 | public function compile(Twig_Compiler $compiler) 40 | { 41 | $compiler 42 | ->addDebugInfo($this) 43 | // the (array) cast bypasses a PHP 5.2.6 bug 44 | ->write("\$context['_parent'] = (array) \$context;\n") 45 | ->write("\$context['_seq'] = twig_ensure_traversable(") 46 | ->subcompile($this->getNode('seq')) 47 | ->raw(");\n") 48 | ; 49 | 50 | if (null !== $this->getNode('else')) { 51 | $compiler->write("\$context['_iterated'] = false;\n"); 52 | } 53 | 54 | if ($this->getAttribute('with_loop')) { 55 | $compiler 56 | ->write("\$context['loop'] = array(\n") 57 | ->write(" 'parent' => \$context['_parent'],\n") 58 | ->write(" 'index0' => 0,\n") 59 | ->write(" 'index' => 1,\n") 60 | ->write(" 'first' => true,\n") 61 | ->write(");\n") 62 | ; 63 | 64 | if (!$this->getAttribute('ifexpr')) { 65 | $compiler 66 | ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof Countable)) {\n") 67 | ->indent() 68 | ->write("\$length = count(\$context['_seq']);\n") 69 | ->write("\$context['loop']['revindex0'] = \$length - 1;\n") 70 | ->write("\$context['loop']['revindex'] = \$length;\n") 71 | ->write("\$context['loop']['length'] = \$length;\n") 72 | ->write("\$context['loop']['last'] = 1 === \$length;\n") 73 | ->outdent() 74 | ->write("}\n") 75 | ; 76 | } 77 | } 78 | 79 | $this->loop->setAttribute('else', null !== $this->getNode('else')); 80 | $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop')); 81 | $this->loop->setAttribute('ifexpr', $this->getAttribute('ifexpr')); 82 | 83 | $compiler 84 | ->write("foreach (\$context['_seq'] as ") 85 | ->subcompile($this->getNode('key_target')) 86 | ->raw(" => ") 87 | ->subcompile($this->getNode('value_target')) 88 | ->raw(") {\n") 89 | ->indent() 90 | ->subcompile($this->getNode('body')) 91 | ->outdent() 92 | ->write("}\n") 93 | ; 94 | 95 | if (null !== $this->getNode('else')) { 96 | $compiler 97 | ->write("if (!\$context['_iterated']) {\n") 98 | ->indent() 99 | ->subcompile($this->getNode('else')) 100 | ->outdent() 101 | ->write("}\n") 102 | ; 103 | } 104 | 105 | $compiler->write("\$_parent = \$context['_parent'];\n"); 106 | 107 | // remove some "private" loop variables (needed for nested loops) 108 | $compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n"); 109 | 110 | // keep the values set in the inner context for variables defined in the outer context 111 | $compiler->write("\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));\n"); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/ForLoop.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_ForLoop extends Twig_Node 19 | { 20 | public function __construct($lineno, $tag = null) 21 | { 22 | parent::__construct(array(), array('with_loop' => false, 'ifexpr' => false, 'else' => false), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | if ($this->getAttribute('else')) { 33 | $compiler->write("\$context['_iterated'] = true;\n"); 34 | } 35 | 36 | if ($this->getAttribute('with_loop')) { 37 | $compiler 38 | ->write("++\$context['loop']['index0'];\n") 39 | ->write("++\$context['loop']['index'];\n") 40 | ->write("\$context['loop']['first'] = false;\n") 41 | ; 42 | 43 | if (!$this->getAttribute('ifexpr')) { 44 | $compiler 45 | ->write("if (isset(\$context['loop']['length'])) {\n") 46 | ->indent() 47 | ->write("--\$context['loop']['revindex0'];\n") 48 | ->write("--\$context['loop']['revindex'];\n") 49 | ->write("\$context['loop']['last'] = 0 === \$context['loop']['revindex0'];\n") 50 | ->outdent() 51 | ->write("}\n") 52 | ; 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/If.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_If extends Twig_Node 20 | { 21 | public function __construct(Twig_NodeInterface $tests, Twig_NodeInterface $else = null, $lineno, $tag = null) 22 | { 23 | parent::__construct(array('tests' => $tests, 'else' => $else), array(), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler->addDebugInfo($this); 34 | for ($i = 0; $i < count($this->getNode('tests')); $i += 2) { 35 | if ($i > 0) { 36 | $compiler 37 | ->outdent() 38 | ->write("} elseif (") 39 | ; 40 | } else { 41 | $compiler 42 | ->write('if (') 43 | ; 44 | } 45 | 46 | $compiler 47 | ->subcompile($this->getNode('tests')->getNode($i)) 48 | ->raw(") {\n") 49 | ->indent() 50 | ->subcompile($this->getNode('tests')->getNode($i + 1)) 51 | ; 52 | } 53 | 54 | if ($this->hasNode('else') && null !== $this->getNode('else')) { 55 | $compiler 56 | ->outdent() 57 | ->write("} else {\n") 58 | ->indent() 59 | ->subcompile($this->getNode('else')) 60 | ; 61 | } 62 | 63 | $compiler 64 | ->outdent() 65 | ->write("}\n"); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Import.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Import extends Twig_Node 19 | { 20 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $var, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('expr' => $expr, 'var' => $var), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write('') 35 | ->subcompile($this->getNode('var')) 36 | ->raw(' = ') 37 | ; 38 | 39 | if ($this->getNode('expr') instanceof Twig_Node_Expression_Name && '_self' === $this->getNode('expr')->getAttribute('name')) { 40 | $compiler->raw("\$this"); 41 | } else { 42 | $compiler 43 | ->raw('$this->env->loadTemplate(') 44 | ->subcompile($this->getNode('expr')) 45 | ->raw(")") 46 | ; 47 | } 48 | 49 | $compiler->raw(";\n"); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Include.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Include extends Twig_Node implements Twig_NodeOutputInterface 20 | { 21 | public function __construct(Twig_Node_Expression $expr, Twig_Node_Expression $variables = null, $only = false, $ignoreMissing = false, $lineno, $tag = null) 22 | { 23 | parent::__construct(array('expr' => $expr, 'variables' => $variables), array('only' => (Boolean) $only, 'ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler->addDebugInfo($this); 34 | 35 | if ($this->getAttribute('ignore_missing')) { 36 | $compiler 37 | ->write("try {\n") 38 | ->indent() 39 | ; 40 | } 41 | 42 | if ($this->getNode('expr') instanceof Twig_Node_Expression_Constant) { 43 | $compiler 44 | ->write("\$this->env->loadTemplate(") 45 | ->subcompile($this->getNode('expr')) 46 | ->raw(")->display(") 47 | ; 48 | } else { 49 | $compiler 50 | ->write("\$template = \$this->env->resolveTemplate(") 51 | ->subcompile($this->getNode('expr')) 52 | ->raw(");\n") 53 | ->write('$template->display(') 54 | ; 55 | } 56 | 57 | if (false === $this->getAttribute('only')) { 58 | if (null === $this->getNode('variables')) { 59 | $compiler->raw('$context'); 60 | } else { 61 | $compiler 62 | ->raw('array_merge($context, ') 63 | ->subcompile($this->getNode('variables')) 64 | ->raw(')') 65 | ; 66 | } 67 | } else { 68 | if (null === $this->getNode('variables')) { 69 | $compiler->raw('array()'); 70 | } else { 71 | $compiler->subcompile($this->getNode('variables')); 72 | } 73 | } 74 | 75 | $compiler->raw(");\n"); 76 | 77 | if ($this->getAttribute('ignore_missing')) { 78 | $compiler 79 | ->outdent() 80 | ->write("} catch (Twig_Error_Loader \$e) {\n") 81 | ->indent() 82 | ->write("// ignore missing template\n") 83 | ->outdent() 84 | ->write("}\n\n") 85 | ; 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Macro.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Macro extends Twig_Node 19 | { 20 | public function __construct($name, Twig_NodeInterface $body, Twig_NodeInterface $arguments, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('body' => $body, 'arguments' => $arguments), array('name' => $name), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $arguments = array(); 33 | foreach ($this->getNode('arguments') as $argument) { 34 | $arguments[] = '$'.$argument->getAttribute('name').' = null'; 35 | } 36 | 37 | $compiler 38 | ->addDebugInfo($this) 39 | ->write(sprintf("public function get%s(%s)\n", $this->getAttribute('name'), implode(', ', $arguments)), "{\n") 40 | ->indent() 41 | ; 42 | 43 | if (!count($this->getNode('arguments'))) { 44 | $compiler->write("\$context = \$this->env->getGlobals();\n\n"); 45 | } else { 46 | $compiler 47 | ->write("\$context = array_merge(\$this->env->getGlobals(), array(\n") 48 | ->indent() 49 | ; 50 | 51 | foreach ($this->getNode('arguments') as $argument) { 52 | $compiler 53 | ->write('') 54 | ->string($argument->getAttribute('name')) 55 | ->raw(' => $'.$argument->getAttribute('name')) 56 | ->raw(",\n") 57 | ; 58 | } 59 | 60 | $compiler 61 | ->outdent() 62 | ->write("));\n\n") 63 | ; 64 | } 65 | 66 | $compiler 67 | ->write("\$blocks = array();\n\n") 68 | ->write("ob_start();\n") 69 | ->write("try {\n") 70 | ->indent() 71 | ->subcompile($this->getNode('body')) 72 | ->outdent() 73 | ->write("} catch(Exception \$e) {\n") 74 | ->indent() 75 | ->write("ob_end_clean();\n\n") 76 | ->write("throw \$e;\n") 77 | ->outdent() 78 | ->write("}\n\n") 79 | ->write("return ob_get_clean();\n") 80 | ->outdent() 81 | ->write("}\n\n") 82 | ; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Print.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Print extends Twig_Node implements Twig_NodeOutputInterface 20 | { 21 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 22 | { 23 | parent::__construct(array('expr' => $expr), array(), $lineno, $tag); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write('echo ') 36 | ->subcompile($this->getNode('expr')) 37 | ->raw(";\n") 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Sandbox.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Sandbox extends Twig_Node 19 | { 20 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 23 | } 24 | 25 | /** 26 | * Compiles the node to PHP. 27 | * 28 | * @param Twig_Compiler A Twig_Compiler instance 29 | */ 30 | public function compile(Twig_Compiler $compiler) 31 | { 32 | $compiler 33 | ->addDebugInfo($this) 34 | ->write("\$sandbox = \$this->env->getExtension('sandbox');\n") 35 | ->write("if (!\$alreadySandboxed = \$sandbox->isSandboxed()) {\n") 36 | ->indent() 37 | ->write("\$sandbox->enableSandbox();\n") 38 | ->outdent() 39 | ->write("}\n") 40 | ->subcompile($this->getNode('body')) 41 | ->write("if (!\$alreadySandboxed) {\n") 42 | ->indent() 43 | ->write("\$sandbox->disableSandbox();\n") 44 | ->outdent() 45 | ->write("}\n") 46 | ; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/SandboxedModule.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_SandboxedModule extends Twig_Node_Module 20 | { 21 | protected $usedFilters; 22 | protected $usedTags; 23 | protected $usedFunctions; 24 | 25 | public function __construct(Twig_Node_Module $node, array $usedFilters, array $usedTags, array $usedFunctions) 26 | { 27 | parent::__construct($node->getNode('body'), $node->getNode('parent'), $node->getNode('blocks'), $node->getNode('macros'), $node->getNode('traits'), $node->getAttribute('filename'), $node->getLine(), $node->getNodeTag()); 28 | 29 | $this->usedFilters = $usedFilters; 30 | $this->usedTags = $usedTags; 31 | $this->usedFunctions = $usedFunctions; 32 | } 33 | 34 | protected function compileDisplayBody(Twig_Compiler $compiler) 35 | { 36 | if (null === $this->getNode('parent')) { 37 | $compiler->write("\$this->checkSecurity();\n"); 38 | } 39 | 40 | parent::compileDisplayBody($compiler); 41 | } 42 | 43 | protected function compileDisplayFooter(Twig_Compiler $compiler) 44 | { 45 | parent::compileDisplayFooter($compiler); 46 | 47 | $compiler 48 | ->write("protected function checkSecurity() {\n") 49 | ->indent() 50 | ->write("\$this->env->getExtension('sandbox')->checkSecurity(\n") 51 | ->indent() 52 | ->write(!$this->usedTags ? "array(),\n" : "array('".implode('\', \'', $this->usedTags)."'),\n") 53 | ->write(!$this->usedFilters ? "array(),\n" : "array('".implode('\', \'', $this->usedFilters)."'),\n") 54 | ->write(!$this->usedFunctions ? "array()\n" : "array('".implode('\', \'', $this->usedFunctions)."')\n") 55 | ->outdent() 56 | ->write(");\n") 57 | ; 58 | 59 | if (null !== $this->getNode('parent')) { 60 | $compiler 61 | ->raw("\n") 62 | ->write("\$this->parent->checkSecurity();\n") 63 | ; 64 | } 65 | 66 | $compiler 67 | ->outdent() 68 | ->write("}\n\n") 69 | ; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/SandboxedPrint.php: -------------------------------------------------------------------------------- 1 | 22 | */ 23 | class Twig_Node_SandboxedPrint extends Twig_Node_Print 24 | { 25 | public function __construct(Twig_Node_Expression $expr, $lineno, $tag = null) 26 | { 27 | parent::__construct($expr, $lineno, $tag); 28 | } 29 | 30 | /** 31 | * Compiles the node to PHP. 32 | * 33 | * @param Twig_Compiler A Twig_Compiler instance 34 | */ 35 | public function compile(Twig_Compiler $compiler) 36 | { 37 | $compiler 38 | ->addDebugInfo($this) 39 | ->write('echo $this->env->getExtension(\'sandbox\')->ensureToStringAllowed(') 40 | ->subcompile($this->getNode('expr')) 41 | ->raw(");\n") 42 | ; 43 | } 44 | 45 | /** 46 | * Removes node filters. 47 | * 48 | * This is mostly needed when another visitor adds filters (like the escaper one). 49 | * 50 | * @param Twig_Node $node A Node 51 | */ 52 | protected function removeNodeFilter($node) 53 | { 54 | if ($node instanceof Twig_Node_Expression_Filter) { 55 | return $this->removeNodeFilter($node->getNode('node')); 56 | } 57 | 58 | return $node; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Set.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Node_Set extends Twig_Node 19 | { 20 | public function __construct($capture, Twig_NodeInterface $names, Twig_NodeInterface $values, $lineno, $tag = null) 21 | { 22 | parent::__construct(array('names' => $names, 'values' => $values), array('capture' => $capture, 'safe' => false), $lineno, $tag); 23 | 24 | /* 25 | * Optimizes the node when capture is used for a large block of text. 26 | * 27 | * {% set foo %}foo{% endset %} is compiled to $context['foo'] = new Twig_Markup("foo"); 28 | */ 29 | if ($this->getAttribute('capture')) { 30 | $this->setAttribute('safe', true); 31 | 32 | $values = $this->getNode('values'); 33 | if ($values instanceof Twig_Node_Text) { 34 | $this->setNode('values', new Twig_Node_Expression_Constant($values->getAttribute('data'), $values->getLine())); 35 | $this->setAttribute('capture', false); 36 | } 37 | } 38 | } 39 | 40 | /** 41 | * Compiles the node to PHP. 42 | * 43 | * @param Twig_Compiler A Twig_Compiler instance 44 | */ 45 | public function compile(Twig_Compiler $compiler) 46 | { 47 | $compiler->addDebugInfo($this); 48 | 49 | if (count($this->getNode('names')) > 1) { 50 | $compiler->write('list('); 51 | foreach ($this->getNode('names') as $idx => $node) { 52 | if ($idx) { 53 | $compiler->raw(', '); 54 | } 55 | 56 | $compiler->subcompile($node); 57 | } 58 | $compiler->raw(')'); 59 | } else { 60 | if ($this->getAttribute('capture')) { 61 | $compiler 62 | ->write("ob_start();\n") 63 | ->subcompile($this->getNode('values')) 64 | ; 65 | } 66 | 67 | $compiler->subcompile($this->getNode('names'), false); 68 | 69 | if ($this->getAttribute('capture')) { 70 | $compiler->raw(" = ('' === \$tmp = ob_get_clean()) ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())"); 71 | } 72 | } 73 | 74 | if (!$this->getAttribute('capture')) { 75 | $compiler->raw(' = '); 76 | 77 | if (count($this->getNode('names')) > 1) { 78 | $compiler->write('array('); 79 | foreach ($this->getNode('values') as $idx => $value) { 80 | if ($idx) { 81 | $compiler->raw(', '); 82 | } 83 | 84 | $compiler->subcompile($value); 85 | } 86 | $compiler->raw(')'); 87 | } else { 88 | if ($this->getAttribute('safe')) { 89 | $compiler 90 | ->raw("('' === \$tmp = ") 91 | ->subcompile($this->getNode('values')) 92 | ->raw(") ? '' : new Twig_Markup(\$tmp, \$this->env->getCharset())") 93 | ; 94 | } else { 95 | $compiler->subcompile($this->getNode('values')); 96 | } 97 | } 98 | } 99 | 100 | $compiler->raw(";\n"); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/SetTemp.php: -------------------------------------------------------------------------------- 1 | $name), $lineno); 17 | } 18 | 19 | public function compile(Twig_Compiler $compiler) 20 | { 21 | $name = $this->getAttribute('name'); 22 | $compiler 23 | ->addDebugInfo($this) 24 | ->write('if (isset($context[') 25 | ->string($name) 26 | ->raw('])) { $_') 27 | ->raw($name) 28 | ->raw('_ = $context[') 29 | ->repr($name) 30 | ->raw(']; } else { $_') 31 | ->raw($name) 32 | ->raw("_ = null; }\n") 33 | ; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Spaceless.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | class Twig_Node_Spaceless extends Twig_Node 21 | { 22 | public function __construct(Twig_NodeInterface $body, $lineno, $tag = 'spaceless') 23 | { 24 | parent::__construct(array('body' => $body), array(), $lineno, $tag); 25 | } 26 | 27 | /** 28 | * Compiles the node to PHP. 29 | * 30 | * @param Twig_Compiler A Twig_Compiler instance 31 | */ 32 | public function compile(Twig_Compiler $compiler) 33 | { 34 | $compiler 35 | ->addDebugInfo($this) 36 | ->write("ob_start();\n") 37 | ->subcompile($this->getNode('body')) 38 | ->write("echo trim(preg_replace('/>\s+<', ob_get_clean()));\n") 39 | ; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Node/Text.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_Node_Text extends Twig_Node implements Twig_NodeOutputInterface 20 | { 21 | public function __construct($data, $lineno) 22 | { 23 | parent::__construct(array(), array('data' => $data), $lineno); 24 | } 25 | 26 | /** 27 | * Compiles the node to PHP. 28 | * 29 | * @param Twig_Compiler A Twig_Compiler instance 30 | */ 31 | public function compile(Twig_Compiler $compiler) 32 | { 33 | $compiler 34 | ->addDebugInfo($this) 35 | ->write('echo ') 36 | ->string($this->getAttribute('data')) 37 | ->raw(";\n") 38 | ; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_NodeInterface extends Countable, IteratorAggregate 19 | { 20 | /** 21 | * Compiles the node to PHP. 22 | * 23 | * @param Twig_Compiler A Twig_Compiler instance 24 | */ 25 | function compile(Twig_Compiler $compiler); 26 | 27 | function getLine(); 28 | 29 | function getNodeTag(); 30 | } 31 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeOutputInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_NodeOutputInterface 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeTraverser.php: -------------------------------------------------------------------------------- 1 | 19 | */ 20 | class Twig_NodeTraverser 21 | { 22 | protected $env; 23 | protected $visitors; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param Twig_Environment $env A Twig_Environment instance 29 | * @param array $visitors An array of Twig_NodeVisitorInterface instances 30 | */ 31 | public function __construct(Twig_Environment $env, array $visitors = array()) 32 | { 33 | $this->env = $env; 34 | $this->visitors = array(); 35 | foreach ($visitors as $visitor) { 36 | $this->addVisitor($visitor); 37 | } 38 | } 39 | 40 | /** 41 | * Adds a visitor. 42 | * 43 | * @param Twig_NodeVisitorInterface $visitor A Twig_NodeVisitorInterface instance 44 | */ 45 | public function addVisitor(Twig_NodeVisitorInterface $visitor) 46 | { 47 | if (!isset($this->visitors[$visitor->getPriority()])) { 48 | $this->visitors[$visitor->getPriority()] = array(); 49 | } 50 | 51 | $this->visitors[$visitor->getPriority()][] = $visitor; 52 | } 53 | 54 | /** 55 | * Traverses a node and calls the registered visitors. 56 | * 57 | * @param Twig_NodeInterface $node A Twig_NodeInterface instance 58 | */ 59 | public function traverse(Twig_NodeInterface $node) 60 | { 61 | ksort($this->visitors); 62 | foreach ($this->visitors as $visitors) { 63 | foreach ($visitors as $visitor) { 64 | $node = $this->traverseForVisitor($visitor, $node); 65 | } 66 | } 67 | 68 | return $node; 69 | } 70 | 71 | protected function traverseForVisitor(Twig_NodeVisitorInterface $visitor, Twig_NodeInterface $node = null) 72 | { 73 | if (null === $node) { 74 | return null; 75 | } 76 | 77 | $node = $visitor->enterNode($node, $this->env); 78 | 79 | foreach ($node as $k => $n) { 80 | if (false !== $n = $this->traverseForVisitor($visitor, $n)) { 81 | $node->setNode($k, $n); 82 | } else { 83 | $node->removeNode($k); 84 | } 85 | } 86 | 87 | return $visitor->leaveNode($node, $this->env); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeVisitor/Escaper.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_NodeVisitor_Escaper implements Twig_NodeVisitorInterface 19 | { 20 | protected $statusStack = array(); 21 | protected $blocks = array(); 22 | 23 | protected $safeAnalysis; 24 | protected $traverser; 25 | 26 | function __construct() 27 | { 28 | $this->safeAnalysis = new Twig_NodeVisitor_SafeAnalysis(); 29 | } 30 | 31 | /** 32 | * Called before child nodes are visited. 33 | * 34 | * @param Twig_NodeInterface $node The node to visit 35 | * @param Twig_Environment $env The Twig environment instance 36 | * 37 | * @return Twig_NodeInterface The modified node 38 | */ 39 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) 40 | { 41 | if ($node instanceof Twig_Node_AutoEscape) { 42 | $this->statusStack[] = $node->getAttribute('value'); 43 | } elseif ($node instanceof Twig_Node_Block) { 44 | $this->statusStack[] = isset($this->blocks[$node->getAttribute('name')]) ? $this->blocks[$node->getAttribute('name')] : $this->needEscaping($env); 45 | } 46 | 47 | return $node; 48 | } 49 | 50 | /** 51 | * Called after child nodes are visited. 52 | * 53 | * @param Twig_NodeInterface $node The node to visit 54 | * @param Twig_Environment $env The Twig environment instance 55 | * 56 | * @return Twig_NodeInterface The modified node 57 | */ 58 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) 59 | { 60 | if ($node instanceof Twig_Node_Expression_Filter) { 61 | return $this->preEscapeFilterNode($node, $env); 62 | } elseif ($node instanceof Twig_Node_Print) { 63 | return $this->escapePrintNode($node, $env, $this->needEscaping($env)); 64 | } 65 | 66 | if ($node instanceof Twig_Node_AutoEscape || $node instanceof Twig_Node_Block) { 67 | array_pop($this->statusStack); 68 | } elseif ($node instanceof Twig_Node_BlockReference) { 69 | $this->blocks[$node->getAttribute('name')] = $this->needEscaping($env); 70 | } 71 | 72 | return $node; 73 | } 74 | 75 | protected function escapePrintNode(Twig_Node_Print $node, Twig_Environment $env, $type) 76 | { 77 | if (false === $type) { 78 | return $node; 79 | } 80 | 81 | $expression = $node->getNode('expr'); 82 | 83 | if ($this->isSafeFor($type, $expression, $env)) { 84 | return $node; 85 | } 86 | 87 | $class = get_class($node); 88 | 89 | return new $class( 90 | $this->getEscaperFilter($type, $expression), 91 | $node->getLine() 92 | ); 93 | } 94 | 95 | protected function preEscapeFilterNode(Twig_Node_Expression_Filter $filter, Twig_Environment $env) 96 | { 97 | $name = $filter->getNode('filter')->getAttribute('value'); 98 | 99 | if (false !== $f = $env->getFilter($name)) { 100 | $type = $f->getPreEscape(); 101 | if (null === $type) { 102 | return $filter; 103 | } 104 | 105 | $node = $filter->getNode('node'); 106 | if ($this->isSafeFor($type, $node, $env)) { 107 | return $filter; 108 | } 109 | 110 | $filter->setNode('node', $this->getEscaperFilter($type, $node)); 111 | 112 | return $filter; 113 | } 114 | 115 | return $filter; 116 | } 117 | 118 | protected function isSafeFor($type, Twig_NodeInterface $expression, $env) 119 | { 120 | $safe = $this->safeAnalysis->getSafe($expression); 121 | 122 | if (null === $safe) { 123 | if (null === $this->traverser) { 124 | $this->traverser = new Twig_NodeTraverser($env, array($this->safeAnalysis)); 125 | } 126 | $this->traverser->traverse($expression); 127 | $safe = $this->safeAnalysis->getSafe($expression); 128 | } 129 | 130 | return in_array($type, $safe) || in_array('all', $safe); 131 | } 132 | 133 | protected function needEscaping(Twig_Environment $env) 134 | { 135 | if (count($this->statusStack)) { 136 | return $this->statusStack[count($this->statusStack) - 1]; 137 | } 138 | 139 | if ($env->hasExtension('escaper') && $env->getExtension('escaper')->isGlobal()) { 140 | return 'html'; 141 | } 142 | 143 | return false; 144 | } 145 | 146 | protected function getEscaperFilter($type, Twig_NodeInterface $node) 147 | { 148 | $line = $node->getLine(); 149 | $name = new Twig_Node_Expression_Constant('escape', $line); 150 | $args = new Twig_Node(array(new Twig_Node_Expression_Constant((string) $type, $line), new Twig_Node_Expression_Constant(null, $line), new Twig_Node_Expression_Constant(true, $line))); 151 | 152 | return new Twig_Node_Expression_Filter($node, $name, $args, $line); 153 | } 154 | 155 | /** 156 | * {@inheritdoc} 157 | */ 158 | public function getPriority() 159 | { 160 | return 0; 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeVisitor/SafeAnalysis.php: -------------------------------------------------------------------------------- 1 | data[$hash])) { 11 | foreach($this->data[$hash] as $bucket) { 12 | if ($bucket['key'] === $node) { 13 | return $bucket['value']; 14 | } 15 | } 16 | } 17 | 18 | return null; 19 | } 20 | 21 | protected function setSafe(Twig_NodeInterface $node, array $safe) 22 | { 23 | $hash = spl_object_hash($node); 24 | if (isset($this->data[$hash])) { 25 | foreach($this->data[$hash] as &$bucket) { 26 | if ($bucket['key'] === $node) { 27 | $bucket['value'] = $safe; 28 | 29 | return; 30 | } 31 | } 32 | } 33 | $this->data[$hash][] = array( 34 | 'key' => $node, 35 | 'value' => $safe, 36 | ); 37 | } 38 | 39 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) 40 | { 41 | return $node; 42 | } 43 | 44 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) 45 | { 46 | if ($node instanceof Twig_Node_Expression_Constant) { 47 | // constants are marked safe for all 48 | $this->setSafe($node, array('all')); 49 | } elseif ($node instanceof Twig_Node_Expression_BlockReference) { 50 | // blocks are safe by definition 51 | $this->setSafe($node, array('all')); 52 | } elseif ($node instanceof Twig_Node_Expression_Parent) { 53 | // parent block is safe by definition 54 | $this->setSafe($node, array('all')); 55 | } elseif ($node instanceof Twig_Node_Expression_Conditional) { 56 | // intersect safeness of both operands 57 | $safe = $this->intersectSafe($this->getSafe($node->getNode('expr2')), $this->getSafe($node->getNode('expr3'))); 58 | $this->setSafe($node, $safe); 59 | } elseif ($node instanceof Twig_Node_Expression_Filter) { 60 | // filter expression is safe when the filter is safe 61 | $name = $node->getNode('filter')->getAttribute('value'); 62 | $args = $node->getNode('arguments'); 63 | if (false !== $filter = $env->getFilter($name)) { 64 | $this->setSafe($node, $filter->getSafe($args)); 65 | } else { 66 | $this->setSafe($node, array()); 67 | } 68 | } elseif ($node instanceof Twig_Node_Expression_Function) { 69 | // function expression is safe when the function is safe 70 | $name = $node->getAttribute('name'); 71 | $args = $node->getNode('arguments'); 72 | $function = $env->getFunction($name); 73 | if (false !== $function) { 74 | $this->setSafe($node, $function->getSafe($args)); 75 | } else { 76 | $this->setSafe($node, array()); 77 | } 78 | } elseif ($node instanceof Twig_Node_Expression_MethodCall) { 79 | if ($node->getAttribute('safe')) { 80 | $this->setSafe($node, array('all')); 81 | } else { 82 | $this->setSafe($node, array()); 83 | } 84 | } else { 85 | $this->setSafe($node, array()); 86 | } 87 | 88 | return $node; 89 | } 90 | 91 | protected function intersectSafe(array $a = null, array $b = null) 92 | { 93 | if (null === $a || null === $b) { 94 | return array(); 95 | } 96 | 97 | if (in_array('all', $a)) { 98 | return $b; 99 | } 100 | 101 | if (in_array('all', $b)) { 102 | return $a; 103 | } 104 | 105 | return array_intersect($a, $b); 106 | } 107 | 108 | /** 109 | * {@inheritdoc} 110 | */ 111 | public function getPriority() 112 | { 113 | return 0; 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeVisitor/Sandbox.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_NodeVisitor_Sandbox implements Twig_NodeVisitorInterface 19 | { 20 | protected $inAModule = false; 21 | protected $tags; 22 | protected $filters; 23 | protected $functions; 24 | 25 | /** 26 | * Called before child nodes are visited. 27 | * 28 | * @param Twig_NodeInterface $node The node to visit 29 | * @param Twig_Environment $env The Twig environment instance 30 | * 31 | * @return Twig_NodeInterface The modified node 32 | */ 33 | public function enterNode(Twig_NodeInterface $node, Twig_Environment $env) 34 | { 35 | if ($node instanceof Twig_Node_Module) { 36 | $this->inAModule = true; 37 | $this->tags = array(); 38 | $this->filters = array(); 39 | $this->functions = array(); 40 | 41 | return $node; 42 | } elseif ($this->inAModule) { 43 | // look for tags 44 | if ($node->getNodeTag()) { 45 | $this->tags[] = $node->getNodeTag(); 46 | } 47 | 48 | // look for filters 49 | if ($node instanceof Twig_Node_Expression_Filter) { 50 | $this->filters[] = $node->getNode('filter')->getAttribute('value'); 51 | } 52 | 53 | // look for functions 54 | if ($node instanceof Twig_Node_Expression_Function) { 55 | $this->functions[] = $node->getAttribute('name'); 56 | } 57 | 58 | // wrap print to check __toString() calls 59 | if ($node instanceof Twig_Node_Print) { 60 | return new Twig_Node_SandboxedPrint($node->getNode('expr'), $node->getLine(), $node->getNodeTag()); 61 | } 62 | } 63 | 64 | return $node; 65 | } 66 | 67 | /** 68 | * Called after child nodes are visited. 69 | * 70 | * @param Twig_NodeInterface $node The node to visit 71 | * @param Twig_Environment $env The Twig environment instance 72 | * 73 | * @return Twig_NodeInterface The modified node 74 | */ 75 | public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env) 76 | { 77 | if ($node instanceof Twig_Node_Module) { 78 | $this->inAModule = false; 79 | 80 | return new Twig_Node_SandboxedModule($node, array_unique($this->filters), array_unique($this->tags), array_unique($this->functions)); 81 | } 82 | 83 | return $node; 84 | } 85 | 86 | /** 87 | * {@inheritdoc} 88 | */ 89 | public function getPriority() 90 | { 91 | return 0; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/NodeVisitorInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_NodeVisitorInterface 19 | { 20 | /** 21 | * Called before child nodes are visited. 22 | * 23 | * @param Twig_NodeInterface $node The node to visit 24 | * @param Twig_Environment $env The Twig environment instance 25 | * 26 | * @return Twig_NodeInterface The modified node 27 | */ 28 | function enterNode(Twig_NodeInterface $node, Twig_Environment $env); 29 | 30 | /** 31 | * Called after child nodes are visited. 32 | * 33 | * @param Twig_NodeInterface $node The node to visit 34 | * @param Twig_Environment $env The Twig environment instance 35 | * 36 | * @return Twig_NodeInterface The modified node 37 | */ 38 | function leaveNode(Twig_NodeInterface $node, Twig_Environment $env); 39 | 40 | /** 41 | * Returns the priority for this visitor. 42 | * 43 | * Priority should be between -10 and 10 (0 is the default). 44 | * 45 | * @return integer The priority level 46 | */ 47 | function getPriority(); 48 | } 49 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/ParserInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_ParserInterface 19 | { 20 | /** 21 | * Converts a token stream to a node tree. 22 | * 23 | * @param Twig_TokenStream $stream A token stream instance 24 | * 25 | * @return Twig_Node_Module A node tree 26 | */ 27 | function parse(Twig_TokenStream $stream); 28 | } 29 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Sandbox/SecurityError.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Sandbox_SecurityError extends Twig_Error 19 | { 20 | } 21 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Sandbox/SecurityPolicy.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Sandbox_SecurityPolicy implements Twig_Sandbox_SecurityPolicyInterface 19 | { 20 | protected $allowedTags; 21 | protected $allowedFilters; 22 | protected $allowedMethods; 23 | protected $allowedProperties; 24 | protected $allowedFunctions; 25 | 26 | public function __construct(array $allowedTags = array(), array $allowedFilters = array(), array $allowedMethods = array(), array $allowedProperties = array(), array $allowedFunctions = array()) 27 | { 28 | $this->allowedTags = $allowedTags; 29 | $this->allowedFilters = $allowedFilters; 30 | $this->setAllowedMethods($allowedMethods); 31 | $this->allowedProperties = $allowedProperties; 32 | $this->allowedFunctions = $allowedFunctions; 33 | } 34 | 35 | public function setAllowedTags(array $tags) 36 | { 37 | $this->allowedTags = $tags; 38 | } 39 | 40 | public function setAllowedFilters(array $filters) 41 | { 42 | $this->allowedFilters = $filters; 43 | } 44 | 45 | public function setAllowedMethods(array $methods) 46 | { 47 | $this->allowedMethods = array(); 48 | foreach ($methods as $class => $m) { 49 | $this->allowedMethods[$class] = array_map('strtolower', is_array($m) ? $m : array($m)); 50 | } 51 | } 52 | 53 | public function setAllowedProperties(array $properties) 54 | { 55 | $this->allowedProperties = $properties; 56 | } 57 | 58 | public function setAllowedFunctions(array $functions) 59 | { 60 | $this->allowedFunctions = $functions; 61 | } 62 | 63 | public function checkSecurity($tags, $filters, $functions) 64 | { 65 | foreach ($tags as $tag) { 66 | if (!in_array($tag, $this->allowedTags)) { 67 | throw new Twig_Sandbox_SecurityError(sprintf('Tag "%s" is not allowed.', $tag)); 68 | } 69 | } 70 | 71 | foreach ($filters as $filter) { 72 | if (!in_array($filter, $this->allowedFilters)) { 73 | throw new Twig_Sandbox_SecurityError(sprintf('Filter "%s" is not allowed.', $filter)); 74 | } 75 | } 76 | 77 | foreach ($functions as $function) { 78 | if (!in_array($function, $this->allowedFunctions)) { 79 | throw new Twig_Sandbox_SecurityError(sprintf('Function "%s" is not allowed.', $function)); 80 | } 81 | } 82 | } 83 | 84 | public function checkMethodAllowed($obj, $method) 85 | { 86 | if ($obj instanceof Twig_TemplateInterface || $obj instanceof Twig_Markup) { 87 | return true; 88 | } 89 | 90 | $allowed = false; 91 | $method = strtolower($method); 92 | foreach ($this->allowedMethods as $class => $methods) { 93 | if ($obj instanceof $class) { 94 | $allowed = in_array($method, $methods); 95 | 96 | break; 97 | } 98 | } 99 | 100 | if (!$allowed) { 101 | throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" method on a "%s" object is not allowed.', $method, get_class($obj))); 102 | } 103 | } 104 | 105 | public function checkPropertyAllowed($obj, $property) 106 | { 107 | $allowed = false; 108 | foreach ($this->allowedProperties as $class => $properties) { 109 | if ($obj instanceof $class) { 110 | $allowed = in_array($property, is_array($properties) ? $properties : array($properties)); 111 | 112 | break; 113 | } 114 | } 115 | 116 | if (!$allowed) { 117 | throw new Twig_Sandbox_SecurityError(sprintf('Calling "%s" property on a "%s" object is not allowed.', $property, get_class($obj))); 118 | } 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Sandbox/SecurityPolicyInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_Sandbox_SecurityPolicyInterface 19 | { 20 | function checkSecurity($tags, $filters, $functions); 21 | 22 | function checkMethodAllowed($obj, $method); 23 | 24 | function checkPropertyAllowed($obj, $method); 25 | } 26 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TemplateInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_TemplateInterface 19 | { 20 | const ANY_CALL = 'any'; 21 | const ARRAY_CALL = 'array'; 22 | const METHOD_CALL = 'method'; 23 | 24 | /** 25 | * Renders the template with the given context and returns it as string. 26 | * 27 | * @param array $context An array of parameters to pass to the template 28 | * 29 | * @return string The rendered template 30 | */ 31 | function render(array $context); 32 | 33 | /** 34 | * Displays the template with the given context. 35 | * 36 | * @param array $context An array of parameters to pass to the template 37 | * @param array $blocks An array of blocks to pass to the template 38 | */ 39 | function display(array $context, array $blocks = array()); 40 | 41 | /** 42 | * Returns the bound environment for this template. 43 | * 44 | * @return Twig_Environment The current environment 45 | */ 46 | function getEnvironment(); 47 | } 48 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Test/Function.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Test_Function implements Twig_TestInterface 19 | { 20 | protected $function; 21 | 22 | public function __construct($function) 23 | { 24 | $this->function = $function; 25 | } 26 | 27 | public function compile() 28 | { 29 | return $this->function; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Test/Method.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Test_Method implements Twig_TestInterface 19 | { 20 | protected $extension, $method; 21 | 22 | public function __construct(Twig_ExtensionInterface $extension, $method) 23 | { 24 | $this->extension = $extension; 25 | $this->method = $method; 26 | } 27 | 28 | public function compile() 29 | { 30 | return sprintf('$this->env->getExtension(\'%s\')->%s', $this->extension->getName(), $this->method); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/Test/Node.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | class Twig_Test_Node implements Twig_TestInterface 19 | { 20 | protected $class; 21 | 22 | public function __construct($class) 23 | { 24 | $this->class = $class; 25 | } 26 | 27 | public function getClass() 28 | { 29 | return $this->class; 30 | } 31 | 32 | public function compile() 33 | { 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TestInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_TestInterface 19 | { 20 | /** 21 | * Compiles a test. 22 | * 23 | * @return string The PHP code for the test 24 | */ 25 | function compile(); 26 | } 27 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | abstract class Twig_TokenParser implements Twig_TokenParserInterface 19 | { 20 | /** 21 | * @var Twig_Parser 22 | */ 23 | protected $parser; 24 | 25 | /** 26 | * Sets the parser associated with this token parser 27 | * 28 | * @param $parser A Twig_Parser instance 29 | */ 30 | public function setParser(Twig_Parser $parser) 31 | { 32 | $this->parser = $parser; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/AutoEscape.php: -------------------------------------------------------------------------------- 1 | 16 | * {% autoescape true %} 17 | * Everything will be automatically escaped in this block 18 | * {% endautoescape %} 19 | * 20 | * {% autoescape false %} 21 | * Everything will be outputed as is in this block 22 | * {% endautoescape %} 23 | * 24 | * {% autoescape true js %} 25 | * Everything will be automatically escaped in this block 26 | * using the js escaping strategy 27 | * {% endautoescape %} 28 | * 29 | */ 30 | class Twig_TokenParser_AutoEscape extends Twig_TokenParser 31 | { 32 | /** 33 | * Parses a token and returns a node. 34 | * 35 | * @param Twig_Token $token A Twig_Token instance 36 | * 37 | * @return Twig_NodeInterface A Twig_NodeInterface instance 38 | */ 39 | public function parse(Twig_Token $token) 40 | { 41 | $lineno = $token->getLine(); 42 | $value = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); 43 | if (!in_array($value, array('true', 'false'))) { 44 | throw new Twig_Error_Syntax("Autoescape value must be 'true' or 'false'", $lineno); 45 | } 46 | $value = 'true' === $value ? 'html' : false; 47 | 48 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { 49 | if (false === $value) { 50 | throw new Twig_Error_Syntax('Unexpected escaping strategy as you set autoescaping to false.', $lineno); 51 | } 52 | 53 | $value = $this->parser->getStream()->next()->getValue(); 54 | } 55 | 56 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 57 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 58 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 59 | 60 | return new Twig_Node_AutoEscape($value, $body, $lineno, $this->getTag()); 61 | } 62 | 63 | public function decideBlockEnd(Twig_Token $token) 64 | { 65 | return $token->test('endautoescape'); 66 | } 67 | 68 | /** 69 | * Gets the tag name associated with this token parser. 70 | * 71 | * @return string The tag name 72 | */ 73 | public function getTag() 74 | { 75 | return 'autoescape'; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Block.php: -------------------------------------------------------------------------------- 1 | 17 | * {% block head %} 18 | * 19 | * {% block title %}{% endblock %} - My Webpage 20 | * {% endblock %} 21 | * 22 | */ 23 | class Twig_TokenParser_Block extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $lineno = $token->getLine(); 35 | $stream = $this->parser->getStream(); 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | if ($this->parser->hasBlock($name)) { 38 | throw new Twig_Error_Syntax("The block '$name' has already been defined", $lineno); 39 | } 40 | $this->parser->pushLocalScope(); 41 | $this->parser->pushBlockStack($name); 42 | 43 | if ($stream->test(Twig_Token::BLOCK_END_TYPE)) { 44 | $stream->next(); 45 | 46 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 47 | if ($stream->test(Twig_Token::NAME_TYPE)) { 48 | $value = $stream->next()->getValue(); 49 | 50 | if ($value != $name) { 51 | throw new Twig_Error_Syntax(sprintf("Expected endblock for block '$name' (but %s given)", $value), $lineno); 52 | } 53 | } 54 | } else { 55 | $body = new Twig_Node(array( 56 | new Twig_Node_Print($this->parser->getExpressionParser()->parseExpression(), $lineno), 57 | )); 58 | } 59 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 60 | 61 | $block = new Twig_Node_Block($name, $body, $lineno); 62 | $this->parser->setBlock($name, $block); 63 | $this->parser->popBlockStack(); 64 | $this->parser->popLocalScope(); 65 | 66 | return new Twig_Node_BlockReference($name, $lineno, $this->getTag()); 67 | } 68 | 69 | public function decideBlockEnd(Twig_Token $token) 70 | { 71 | return $token->test('endblock'); 72 | } 73 | 74 | /** 75 | * Gets the tag name associated with this token parser. 76 | * 77 | * @return string The tag name 78 | */ 79 | public function getTag() 80 | { 81 | return 'block'; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Do.php: -------------------------------------------------------------------------------- 1 | parser->getExpressionParser()->parseExpression(); 27 | 28 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Do($expr, $token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'do'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Extends.php: -------------------------------------------------------------------------------- 1 | 17 | * {% extends "base.html" %} 18 | * 19 | */ 20 | class Twig_TokenParser_Extends extends Twig_TokenParser 21 | { 22 | /** 23 | * Parses a token and returns a node. 24 | * 25 | * @param Twig_Token $token A Twig_Token instance 26 | * 27 | * @return Twig_NodeInterface A Twig_NodeInterface instance 28 | */ 29 | public function parse(Twig_Token $token) 30 | { 31 | if (!$this->parser->isMainScope()) { 32 | throw new Twig_Error_Syntax('Cannot extend from a block', $token->getLine()); 33 | } 34 | 35 | if (null !== $this->parser->getParent()) { 36 | throw new Twig_Error_Syntax('Multiple extends tags are forbidden', $token->getLine()); 37 | } 38 | $this->parser->setParent($this->parser->getExpressionParser()->parseExpression()); 39 | 40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 41 | 42 | return null; 43 | } 44 | 45 | /** 46 | * Gets the tag name associated with this token parser. 47 | * 48 | * @return string The tag name 49 | */ 50 | public function getTag() 51 | { 52 | return 'extends'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Filter.php: -------------------------------------------------------------------------------- 1 | 16 | * {% filter upper %} 17 | * This text becomes uppercase 18 | * {% endfilter %} 19 | * 20 | */ 21 | class Twig_TokenParser_Filter extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $name = $this->parser->getVarName(); 33 | $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag()); 34 | 35 | $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag()); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 39 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 40 | 41 | $block = new Twig_Node_Block($name, $body, $token->getLine()); 42 | $this->parser->setBlock($name, $block); 43 | 44 | return new Twig_Node_Print($filter, $token->getLine(), $this->getTag()); 45 | } 46 | 47 | public function decideBlockEnd(Twig_Token $token) 48 | { 49 | return $token->test('endfilter'); 50 | } 51 | 52 | /** 53 | * Gets the tag name associated with this token parser. 54 | * 55 | * @return string The tag name 56 | */ 57 | public function getTag() 58 | { 59 | return 'filter'; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Flush.php: -------------------------------------------------------------------------------- 1 | parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 29 | 30 | return new Twig_Node_Flush($token->getLine(), $this->getTag()); 31 | } 32 | 33 | /** 34 | * Gets the tag name associated with this token parser. 35 | * 36 | * @return string The tag name 37 | */ 38 | public function getTag() 39 | { 40 | return 'flush'; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/For.php: -------------------------------------------------------------------------------- 1 | 17 | *
    18 | * {% for user in users %} 19 | *
  • {{ user.username|e }}
  • 20 | * {% endfor %} 21 | *
22 | * 23 | */ 24 | class Twig_TokenParser_For extends Twig_TokenParser 25 | { 26 | /** 27 | * Parses a token and returns a node. 28 | * 29 | * @param Twig_Token $token A Twig_Token instance 30 | * 31 | * @return Twig_NodeInterface A Twig_NodeInterface instance 32 | */ 33 | public function parse(Twig_Token $token) 34 | { 35 | $lineno = $token->getLine(); 36 | $targets = $this->parser->getExpressionParser()->parseAssignmentExpression(); 37 | $this->parser->getStream()->expect(Twig_Token::OPERATOR_TYPE, 'in'); 38 | $seq = $this->parser->getExpressionParser()->parseExpression(); 39 | 40 | $ifexpr = null; 41 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'if')) { 42 | $this->parser->getStream()->next(); 43 | $ifexpr = $this->parser->getExpressionParser()->parseExpression(); 44 | } 45 | 46 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 47 | $body = $this->parser->subparse(array($this, 'decideForFork')); 48 | if ($this->parser->getStream()->next()->getValue() == 'else') { 49 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 50 | $else = $this->parser->subparse(array($this, 'decideForEnd'), true); 51 | } else { 52 | $else = null; 53 | } 54 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 55 | 56 | if (count($targets) > 1) { 57 | $keyTarget = $targets->getNode(0); 58 | $keyTarget = new Twig_Node_Expression_AssignName($keyTarget->getAttribute('name'), $keyTarget->getLine()); 59 | $valueTarget = $targets->getNode(1); 60 | $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine()); 61 | } else { 62 | $keyTarget = new Twig_Node_Expression_AssignName('_key', $lineno); 63 | $valueTarget = $targets->getNode(0); 64 | $valueTarget = new Twig_Node_Expression_AssignName($valueTarget->getAttribute('name'), $valueTarget->getLine()); 65 | } 66 | 67 | return new Twig_Node_For($keyTarget, $valueTarget, $seq, $ifexpr, $body, $else, $lineno, $this->getTag()); 68 | } 69 | 70 | public function decideForFork(Twig_Token $token) 71 | { 72 | return $token->test(array('else', 'endfor')); 73 | } 74 | 75 | public function decideForEnd(Twig_Token $token) 76 | { 77 | return $token->test('endfor'); 78 | } 79 | 80 | /** 81 | * Gets the tag name associated with this token parser. 82 | * 83 | * @return string The tag name 84 | */ 85 | public function getTag() 86 | { 87 | return 'for'; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/From.php: -------------------------------------------------------------------------------- 1 | 16 | * {% from 'forms.html' import forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_From extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $stream = $this->parser->getStream(); 32 | $stream->expect('import'); 33 | 34 | $targets = array(); 35 | do { 36 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 37 | 38 | $alias = $name; 39 | if ($stream->test('as')) { 40 | $stream->next(); 41 | 42 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 43 | } 44 | 45 | $targets[$name] = $alias; 46 | 47 | if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) { 48 | break; 49 | } 50 | 51 | $stream->next(); 52 | } while (true); 53 | 54 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 55 | 56 | $node = new Twig_Node_Import($macro, new Twig_Node_Expression_AssignName($this->parser->getVarName(), $token->getLine()), $token->getLine(), $this->getTag()); 57 | 58 | foreach($targets as $name => $alias) { 59 | $this->parser->addImportedFunction($alias, 'get'.$name, $node->getNode('var')); 60 | } 61 | 62 | return $node; 63 | } 64 | 65 | /** 66 | * Gets the tag name associated with this token parser. 67 | * 68 | * @return string The tag name 69 | */ 70 | public function getTag() 71 | { 72 | return 'from'; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/If.php: -------------------------------------------------------------------------------- 1 | 17 | * {% if users %} 18 | *
    19 | * {% for user in users %} 20 | *
  • {{ user.username|e }}
  • 21 | * {% endfor %} 22 | *
23 | * {% endif %} 24 | * 25 | */ 26 | class Twig_TokenParser_If extends Twig_TokenParser 27 | { 28 | /** 29 | * Parses a token and returns a node. 30 | * 31 | * @param Twig_Token $token A Twig_Token instance 32 | * 33 | * @return Twig_NodeInterface A Twig_NodeInterface instance 34 | */ 35 | public function parse(Twig_Token $token) 36 | { 37 | $lineno = $token->getLine(); 38 | $expr = $this->parser->getExpressionParser()->parseExpression(); 39 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 40 | $body = $this->parser->subparse(array($this, 'decideIfFork')); 41 | $tests = array($expr, $body); 42 | $else = null; 43 | 44 | $end = false; 45 | while (!$end) { 46 | switch ($this->parser->getStream()->next()->getValue()) { 47 | case 'else': 48 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 49 | $else = $this->parser->subparse(array($this, 'decideIfEnd')); 50 | break; 51 | 52 | case 'elseif': 53 | $expr = $this->parser->getExpressionParser()->parseExpression(); 54 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 55 | $body = $this->parser->subparse(array($this, 'decideIfFork')); 56 | $tests[] = $expr; 57 | $tests[] = $body; 58 | break; 59 | 60 | case 'endif': 61 | $end = true; 62 | break; 63 | 64 | default: 65 | throw new Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for the following tags "else", "elseif", or "endif" to close the "if" block started at line %d)', $lineno), -1); 66 | } 67 | } 68 | 69 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 70 | 71 | return new Twig_Node_If(new Twig_Node($tests), $else, $lineno, $this->getTag()); 72 | } 73 | 74 | public function decideIfFork(Twig_Token $token) 75 | { 76 | return $token->test(array('elseif', 'else', 'endif')); 77 | } 78 | 79 | public function decideIfEnd(Twig_Token $token) 80 | { 81 | return $token->test(array('endif')); 82 | } 83 | 84 | /** 85 | * Gets the tag name associated with this token parser. 86 | * 87 | * @return string The tag name 88 | */ 89 | public function getTag() 90 | { 91 | return 'if'; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Import.php: -------------------------------------------------------------------------------- 1 | 16 | * {% import 'forms.html' as forms %} 17 | * 18 | */ 19 | class Twig_TokenParser_Import extends Twig_TokenParser 20 | { 21 | /** 22 | * Parses a token and returns a node. 23 | * 24 | * @param Twig_Token $token A Twig_Token instance 25 | * 26 | * @return Twig_NodeInterface A Twig_NodeInterface instance 27 | */ 28 | public function parse(Twig_Token $token) 29 | { 30 | $macro = $this->parser->getExpressionParser()->parseExpression(); 31 | $this->parser->getStream()->expect('as'); 32 | $var = new Twig_Node_Expression_AssignName($this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(), $token->getLine()); 33 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 34 | 35 | return new Twig_Node_Import($macro, $var, $token->getLine(), $this->getTag()); 36 | } 37 | 38 | /** 39 | * Gets the tag name associated with this token parser. 40 | * 41 | * @return string The tag name 42 | */ 43 | public function getTag() 44 | { 45 | return 'import'; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Include.php: -------------------------------------------------------------------------------- 1 | 17 | * {% include 'header.html' %} 18 | * Body 19 | * {% include 'footer.html' %} 20 | * 21 | */ 22 | class Twig_TokenParser_Include extends Twig_TokenParser 23 | { 24 | /** 25 | * Parses a token and returns a node. 26 | * 27 | * @param Twig_Token $token A Twig_Token instance 28 | * 29 | * @return Twig_NodeInterface A Twig_NodeInterface instance 30 | */ 31 | public function parse(Twig_Token $token) 32 | { 33 | $expr = $this->parser->getExpressionParser()->parseExpression(); 34 | 35 | $ignoreMissing = false; 36 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'ignore')) { 37 | $this->parser->getStream()->next(); 38 | $this->parser->getStream()->expect(Twig_Token::NAME_TYPE, 'missing'); 39 | 40 | $ignoreMissing = true; 41 | } 42 | 43 | $variables = null; 44 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'with')) { 45 | $this->parser->getStream()->next(); 46 | 47 | $variables = $this->parser->getExpressionParser()->parseExpression(); 48 | } 49 | 50 | $only = false; 51 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE, 'only')) { 52 | $this->parser->getStream()->next(); 53 | 54 | $only = true; 55 | } 56 | 57 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 58 | 59 | return new Twig_Node_Include($expr, $variables, $only, $ignoreMissing, $token->getLine(), $this->getTag()); 60 | } 61 | 62 | /** 63 | * Gets the tag name associated with this token parser. 64 | * 65 | * @return string The tag name 66 | */ 67 | public function getTag() 68 | { 69 | return 'include'; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Macro.php: -------------------------------------------------------------------------------- 1 | 16 | * {% macro input(name, value, type, size) %} 17 | * 18 | * {% endmacro %} 19 | * 20 | */ 21 | class Twig_TokenParser_Macro extends Twig_TokenParser 22 | { 23 | /** 24 | * Parses a token and returns a node. 25 | * 26 | * @param Twig_Token $token A Twig_Token instance 27 | * 28 | * @return Twig_NodeInterface A Twig_NodeInterface instance 29 | */ 30 | public function parse(Twig_Token $token) 31 | { 32 | $lineno = $token->getLine(); 33 | $name = $this->parser->getStream()->expect(Twig_Token::NAME_TYPE)->getValue(); 34 | 35 | $arguments = $this->parser->getExpressionParser()->parseArguments(); 36 | 37 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 38 | $this->parser->pushLocalScope(); 39 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 40 | if ($this->parser->getStream()->test(Twig_Token::NAME_TYPE)) { 41 | $value = $this->parser->getStream()->next()->getValue(); 42 | 43 | if ($value != $name) { 44 | throw new Twig_Error_Syntax(sprintf("Expected endmacro for macro '$name' (but %s given)", $value), $lineno); 45 | } 46 | } 47 | $this->parser->popLocalScope(); 48 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 49 | 50 | $this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag())); 51 | 52 | return null; 53 | } 54 | 55 | public function decideBlockEnd(Twig_Token $token) 56 | { 57 | return $token->test('endmacro'); 58 | } 59 | 60 | /** 61 | * Gets the tag name associated with this token parser. 62 | * 63 | * @return string The tag name 64 | */ 65 | public function getTag() 66 | { 67 | return 'macro'; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Sandbox.php: -------------------------------------------------------------------------------- 1 | 16 | * {% sandbox %} 17 | * {% include 'user.html' %} 18 | * {% endsandbox %} 19 | * 20 | * 21 | * @see http://www.twig-project.org/doc/api.html#sandbox-extension for details 22 | */ 23 | class Twig_TokenParser_Sandbox extends Twig_TokenParser 24 | { 25 | /** 26 | * Parses a token and returns a node. 27 | * 28 | * @param Twig_Token $token A Twig_Token instance 29 | * 30 | * @return Twig_NodeInterface A Twig_NodeInterface instance 31 | */ 32 | public function parse(Twig_Token $token) 33 | { 34 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 35 | $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 36 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 37 | 38 | return new Twig_Node_Sandbox($body, $token->getLine(), $this->getTag()); 39 | } 40 | 41 | public function decideBlockEnd(Twig_Token $token) 42 | { 43 | return $token->test('endsandbox'); 44 | } 45 | 46 | /** 47 | * Gets the tag name associated with this token parser. 48 | * 49 | * @return string The tag name 50 | */ 51 | public function getTag() 52 | { 53 | return 'sandbox'; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Set.php: -------------------------------------------------------------------------------- 1 | 16 | * {% set foo = 'foo' %} 17 | * 18 | * {% set foo = [1, 2] %} 19 | * 20 | * {% set foo = {'foo': 'bar'} %} 21 | * 22 | * {% set foo = 'foo' ~ 'bar' %} 23 | * 24 | * {% set foo, bar = 'foo', 'bar' %} 25 | * 26 | * {% set foo %}Some content{% endset %} 27 | * 28 | */ 29 | class Twig_TokenParser_Set extends Twig_TokenParser 30 | { 31 | /** 32 | * Parses a token and returns a node. 33 | * 34 | * @param Twig_Token $token A Twig_Token instance 35 | * 36 | * @return Twig_NodeInterface A Twig_NodeInterface instance 37 | */ 38 | public function parse(Twig_Token $token) 39 | { 40 | $lineno = $token->getLine(); 41 | $stream = $this->parser->getStream(); 42 | $names = $this->parser->getExpressionParser()->parseAssignmentExpression(); 43 | 44 | $capture = false; 45 | if ($stream->test(Twig_Token::OPERATOR_TYPE, '=')) { 46 | $stream->next(); 47 | $values = $this->parser->getExpressionParser()->parseMultitargetExpression(); 48 | 49 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 50 | 51 | if (count($names) !== count($values)) { 52 | throw new Twig_Error_Syntax("When using set, you must have the same number of variables and assignements.", $lineno); 53 | } 54 | } else { 55 | $capture = true; 56 | 57 | if (count($names) > 1) { 58 | throw new Twig_Error_Syntax("When using set with a block, you cannot have a multi-target.", $lineno); 59 | } 60 | 61 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 62 | 63 | $values = $this->parser->subparse(array($this, 'decideBlockEnd'), true); 64 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 65 | } 66 | 67 | return new Twig_Node_Set($capture, $names, $values, $lineno, $this->getTag()); 68 | } 69 | 70 | public function decideBlockEnd(Twig_Token $token) 71 | { 72 | return $token->test('endset'); 73 | } 74 | 75 | /** 76 | * Gets the tag name associated with this token parser. 77 | * 78 | * @return string The tag name 79 | */ 80 | public function getTag() 81 | { 82 | return 'set'; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Spaceless.php: -------------------------------------------------------------------------------- 1 | 16 | * {% spaceless %} 17 | *
18 | * foo 19 | *
20 | * {% endspaceless %} 21 | * 22 | * {# output will be
foo
#} 23 | * 24 | */ 25 | class Twig_TokenParser_Spaceless extends Twig_TokenParser 26 | { 27 | /** 28 | * Parses a token and returns a node. 29 | * 30 | * @param Twig_Token $token A Twig_Token instance 31 | * 32 | * @return Twig_NodeInterface A Twig_NodeInterface instance 33 | */ 34 | public function parse(Twig_Token $token) 35 | { 36 | $lineno = $token->getLine(); 37 | 38 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 39 | $body = $this->parser->subparse(array($this, 'decideSpacelessEnd'), true); 40 | $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE); 41 | 42 | return new Twig_Node_Spaceless($body, $lineno, $this->getTag()); 43 | } 44 | 45 | public function decideSpacelessEnd(Twig_Token $token) 46 | { 47 | return $token->test('endspaceless'); 48 | } 49 | 50 | /** 51 | * Gets the tag name associated with this token parser. 52 | * 53 | * @return string The tag name 54 | */ 55 | public function getTag() 56 | { 57 | return 'spaceless'; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParser/Use.php: -------------------------------------------------------------------------------- 1 | 16 | * {% extends "base.html" %} 17 | * 18 | * {% use "blocks.html" %} 19 | * 20 | * {% block title %}{% endblock %} 21 | * {% block content %}{% endblock %} 22 | * 23 | * 24 | * @see http://www.twig-project.org/doc/templates.html#horizontal-reuse for details. 25 | */ 26 | class Twig_TokenParser_Use extends Twig_TokenParser 27 | { 28 | /** 29 | * Parses a token and returns a node. 30 | * 31 | * @param Twig_Token $token A Twig_Token instance 32 | * 33 | * @return Twig_NodeInterface A Twig_NodeInterface instance 34 | */ 35 | public function parse(Twig_Token $token) 36 | { 37 | $template = $this->parser->getExpressionParser()->parseExpression(); 38 | 39 | if (!$template instanceof Twig_Node_Expression_Constant) { 40 | throw new Twig_Error_Syntax('The template references in a "use" statement must be a string.', $token->getLine()); 41 | } 42 | 43 | $stream = $this->parser->getStream(); 44 | 45 | $targets = array(); 46 | if ($stream->test('with')) { 47 | $stream->next(); 48 | 49 | do { 50 | $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 51 | 52 | $alias = $name; 53 | if ($stream->test('as')) { 54 | $stream->next(); 55 | 56 | $alias = $stream->expect(Twig_Token::NAME_TYPE)->getValue(); 57 | } 58 | 59 | $targets[$name] = new Twig_Node_Expression_Constant($alias, -1); 60 | 61 | if (!$stream->test(Twig_Token::PUNCTUATION_TYPE, ',')) { 62 | break; 63 | } 64 | 65 | $stream->next(); 66 | } while (true); 67 | } 68 | 69 | $stream->expect(Twig_Token::BLOCK_END_TYPE); 70 | 71 | $this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets)))); 72 | 73 | return null; 74 | } 75 | 76 | /** 77 | * Gets the tag name associated with this token parser. 78 | * 79 | * @return string The tag name 80 | */ 81 | public function getTag() 82 | { 83 | return 'use'; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParserBroker.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface 20 | { 21 | protected $parser; 22 | protected $parsers = array(); 23 | protected $brokers = array(); 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array|Traversable $parsers A Traversable of Twig_TokenParserInterface instances 29 | * @param array|Traversable $brokers A Traversable of Twig_TokenParserBrokerInterface instances 30 | */ 31 | public function __construct($parsers = array(), $brokers = array()) 32 | { 33 | foreach ($parsers as $parser) { 34 | if (!$parser instanceof Twig_TokenParserInterface) { 35 | throw new Twig_Error('$parsers must a an array of Twig_TokenParserInterface'); 36 | } 37 | $this->parsers[$parser->getTag()] = $parser; 38 | } 39 | foreach ($brokers as $broker) { 40 | if (!$broker instanceof Twig_TokenParserBrokerInterface) { 41 | throw new Twig_Error('$brokers must a an array of Twig_TokenParserBrokerInterface'); 42 | } 43 | $this->brokers[] = $broker; 44 | } 45 | } 46 | 47 | /** 48 | * Adds a TokenParser. 49 | * 50 | * @param Twig_TokenParserInterface $parser A Twig_TokenParserInterface instance 51 | */ 52 | public function addTokenParser(Twig_TokenParserInterface $parser) 53 | { 54 | $this->parsers[$parser->getTag()] = $parser; 55 | } 56 | 57 | /** 58 | * Adds a TokenParserBroker. 59 | * 60 | * @param Twig_TokenParserBroker $broker A Twig_TokenParserBroker instance 61 | */ 62 | public function addTokenParserBroker(Twig_TokenParserBroker $broker) 63 | { 64 | $this->brokers[] = $broker; 65 | } 66 | 67 | /** 68 | * Gets a suitable TokenParser for a tag. 69 | * 70 | * First looks in parsers, then in brokers. 71 | * 72 | * @param string $tag A tag name 73 | * 74 | * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found 75 | */ 76 | public function getTokenParser($tag) 77 | { 78 | if (isset($this->parsers[$tag])) { 79 | return $this->parsers[$tag]; 80 | } 81 | $broker = end($this->brokers); 82 | while (false !== $broker) { 83 | $parser = $broker->getTokenParser($tag); 84 | if (null !== $parser) { 85 | return $parser; 86 | } 87 | $broker = prev($this->brokers); 88 | } 89 | 90 | return null; 91 | } 92 | 93 | public function getParsers() 94 | { 95 | return $this->parsers; 96 | } 97 | 98 | public function getParser() 99 | { 100 | return $this->parser; 101 | } 102 | 103 | public function setParser(Twig_ParserInterface $parser) 104 | { 105 | $this->parser = $parser; 106 | foreach ($this->parsers as $tokenParser) { 107 | $tokenParser->setParser($parser); 108 | } 109 | foreach ($this->brokers as $broker) { 110 | $broker->setParser($parser); 111 | } 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParserBrokerInterface.php: -------------------------------------------------------------------------------- 1 | 20 | */ 21 | interface Twig_TokenParserBrokerInterface 22 | { 23 | /** 24 | * Gets a TokenParser suitable for a tag. 25 | * 26 | * @param string $tag A tag name 27 | * 28 | * @return null|Twig_TokenParserInterface A Twig_TokenParserInterface or null if no suitable TokenParser was found 29 | */ 30 | function getTokenParser($tag); 31 | 32 | /** 33 | * Calls Twig_TokenParserInterface::setParser on all parsers the implementation knows of. 34 | * 35 | * @param Twig_ParserInterface $parser A Twig_ParserInterface interface 36 | */ 37 | function setParser(Twig_ParserInterface $parser); 38 | 39 | /** 40 | * Gets the Twig_ParserInterface. 41 | * 42 | * @return null|Twig_ParserInterface A Twig_ParserInterface instance of null 43 | */ 44 | function getParser(); 45 | } 46 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenParserInterface.php: -------------------------------------------------------------------------------- 1 | 17 | */ 18 | interface Twig_TokenParserInterface 19 | { 20 | /** 21 | * Sets the parser associated with this token parser 22 | * 23 | * @param $parser A Twig_Parser instance 24 | */ 25 | function setParser(Twig_Parser $parser); 26 | 27 | /** 28 | * Parses a token and returns a node. 29 | * 30 | * @param Twig_Token $token A Twig_Token instance 31 | * 32 | * @return Twig_NodeInterface A Twig_NodeInterface instance 33 | */ 34 | function parse(Twig_Token $token); 35 | 36 | /** 37 | * Gets the tag name associated with this token parser. 38 | * 39 | * @return string The tag name 40 | */ 41 | function getTag(); 42 | } 43 | -------------------------------------------------------------------------------- /vendor/Twig/lib/Twig/TokenStream.php: -------------------------------------------------------------------------------- 1 | 18 | */ 19 | class Twig_TokenStream 20 | { 21 | protected $tokens; 22 | protected $current; 23 | protected $filename; 24 | 25 | /** 26 | * Constructor. 27 | * 28 | * @param array $tokens An array of tokens 29 | * @param string $filename The name of the filename which tokens are associated with 30 | */ 31 | public function __construct(array $tokens, $filename = null) 32 | { 33 | $this->tokens = $tokens; 34 | $this->current = 0; 35 | $this->filename = $filename; 36 | } 37 | 38 | /** 39 | * Returns a string representation of the token stream. 40 | * 41 | * @return string 42 | */ 43 | public function __toString() 44 | { 45 | return implode("\n", $this->tokens); 46 | } 47 | 48 | /** 49 | * Sets the pointer to the next token and returns the old one. 50 | * 51 | * @return Twig_Token 52 | */ 53 | public function next() 54 | { 55 | if (!isset($this->tokens[++$this->current])) { 56 | throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); 57 | } 58 | 59 | return $this->tokens[$this->current - 1]; 60 | } 61 | 62 | /** 63 | * Tests a token and returns it or throws a syntax error. 64 | * 65 | * @return Twig_Token 66 | */ 67 | public function expect($type, $value = null, $message = null) 68 | { 69 | $token = $this->tokens[$this->current]; 70 | if (!$token->test($type, $value)) { 71 | $line = $token->getLine(); 72 | throw new Twig_Error_Syntax(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', 73 | $message ? $message.'. ' : '', 74 | Twig_Token::typeToEnglish($token->getType(), $line), $token->getValue(), 75 | Twig_Token::typeToEnglish($type, $line), $value ? sprintf(' with value "%s"', $value) : ''), 76 | $line, 77 | $this->filename 78 | ); 79 | } 80 | $this->next(); 81 | 82 | return $token; 83 | } 84 | 85 | /** 86 | * Looks at the next token. 87 | * 88 | * @param integer $number 89 | * 90 | * @return Twig_Token 91 | */ 92 | public function look($number = 1) 93 | { 94 | if (!isset($this->tokens[$this->current + $number])) { 95 | throw new Twig_Error_Syntax('Unexpected end of template', -1, $this->filename); 96 | } 97 | 98 | return $this->tokens[$this->current + $number]; 99 | } 100 | 101 | /** 102 | * Tests the current token 103 | * 104 | * @return bool 105 | */ 106 | public function test($primary, $secondary = null) 107 | { 108 | return $this->tokens[$this->current]->test($primary, $secondary); 109 | } 110 | 111 | /** 112 | * Checks if end of stream was reached 113 | * 114 | * @return bool 115 | */ 116 | public function isEOF() 117 | { 118 | return $this->tokens[$this->current]->getType() === Twig_Token::EOF_TYPE; 119 | } 120 | 121 | /** 122 | * Gets the current token 123 | * 124 | * @return Twig_Token 125 | */ 126 | public function getCurrent() 127 | { 128 | return $this->tokens[$this->current]; 129 | } 130 | 131 | /** 132 | * Gets the filename associated with this stream 133 | * 134 | * @return string 135 | */ 136 | public function getFilename() 137 | { 138 | return $this->filename; 139 | } 140 | } 141 | --------------------------------------------------------------------------------