Example #1
0
 /**
  * @Fraym\Annotation\Route("/fraym/dynamic-template/inline-editor-save", name="dynamicTemplateSaveInlineEditor", permission={"\Fraym\User\User"="isAdmin"})
  */
 public function saveDynamicTemplateInline()
 {
     $blockId = $this->request->post('blockId');
     // Convert int key to string
     $configField = json_decode(json_encode((object) $this->request->post('config')), true);
     // Get the block element
     $block = $this->db->getRepository('\\Fraym\\Block\\Entity\\Block')->findOneById($blockId);
     // Read the xml config from the block
     $configXml = $this->blockParser->getXmlObjectFromString($this->blockParser->wrapBlockConfig($block));
     $config = unserialize($configXml->dynamicTemplateConfig);
     $config = json_decode(json_encode($config), true);
     $newConfig = array_replace_recursive($config, $configField);
     // Create the new config xml date
     $configXml->dynamicTemplateConfig = serialize($newConfig);
     $newConfig = $this->blockParser->getBlockConfig($this->blockParser->removeXmlHeader($configXml->asXML()));
     // Save changes to new change set
     $changeSet = $this->dynamicTemplate->createChangeSet($block, $newConfig);
     $this->response->sendAsJson(['blockId' => $block->id, 'data' => $this->blockController->prepareBlockOutput($changeSet)]);
 }
Example #2
0
 /**
  * Exec content element template
  *
  * @param $xml
  */
 public function execBlock($xml)
 {
     return $this->blockController->renderContentBlock($xml);
 }
Example #3
0
 /**
  * @param $xml
  * @return array|string
  */
 private function contentChildViews($xml)
 {
     $childsHtml = array();
     foreach ($xml->children() as $child) {
         $contentId = $this->getContentId($child);
         $blocks = $this->getDataFromBlocksByContentId($contentId);
         // In Editmode we want to render all views to insert content
         if (empty($blocks) && $this->getXMLAttr($child, 'hideEmpty') !== false && $this->block->inEditMode() === false) {
             continue;
         }
         // result returns an array
         $result = $this->contentChildViews($child);
         $addContent = $this->getXMLAttr($child, 'add') ?: 'afterContent';
         if (!isset($childsHtml[$addContent])) {
             $childsHtml[$addContent] = '';
         }
         if (count($result) > 0) {
             $blockhtml = (isset($result['beforeContent']) ? $result['beforeContent'] : '') . $this->core->evalString($blocks) . (isset($result['afterContent']) ? $result['afterContent'] : '');
             if (($this->getXMLAttr($child, 'hideEmpty') === null || $this->getXMLAttr($child, 'hideEmpty') === true) && $this->block->inEditMode() === false && trim($blockhtml) == '') {
                 $childsHtml[$addContent] .= isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '';
             } else {
                 $childsHtml[$addContent] .= (isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '') . $this->blockController->createEditViewContentDIV($child, $blockhtml);
             }
         } else {
             $blockhtml = $this->core->evalString($blocks);
             if (($this->getXMLAttr($child, 'hideEmpty') === null || $this->getXMLAttr($child, 'hideEmpty') === true) && $this->block->inEditMode() === false && trim($blockhtml) == '') {
                 $childsHtml[$addContent] .= '';
             } else {
                 $childsHtml[$addContent] .= $this->blockController->createEditViewContentDIV($child, $blockhtml);
             }
         }
     }
     return $childsHtml;
 }
Example #4
0
 /**
  * @param $xml
  * @return array|string
  */
 protected function contentChildViews($xml)
 {
     $childsHtml = [];
     foreach ($xml->children() as $child) {
         $contentId = $this->getContentId($child);
         $blocks = $this->getDataFromBlocksByContentId($contentId);
         // In Editmode we want to render all views to insert content
         if (empty($blocks) && $this->getXmlAttr($child, 'hideEmpty') !== false && empty($placeholder) && $this->block->inEditMode() === false) {
             continue;
         }
         if (empty($blocks) && !empty($placeholder) && $this->block->inEditMode() === false) {
             $blocks = $this->blockController->createEditViewElement($child, $placeholder);
         }
         // result returns an array
         $result = $this->contentChildViews($child);
         $addContent = $this->getXmlAttr($child, 'add') ?: 'afterContent';
         if (!isset($childsHtml[$addContent])) {
             $childsHtml[$addContent] = '';
         }
         if (count($result) > 0) {
             $blockhtml = (isset($result['beforeContent']) ? $result['beforeContent'] : '') . $this->core->includeScript($blocks) . (isset($result['afterContent']) ? $result['afterContent'] : '');
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '';
             } else {
                 $childsHtml[$addContent] .= (isset($childsHtml[$addContent]) ? $childsHtml[$addContent] : '') . $this->blockController->createEditViewElement($child, $blockhtml);
             }
         } else {
             $blockhtml = $this->core->includeScript($blocks);
             if (trim($blockhtml) === '') {
                 $childsHtml[$addContent] .= '';
             } else {
                 $childsHtml[$addContent] .= $this->blockController->createEditViewElement($child, $blockhtml);
             }
         }
     }
     return $childsHtml;
 }