[ Index ] |
PHP Cross Reference of phpBB-3.3.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * 4 * This file is part of the phpBB Forum Software package. 5 * 6 * @copyright (c) phpBB Limited <https://www.phpbb.com> 7 * Sections (c) 2009 Fabien Potencier, Armin Ronacher 8 * @license GNU General Public License, version 2 (GPL-2.0) 9 * 10 * For full copyright and license information, please see 11 * the docs/CREDITS.txt file. 12 * 13 */ 14 15 namespace phpbb\template\twig\node; 16 17 class includephp extends \Twig\Node\Node 18 { 19 /** @var \Twig\Environment */ 20 protected $environment; 21 22 public function __construct(\Twig\Node\Expression\AbstractExpression $expr, \phpbb\template\twig\environment $environment, $lineno, $ignoreMissing = false, $tag = null) 23 { 24 $this->environment = $environment; 25 26 parent::__construct(array('expr' => $expr), array('ignore_missing' => (Boolean) $ignoreMissing), $lineno, $tag); 27 } 28 29 /** 30 * Compiles the node to PHP. 31 * 32 * @param \Twig\Compiler A Twig\Compiler instance 33 */ 34 public function compile(\Twig\Compiler $compiler) 35 { 36 $compiler->addDebugInfo($this); 37 38 $config = $this->environment->get_phpbb_config(); 39 40 if (!$config['tpl_allow_php']) 41 { 42 $compiler 43 ->write("// INCLUDEPHP Disabled\n") 44 ; 45 46 return; 47 } 48 49 if ($this->getAttribute('ignore_missing')) 50 { 51 $compiler 52 ->write("try {\n") 53 ->indent() 54 ; 55 } 56 57 $compiler 58 ->write("\$location = ") 59 ->subcompile($this->getNode('expr')) 60 ->raw(";\n") 61 ->write("if (phpbb_is_absolute(\$location)) {\n") 62 ->indent() 63 // Absolute path specified 64 ->write("require(\$location);\n") 65 ->outdent() 66 ->write("} else if (file_exists(\$this->env->get_phpbb_root_path() . \$location)) {\n") 67 ->indent() 68 // PHP file relative to phpbb_root_path 69 ->write("require(\$this->env->get_phpbb_root_path() . \$location);\n") 70 ->outdent() 71 ->write("} else {\n") 72 ->indent() 73 // Local path (behaves like INCLUDE) 74 ->write("require(\$this->env->getLoader()->getCacheKey(\$location));\n") 75 ->outdent() 76 ->write("}\n") 77 ; 78 79 if ($this->getAttribute('ignore_missing')) 80 { 81 $compiler 82 ->outdent() 83 ->write("} catch (\Twig\Error\LoaderError \$e) {\n") 84 ->indent() 85 ->write("// ignore missing template\n") 86 ->outdent() 87 ->write("}\n\n") 88 ; 89 } 90 } 91 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Jun 23 12:25:44 2024 | Cross-referenced by PHPXref 0.7.1 |