public function saveAction() { if ($datas = $this->getRequest()->getParams()) { try { if (empty($datas['design_id'])) { throw new Exception($this->_('An error occurred while saving')); } $application = $this->getApplication(); $category = new Template_Model_Category(); $design = new Template_Model_Design(); $design->find($datas['design_id']); if (!$design->getId()) { throw new Exception($this->_('An error occurred while saving')); } else { if ($design->getCode() != "blank" && empty($datas['category_id'])) { throw new Exception($this->_('An error occurred while saving')); } } if (!empty($datas['category_id'])) { $category->find($datas['category_id']); if (!$category->getCode()) { throw new Exception($this->_('An error occurred while saving')); } } $this->getApplication()->setLayoutVisibility(Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE)->setDesign($design, $category)->save(); $html = array('success' => 1, 'overview_src' => $design->getOverview(), 'homepage_standard' => $application->getHomepageBackgroundImageUrl(), 'homepage_hd' => $application->getHomepageBackgroundImageUrl('hd'), 'homepage_tablet' => $application->getHomepageBackgroundImageUrl('tablet'), 'app_icon' => $application->getIcon(), "display_layout_options" => $application->getLayout()->getVisibility() == Application_Model_Layout_Homepage::VISIBILITY_ALWAYS); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_buttom' => 1, 'message_loader' => 1); } } $this->getLayout()->setHtml(Zend_Json::encode($html)); }
public function saveAction() { if ($categories = Zend_Json::decode($this->getRequest()->getRawBody())) { try { foreach ($categories as $data) { $category = new Template_Model_Category(); $category->find($data["category_id"]); $category->addData($data)->save(); } $data = array("success" => 1, "message" => $this->_("Info successfully saved")); } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
$this->_db->insert("template_design_block", $block_data); } } } } // Assigning designs to categories $categories_designs = array("entertainment" => array("fairground"), "local_business" => array("pizza"), "music" => array("dj")); // Listing all design ids $design_ids = array(); $design = new Template_Model_Design(); foreach ($design->findAll() as $design_data) { $design_ids[$design_data->getCode()] = $design_data->getId(); } // Listing all category ids $category_ids = array(); $category = new Template_Model_Category(); foreach ($category->findAll() as $category_data) { $category_ids[$category_data->getCode()] = $category_data->getId(); } foreach ($categories_designs as $category_code => $design_codes) { $categories_designs_data = array("category_id" => $category_ids[$category_code]); foreach ($design_codes as $design_code) { $categories_designs_data["design_id"] = $design_ids[$design_code]; $this->_db->insert("template_design_category", $categories_designs_data); } } // Assigning features to designs $design_codes = array("dj" => array("newswall" => array("icon" => "/newswall/newswall2.png"), "music_gallery" => array("name" => "Playlists"), "push_notification" => array("name" => "Messages", "icon" => "/push_notifications/push2.png"), "image_gallery" => array("icon" => "/images/image5.png"), "facebook" => array(), "calendar" => array("icon" => "/calendar/calendar2.png"), "video_gallery" => array("icon" => "/videos/video2.png"), "custom_page" => array("name" => "About me"), "booking" => array("icon" => "/booking/booking4.png")), "fairground" => array("fanwall" => array("icon" => "/../../images/templates/fairground/icons/fanwall.png"), "loyalty" => array("name" => "Loyalty", "icon" => "/loyalty/loyalty4.png"), "social_gaming" => array("icon" => "/contest/contest4.png"), "discount" => array("name" => "Coupons", "icon" => "/discount/discount5.png"), "calendar" => array("icon" => "/calendar/calendar2.png"), "image_gallery" => array("icon" => "/images/image7.png"), "push_notification" => array("name" => "Push", "icon" => "/push_notifications/push3.png"), "video_gallery" => array(), "newswall" => array("name" => "News"), "facebook" => array()), "pizza" => array("m_commerce" => array("name" => "Orders"), "loyalty" => array("name" => "Loyalty"), "social_gaming" => array(), "discount" => array(), "facebook" => array(), "contact" => array())); foreach ($design_codes as $design_code => $option_codes) { foreach ($option_codes as $option_code => $option_infos) { $design = new Template_Model_Design();