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

index.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 6.71 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  /**
 015  * @ignore
 016  */
 017  if (!defined('IN_PHPBB'))
 018  {
 019      exit;
 020  }
 021   
 022  /**
 023  * phpBB Hook Class
 024  */
 025  class phpbb_hook
 026  {
 027      /**
 028      * Registered hooks
 029      */
 030      var $hooks = array();
 031   
 032      /**
 033      * Results returned by functions called
 034      */
 035      var $hook_result = array();
 036   
 037      /**
 038      * internal pointer
 039      */
 040      var $current_hook = NULL;
 041   
 042      /**
 043      * Initialize hook class.
 044      *
 045      * @param array $valid_hooks array containing the hookable functions/methods
 046      */
 047      function phpbb_hook($valid_hooks)
 048      {
 049          foreach ($valid_hooks as $_null => $method)
 050          {
 051              $this->add_hook($method);
 052          }
 053   
 054          if (function_exists('phpbb_hook_register'))
 055          {
 056              phpbb_hook_register($this);
 057          }
 058      }
 059   
 060      /**
 061      * Register function/method to be called within hook
 062      * This function is normally called by the modification/application to attach/register the functions.
 063      *
 064      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 065      * @param mixed $hook The replacement function/method to be called. Passing function name or array with object/class definition
 066      * @param string $mode Specify the priority/chain mode. 'normal' -> hook gets appended to the chain. 'standalone' -> only the specified hook gets called - later hooks are not able to overwrite this (E_NOTICE is triggered then). 'first' -> hook is called as the first one within the chain. 'last' -> hook is called as the last one within the chain.
 067      */
 068      function register($definition, $hook, $mode = 'normal')
 069      {
 070          $class = (!is_array($definition)) ? '__global' : $definition[0];
 071          $function = (!is_array($definition)) ? $definition : $definition[1];
 072   
 073          // Method able to be hooked?
 074          if (isset($this->hooks[$class][$function]))
 075          {
 076              switch ($mode)
 077              {
 078                  case 'standalone':
 079                      if (!isset($this->hooks[$class][$function]['standalone']))
 080                      {
 081                          $this->hooks[$class][$function] = array('standalone' => $hook);
 082                      }
 083                      else
 084                      {
 085                          trigger_error('Hook not able to be called standalone, previous hook already standalone.', E_NOTICE);
 086                      }
 087                  break;
 088   
 089                  case 'first':
 090                  case 'last':
 091                      $this->hooks[$class][$function][$mode][] = $hook;
 092                  break;
 093   
 094                  case 'normal':
 095                  default:
 096                      $this->hooks[$class][$function]['normal'][] = $hook;
 097                  break;
 098              }
 099          }
 100      }
 101   
 102      /**
 103      * Calling all functions/methods attached to a specified hook.
 104      * Called by the function allowing hooks...
 105      *
 106      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 107      * @return bool False if no hook got executed, true otherwise
 108      */
 109      function call_hook($definition)
 110      {
 111          $class = (!is_array($definition)) ? '__global' : $definition[0];
 112          $function = (!is_array($definition)) ? $definition : $definition[1];
 113   
 114          if (!empty($this->hooks[$class][$function]))
 115          {
 116              // Developer tries to call a hooked function within the hooked function...
 117              if ($this->current_hook !== NULL && $this->current_hook['class'] === $class && $this->current_hook['function'] === $function)
 118              {
 119                  return false;
 120              }
 121   
 122              // Call the hook with the arguments attached and store result
 123              $arguments = func_get_args();
 124              $this->current_hook = array('class' => $class, 'function' => $function);
 125              $arguments[0] = &$this;
 126   
 127              // Call the hook chain...
 128              if (isset($this->hooks[$class][$function]['standalone']))
 129              {
 130                  $this->hook_result[$class][$function] = call_user_func_array($this->hooks[$class][$function]['standalone'], $arguments);
 131              }
 132              else
 133              {
 134                  foreach (array('first', 'normal', 'last') as $mode)
 135                  {
 136                      if (!isset($this->hooks[$class][$function][$mode]))
 137                      {
 138                          continue;
 139                      }
 140   
 141                      foreach ($this->hooks[$class][$function][$mode] as $hook)
 142                      {
 143                          $this->hook_result[$class][$function] = call_user_func_array($hook, $arguments);
 144                      }
 145                  }
 146              }
 147   
 148              $this->current_hook = NULL;
 149              return true;
 150          }
 151   
 152          $this->current_hook = NULL;
 153          return false;
 154      }
 155   
 156      /**
 157      * Get result from previously called functions/methods for the same hook
 158      *
 159      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 160      * @return mixed False if nothing returned if there is no result, else array('result' => ... )
 161      */
 162      function previous_hook_result($definition)
 163      {
 164          $class = (!is_array($definition)) ? '__global' : $definition[0];
 165          $function = (!is_array($definition)) ? $definition : $definition[1];
 166   
 167          if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
 168          {
 169              return array('result' => $this->hook_result[$class][$function]);
 170          }
 171   
 172          return false;
 173      }
 174   
 175      /**
 176      * Check if the called functions/methods returned something.
 177      *
 178      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 179      * @return bool True if results are there, false if not
 180      */
 181      function hook_return($definition)
 182      {
 183          $class = (!is_array($definition)) ? '__global' : $definition[0];
 184          $function = (!is_array($definition)) ? $definition : $definition[1];
 185   
 186          if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
 187          {
 188              return true;
 189          }
 190   
 191          return false;
 192      }
 193   
 194      /**
 195      * Give actual result from called functions/methods back.
 196      *
 197      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 198      * @return mixed The result
 199      */
 200      function hook_return_result($definition)
 201      {
 202          $class = (!is_array($definition)) ? '__global' : $definition[0];
 203          $function = (!is_array($definition)) ? $definition : $definition[1];
 204   
 205          if (!empty($this->hooks[$class][$function]) && isset($this->hook_result[$class][$function]))
 206          {
 207              $result = $this->hook_result[$class][$function];
 208              unset($this->hook_result[$class][$function]);
 209              return $result;
 210          }
 211   
 212          return;
 213      }
 214   
 215      /**
 216      * Add new function to the allowed hooks.
 217      *
 218      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 219      */
 220      function add_hook($definition)
 221      {
 222          if (!is_array($definition))
 223          {
 224              $definition = array('__global', $definition);
 225          }
 226   
 227          $this->hooks[$definition[0]][$definition[1]] = array();
 228      }
 229   
 230      /**
 231      * Remove function from the allowed hooks.
 232      *
 233      * @param mixed $definition Declaring function (with __FUNCTION__) or class with array(__CLASS__, __FUNCTION__)
 234      */
 235      function remove_hook($definition)
 236      {
 237          $class = (!is_array($definition)) ? '__global' : $definition[0];
 238          $function = (!is_array($definition)) ? $definition : $definition[1];
 239   
 240          if (isset($this->hooks[$class][$function]))
 241          {
 242              unset($this->hooks[$class][$function]);
 243   
 244              if (isset($this->hook_result[$class][$function]))
 245              {
 246                  unset($this->hook_result[$class][$function]);
 247              }
 248          }
 249      }
 250  }
 251