Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
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. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
FileLinkFormatter.php
001 <?php
002
003 /*
004 * This file is part of the Symfony package.
005 *
006 * (c) Fabien Potencier <fabien@symfony.com>
007 *
008 * For the full copyright and license information, please view the LICENSE
009 * file that was distributed with this source code.
010 */
011
012 namespace Symfony\Component\HttpKernel\Debug;
013
014 use Symfony\Component\HttpFoundation\Request;
015 use Symfony\Component\HttpFoundation\RequestStack;
016 use Symfony\Component\Routing\Exception\ExceptionInterface;
017 use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
018
019 /**
020 * Formats debug file links.
021 *
022 * @author Jérémy Romey <jeremy@free-agent.fr>
023 */
024 class FileLinkFormatter implements \Serializable
025 {
026 private $fileLinkFormat;
027 private $requestStack;
028 private $baseDir;
029 private $urlFormat;
030
031 /**
032 * @param string|\Closure $urlFormat the URL format, or a closure that returns it on-demand
033 */
034 public function __construct($fileLinkFormat = null, RequestStack $requestStack = null, $baseDir = null, $urlFormat = null)
035 {
036 $fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
037 if ($fileLinkFormat && !\is_array($fileLinkFormat)) {
038 $i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
039 $fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);
040 }
041
042 $this->fileLinkFormat = $fileLinkFormat;
043 $this->requestStack = $requestStack;
044 $this->baseDir = $baseDir;
045 $this->urlFormat = $urlFormat;
046 }
047
048 public function format($file, $line)
049 {
050 if ($fmt = $this->getFileLinkFormat()) {
051 for ($i = 1; isset($fmt[$i]); ++$i) {
052 if (0 === strpos($file, $k = $fmt[$i++])) {
053 $file = substr_replace($file, $fmt[$i], 0, \strlen($k));
054 break;
055 }
056 }
057
058 return strtr($fmt[0], ['%f' => $file, '%l' => $line]);
059 }
060
061 return false;
062 }
063
064 /**
065 * @internal
066 */
067 public function serialize()
068 {
069 return serialize($this->getFileLinkFormat());
070 }
071
072 /**
073 * @internal
074 */
075 public function unserialize($serialized)
076 {
077 if (\PHP_VERSION_ID >= 70000) {
078 $this->fileLinkFormat = unserialize($serialized, ['allowed_classes' => false]);
079 } else {
080 $this->fileLinkFormat = unserialize($serialized);
081 }
082 }
083
084 /**
085 * @internal
086 */
087 public static function generateUrlFormat(UrlGeneratorInterface $router, $routeName, $queryString)
088 {
089 try {
090 return $router->generate($routeName).$queryString;
091 } catch (ExceptionInterface $e) {
092 return null;
093 }
094 }
095
096 private function getFileLinkFormat()
097 {
098 if ($this->fileLinkFormat) {
099 return $this->fileLinkFormat;
100 }
101 if ($this->requestStack && $this->baseDir && $this->urlFormat) {
102 $request = $this->requestStack->getMasterRequest();
103 if ($request instanceof Request) {
104 if ($this->urlFormat instanceof \Closure && !$this->urlFormat = \call_user_func($this->urlFormat)) {
105 return null;
106 }
107
108 return [
109 $request->getSchemeAndHttpHost().$this->urlFormat,
110 $this->baseDir.\DIRECTORY_SEPARATOR, '',
111 ];
112 }
113 }
114
115 return null;
116 }
117 }
118