Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

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

SiteDefinitionCollection.php

Zuletzt modifiziert: 01.05.2026, 11:29 - Dateigröße: 2.57 KiB


 001  <?php
 002   
 003  /**
 004  * @package   s9e\TextFormatter
 005  * @copyright Copyright (c) 2010-2022 The s9e authors
 006  * @license   http://www.opensource.org/licenses/mit-license.php The MIT License
 007  */
 008  namespace s9e\TextFormatter\Plugins\MediaEmbed\Configurator\Collections;
 009   
 010  use InvalidArgumentException;
 011  use RuntimeException;
 012  use s9e\TextFormatter\Configurator\Collections\NormalizedCollection;
 013   
 014  class SiteDefinitionCollection extends NormalizedCollection
 015  {
 016      /**
 017      * {@inheritdoc}
 018      */
 019      protected $onDuplicateAction = 'replace';
 020   
 021      /**
 022      * {@inheritdoc}
 023      */
 024      protected function getAlreadyExistsException($key)
 025      {
 026          return new RuntimeException("Media site '" . $key . "' already exists");
 027      }
 028   
 029      /**
 030      * {@inheritdoc}
 031      */
 032      protected function getNotExistException($key)
 033      {
 034          return new RuntimeException("Media site '" . $key . "' does not exist");
 035      }
 036   
 037      /**
 038      * Validate and normalize a site ID
 039      *
 040      * @param  string $siteId
 041      * @return string
 042      */
 043      public function normalizeKey($siteId)
 044      {
 045          $siteId = strtolower($siteId);
 046          if (!preg_match('(^[a-z0-9]+$)', $siteId))
 047          {
 048              throw new InvalidArgumentException('Invalid site ID');
 049          }
 050   
 051          return $siteId;
 052      }
 053   
 054      /**
 055      * {@inheritdoc}
 056      */
 057      public function normalizeValue($siteConfig)
 058      {
 059          if (!is_array($siteConfig))
 060          {
 061              throw new InvalidArgumentException('Invalid site definition type');
 062          }
 063          if (!isset($siteConfig['host']))
 064          {
 065              throw new InvalidArgumentException('Missing host from site definition');
 066          }
 067   
 068          $siteConfig           += ['attributes' => [], 'extract' => [], 'scrape' => []];
 069          $siteConfig['extract'] = $this->normalizeRegexp($siteConfig['extract']);
 070          $siteConfig['host']    = array_map('strtolower', (array) $siteConfig['host']);
 071          $siteConfig['scrape']  = $this->normalizeScrape($siteConfig['scrape']);
 072   
 073          foreach ($siteConfig['attributes'] as &$attrConfig)
 074          {
 075              if (isset($attrConfig['filterChain']))
 076              {
 077                  $attrConfig['filterChain'] = (array) $attrConfig['filterChain'];
 078              }
 079          }
 080          unset($attrConfig);
 081   
 082          return $siteConfig;
 083      }
 084   
 085      /**
 086      * Normalize a regexp / indexed array of regexps
 087      *
 088      * @param  array|string $value
 089      * @return array
 090      */
 091      protected function normalizeRegexp($value)
 092      {
 093          return (array) $value;
 094      }
 095   
 096      /**
 097      * Normalize the "scrape" value
 098      *
 099      * @param  array $value
 100      * @return array
 101      */
 102      protected function normalizeScrape($value)
 103      {
 104          if (!empty($value) && !isset($value[0]))
 105          {
 106              $value = [$value];
 107          }
 108          foreach ($value as &$scrape)
 109          {
 110              $scrape           += ['extract' => [], 'match' => '//'];
 111              $scrape['extract'] = $this->normalizeRegexp($scrape['extract']);
 112              $scrape['match']   = $this->normalizeRegexp($scrape['match']);
 113          }
 114          unset($scrape);
 115   
 116          return $value;
 117      }
 118  }