Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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

environment.php

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 4.17 KiB


 001  <?php
 002  /**
 003  *
 004  * This file is part of the phpBB Forum Software package.
 005  *
 006  * @copyright (c) phpBB Limited <https://www.phpbb.com>
 007  * @license GNU General Public License, version 2 (GPL-2.0)
 008  *
 009  * For full copyright and license information, please see
 010  * the docs/CREDITS.txt file.
 011  *
 012  */
 013   
 014  namespace phpbb\template\twig;
 015   
 016  class environment extends \Twig_Environment
 017  {
 018      /** @var \phpbb\config\config */
 019      protected $phpbb_config;
 020   
 021      /** @var \phpbb\path_helper */
 022      protected $phpbb_path_helper;
 023   
 024      /** @var \phpbb\extension\manager */
 025      protected $extension_manager;
 026   
 027      /** @var string */
 028      protected $phpbb_root_path;
 029   
 030      /** @var string */
 031      protected $web_root_path;
 032   
 033      /** @var array **/
 034      protected $namespace_look_up_order = array('__main__');
 035   
 036      /**
 037      * Constructor
 038      *
 039      * @param \phpbb\config\config $phpbb_config The phpBB configuration
 040      * @param \phpbb\path_helper $path_helper phpBB path helper
 041      * @param \phpbb\extension\manager $extension_manager phpBB extension manager
 042      * @param \Twig_LoaderInterface $loader Twig loader interface
 043      * @param array $options Array of options to pass to Twig
 044      */
 045      public function __construct($phpbb_config, \phpbb\path_helper $path_helper, \phpbb\extension\manager $extension_manager = null, \Twig_LoaderInterface $loader = null, $options = array())
 046      {
 047          $this->phpbb_config = $phpbb_config;
 048   
 049          $this->phpbb_path_helper = $path_helper;
 050          $this->extension_manager = $extension_manager;
 051   
 052          $this->phpbb_root_path = $this->phpbb_path_helper->get_phpbb_root_path();
 053          $this->web_root_path = $this->phpbb_path_helper->get_web_root_path();
 054   
 055          return parent::__construct($loader, $options);
 056      }
 057   
 058      /**
 059      * Get the list of enabled phpBB extensions
 060      *
 061      * Used in EVENT node
 062      *
 063      * @return array
 064      */
 065      public function get_phpbb_extensions()
 066      {
 067          return ($this->extension_manager) ? $this->extension_manager->all_enabled() : array();
 068      }
 069   
 070      /**
 071      * Get phpBB config
 072      *
 073      * @return \phpbb\config\config
 074      */
 075      public function get_phpbb_config()
 076      {
 077          return $this->phpbb_config;
 078      }
 079   
 080      /**
 081      * Get the phpBB root path
 082      *
 083      * @return string
 084      */
 085      public function get_phpbb_root_path()
 086      {
 087          return $this->phpbb_root_path;
 088      }
 089   
 090      /**
 091      * Get the web root path
 092      *
 093      * @return string
 094      */
 095      public function get_web_root_path()
 096      {
 097          return $this->web_root_path;
 098      }
 099   
 100      /**
 101      * Get the phpbb path helper object
 102      *
 103      * @return \phpbb\path_helper
 104      */
 105      public function get_path_helper()
 106      {
 107          return $this->phpbb_path_helper;
 108      }
 109   
 110      /**
 111      * Get the namespace look up order
 112      *
 113      * @return array
 114      */
 115      public function getNamespaceLookUpOrder()
 116      {
 117          return $this->namespace_look_up_order;
 118      }
 119   
 120      /**
 121      * Set the namespace look up order to load templates from
 122      *
 123      * @param array $namespace
 124      * @return \Twig_Environment
 125      */
 126      public function setNamespaceLookUpOrder($namespace)
 127      {
 128          $this->namespace_look_up_order = $namespace;
 129   
 130          return $this;
 131      }
 132   
 133      /**
 134      * Loads a template by name.
 135      *
 136      * @param string  $name  The template name
 137      * @param integer $index The index if it is an embedded template
 138      * @return \Twig_TemplateInterface A template instance representing the given template name
 139      * @throws \Twig_Error_Loader
 140      */
 141      public function loadTemplate($name, $index = null)
 142      {
 143          if (strpos($name, '@') === false)
 144          {
 145              foreach ($this->getNamespaceLookUpOrder() as $namespace)
 146              {
 147                  try
 148                  {
 149                      if ($namespace === '__main__')
 150                      {
 151                          return parent::loadTemplate($name, $index);
 152                      }
 153   
 154                      return parent::loadTemplate('@' . $namespace . '/' . $name, $index);
 155                  }
 156                  catch (\Twig_Error_Loader $e)
 157                  {
 158                  }
 159              }
 160   
 161              // We were unable to load any templates
 162              throw $e;
 163          }
 164          else
 165          {
 166              return parent::loadTemplate($name, $index);
 167          }
 168      }
 169   
 170      /**
 171      * Finds a template by name.
 172      *
 173      * @param string  $name  The template name
 174      * @return string
 175      * @throws \Twig_Error_Loader
 176      */
 177      public function findTemplate($name)
 178      {
 179          if (strpos($name, '@') === false)
 180          {
 181              foreach ($this->getNamespaceLookUpOrder() as $namespace)
 182              {
 183                  try
 184                  {
 185                      if ($namespace === '__main__')
 186                      {
 187                          return parent::getLoader()->getCacheKey($name);
 188                      }
 189   
 190                      return parent::getLoader()->getCacheKey('@' . $namespace . '/' . $name);
 191                  }
 192                  catch (\Twig_Error_Loader $e)
 193                  {
 194                  }
 195              }
 196   
 197              // We were unable to load any templates
 198              throw $e;
 199          }
 200          else
 201          {
 202              return parent::getLoader()->getCacheKey($name);
 203          }
 204      }
 205  }
 206