Ejemplo n.º 1
0
 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));
 }
Ejemplo n.º 2
0
 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));
 }
Ejemplo n.º 3
0
<?php

$this->query("\n\n    CREATE TABLE `template_design` (\n        `design_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `layout_id` int(11) unsigned NOT NULL,\n        `code` varchar(20) COLLATE utf8_unicode_ci NOT NULL,\n        `name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `overview` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `background_image` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `background_image_retina` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`design_id`),\n        KEY `KEY_LAYOUT_ID` (`layout_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `template_block` (\n        `block_id` int(11) NOT NULL AUTO_INCREMENT,\n        `code` varchar(15) COLLATE utf8_unicode_ci NOT NULL,\n        `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `color` varchar(10) COLLATE utf8_unicode_ci NOT NULL,\n        `background_color` varchar(10) COLLATE utf8_unicode_ci NOT NULL,\n        `image_color` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `position` smallint(5) NOT NULL DEFAULT '0',\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`block_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `template_block_app` (\n        `block_id` int(11) NOT NULL,\n        `app_id` int(11) unsigned NOT NULL,\n        `color` varchar(10) NOT NULL,\n        `background_color` varchar(10) NOT NULL,\n        `image_color` varchar(255) DEFAULT NULL,\n        PRIMARY KEY (`block_id`, `app_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `template_design_block` (\n        `design_block_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `design_id` int(11) unsigned NOT NULL,\n        `block_id` int(11) NOT NULL,\n        `background_color` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `color` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `image_color` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,\n        PRIMARY KEY (`design_block_id`),\n        KEY `KEY_DESIGN_ID` (`design_id`),\n        KEY `KEY_BLOCK_ID` (`block_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n");
$this->query("\n    ALTER TABLE `template_design`\n        ADD FOREIGN KEY `FK_LAYOUT_ID` (`layout_id`) REFERENCES `application_layout_homepage` (`layout_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `template_design_block`\n        ADD FOREIGN KEY `FK_DESIGN_ID` (`design_id`) REFERENCES `template_design` (`design_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_BLOCK_ID` (`block_id`) REFERENCES `template_block` (`block_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `template_block_app`\n        ADD FOREIGN KEY `FK_TEMPLATE_BLOCK_BLOCK_ID` (`block_id`) REFERENCES `template_block` (`block_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_APPLICATION_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$datas = array(array('code' => 'header', 'name' => 'Header', 'use_color' => 1, 'color' => '#00377a', 'use_background_color' => 1, 'background_color' => '#739c03', 'position' => 10), array('code' => 'subheader', 'name' => 'Subheader', 'use_color' => 1, 'color' => '#00377a', 'use_background_color' => 1, 'background_color' => '#739c03', 'position' => 20), array('code' => 'connect_button', 'name' => 'Connect Button', 'use_color' => 1, 'color' => '#233799', 'use_background_color' => 1, 'background_color' => '#f2f2f2', 'position' => 30), array('code' => 'background', 'name' => 'Background', 'use_color' => 1, 'color' => '#ffffff', 'use_background_color' => 1, 'background_color' => '#0c6ec4', 'position' => 40), array('code' => 'discount', 'name' => 'Discount Zone', 'use_color' => 1, 'color' => '#fcfcfc', 'use_background_color' => 1, 'background_color' => '#739c03', 'position' => 50), array('code' => 'button', 'name' => 'Button', 'use_color' => 1, 'color' => '#fcfcfc', 'use_background_color' => 1, 'background_color' => '#00377a', 'position' => 60), array('code' => 'news', 'name' => 'News', 'use_color' => 1, 'color' => '#fcfcfc', 'use_background_color' => 1, 'background_color' => '#00377a', 'position' => 70), array('code' => 'comments', 'name' => 'Comments', 'use_color' => 1, 'color' => '#ffffff', 'use_background_color' => 1, 'background_color' => '#4d5d8a', 'position' => 80), array('code' => 'tabbar', 'name' => 'Tabbar', 'use_color' => 1, 'color' => '#ffffff', 'use_background_color' => 1, 'background_color' => '#739c03', 'image_color' => '#ffffff', 'position' => 90));
foreach ($datas as $data) {
    $block = new Template_Model_Block();
    $block->setData($data)->save();
}
$datas = array(array("layout_id" => 1, "code" => "zenstitut", "name" => "Zenstitut", "overview" => "/zenstitut/overview.jpg", "background_image" => "/zenstitut/background.jpg", "background_image_retina" => "/zenstitut/background-568h@2x.jpg"), array("layout_id" => 2, "code" => "hairdresser", "name" => "Hairdresser", "overview" => "/hairdresser/overview.jpg", "background_image" => "/hairdresser/background.jpg", "background_image_retina" => "/hairdresser/background-568h@2x.jpg"), array("layout_id" => 3, "code" => "fall_wedding", "name" => "Wedding", "overview" => "/wedding/overview.jpg", "background_image" => "/wedding/background.jpg", "background_image_retina" => "/wedding/background-568h@2x.jpg"), array("layout_id" => 4, "code" => "purple_croco", "name" => "Violet", "overview" => "/purple_croco/overview.jpg", "background_image" => "/purple_croco/background.jpg", "background_image_retina" => "/purple_croco/background-568h@2x.jpg"), array("layout_id" => 5, "code" => "grand_palace", "name" => "Grand Palace", "overview" => "/grand_palace/overview.jpg", "background_image" => "/grand_palace/background.jpg", "background_image_retina" => "/grand_palace/background-568h@2x.jpg"), array("layout_id" => 6, "code" => "white_shadow", "name" => "White Shadow", "overview" => "/white_shadow/overview.jpg", "background_image" => "/white_shadow/background.jpg", "background_image_retina" => "/white_shadow/background-568h@2x.jpg"), array("layout_id" => 7, "code" => "side_brown", "name" => "Marron", "overview" => "/side_brown/overview.jpg", "background_image" => "/side_brown/background.jpg", "background_image_retina" => "/side_brown/background-568h@2x.jpg"));
foreach ($datas as $data) {
    $design = new Template_Model_Design();
    $design->setData($data)->save();
}
$this->query("\n    INSERT INTO `template_design_block` VALUES(1, 1, 1, '#CB0052', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(2, 1, 2, '#FFFFFF', '#CB0052', NULL);\n    INSERT INTO `template_design_block` VALUES(3, 1, 3, '#CB0052', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(4, 1, 4, '#CB0052', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(5, 1, 5, '#CB0052', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(6, 1, 6, '#CB0052', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(7, 1, 7, '#2B8901', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(8, 1, 8, '#FFFFFF', '#CB0052', NULL);\n    INSERT INTO `template_design_block` VALUES(9, 1, 9, '#2B8901', '#000000', '#000000');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(10, 2, 1, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(11, 2, 2, '#FFFFFF', '#56718E', NULL);\n    INSERT INTO `template_design_block` VALUES(12, 2, 3, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(13, 2, 4, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(14, 2, 5, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(15, 2, 6, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(16, 2, 7, '#56718E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(17, 2, 8, '#FFFFFF', '#56718e', NULL);\n    INSERT INTO `template_design_block` VALUES(18, 2, 9, '#56718E', '#FFFFFF', '#FFFFFF');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(19, 3, 1, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(20, 3, 2, '#5B371F', '#BA5521', NULL);\n    INSERT INTO `template_design_block` VALUES(21, 3, 3, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(22, 3, 4, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(23, 3, 5, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(24, 3, 6, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(25, 3, 7, '#BA5521', '#5B371F', NULL);\n    INSERT INTO `template_design_block` VALUES(26, 3, 8, '#5B371F', '#BA5521', NULL);\n    INSERT INTO `template_design_block` VALUES(27, 3, 9, '#BA5521', '#5B371F', '#5B371F');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(28, 4, 1, '#2E2E2E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(29, 4, 2, '#734957', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(30, 4, 3, '#734957', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(31, 4, 4, '#2E2E2E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(32, 4, 5, '#2E2E2E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(33, 4, 6, '#2E2E2E', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(34, 4, 7, '#FFFFFF', '#2E2E2E', NULL);\n    INSERT INTO `template_design_block` VALUES(35, 4, 8, '#734957', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(36, 4, 9, '#FFFFFF', '#2E2E2E', '#2E2E2E');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(37, 5, 1, '#000000', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(38, 5, 2, '#FFFFFF', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(39, 5, 3, '#000000', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(40, 5, 4, '#FFFFFF', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(41, 5, 5, '#FFFFFF', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(42, 5, 6, '#FFFFFF', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(43, 5, 7, '#FFFFFF', '#000000', NULL);\n    INSERT INTO `template_design_block` VALUES(44, 5, 8, '#000000', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(45, 5, 9, '#FFFFFF', '#FFFFFF', '#FFFFFF');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(46, 6, 1, '#1F6FAA', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(47, 6, 2, '#FFFFFF', '#1f6faa', NULL);\n    INSERT INTO `template_design_block` VALUES(48, 6, 3, '#1F6FAA', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(49, 6, 4, '#FFFFFF', '#1F6FAA', NULL);\n    INSERT INTO `template_design_block` VALUES(50, 6, 5, '#FFFFFF', '#1F6FAA', NULL);\n    INSERT INTO `template_design_block` VALUES(51, 6, 6, '#FFFFFF', '#1F6FAA', NULL);\n    INSERT INTO `template_design_block` VALUES(52, 6, 7, '#FFFFFF', '#1F6FAA', NULL);\n    INSERT INTO `template_design_block` VALUES(53, 6, 8, '#FFFFFF', '#1F6FAA', NULL);\n    INSERT INTO `template_design_block` VALUES(54, 6, 9, '#FFFFFF', '#FFFFFF', '#FFFFFF');\n");
$this->query("\n    INSERT INTO `template_design_block` VALUES(55, 7, 1, '#FFFFFF', '#43352A', NULL);\n    INSERT INTO `template_design_block` VALUES(56, 7, 2, '#43352A', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(57, 7, 3, '#FFFFFF', '#43352A', NULL);\n    INSERT INTO `template_design_block` VALUES(58, 7, 4, '#43352A', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(59, 7, 5, '#43352A', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(60, 7, 6, '#43352A', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(61, 7, 7, '#FFFFFF', '#43352A', NULL);\n    INSERT INTO `template_design_block` VALUES(62, 7, 8, '#43352A', '#FFFFFF', NULL);\n    INSERT INTO `template_design_block` VALUES(63, 7, 9, '#FFFFFF', '#43352A', '#43352A');\n");
$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();
        $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();
Ejemplo n.º 5
0
 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;
             }
         }
     }
 }
