PEEL Shopping
Open source ecommerce : PEEL Shopping
Name.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of Twig.
5  *
6  * (c) 2009 Fabien Potencier
7  * (c) 2009 Armin Ronacher
8  *
9  * For the full copyright and license information, please view the LICENSE
10  * file that was distributed with this source code.
11  */
13 {
14  protected $specialVars = array(
15  '_self' => '$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, 'always_defined' => 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  } elseif ($this->getAttribute('always_defined')) {
38  $compiler
39  ->raw('$context[')
40  ->string($name)
41  ->raw(']')
42  ;
43  } else {
44  // remove the non-PHP 5.4 version when PHP 5.3 support is dropped
45  // as the non-optimized version is just a workaround for slow ternary operator
46  // when the context has a lot of variables
47  if (version_compare(phpversion(), '5.4.0RC1', '>=')) {
48  // PHP 5.4 ternary operator performance was optimized
49  $compiler
50  ->raw('(isset($context[')
51  ->string($name)
52  ->raw(']) ? $context[')
53  ->string($name)
54  ->raw('] : ')
55  ;
56 
57  if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
58  $compiler->raw('null)');
59  } else {
60  $compiler->raw('$this->getContext($context, ')->string($name)->raw('))');
61  }
62  } else {
63  $compiler
64  ->raw('$this->getContext($context, ')
65  ->string($name)
66  ;
67 
68  if ($this->getAttribute('ignore_strict_check')) {
69  $compiler->raw(', true');
70  }
71 
72  $compiler
73  ->raw(')')
74  ;
75  }
76  }
77  }
78 
79  public function isSpecial()
80  {
81  return isset($this->specialVars[$this->getAttribute('name')]);
82  }
83 
84  public function isSimple()
85  {
86  return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
87  }
88 }
Compiles a node to PHP code.
Definition: Compiler.php:18
compile(Twig_Compiler $compiler)
Compiles the node to PHP.
Definition: Name.php:25
__construct($name, $lineno)
Definition: Name.php:20
getAttribute($name)
Gets an attribute.
Definition: Node.php:138
$lineno
Definition: Node.php:22
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
Abstract class for all nodes that represents an expression.
Definition: Expression.php:18
getEnvironment()
Returns the environment instance related to this compiler.
Definition: Compiler.php:50
repr($value)
Returns a PHP representation of a given value.
Definition: Compiler.php:165
raw($string)
Adds a raw string to the compiled code.
Definition: Compiler.php:109

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:18 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.