/** * @param $xmlString * @return bool|mixed|string * @throws \Exception */ public function exec($xmlString) { $xmlString = is_array($xmlString) ? $xmlString[0] : $xmlString; $this->xmlString = $xmlString; $xml = $this->getXMLObjectFromString($this->xmlString); if ($xml === false) { throw new \Exception('XML Error'); } elseif ($this->isBlockEnable($xml) === false) { return ''; } elseif ($this->isBlockCached($xml) === true) { return $this->xmlString; } elseif ($this->isAllowedDevice($xml) === false) { return ''; } if ($this->getXMLAttr($xml, 'id')) { $this->core->startTimer('blockExecution_' . $this->getXMLAttr($xml, 'id')); } if ($this->getXMLAttr($xml, 'cached') == '1') { $this->db->connect(); } switch (strtolower($this->getXMLAttr($xml, 'type'))) { case 'css': return $this->execBlockOfTypeCSS($xml); break; case 'js': return $this->execBlockOfTypeJS($xml); break; case 'module': $blockHtml = $this->execBlockOfTypeModule($xml); break; case 'content': $blockHtml = $this->execBlockOfTypeContent($xml); break; case 'cache': $blockHtml = $this->execBlockOfTypeCache($xml); break; case 'php': $blockHtml = $this->execBlockOfTypePhp($xml); break; case 'image': $blockHtml = $this->execBlockOfTypeImage($xml); break; default: // extensions $blockHtml = $this->execBlockOfTypeExtension($xml); break; } return $this->processBlockAttributes($xml, $blockHtml); }
/** * @param $xmlString * @return bool|mixed|string * @throws \Exception */ public function exec($xmlString) { $xmlString = is_array($xmlString) ? $xmlString[0] : $xmlString; $this->xmlString = $xmlString; $xml = $this->getXmlObjectFromString($this->xmlString); if ($xml === false) { throw new \Exception('XML Error. XML Block is not supported: ' . $this->xmlString); } elseif ($this->isBlockEnable($xml) === false) { return ''; } elseif ($this->isBlockCached($xml) === true) { return $this->xmlString; } elseif ($this->isAllowedDevice($xml) === false) { return ''; } if ($this->getXmlAttr($xml, 'id')) { // interleaved unique content elements -> push element if ($this->user->isAdmin()) { $block = $this->getBaseBlock($this->getXmlAttr($xml, 'id')); $blockId = $block->id; } else { $blockId = $this->getXmlAttr($xml, 'id'); } $this->parsingBlockIds[$blockId] = $blockId; $this->core->startTimer('blockExecution_' . $blockId); } if ($this->getXmlAttr($xml, 'cached') == '1') { $this->db->connect()->setUpTranslateable(); } $blockType = strtolower($this->getXmlAttr($xml, 'type')); switch ($blockType) { case 'css': return $this->execBlockOfTypeCss($xml); break; case 'js': return $this->execBlockOfTypeJS($xml); break; case 'link': return $this->execBlockOfTypeLink($xml); break; case 'module': $blockHtml = $this->execBlockOfTypeModule($xml); break; case 'content': $blockHtml = $this->execBlockOfTypeContent($xml); break; case 'cache': $blockHtml = $this->execBlockOfTypeCache($xml); break; case 'php': $blockHtml = $this->execBlockOfTypePhp($xml); break; case 'image': $blockHtml = $this->execBlockOfTypeImage($xml); break; case 'javascript': $blockHtml = $this->execBlockOfTypeJavascript($xml); break; default: // extensions & custom block types if (isset($this->customBlockTypes[$blockType])) { $blockHtml = call_user_func($this->customBlockTypes[$blockType]); } else { $blockHtml = $this->execBlockOfTypeExtension($xml); } break; } return $this->processBlockAttributes($xml, $blockHtml); }