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

MetadataBag.php

Zuletzt modifiziert: 09.10.2024, 12:59 - Dateigröße: 3.30 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\HttpFoundation\Session\Storage;
013   
014  use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
015   
016  /**
017   * Metadata container.
018   *
019   * Adds metadata to the session.
020   *
021   * @author Drak <drak@zikula.org>
022   */
023  class MetadataBag implements SessionBagInterface
024  {
025      const CREATED = 'c';
026      const UPDATED = 'u';
027      const LIFETIME = 'l';
028   
029      /**
030       * @var string
031       */
032      private $name = '__metadata';
033   
034      /**
035       * @var string
036       */
037      private $storageKey;
038   
039      /**
040       * @var array
041       */
042      protected $meta = array();
043   
044      /**
045       * Unix timestamp.
046       *
047       * @var int
048       */
049      private $lastUsed;
050   
051      /**
052       * Constructor.
053       *
054       * @param string $storageKey The key used to store bag in the session.
055       */
056      public function __construct($storageKey = '_sf2_meta')
057      {
058          $this->storageKey = $storageKey;
059          $this->meta = array(self::CREATED => 0, self::UPDATED => 0, self::LIFETIME => 0);
060      }
061   
062      /**
063       * {@inheritdoc}
064       */
065      public function initialize(array &$array)
066      {
067          $this->meta = &$array;
068   
069          if (isset($array[self::CREATED])) {
070              $this->lastUsed = $this->meta[self::UPDATED];
071              $this->meta[self::UPDATED] = time();
072          } else {
073              $this->stampCreated();
074          }
075      }
076   
077      /**
078       * Gets the lifetime that the session cookie was set with.
079       *
080       * @return int
081       */
082      public function getLifetime()
083      {
084          return $this->meta[self::LIFETIME];
085      }
086   
087      /**
088       * Stamps a new session's metadata.
089       *
090       * @param int     $lifetime Sets the cookie lifetime for the session cookie. A null value
091       *                          will leave the system settings unchanged, 0 sets the cookie
092       *                          to expire with browser session. Time is in seconds, and is
093       *                          not a Unix timestamp.
094       */
095      public function stampNew($lifetime = null)
096      {
097          $this->stampCreated($lifetime);
098      }
099   
100      /**
101       * {@inheritdoc}
102       */
103      public function getStorageKey()
104      {
105          return $this->storageKey;
106      }
107   
108      /**
109       * Gets the created timestamp metadata.
110       *
111       * @return int     Unix timestamp
112       */
113      public function getCreated()
114      {
115          return $this->meta[self::CREATED];
116      }
117   
118      /**
119       * Gets the last used metadata.
120       *
121       * @return int     Unix timestamp
122       */
123      public function getLastUsed()
124      {
125          return $this->lastUsed;
126      }
127   
128      /**
129       * {@inheritdoc}
130       */
131      public function clear()
132      {
133          // nothing to do
134      }
135   
136      /**
137       * {@inheritdoc}
138       */
139      public function getName()
140      {
141          return $this->name;
142      }
143   
144      /**
145       * Sets name.
146       *
147       * @param string $name
148       */
149      public function setName($name)
150      {
151          $this->name = $name;
152      }
153   
154      private function stampCreated($lifetime = null)
155      {
156          $timeStamp = time();
157          $this->meta[self::CREATED] = $this->meta[self::UPDATED] = $this->lastUsed = $timeStamp;
158          $this->meta[self::LIFETIME] = (null === $lifetime) ? ini_get('session.cookie_lifetime') : $lifetime;
159      }
160  }
161