PEEL Shopping
Open source ecommerce : PEEL Shopping
Environment.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  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11 
18 {
19  const VERSION = '1.13.2';
20 
21  protected $charset;
22  protected $loader;
23  protected $debug;
24  protected $autoReload;
25  protected $cache;
26  protected $lexer;
27  protected $parser;
28  protected $compiler;
29  protected $baseTemplateClass;
30  protected $extensions;
31  protected $parsers;
32  protected $visitors;
33  protected $filters;
34  protected $tests;
35  protected $functions;
36  protected $globals;
39  protected $loadedTemplates;
40  protected $strictVariables;
41  protected $unaryOperators;
42  protected $binaryOperators;
43  protected $templateClassPrefix = '__TwigTemplate_';
44  protected $functionCallbacks;
45  protected $filterCallbacks;
46  protected $staging;
47 
84  public function __construct(Twig_LoaderInterface $loader = null, $options = array())
85  {
86  if (null !== $loader) {
87  $this->setLoader($loader);
88  }
89 
90  $options = array_merge(array(
91  'debug' => false,
92  'charset' => 'UTF-8',
93  'base_template_class' => 'Twig_Template',
94  'strict_variables' => false,
95  'autoescape' => 'html',
96  'cache' => false,
97  'auto_reload' => null,
98  'optimizations' => -1,
99  ), $options);
100 
101  $this->debug = (bool) $options['debug'];
102  $this->charset = strtoupper($options['charset']);
103  $this->baseTemplateClass = $options['base_template_class'];
104  $this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
105  $this->strictVariables = (bool) $options['strict_variables'];
106  $this->runtimeInitialized = false;
107  $this->setCache($options['cache']);
108  $this->functionCallbacks = array();
109  $this->filterCallbacks = array();
110 
111  $this->addExtension(new Twig_Extension_Core());
112  $this->addExtension(new Twig_Extension_Escaper($options['autoescape']));
113  $this->addExtension(new Twig_Extension_Optimizer($options['optimizations']));
114  $this->extensionInitialized = false;
115  $this->staging = new Twig_Extension_Staging();
116  }
117 
123  public function getBaseTemplateClass()
124  {
126  }
127 
133  public function setBaseTemplateClass($class)
134  {
135  $this->baseTemplateClass = $class;
136  }
137 
141  public function enableDebug()
142  {
143  $this->debug = true;
144  }
145 
149  public function disableDebug()
150  {
151  $this->debug = false;
152  }
153 
159  public function isDebug()
160  {
161  return $this->debug;
162  }
163 
167  public function enableAutoReload()
168  {
169  $this->autoReload = true;
170  }
171 
175  public function disableAutoReload()
176  {
177  $this->autoReload = false;
178  }
179 
185  public function isAutoReload()
186  {
187  return $this->autoReload;
188  }
189 
193  public function enableStrictVariables()
194  {
195  $this->strictVariables = true;
196  }
197 
201  public function disableStrictVariables()
202  {
203  $this->strictVariables = false;
204  }
205 
211  public function isStrictVariables()
212  {
213  return $this->strictVariables;
214  }
215 
221  public function getCache()
222  {
223  return $this->cache;
224  }
225 
232  public function setCache($cache)
233  {
234  $this->cache = $cache ? $cache : false;
235  }
236 
244  public function getCacheFilename($name)
245  {
246  if (false === $this->cache) {
247  return false;
248  }
249 
250  $class = substr($this->getTemplateClass($name), strlen($this->templateClassPrefix));
251 
252  return $this->getCache().'/'.substr($class, 0, 2).'/'.substr($class, 2, 2).'/'.substr($class, 4).'.php';
253  }
254 
263  public function getTemplateClass($name, $index = null)
264  {
265  return $this->templateClassPrefix.md5($this->getLoader()->getCacheKey($name)).(null === $index ? '' : '_'.$index);
266  }
267 
273  public function getTemplateClassPrefix()
274  {
276  }
277 
286  public function render($name, array $context = array())
287  {
288  return $this->loadTemplate($name)->render($context);
289  }
290 
297  public function display($name, array $context = array())
298  {
299  $this->loadTemplate($name)->display($context);
300  }
301 
310  public function loadTemplate($name, $index = null)
311  {
312  $cls = $this->getTemplateClass($name, $index);
313 
314  if (isset($this->loadedTemplates[$cls])) {
315  return $this->loadedTemplates[$cls];
316  }
317 
318  if (!class_exists($cls, false)) {
319  if (false === $cache = $this->getCacheFilename($name)) {
320  eval('?>'.$this->compileSource($this->getLoader()->getSource($name), $name));
321  } else {
322  if (!is_file($cache) || ($this->isAutoReload() && !$this->isTemplateFresh($name, filemtime($cache)))) {
323  $this->writeCacheFile($cache, $this->compileSource($this->getLoader()->getSource($name), $name));
324  }
325 
326  require_once $cache;
327  }
328  }
329 
330  if (!$this->runtimeInitialized) {
331  $this->initRuntime();
332  }
333 
334  return $this->loadedTemplates[$cls] = new $cls($this);
335  }
336 
349  public function isTemplateFresh($name, $time)
350  {
351  foreach ($this->extensions as $extension) {
352  $r = new ReflectionObject($extension);
353  if (filemtime($r->getFileName()) > $time) {
354  return false;
355  }
356  }
357 
358  return $this->getLoader()->isFresh($name, $time);
359  }
360 
361  public function resolveTemplate($names)
362  {
363  if (!is_array($names)) {
364  $names = array($names);
365  }
366 
367  foreach ($names as $name) {
368  if ($name instanceof Twig_Template) {
369  return $name;
370  }
371 
372  try {
373  return $this->loadTemplate($name);
374  } catch (Twig_Error_Loader $e) {
375  }
376  }
377 
378  if (1 === count($names)) {
379  throw $e;
380  }
381 
382  throw new Twig_Error_Loader(sprintf('Unable to find one of the following templates: "%s".', implode('", "', $names)));
383  }
384 
388  public function clearTemplateCache()
389  {
390  $this->loadedTemplates = array();
391  }
392 
396  public function clearCacheFiles()
397  {
398  if (false === $this->cache) {
399  return;
400  }
401 
402  foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->cache), RecursiveIteratorIterator::LEAVES_ONLY) as $file) {
403  if ($file->isFile()) {
404  @unlink($file->getPathname());
405  }
406  }
407  }
408 
414  public function getLexer()
415  {
416  if (null === $this->lexer) {
417  $this->lexer = new Twig_Lexer($this);
418  }
419 
420  return $this->lexer;
421  }
422 
429  {
430  $this->lexer = $lexer;
431  }
432 
441  public function tokenize($source, $name = null)
442  {
443  return $this->getLexer()->tokenize($source, $name);
444  }
445 
451  public function getParser()
452  {
453  if (null === $this->parser) {
454  $this->parser = new Twig_Parser($this);
455  }
456 
457  return $this->parser;
458  }
459 
466  {
467  $this->parser = $parser;
468  }
469 
477  public function parse(Twig_TokenStream $tokens)
478  {
479  return $this->getParser()->parse($tokens);
480  }
481 
487  public function getCompiler()
488  {
489  if (null === $this->compiler) {
490  $this->compiler = new Twig_Compiler($this);
491  }
492 
493  return $this->compiler;
494  }
495 
502  {
503  $this->compiler = $compiler;
504  }
505 
513  public function compile(Twig_NodeInterface $node)
514  {
515  return $this->getCompiler()->compile($node)->getSource();
516  }
517 
526  public function compileSource($source, $name = null)
527  {
528  try {
529  return $this->compile($this->parse($this->tokenize($source, $name)));
530  } catch (Twig_Error $e) {
531  $e->setTemplateFile($name);
532  throw $e;
533  } catch (Exception $e) {
534  throw new Twig_Error_Runtime(sprintf('An exception has been thrown during the compilation of a template ("%s").', $e->getMessage()), -1, $name, $e);
535  }
536  }
537 
544  {
545  $this->loader = $loader;
546  }
547 
553  public function getLoader()
554  {
555  if (null === $this->loader) {
556  throw new LogicException('You must set a loader first.');
557  }
558 
559  return $this->loader;
560  }
561 
567  public function setCharset($charset)
568  {
569  $this->charset = strtoupper($charset);
570  }
571 
577  public function getCharset()
578  {
579  return $this->charset;
580  }
581 
585  public function initRuntime()
586  {
587  $this->runtimeInitialized = true;
588 
589  foreach ($this->getExtensions() as $extension) {
590  $extension->initRuntime($this);
591  }
592  }
593 
601  public function hasExtension($name)
602  {
603  return isset($this->extensions[$name]);
604  }
605 
613  public function getExtension($name)
614  {
615  if (!isset($this->extensions[$name])) {
616  throw new Twig_Error_Runtime(sprintf('The "%s" extension is not enabled.', $name));
617  }
618 
619  return $this->extensions[$name];
620  }
621 
628  {
629  if ($this->extensionInitialized) {
630  throw new LogicException(sprintf('Unable to register extension "%s" as extensions have already been initialized.', $extension->getName()));
631  }
632 
633  $this->extensions[$extension->getName()] = $extension;
634  }
635 
645  public function removeExtension($name)
646  {
647  if ($this->extensionInitialized) {
648  throw new LogicException(sprintf('Unable to remove extension "%s" as extensions have already been initialized.', $name));
649  }
650 
651  unset($this->extensions[$name]);
652  }
653 
659  public function setExtensions(array $extensions)
660  {
661  foreach ($extensions as $extension) {
662  $this->addExtension($extension);
663  }
664  }
665 
671  public function getExtensions()
672  {
673  return $this->extensions;
674  }
675 
682  {
683  if ($this->extensionInitialized) {
684  throw new LogicException('Unable to add a token parser as extensions have already been initialized.');
685  }
686 
687  $this->staging->addTokenParser($parser);
688  }
689 
695  public function getTokenParsers()
696  {
697  if (!$this->extensionInitialized) {
698  $this->initExtensions();
699  }
700 
701  return $this->parsers;
702  }
703 
711  public function getTags()
712  {
713  $tags = array();
714  foreach ($this->getTokenParsers()->getParsers() as $parser) {
715  if ($parser instanceof Twig_TokenParserInterface) {
716  $tags[$parser->getTag()] = $parser;
717  }
718  }
719 
720  return $tags;
721  }
722 
728  public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
729  {
730  if ($this->extensionInitialized) {
731  throw new LogicException('Unable to add a node visitor as extensions have already been initialized.');
732  }
733 
734  $this->staging->addNodeVisitor($visitor);
735  }
736 
742  public function getNodeVisitors()
743  {
744  if (!$this->extensionInitialized) {
745  $this->initExtensions();
746  }
747 
748  return $this->visitors;
749  }
750 
757  public function addFilter($name, $filter = null)
758  {
759  if (!$name instanceof Twig_SimpleFilter && !($filter instanceof Twig_SimpleFilter || $filter instanceof Twig_FilterInterface)) {
760  throw new LogicException('A filter must be an instance of Twig_FilterInterface or Twig_SimpleFilter');
761  }
762 
763  if ($name instanceof Twig_SimpleFilter) {
764  $filter = $name;
765  $name = $filter->getName();
766  }
767 
768  if ($this->extensionInitialized) {
769  throw new LogicException(sprintf('Unable to add filter "%s" as extensions have already been initialized.', $name));
770  }
771 
772  $this->staging->addFilter($name, $filter);
773  }
774 
785  public function getFilter($name)
786  {
787  if (!$this->extensionInitialized) {
788  $this->initExtensions();
789  }
790 
791  if (isset($this->filters[$name])) {
792  return $this->filters[$name];
793  }
794 
795  foreach ($this->filters as $pattern => $filter) {
796  $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
797 
798  if ($count) {
799  if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
800  array_shift($matches);
801  $filter->setArguments($matches);
802 
803  return $filter;
804  }
805  }
806  }
807 
808  foreach ($this->filterCallbacks as $callback) {
809  if (false !== $filter = call_user_func($callback, $name)) {
810  return $filter;
811  }
812  }
813 
814  return false;
815  }
816 
817  public function registerUndefinedFilterCallback($callable)
818  {
819  $this->filterCallbacks[] = $callable;
820  }
821 
831  public function getFilters()
832  {
833  if (!$this->extensionInitialized) {
834  $this->initExtensions();
835  }
836 
837  return $this->filters;
838  }
839 
846  public function addTest($name, $test = null)
847  {
848  if (!$name instanceof Twig_SimpleTest && !($test instanceof Twig_SimpleTest || $test instanceof Twig_TestInterface)) {
849  throw new LogicException('A test must be an instance of Twig_TestInterface or Twig_SimpleTest');
850  }
851 
852  if ($name instanceof Twig_SimpleTest) {
853  $test = $name;
854  $name = $test->getName();
855  }
856 
857  if ($this->extensionInitialized) {
858  throw new LogicException(sprintf('Unable to add test "%s" as extensions have already been initialized.', $name));
859  }
860 
861  $this->staging->addTest($name, $test);
862  }
863 
869  public function getTests()
870  {
871  if (!$this->extensionInitialized) {
872  $this->initExtensions();
873  }
874 
875  return $this->tests;
876  }
877 
885  public function getTest($name)
886  {
887  if (!$this->extensionInitialized) {
888  $this->initExtensions();
889  }
890 
891  if (isset($this->tests[$name])) {
892  return $this->tests[$name];
893  }
894 
895  return false;
896  }
897 
904  public function addFunction($name, $function = null)
905  {
906  if (!$name instanceof Twig_SimpleFunction && !($function instanceof Twig_SimpleFunction || $function instanceof Twig_FunctionInterface)) {
907  throw new LogicException('A function must be an instance of Twig_FunctionInterface or Twig_SimpleFunction');
908  }
909 
910  if ($name instanceof Twig_SimpleFunction) {
911  $function = $name;
912  $name = $function->getName();
913  }
914 
915  if ($this->extensionInitialized) {
916  throw new LogicException(sprintf('Unable to add function "%s" as extensions have already been initialized.', $name));
917  }
918 
919  $this->staging->addFunction($name, $function);
920  }
921 
932  public function getFunction($name)
933  {
934  if (!$this->extensionInitialized) {
935  $this->initExtensions();
936  }
937 
938  if (isset($this->functions[$name])) {
939  return $this->functions[$name];
940  }
941 
942  foreach ($this->functions as $pattern => $function) {
943  $pattern = str_replace('\\*', '(.*?)', preg_quote($pattern, '#'), $count);
944 
945  if ($count) {
946  if (preg_match('#^'.$pattern.'$#', $name, $matches)) {
947  array_shift($matches);
948  $function->setArguments($matches);
949 
950  return $function;
951  }
952  }
953  }
954 
955  foreach ($this->functionCallbacks as $callback) {
956  if (false !== $function = call_user_func($callback, $name)) {
957  return $function;
958  }
959  }
960 
961  return false;
962  }
963 
964  public function registerUndefinedFunctionCallback($callable)
965  {
966  $this->functionCallbacks[] = $callable;
967  }
968 
978  public function getFunctions()
979  {
980  if (!$this->extensionInitialized) {
981  $this->initExtensions();
982  }
983 
984  return $this->functions;
985  }
986 
996  public function addGlobal($name, $value)
997  {
998  if ($this->extensionInitialized || $this->runtimeInitialized) {
999  if (null === $this->globals) {
1000  $this->globals = $this->initGlobals();
1001  }
1002 
1003  /* This condition must be uncommented in Twig 2.0
1004  if (!array_key_exists($name, $this->globals)) {
1005  throw new LogicException(sprintf('Unable to add global "%s" as the runtime or the extensions have already been initialized.', $name));
1006  }
1007  */
1008  }
1009 
1010  if ($this->extensionInitialized || $this->runtimeInitialized) {
1011  // update the value
1012  $this->globals[$name] = $value;
1013  } else {
1014  $this->staging->addGlobal($name, $value);
1015  }
1016  }
1017 
1023  public function getGlobals()
1024  {
1025  if (!$this->runtimeInitialized && !$this->extensionInitialized) {
1026  return $this->initGlobals();
1027  }
1028 
1029  if (null === $this->globals) {
1030  $this->globals = $this->initGlobals();
1031  }
1032 
1033  return $this->globals;
1034  }
1035 
1043  public function mergeGlobals(array $context)
1044  {
1045  // we don't use array_merge as the context being generally
1046  // bigger than globals, this code is faster.
1047  foreach ($this->getGlobals() as $key => $value) {
1048  if (!array_key_exists($key, $context)) {
1049  $context[$key] = $value;
1050  }
1051  }
1052 
1053  return $context;
1054  }
1055 
1061  public function getUnaryOperators()
1062  {
1063  if (!$this->extensionInitialized) {
1064  $this->initExtensions();
1065  }
1066 
1067  return $this->unaryOperators;
1068  }
1069 
1075  public function getBinaryOperators()
1076  {
1077  if (!$this->extensionInitialized) {
1078  $this->initExtensions();
1079  }
1080 
1081  return $this->binaryOperators;
1082  }
1083 
1084  public function computeAlternatives($name, $items)
1085  {
1086  $alternatives = array();
1087  foreach ($items as $item) {
1088  $lev = levenshtein($name, $item);
1089  if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1090  $alternatives[$item] = $lev;
1091  }
1092  }
1093  asort($alternatives);
1094 
1095  return array_keys($alternatives);
1096  }
1097 
1098  protected function initGlobals()
1099  {
1100  $globals = array();
1101  foreach ($this->extensions as $extension) {
1102  $extGlob = $extension->getGlobals();
1103  if (!is_array($extGlob)) {
1104  throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
1105  }
1106 
1107  $globals[] = $extGlob;
1108  }
1109 
1110  $globals[] = $this->staging->getGlobals();
1111 
1112  return call_user_func_array('array_merge', $globals);
1113  }
1114 
1115  protected function initExtensions()
1116  {
1117  if ($this->extensionInitialized) {
1118  return;
1119  }
1120 
1121  $this->extensionInitialized = true;
1122  $this->parsers = new Twig_TokenParserBroker();
1123  $this->filters = array();
1124  $this->functions = array();
1125  $this->tests = array();
1126  $this->visitors = array();
1127  $this->unaryOperators = array();
1128  $this->binaryOperators = array();
1129 
1130  foreach ($this->extensions as $extension) {
1131  $this->initExtension($extension);
1132  }
1133  $this->initExtension($this->staging);
1134  }
1135 
1137  {
1138  // filters
1139  foreach ($extension->getFilters() as $name => $filter) {
1140  if ($name instanceof Twig_SimpleFilter) {
1141  $filter = $name;
1142  $name = $filter->getName();
1143  } elseif ($filter instanceof Twig_SimpleFilter) {
1144  $name = $filter->getName();
1145  }
1146 
1147  $this->filters[$name] = $filter;
1148  }
1149 
1150  // functions
1151  foreach ($extension->getFunctions() as $name => $function) {
1152  if ($name instanceof Twig_SimpleFunction) {
1153  $function = $name;
1154  $name = $function->getName();
1155  } elseif ($function instanceof Twig_SimpleFunction) {
1156  $name = $function->getName();
1157  }
1158 
1159  $this->functions[$name] = $function;
1160  }
1161 
1162  // tests
1163  foreach ($extension->getTests() as $name => $test) {
1164  if ($name instanceof Twig_SimpleTest) {
1165  $test = $name;
1166  $name = $test->getName();
1167  } elseif ($test instanceof Twig_SimpleTest) {
1168  $name = $test->getName();
1169  }
1170 
1171  $this->tests[$name] = $test;
1172  }
1173 
1174  // token parsers
1175  foreach ($extension->getTokenParsers() as $parser) {
1176  if ($parser instanceof Twig_TokenParserInterface) {
1177  $this->parsers->addTokenParser($parser);
1179  $this->parsers->addTokenParserBroker($parser);
1180  } else {
1181  throw new LogicException('getTokenParsers() must return an array of Twig_TokenParserInterface or Twig_TokenParserBrokerInterface instances');
1182  }
1183  }
1184 
1185  // node visitors
1186  foreach ($extension->getNodeVisitors() as $visitor) {
1187  $this->visitors[] = $visitor;
1188  }
1189 
1190  // operators
1191  if ($operators = $extension->getOperators()) {
1192  if (2 !== count($operators)) {
1193  throw new InvalidArgumentException(sprintf('"%s::getOperators()" does not return a valid operators array.', get_class($extension)));
1194  }
1195 
1196  $this->unaryOperators = array_merge($this->unaryOperators, $operators[0]);
1197  $this->binaryOperators = array_merge($this->binaryOperators, $operators[1]);
1198  }
1199  }
1200 
1201  protected function writeCacheFile($file, $content)
1202  {
1203  $dir = dirname($file);
1204  if (!is_dir($dir)) {
1205  if (false === @mkdir($dir, 0777, true) && !is_dir($dir)) {
1206  throw new RuntimeException(sprintf("Unable to create the cache directory (%s).", $dir));
1207  }
1208  } elseif (!is_writable($dir)) {
1209  throw new RuntimeException(sprintf("Unable to write in the cache directory (%s).", $dir));
1210  }
1211 
1212  $tmpFile = tempnam(dirname($file), basename($file));
1213  if (false !== @file_put_contents($tmpFile, $content)) {
1214  // rename does not work on Win32 before 5.2.6
1215  if (@rename($tmpFile, $file) || (@copy($tmpFile, $file) && unlink($tmpFile))) {
1216  @chmod($file, 0666 & ~umask());
1217 
1218  return;
1219  }
1220  }
1221 
1222  throw new RuntimeException(sprintf('Failed to write cache file "%s".', $file));
1223  }
1224 }
compile(Twig_NodeInterface $node)
Compiles a Node.
clearTemplateCache()
Clears the internal template cache.
getOperators()
Returns a list of operators to add to the existing list.
getBinaryOperators()
Gets the registered binary Operators.
render($name, array $context=array())
Renders a template.
getLoader()
Gets the Loader instance.
initRuntime()
Initializes the runtime environment.
isAutoReload()
Checks if the auto_reload option is enabled.
enableAutoReload()
Enables the auto_reload option.
getCompiler()
Gets the Compiler instance.
addExtension(Twig_ExtensionInterface $extension)
Registers an extension.
Interface implemented by compiler classes.
getGlobals()
Gets the registered Globals.
getNodeVisitors()
Gets the registered Node Visitors.
addFilter($name, $filter=null)
Registers a Filter.
getNodeVisitors()
Returns the node visitor instances to add to the existing list.
setParser(Twig_ParserInterface $parser)
Sets the Parser instance.
Default implementation of a token parser broker.
if($rub=fetch_assoc($rub_query)) if(check_if_module_active('url_rewriting')) $class
Definition: index.php:68
Compiles a node to PHP code.
Definition: Compiler.php:18
Represents a template function.
Internal class.
Definition: Staging.php:19
getLexer()
Gets the Lexer instance.
getTokenParsers()
Returns the token parser instances to add to the existing list.
getFilters()
Gets the registered Filters.
getExtensions()
Returns all registered extensions.
parse(Twig_TokenStream $tokens)
Parses a token stream.
__construct(Twig_LoaderInterface $loader=null, $options=array())
Constructor.
Definition: Environment.php:84
$extension
getFunction($name)
Get a function by name.
getParser()
Gets the Parser instance.
getFilter($name)
Get a filter by name.
initExtension(Twig_ExtensionInterface $extension)
isTemplateFresh($name, $time)
Returns true if the template is still fresh.
resolveTemplate($names)
removeExtension($name)
Removes an extension by name.
computeAlternatives($name, $items)
getTests()
Gets the registered Tests.
getTemplateClass($name, $index=null)
Gets the template class associated with the given string.
Lexes a template string.
Definition: Lexer.php:18
Represents a template function.
clearCacheFiles()
Clears the template cache files on the filesystem.
Twig base exception.
Definition: Error.php:34
addFunction($name, $function=null)
Registers a Function.
setLoader(Twig_LoaderInterface $loader)
Sets the Loader instance.
isStrictVariables()
Checks if the strict_variables option is enabled.
disableDebug()
Disables debugging mode.
getCacheFilename($name)
Gets the cache filename for a given template.
setBaseTemplateClass($class)
Sets the base template class for compiled templates.
Default parser implementation.
Definition: Parser.php:18
Interface implemented by lexer classes.
disableAutoReload()
Disables the auto_reload option.
Interface implemented by token parsers.
getTests()
Returns a list of tests to add to the existing list.
getTest($name)
Gets a test by name.
getBaseTemplateClass()
Gets the base template class for compiled templates.
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
setCache($cache)
Sets the cache directory or false if cache is disabled.
getCache()
Gets the cache directory or false if cache is disabled.
compileSource($source, $name=null)
Compiles a template source code.
addGlobal($name, $value)
Registers a Global.
getName()
Returns the name of the extension.
loadTemplate($name, $index=null)
Loads a template by name.
addTokenParser(Twig_TokenParserInterface $parser)
Registers a Token Parser.
getTokenParsers()
Gets the registered Token Parsers.
isDebug()
Checks if debug mode is enabled.
Default base class for compiled templates.
Definition: Template.php:18
addTest($name, $test=null)
Registers a Test.
mergeGlobals(array $context)
Merges a context with the defined globals.
registerUndefinedFunctionCallback($callable)
Represents a token stream.
Definition: TokenStream.php:18
writeCacheFile($file, $content)
Interface implemented by token parser brokers.
Represents a template filter.
addNodeVisitor(Twig_NodeVisitorInterface $visitor)
Registers a Node Visitor.
Interface implemented by extension classes.
getFilters()
Returns a list of filters to add to the existing list.
getExtension($name)
Gets an extension by name.
Twig_NodeVisitorInterface is the interface the all node visitor classes must implement.
Represents a node in the AST.
setLexer(Twig_LexerInterface $lexer)
Sets the Lexer instance.
hasExtension($name)
Returns true if the given extension is registered.
disableStrictVariables()
Disables the strict_variables option.
getTemplateClassPrefix()
Gets the template class prefix.
registerUndefinedFilterCallback($callable)
Stores the Twig configuration.
Definition: Environment.php:17
getCharset()
Gets the default template charset.
Interface all loaders must implement.
setCompiler(Twig_CompilerInterface $compiler)
Sets the Compiler instance.
enableDebug()
Enables debugging mode.
setExtensions(array $extensions)
Registers an array of extensions.
getUnaryOperators()
Gets the registered unary Operators.
display($name, array $context=array())
Displays a template.
Represents a template test.
Definition: SimpleTest.php:17
Represents a template filter.
Represents a template test.
getFunctions()
Returns a list of functions to add to the existing list.
Exception thrown when an error occurs during template loading.
Definition: Loader.php:25
Interface implemented by parser classes.
getTags()
Gets registered tags.
Exception thrown when an error occurs at runtime.
Definition: Runtime.php:18
tokenize($source, $name=null)
Tokenizes a source code.
getFunctions()
Gets registered functions.
setTemplateFile($filename)
Sets the filename where the error occurred.
Definition: Error.php:104
enableStrictVariables()
Enables the strict_variables option.
setCharset($charset)
Sets the default template charset.

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.