Ejemplo n.º 1
0
 /**
  * @param $xml
  * @param $blockHtml
  * @return mixed|\SimpleXMLElement|string
  */
 private function processBlockAttributes($xml, $blockHtml)
 {
     $blockType = strtolower($this->getXMLAttr($xml, 'type'));
     if ($this->request->isXmlHttpRequest() === false) {
         if ($this->block->inEditMode() && in_array($blockType, $this->editModeTypes)) {
             $block = null;
             if (($this->getXMLAttr($xml, 'type') === 'extension' || $this->getXMLAttr($xml, 'type') === null) && ($id = $this->getXMLAttr($xml, 'id'))) {
                 $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id);
             }
             $editable = $this->getXMLAttr($xml, 'editable');
             if ($editable === true || $editable === null) {
                 $blockHtml = $this->blockController->addBlockInfo($block, $blockHtml, $xml);
             }
         }
         // Disable cache on block attribute or on element level
         if ($this->getXMLAttr($xml, 'cached') != '1' && ($this->getXMLAttr($xml, 'cache') === false || isset($xml->cache) && $xml->cache == 0)) {
             $blockHtml = $this->disableBlockCaching($xml);
         } else {
             // add block state to check permission or end/start date on caching
             $blockHtml = $this->addBlockCacheState($xml, $blockHtml);
         }
         if ($this->getXMLAttr($xml, 'placeholder') !== null) {
             return $this->addPlaceholderReplacement($xml, $blockHtml);
         }
     }
     return $blockHtml;
 }
Ejemplo n.º 2
0
 /**
  * @param $xml
  * @param $blockHtml
  * @return mixed|\SimpleXMLElement|string
  */
 protected function processBlockAttributes($xml, $blockHtml)
 {
     $blockType = strtolower($this->getXmlAttr($xml, 'type'));
     if ($this->block->inEditMode() && in_array($blockType, $this->editModeTypes)) {
         $block = null;
         if (($this->getXmlAttr($xml, 'type') === 'extension' || $this->getXmlAttr($xml, 'type') === null) && ($id = $this->getXmlAttr($xml, 'id'))) {
             $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($id);
         }
         $editable = $this->getXmlAttr($xml, 'editable');
         if ($editable === true || $editable === null) {
             $blockHtml = $this->blockController->addBlockInfo($block, $blockHtml, $xml, true);
         }
     }
     // interleaved unique content elements -> pop last element
     if (end($this->parsingBlockIds) == $this->getXmlAttr($xml, 'id')) {
         array_pop($this->parsingBlockIds);
     }
     // Disable cache on block attribute or on element level
     if ($this->getXmlAttr($xml, 'cached') != '1' && ($this->getXmlAttr($xml, 'cache') === false || isset($xml->cache) && $xml->cache == 0 && !$this->request->isPost() && GLOBAL_CACHING_ENABLED === true && $this->route->getCurrentMenuItem()->caching === true)) {
         $blockHtml = $this->disableBlockCaching($xml);
     } else {
         // add block state to check permission or end/start date on caching
         $blockHtml = $this->addBlockCacheState($xml, $blockHtml);
     }
     if ($this->getXmlAttr($xml, 'placeholder') !== null) {
         return $this->addPlaceholderReplacement($xml, $blockHtml);
     }
     return $blockHtml;
 }