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)); }