Esempio n. 1
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveSiteMenu($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $newMenuItems = json_decode($blockConfig->customMenu);
     $iteration = function (&$dom, $newMenuItems) use(&$iteration) {
         $childs = [];
         foreach ($newMenuItems as $item) {
             $element = $dom->createElement('item');
             $element->setAttribute('id', $item->key);
             if (isset($item->children) && count($item->children)) {
                 $subChilds = $iteration($dom, $item->children);
                 foreach ($subChilds as $child) {
                     $element->appendChild($child);
                 }
             }
             $childs[] = $element;
         }
         return $childs;
     };
     if (count($newMenuItems)) {
         $customDom = new \Fraym\Block\BlockXmlDom();
         $element = $customDom->createElement('menuItems');
         $element->setAttribute('site', $blockConfig->site);
         $childs = $iteration($customDom, $newMenuItems);
         foreach ($childs as $child) {
             $element->appendChild($child);
         }
         $customDom->appendChild($element);
         $blockXML->setCustomProperty($customDom);
     }
     return $blockXML;
 }
Esempio n. 2
0
File: Image.php Progetto: fraym/core
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $data = $this->request->post('image');
     $data['auto_size'] = isset($data['auto_size']) && $data['auto_size'] == '1' ? true : false;
     $customProperties = new \Fraym\Block\BlockXmlDom();
     foreach ($data as $prop => $val) {
         if (!empty($val)) {
             $element = $customProperties->createElement('image_' . $prop);
             $element->nodeValue = $val;
             $customProperties->appendChild($element);
         }
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Esempio n. 3
0
 /**
  * @param $blockId
  * @param BlockXml $blockXML
  * @return BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     if (isset($blockConfig->config)) {
         $element = $customProperties->createElement('dynamicTemplateConfig');
         $element->appendChild($customProperties->createCDATASection(serialize($blockConfig->config)));
         $customProperties->appendChild($element);
     }
     $element = $customProperties->createElement('dynamicTemplate');
     $element->nodeValue = $blockConfig->dynamicTemplate;
     $customProperties->appendChild($element);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Esempio n. 4
0
 /**
  * @param $blockId
  * @param BlockXml $blockXML
  * @return BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     foreach ($blockConfig->html as $localeId => $content) {
         $element = $customProperties->createElement('html');
         $domAttribute = $customProperties->createAttribute('locale');
         $domAttribute->value = $localeId;
         $element->appendChild($domAttribute);
         $element->appendChild($customProperties->createCDATASection($content));
         $customProperties->appendChild($element);
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Esempio n. 5
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     $element = $customProperties->createElement('mailformOptions');
     $element->appendChild($customProperties->createCDATASection(json_encode($blockConfig->config)));
     $customProperties->appendChild($element);
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }
Esempio n. 6
0
 /**
  * @param $blockId
  * @param \Fraym\Block\BlockXml $blockXML
  * @return \Fraym\Block\BlockXml
  */
 public function saveBlockConfig($blockId, \Fraym\Block\BlockXml $blockXML)
 {
     $blockConfig = $this->request->getGPAsObject();
     $customProperties = new \Fraym\Block\BlockXmlDom();
     $element = $customProperties->createElement('view');
     $element->appendChild($customProperties->createCDATASection($blockConfig->newsView));
     $customProperties->appendChild($element);
     $listPage = isset($blockConfig->listPage) ? intval($blockConfig->listPage) : 1;
     if ($blockConfig->newsView === 'detail' || $blockConfig->newsView === 'detail-category' || $blockConfig->newsView === 'detail-tag') {
         $element = $customProperties->createElement('listPage', $listPage);
         $customProperties->appendChild($element);
     } elseif ($blockConfig->newsView === 'list-category' || $blockConfig->newsView === 'list-tag') {
         $element = $customProperties->createElement('listPage', $this->route->getCurrentMenuItem()->id);
         $customProperties->appendChild($element);
     } elseif ($blockConfig->newsView === 'list') {
         $element = $customProperties->createElement('limit');
         $element->nodeValue = $blockConfig->limit;
         $customProperties->appendChild($element);
         $forceShowOnDetail = property_exists($blockConfig, 'forceShowOnDetail') && $blockConfig->forceShowOnDetail == '1' ? 1 : 0;
         $element = $customProperties->createElement('forceShowOnDetail', $forceShowOnDetail);
         $customProperties->appendChild($element);
         if (isset($blockConfig->detailPage)) {
             $element = $customProperties->createElement('detailPage', intval($blockConfig->detailPage));
             $customProperties->appendChild($element);
         }
         $element = $customProperties->createElement('listItems');
         if (isset($blockConfig->newsListItems)) {
             $element->appendChild($customProperties->createCDATASection(implode(',', $blockConfig->newsListItems)));
         }
         $customProperties->appendChild($element);
         $element = $customProperties->createElement('newsListSort');
         $element->nodeValue = $blockConfig->newsListSort;
         $customProperties->appendChild($element);
     }
     $blockXML->setCustomProperty($customProperties);
     return $blockXML;
 }