Ejemplo n.º 6
0
        $this->_db->insert("template_design_category", $categories_designs_data);
    }
}
// Assigning features to designs
$design_codes = array("big_company" => array("custom_page" => array("name" => "Company"), "newswall" => array(), "push_notification" => array("name" => "Push", "icon" => "/push_notifications/push4.png"), "folder" => array("name" => "Products", "icon" => "/booking/booking4.png"), "places" => array("name" => "Locations"), "video_gallery" => array(), "contact" => array(), "facebook" => array(), "weblink_multi" => array(), "form" => 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()), "fitness" => array("newswall" => array("icon" => "/fanwall/fanwall2.png"), "loyalty" => array("icon" => "/loyalty/loyalty2.png"), "push_notification" => array("name" => "Push Notifications", "icon" => "/push_notifications/push5.png"), "discount" => array("name" => "Coupons", "icon" => "/discount/discount4.png"), "facebook" => array(), "fanwall" => array("name" => "Activity", "icon" => "/fanwall/fanwall4.png"), "custom_page" => array("name" => "About us"), "source_code" => array("name" => "BMI", "icon" => "/booking/booking4.png"), "image_gallery" => array("icon" => "/images/image4.png"), "video_gallery" => array("icon" => "/videos/video2.png"), "contact" => array()), "grande_palace" => array("newswall" => array("background_image" => "/../../images/templates/grande_palace/content/bg.png"), "discount" => array("icon" => "/discount/discount4.png", "background_image" => "/../../images/templates/grande_palace/content/bg.png"), "loyalty" => array("icon" => "/loyalty/loyalty5.png", "background_image" => "/../../images/templates/grande_palace/content/bg.png"), "folder" => array("name" => "Infos", "icon" => "/../../images/templates/grande_palace/icons/infos.png", "background_image" => "/../../images/templates/grande_palace/content/bg.png"), "booking" => array("background_image" => "/../../images/templates/grande_palace/content/bg.png"), "form" => array("name" => "Feedbacks", "icon" => "/form/form3.png", "background_image" => "/../../images/templates/grande_palace/content/bg.png"), "push_notification" => array("icon" => "/push_notifications/push5.png", "background_image" => "/../../images/templates/grande_palace/content/bg.png"), "contact" => array()), "jewellery" => array("m_commerce" => array("name" => "Shop", "icon" => "/../../images/templates/jewellery/icons/shop.png"), "discount" => array("name" => "Coupons", "icon" => "/discount/discount3.png"), "form" => array("name" => "Pre-order"), "image_gallery" => array("name" => "Gallery", "icon" => "/images/image3.png"), "places" => array("name" => "Locations"), "custom_page" => array("name" => "About")), "paris" => array("custom_page" => array("name" => "The City"), "video_gallery" => array("icon" => "/videos/video5.png"), "calendar" => array(), "places" => array(), "fanwall" => array("name" => "Activity Wall", "icon" => "/fanwall/fanwall2.png"), "push_notification" => array("name" => "Messages", "icon" => "/push_notifications/push3.png"), "image_gallery" => array("icon" => "/images/image5.png"), "radio" => array(), "weblink_multi" => array(), "folder" => array("icon" => "/folders/folder5.png")), "pizza" => array("m_commerce" => array("name" => "Orders"), "loyalty" => array("name" => "Loyalty"), "social_gaming" => array(), "discount" => array(), "facebook" => array(), "contact" => array()), "publisher" => array("newswall" => array(), "image_gallery" => array("name" => "Portfolio", "icon" => "/images/image5.png"), "catalog" => array("icon" => "/../../images/templates/publisher/icons/catalog.png"), "push_notification" => array("name" => "Push"), "custom_page" => array("name" => "Custom"), "rss_feed" => array(), "facebook" => array(), "form" => array(), "contact" => array()), "real_estate_one" => array("custom_page" => array("name" => "About", "icon" => "/../../images/templates/real_estate_one/icons/about.png"), "newswall" => array("name" => "New Rentals", "icon" => "/newswall/newswall2.png"), "push_notification" => array("name" => "Push", "icon" => "/push_notifications/push5.png"), "form" => array("name" => "Your needs", "icon" => "/form/form2.png"), "booking" => array("name" => "Appointment"), "image_gallery" => array("name" => "Properties", "icon" => "/images/image3.png"), "contact" => array(), "facebook" => array()), "rush_cafe" => array("newswall" => array(), "loyalty" => array("icon" => "/loyalty/loyalty6.png"), "push_notification" => array("name" => "Notifications", "icon" => "/push_notifications/push2.png"), "catalog" => array(), "set_meal" => array(), "discount" => array("name" => "Coupons"), "facebook" => array(), "fanwall" => array(), "form" => array("icon" => "/form/form3.png"), "places" => array(), "contact" => array()), "surgery" => array("custom_page" => array("name" => "About us"), "discount" => array("name" => "Specials", "icon" => "/discount/discount3.png"), "form" => array("name" => "Requests", "icon" => "/form/form2.png"), "image_gallery" => array("name" => "Galleries", "icon" => "/images/image7.png"), "padlock" => array("name" => "Restricted"), "places" => array("name" => "Locations"), "booking" => array(), "contact" => array()), "university" => array("custom_page" => array("name" => "Studies", "icon" => "/newswall/newswall4.png"), "newswall" => array(), "rss_feed" => array(), "radio" => array(), "calendar" => array("icon" => "/calendar/calendar3.png"), "folder" => array("icon" => "/folders/folder4.png"), "push_notification" => array("name" => "Notifications"), "facebook" => array(), "fanwall" => array("icon" => "/fanwall/fanwall2.png"), "image_gallery" => array("icon" => "/images/image4.png"), "video_gallery" => array("icon" => "/videos/video5.png"), "form" => array("name" => "Requests", "icon" => "/form/form2.png")));
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);
            $this->_db->insert("template_design_content", $data);
        }
    }
}
$design_codes = array("zenstitut", "hairdresser", "fall_wedding", "purple_croco", "grand_palace", "white_shadow", "side_brown");
foreach ($design_codes as $design_code) {
    $design = new Template_Model_Design();
    $design->find($design_code, "code")->delete();
}