[ 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\Configurator\JavaScript; 9 use ReflectionClass; 10 use s9e\TextFormatter\Configurator\Collections\PluginCollection; 11 class HintGenerator 12 { 13 protected $config; 14 protected $hints; 15 protected $plugins; 16 protected $xsl; 17 public function getHints() 18 { 19 $this->hints = []; 20 $this->setPluginsHints(); 21 $this->setRenderingHints(); 22 $this->setRulesHints(); 23 $this->setTagsHints(); 24 $js = "/** @const */ var HINT={};\n"; 25 \ksort($this->hints); 26 foreach ($this->hints as $hintName => $hintValue) 27 $js .= '/** @const */ HINT.' . $hintName . '=' . \json_encode($hintValue) . ";\n"; 28 return $js; 29 } 30 public function setConfig(array $config) 31 { 32 $this->config = $config; 33 } 34 public function setPlugins(PluginCollection $plugins) 35 { 36 $this->plugins = $plugins; 37 } 38 public function setXSL($xsl) 39 { 40 $this->xsl = $xsl; 41 } 42 protected function setPluginsHints() 43 { 44 foreach ($this->plugins as $plugins) 45 $this->hints += $plugins->getJSHints(); 46 } 47 protected function setRenderingHints() 48 { 49 $this->hints['postProcessing'] = (int) (\strpos($this->xsl, 'data-s9e-livepreview-postprocess') !== \false); 50 $this->hints['ignoreAttrs'] = (int) (\strpos($this->xsl, 'data-s9e-livepreview-ignore-attrs') !== \false); 51 } 52 protected function setRulesHints() 53 { 54 $this->hints['closeAncestor'] = 0; 55 $this->hints['closeParent'] = 0; 56 $this->hints['createChild'] = 0; 57 $this->hints['fosterParent'] = 0; 58 $this->hints['requireAncestor'] = 0; 59 $flags = 0; 60 foreach ($this->config['tags'] as $tagConfig) 61 { 62 foreach (\array_intersect_key($tagConfig['rules'], $this->hints) as $k => $v) 63 $this->hints[$k] = 1; 64 $flags |= $tagConfig['rules']['flags']; 65 } 66 $flags |= $this->config['rootContext']['flags']; 67 $parser = new ReflectionClass('s9e\\TextFormatter\\Parser'); 68 foreach ($parser->getConstants() as $constName => $constValue) 69 if (\substr($constName, 0, 5) === 'RULE_') 70 $this->hints[$constName] = ($flags & $constValue) ? 1 : 0; 71 } 72 protected function setTagAttributesHints(array $tagConfig) 73 { 74 if (empty($tagConfig['attributes'])) 75 return; 76 foreach ($tagConfig['attributes'] as $attrConfig) 77 $this->hints['attributeDefaultValue'] |= isset($attrConfig['defaultValue']); 78 } 79 protected function setTagsHints() 80 { 81 $this->hints['attributeDefaultValue'] = 0; 82 $this->hints['namespaces'] = 0; 83 foreach ($this->config['tags'] as $tagName => $tagConfig) 84 { 85 $this->hints['namespaces'] |= (\strpos($tagName, ':') !== \false); 86 $this->setTagAttributesHints($tagConfig); 87 } 88 } 89 }
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 |