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 ($datas = $this->getRequest()->getParams()) { try { if (empty($datas['design_id'])) { throw new Exception($this->_('An error occurred while saving')); } $application = $this->getApplication(); $design = new Template_Model_Design(); $design->find($datas['design_id']); if (!$design->getId()) { throw new Exception($this->_('An error occurred while saving')); } $this->getApplication()->setDesign($design)->save(); $html = array('success' => 1, 'overview_src' => $design->getOverview(), 'homepage_normal' => $application->getHomepageBackgroundImageUrl(), 'homepage_retina4' => $application->getHomepageBackgroundImageUrl('retina')); } catch (Exception $e) { $html = array('message' => $e->getMessage(), 'message_buttom' => 1, 'message_loader' => 1); } } $this->getLayout()->setHtml(Zend_Json::encode($html)); }
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(); $design->find($design_code, "code"); $option = new Application_Model_Option(); $options = $option->findAll(array("code IN (?)" => $option_code)); foreach ($options as $option) { $icon_id = NULL; if (isset($option_infos["icon"])) { $icon = new Media_Model_Library_Image(); $icon->find($option_infos["icon"], "link"); if (!$icon->getData()) { $icon->setLibraryId($option->getLibraryId())->setLink($option_infos["icon"])->setOptionId($option->getId())->setCanBeColorized(1)->setPosition(0)->save(); } $icon_id = $icon->getId(); } $data = array("design_id" => $design->getId(), "option_id" => $option->getId(), "option_tabbar_name" => isset($option_infos["name"]) ? $option_infos["name"] : NULL, "option_icon" => $icon_id, "option_background_image" => isset($option_infos["background_image"]) ? $option_infos["background_image"] : NULL); $design_content = new Template_Model_Design_Content(); $design_content->setData($data)->save(); } } }
public function checkDependencies() { $package = $this->getPackageDetails(); $dependencies = $package->getDependencies(); if (!empty($dependencies) and is_array($dependencies)) { foreach ($dependencies as $type => $dependency) { switch ($type) { case "system": if (strtolower($dependency["type"]) != strtolower(Siberian_Version::TYPE)) { throw new Exception($this->_("This update is designed for the %s, you can't install it in your %s.", $package->getName(), Siberian_Version::NAME)); } // If the current version of Siberian equals the package's version if (version_compare(Siberian_Version::VERSION, $package->getVersion()) >= 0) { throw new Exception($this->_("You already have installed this update.")); // If the current version is too old } else { $compare = version_compare(Siberian_Version::VERSION, $dependency["version"]); if ($compare == -1) { throw new Exception($this->_("Please update your system to the %s version before installing this update.", $dependency["version"])); } elseif ($compare == 1) { throw new Exception($this->_("You already have installed this update.")); } } break; case "module": /** * @todo Test the module installs' / updates' dependencies */ // $module = new Installer_Model_Installer_Module(); // $module->prepare($dependency["name"]); // $version = $module->getVersion() ? $module->getVersion() : Installer_Model_Installer_Module::DEFAULT_VERSION; // $compare = version_compare($version, $dependency["version"]); // // if($compare == 1) { // throw new Exception($this->_("You already have installed this update.")); // } else if($compare == -1) { // throw new Exception($this->_("Please update the module to the %s version before installing this update.", $dependency["version"])); // } break; case "template": $template_design = new Template_Model_Design(); $template_design->find($package->getCode(), "code"); if ($template_design->getId()) { throw new Exception($this->_("You already have installed this template.")); } $compare = version_compare(Siberian_Version::VERSION, $dependency["version"]); if ($compare == -1) { throw new Exception($this->_("Please update your system to the %s version before installing this update.", $dependency["version"])); } break; } } } }