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

asset.php

Zuletzt modifiziert: 09.10.2024, 12:52 - Dateigröße: 3.75 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;
 015   
 016  class asset
 017  {
 018      protected $components = array();
 019   
 020      /** @var \phpbb\path_helper **/
 021      protected $path_helper;
 022   
 023      /**
 024      * Constructor
 025      *
 026      * @param string $url URL
 027      * @param \phpbb\path_helper $path_helper Path helper object
 028      */
 029      public function __construct($url, \phpbb\path_helper $path_helper)
 030      {
 031          $this->path_helper = $path_helper;
 032   
 033          $this->set_url($url);
 034      }
 035   
 036      /**
 037      * Set URL
 038      *
 039      * @param string $url URL
 040      */
 041      public function set_url($url)
 042      {
 043          if (version_compare(PHP_VERSION, '5.4.7') < 0 && substr($url, 0, 2) === '//')
 044          {
 045              // Workaround for PHP 5.4.6 and older bug #62844 - add fake scheme and then remove it
 046              $this->components = parse_url('http:' . $url);
 047              $this->components['scheme'] = '';
 048              return;
 049          }
 050          $this->components = parse_url($url);
 051      }
 052   
 053      /**
 054      * Convert URL components into string
 055      *
 056      * @param array $components URL components
 057      * @return string URL
 058      */
 059      protected function join_url($components)
 060      {
 061          $path = '';
 062          if (isset($components['scheme']))
 063          {
 064              $path = $components['scheme'] === '' ? '//' : $components['scheme'] . '://';
 065          }
 066   
 067          if (isset($components['user']) || isset($components['pass']))
 068          {
 069              if ($path === '' && !isset($components['port']))
 070              {
 071                  $path = '//';
 072              }
 073              $path .= $components['user'];
 074              if (isset($components['pass']))
 075              {
 076                  $path .= ':' . $components['pass'];
 077              }
 078              $path .= '@';
 079          }
 080   
 081          if (isset($components['host']))
 082          {
 083              if ($path === '' && !isset($components['port']))
 084              {
 085                  $path = '//';
 086              }
 087              $path .= $components['host'];
 088              if (isset($components['port']))
 089              {
 090                  $path .= ':' . $components['port'];
 091              }
 092          }
 093   
 094          if (isset($components['path']))
 095          {
 096              $path .= $components['path'];
 097          }
 098   
 099          if (isset($components['query']))
 100          {
 101              $path .= '?' . $components['query'];
 102          }
 103   
 104          if (isset($components['fragment']))
 105          {
 106              $path .= '#' . $components['fragment'];
 107          }
 108   
 109          return $path;
 110      }
 111   
 112      /**
 113      * Get URL
 114      *
 115      * @return string URL
 116      */
 117      public function get_url()
 118      {
 119          return $this->path_helper->update_web_root_path($this->join_url($this->components));
 120      }
 121   
 122      /**
 123      * Checks if URL is local and relative
 124      *
 125      * @return boolean True if URL is local and relative
 126      */
 127      public function is_relative()
 128      {
 129          if (empty($this->components) || !isset($this->components['path']))
 130          {
 131              // Invalid URL
 132              return false;
 133          }
 134          return !isset($this->components['scheme']) && !isset($this->components['host']) && substr($this->components['path'], 0, 1) !== '/';
 135      }
 136   
 137      /**
 138      * Get path component of current URL
 139      *
 140      * @return string Path
 141      */
 142      public function get_path()
 143      {
 144          return isset($this->components['path']) ? $this->components['path'] : '';
 145      }
 146   
 147      /**
 148      * Set path component
 149      *
 150      * @param string $path Path component
 151      * @param boolean $urlencode If true, parts of path should be encoded with rawurlencode()
 152      */
 153      public function set_path($path, $urlencode = false)
 154      {
 155          if ($urlencode)
 156          {
 157              $paths = explode('/', $path);
 158              foreach ($paths as &$dir)
 159              {
 160                  $dir = rawurlencode($dir);
 161              }
 162              $path = implode('/', $paths);
 163          }
 164          $this->components['path'] = $path;
 165      }
 166   
 167      /**
 168      * Add assets_version parameter to URL.
 169      * Parameter will not be added if assets_version already exists in URL
 170      *
 171      * @param string $version Version
 172      */
 173      public function add_assets_version($version)
 174      {
 175          if (!isset($this->components['query']))
 176          {
 177              $this->components['query'] = 'assets_version=' . $version;
 178              return;
 179          }
 180          $query = $this->components['query'];
 181          if (!preg_match('/(^|[&;])assets_version=/', $query))
 182          {
 183              $this->components['query'] = $query . '&amp;assets_version=' . $version;
 184          }
 185      }
 186  }
 187