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

DirectoryResource.php

Zuletzt modifiziert: 09.10.2024, 12:56 - Dateigröße: 2.46 KiB


 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\Config\Resource;
 013   
 014  /**
 015   * DirectoryResource represents a resources stored in a subdirectory tree.
 016   *
 017   * @author Fabien Potencier <fabien@symfony.com>
 018   */
 019  class DirectoryResource implements SelfCheckingResourceInterface, \Serializable
 020  {
 021      private $resource;
 022      private $pattern;
 023   
 024      /**
 025       * Constructor.
 026       *
 027       * @param string      $resource The file path to the resource
 028       * @param string|null $pattern  A pattern to restrict monitored files
 029       */
 030      public function __construct($resource, $pattern = null)
 031      {
 032          $this->resource = $resource;
 033          $this->pattern = $pattern;
 034      }
 035   
 036      /**
 037       * {@inheritdoc}
 038       */
 039      public function __toString()
 040      {
 041          return md5(serialize(array($this->resource, $this->pattern)));
 042      }
 043   
 044      /**
 045       * {@inheritdoc}
 046       */
 047      public function getResource()
 048      {
 049          return $this->resource;
 050      }
 051   
 052      /**
 053       * Returns the pattern to restrict monitored files.
 054       *
 055       * @return string|null
 056       */
 057      public function getPattern()
 058      {
 059          return $this->pattern;
 060      }
 061   
 062      /**
 063       * {@inheritdoc}
 064       */
 065      public function isFresh($timestamp)
 066      {
 067          if (!is_dir($this->resource)) {
 068              return false;
 069          }
 070   
 071          $newestMTime = filemtime($this->resource);
 072          foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->resource), \RecursiveIteratorIterator::SELF_FIRST) as $file) {
 073              // if regex filtering is enabled only check matching files
 074              if ($this->pattern && $file->isFile() && !preg_match($this->pattern, $file->getBasename())) {
 075                  continue;
 076              }
 077   
 078              // always monitor directories for changes, except the .. entries
 079              // (otherwise deleted files wouldn't get detected)
 080              if ($file->isDir() && '/..' === substr($file, -3)) {
 081                  continue;
 082              }
 083   
 084              $newestMTime = max($file->getMTime(), $newestMTime);
 085          }
 086   
 087          return $newestMTime < $timestamp;
 088      }
 089   
 090      public function serialize()
 091      {
 092          return serialize(array($this->resource, $this->pattern));
 093      }
 094   
 095      public function unserialize($serialized)
 096      {
 097          list($this->resource, $this->pattern) = unserialize($serialized);
 098      }
 099  }
 100