[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2019 The s9e Authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Plugins\MediaEmbed\Configurator; 9 use DOMXPath; 10 use s9e\TextFormatter\Configurator\Helpers\TemplateHelper; 11 use s9e\TextFormatter\Plugins\MediaEmbed\Configurator\TemplateGenerators\Choose; 12 use s9e\TextFormatter\Plugins\MediaEmbed\Configurator\TemplateGenerators\Flash; 13 use s9e\TextFormatter\Plugins\MediaEmbed\Configurator\TemplateGenerators\Iframe; 14 class TemplateBuilder 15 { 16 protected $templateGenerators = []; 17 public function __construct() 18 { 19 $this->templateGenerators['choose'] = new Choose($this); 20 $this->templateGenerators['flash'] = new Flash; 21 $this->templateGenerators['iframe'] = new Iframe; 22 } 23 public function build($siteId, array $siteConfig) 24 { 25 return $this->addSiteId($siteId, $this->getTemplate($siteConfig)); 26 } 27 public function getTemplate(array $config) 28 { 29 foreach ($this->templateGenerators as $type => $generator) 30 if (isset($config[$type])) 31 return $generator->getTemplate($config[$type]); 32 return ''; 33 } 34 protected function addSiteId($siteId, $template) 35 { 36 $dom = TemplateHelper::loadTemplate($template); 37 $xpath = new DOMXPath($dom); 38 $query = '//*[namespace-uri() != "' . TemplateHelper::XMLNS_XSL . '"][not(ancestor::*[namespace-uri() != "' . TemplateHelper::XMLNS_XSL . '"])]'; 39 foreach ($xpath->query($query) as $element) 40 $element->setAttribute('data-s9e-mediaembed', $siteId); 41 return TemplateHelper::saveTemplate($dom); 42 } 43 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |