Beispiel #1
0
 public function createDummyContents($option_value, $design, $category)
 {
     $option = new Application_Model_Option();
     $option->find($option_value->getOptionId());
     $dummy_content_xml = $this->_getDummyXml($design, $category);
     if ($option->getCode() == 'places' && $dummy_content_xml->places) {
         foreach ($dummy_content_xml->places->children() as $content) {
             $this->unsData();
             $blocks = array();
             $i = 1;
             foreach ($content->block as $block_content) {
                 $block = new Cms_Model_Application_Block();
                 $block->find((string) $block_content->type, "type");
                 $data = (array) $block_content;
                 if ($block_content->image_url) {
                     $data['image_url'] = (array) $block_content->image_url;
                     $data['image_fullsize_url'] = (array) $block_content->image_fullsize_url;
                 }
                 $data["block_id"] = $block->getId();
                 $blocks[$i++] = $data;
             }
             $this->addData((array) $content->content)->setBlock($blocks)->setValueId($option_value->getId())->save();
         }
     } else {
         $blocks = array();
         $i = 1;
         foreach ($dummy_content_xml->blocks->children() as $content) {
             $block = new Cms_Model_Application_Block();
             $block->find((string) $content->type, "type");
             $data = (array) $content;
             if ($content->image_url) {
                 $data['image_url'] = (array) $content->image_url;
                 $data['image_fullsize_url'] = (array) $content->image_fullsize_url;
             }
             $data["block_id"] = $block->getId();
             $blocks[$i++] = $data;
         }
         $this->setValueId($option_value->getId())->setBlock($blocks)->save();
     }
 }
 public function addblockAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $position = $this->getRequest()->getParam('position');
             if (empty($datas['block_id'])) {
                 throw new Exception($this->_('An error occurred during process. Please try again later.'));
             }
             if (empty($position)) {
                 throw new Exception($this->_('An error occurred during process. Please try again later.'));
             }
             $block = new Cms_Model_Application_Block();
             $block->find($datas['block_id']);
             if (!$block->getId()) {
                 throw new Exception($this->_('An error occurred during process. Please try again later.'));
             }
             $html = array('success' => 1);
             $html['layout'] = $this->getLayout()->addPartial('row', 'admin_view_default', $block->getTemplate())->setCurrentBlock($block)->setCurrentOptionValue($this->getCurrentOptionValue())->setPosition($position)->toHtml();
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }