Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

event.php

Zuletzt modifiziert: 09.10.2024, 12:55 - Dateigröße: 2.33 KiB


 01  <?php
 02  /**
 03  *
 04  * This file is part of the phpBB Forum Software package.
 05  *
 06  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 07  * @license GNU General Public License, version 2 (GPL-2.0)
 08  *
 09  * For full copyright and license information, please see
 10  * the docs/CREDITS.txt file.
 11  *
 12  */
 13   
 14  namespace phpbb\template\twig\node;
 15   
 16  class event extends \Twig_Node
 17  {
 18      /**
 19      * The subdirectory in which all template listener files must be placed
 20      * @var string
 21      */
 22      protected $listener_directory = 'event/';
 23   
 24      /** @var \Twig_Environment */
 25      protected $environment;
 26   
 27      public function __construct(\Twig_Node_Expression $expr, \phpbb\template\twig\environment $environment, $lineno, $tag = null)
 28      {
 29          $this->environment = $environment;
 30   
 31          parent::__construct(array('expr' => $expr), array(), $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->addDebugInfo($this);
 42   
 43          $location = $this->listener_directory . $this->getNode('expr')->getAttribute('name');
 44   
 45          foreach ($this->environment->get_phpbb_extensions() as $ext_namespace => $ext_path)
 46          {
 47              $ext_namespace = str_replace('/', '_', $ext_namespace);
 48   
 49              if ($this->environment->isDebug())
 50              {
 51                  // If debug mode is enabled, lets check for new/removed EVENT
 52                  //  templates on page load rather than at compile. This is
 53                  //  slower, but makes developing extensions easier (no need to
 54                  //  purge the cache when a new event template file is added)
 55                  $compiler
 56                      ->write("if (\$this->env->getLoader()->exists('@{$ext_namespace}/{$location}.html')) {\n")
 57                      ->indent()
 58                  ;
 59              }
 60   
 61              if ($this->environment->isDebug() || $this->environment->getLoader()->exists('@' . $ext_namespace . '/' . $location . '.html'))
 62              {
 63                  $compiler
 64                      ->write("\$previous_look_up_order = \$this->env->getNamespaceLookUpOrder();\n")
 65   
 66                      // We set the namespace lookup order to be this extension first, then the main path
 67                      ->write("\$this->env->setNamespaceLookUpOrder(array('{$ext_namespace}', '__main__'));\n")
 68                      ->write("\$this->env->loadTemplate('@{$ext_namespace}/{$location}.html')->display(\$context);\n")
 69                      ->write("\$this->env->setNamespaceLookUpOrder(\$previous_look_up_order);\n")
 70                  ;
 71              }
 72   
 73              if ($this->environment->isDebug())
 74              {
 75                  $compiler
 76                      ->outdent()
 77                      ->write("}\n\n")
 78                  ;
 79              }
 80          }
 81      }
 82  }
 83