`location_label` VARCHAR(50) NULL DEFAULT NULL,
        `location_url` VARCHAR(50) NULL DEFAULT NULL,
        `rsvp` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
        `ticket_shop_url` VARCHAR(255) NULL DEFAULT NULL,
        `websites` TEXT NULL DEFAULT NULL,
        `picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
        `created_at` datetime NOT NULL,
        `updated_at` datetime NOT NULL,
        PRIMARY KEY (`event_id`),
        KEY `KEY_AGENDA_ID` (`agenda_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

');
$this->query("\n    ALTER TABLE `event_custom`\n        ADD FOREIGN KEY `FK_AGENDA_ID` (`agenda_id`) REFERENCES `event` (`event_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Calendar')->save();
$icon_paths = array('/calendar/calendar1.png', '/calendar/calendar2.png', '/calendar/calendar3.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("events", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'calendar', 'name' => 'Calendar', 'model' => 'Event_Model_Event', 'desktop_uri' => 'event/application/', 'mobile_uri' => 'event/mobile_list/', 'mobile_view_uri' => 'event/mobile_view/', 'mobile_view_uri_parameter' => 'event_id', 'only_once' => 0, 'is_ajax' => 1, 'position' => 200, 'social_sharing_is_available' => 1);
$option = new Application_Model_Option();
$option->setData($data)->save();
Пример #2
0
// Create the gallery
$library = new Media_Model_Library();
$library->setName('Maps')->save();
// Create the icons
$icons = array("/maps/maps1.png", "/maps/maps2.png", "/maps/maps3.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
//Categorization
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$category_id = $category->getId();
// Create and declare the feature
$data = array('library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'maps', 'name' => 'Maps', 'model' => 'Maps_Model_Maps', 'desktop_uri' => 'maps/application/', 'mobile_uri' => 'maps/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240, 'category_id' => $category_id);
$option = new Application_Model_Option();
$option->setData($data)->save();
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "feature_maps", "label" => "Maps", "url" => "maps/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("feature_maps", "code");
    $resource->addData($data)->save();
}
$this->query("\n    CREATE TABLE `maps` (\n      `maps_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n      `value_id` int(11) unsigned NOT NULL,\n      `address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n      `latitude` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n      `longitude` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n      PRIMARY KEY(`maps_id`),\n      KEY `value_id` (`value_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n");
<?php

$media_library = new Media_Model_Library();
$media_library->setName("Code Scan")->save();
$icon_id = null;
$files_icon = new DirectoryIterator(Core_Model_Directory::getBasePathTo("images/library/code_scan"));
foreach ($files_icon as $file) {
    if ($file->isDot()) {
        continue;
    }
    $icon = new Media_Model_Library_Image();
    $icon_data = array("library_id" => $media_library->getId(), "link" => "/code_scan/" . $file->getFilename(), "can_be_colorized" => 1);
    $icon->setData($icon_data)->save();
    if ($icon_id == null) {
        $icon_id = $icon->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$data = array("category_id" => $category->getId(), "library_id" => $media_library->getId(), "code" => "code_scan", "name" => "Code Scan", "model" => "Codescan_Model_Codescan", "library_id" => $media_library->getId(), "icon_id" => $icon_id, "desktop_uri" => "codescan/application/", "mobile_uri" => "codescan/mobile_view/", "position" => 150);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n    CREATE TABLE `maps` (\n      `maps_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n      `value_id` int(11) unsigned NOT NULL,\n      `address` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n      `latitude` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n      `longitude` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n      PRIMARY KEY(`maps_id`),\n      KEY `value_id` (`value_id`)\n) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n");
$this->query("\n    ALTER TABLE `maps` ADD CONSTRAINT `FK_MAPS_VALUE_ID` FOREIGN KEY (`value_id`) REFERENCES `application_option_value`(`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `maps` ADD `unit` VARCHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL ;\n");
// Create the gallery
$library = new Media_Model_Library();
$library->setName('Maps')->save();
// Create the icons
$icons = array("/maps/maps1.png", "/maps/maps2.png", "/maps/maps3.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'maps', 'name' => 'Maps', 'model' => 'Maps_Model_Maps', 'desktop_uri' => 'maps/application/', 'mobile_uri' => 'maps/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n    CREATE TABLE `contact` (\n        `contact_id` int(11) NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `name` longtext COLLATE utf8_unicode_ci,\n        `description` longtext COLLATE utf8_unicode_ci,\n        `facebook` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `twitter` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `website` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `cover` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `email` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `civility` varchar(5) COLLATE utf8_unicode_ci NOT NULL,\n        `firstname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `lastname` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `street` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `postcode` varchar(10) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `city` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `country` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `latitude` DECIMAL(11,8) NULL DEFAULT NULL,\n        `longitude` DECIMAL(11,8) NULL DEFAULT NULL,\n        `phone` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`contact_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `contact`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Contact')->save();
$icon_paths = array('/contact/contact1.png', '/contact/contact2.png', '/contact/contact3.png', '/contact/contact4.png', '/contact/contact5.png', '/contact/contact6.png', '/contact/contact7.png', '/contact/contact8.png', '/contact/contact9.png', '/contact/contact10.png', '/contact/contact11.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("contact", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'contact', 'name' => 'Contact', 'model' => 'Contact_Model_Contact', 'desktop_uri' => 'contact/application/', 'mobile_uri' => 'contact/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 120);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n\n    CREATE TABLE `loyalty_card` (\n        `card_id` int(11) NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `number_of_points` smallint(5) NOT NULL,\n        `advantage` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `conditions` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `use_once` TINYINT(1) NOT NULL DEFAULT 0,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        KEY `KEY_VALUE_ID` (`value_id`),\n        PRIMARY KEY (`card_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `loyalty_card_customer` (\n        `customer_card_id` int(11) NOT NULL AUTO_INCREMENT,\n        `card_id` int(11) NOT NULL,\n        `customer_id` int(11) UNSIGNED NOT NULL,\n        `number_of_points` smallint(5) NOT NULL,\n        `is_used` tinyint(1) NOT NULL DEFAULT '0',\n        `number_of_error` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `validate_by` int(11) DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        `used_at` datetime DEFAULT NULL,\n        `last_error` datetime DEFAULT NULL,\n        PRIMARY KEY (`customer_card_id`),\n        KEY `KEY_CARD_ID` (`card_id`),\n        KEY `KEY_CUSTOMER_ID` (`customer_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `loyalty_card_customer_log` (\n        `log_id` int(11) NOT NULL AUTO_INCREMENT,\n        `customer_id` int(11) UNSIGNED NOT NULL,\n        `card_id` int(11) NOT NULL,\n        `password_id` int(11) NOT NULL,\n        `number_of_points` smallint(5) unsigned NOT NULL DEFAULT '1',\n        `created_at` datetime NOT NULL,\n        PRIMARY KEY (`log_id`),\n        KEY `KEY_CUSTOMER_ID` (`customer_id`),\n        KEY `KEY_CARD_ID` (`card_id`),\n        KEY `KEY_PASSWORD_ID` (`password_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `loyalty_card_password` (\n        `password_id` int(11) NOT NULL AUTO_INCREMENT,\n        `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `password` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\n        `app_id` int(11) UNSIGNED NOT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`password_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `loyalty_card`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `loyalty_card_customer`\n        ADD FOREIGN KEY `FK_CARD_ID` (`card_id`) REFERENCES `loyalty_card` (`card_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `loyalty_card_customer_log`\n        ADD FOREIGN KEY `FK_CARD_ID` (`card_id`) REFERENCES `loyalty_card` (`card_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `loyalty_card_password`\n        ADD FOREIGN KEY `FK_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Loyalty Card')->save();
$icon_paths = array('/loyalty/loyalty1.png', '/loyalty/loyalty2.png', '/loyalty/loyalty3.png', '/loyalty/loyalty4.png', '/loyalty/loyalty5.png', '/loyalty/loyalty6.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("monetization", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "loyalty", 'name' => "Loyalty Card", 'model' => "LoyaltyCard_Model_LoyaltyCard", 'desktop_uri' => "loyaltycard/application/", 'mobile_uri' => "loyaltycard/mobile_view/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 50);
$option = new Application_Model_Option();
$option->setData($data)->save();
Пример #7
0
// Create the gallery
$library = new Media_Model_Library();
$library->setName('Weather')->save();
// Create the icons
$icons = array("/weather/weather1.png", "/weather/weather2.png", "/weather/weather3.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
//Categorization
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$category_id = null;
if ($category->getId()) {
    $category_id = $category->getId();
}
// Create and declare the feature
$data = array('library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'weather', 'name' => 'Weather', 'model' => 'Weather_Model_Weather', 'desktop_uri' => 'weather/application/', 'mobile_uri' => 'weather/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240, 'category_id' => $category_id);
$option = new Application_Model_Option();
$option->setData($data)->save();
$resource = new Acl_Model_Resource();
$resource->find("feature", "code");
if ($resource_id = $resource->getId()) {
    $data = array("parent_id" => $resource_id, "code" => "weather", "label" => "Access the weather feature", "url" => "weather/application/*");
    $resource = new Acl_Model_Resource();
    $resource->find("weather", "code");
$this->query("\n    CREATE TABLE `promotion` (\n        `promotion_id` int(11) NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `picture` VARCHAR(255) NULL DEFAULT NULL,\n        `description` text COLLATE utf8_unicode_ci NOT NULL,\n        `conditions` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\n        `is_unique` tinyint(1) NOT NULL DEFAULT '0',\n        `end_at` date DEFAULT NULL,\n        `force_validation` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `is_active` tinyint(1) NOT NULL DEFAULT '1',\n        `condition_type` varchar(9) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `condition_number_of_points` tinyint(2) DEFAULT NULL,\n        `condition_period_number` tinyint(2) DEFAULT NULL,\n        `condition_period_type` varchar(5) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `is_shared` tinyint(1) NOT NULL DEFAULT '0',\n        `owner` tinyint(1) NOT NULL DEFAULT '1',\n        `unlock_by` enum('account', 'qrcode') NOT NULL DEFAULT 'account',\n        `unlock_code` VARCHAR(10) NULL DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`promotion_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `promotion_customer` (\n        `promotion_customer_id` int(11) NOT NULL AUTO_INCREMENT,\n        `promotion_id` int(11) NOT NULL,\n        `pos_id` int(11) DEFAULT NULL,\n        `customer_id` int(11) UNSIGNED NOT NULL,\n        `is_used` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `number_of_error` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `created_at` datetime NOT NULL,\n        `last_error` datetime DEFAULT NULL,\n        PRIMARY KEY (`promotion_customer_id`),\n        KEY `KEY_PROMOTION_ID` (`promotion_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `promotion`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `promotion_customer`\n        ADD FOREIGN KEY `FK_PROMOTION_ID` (`promotion_id`) REFERENCES `promotion` (`promotion_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName("Discount")->save();
$icon_paths = array("/discount/discount1.png", "/discount/discount2.png", "/discount/discount3.png", "/discount/discount4.png", "/discount/discount5.png", "/loyalty/loyalty6.png");
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array("library_id" => $library->getId(), "link" => $icon_path, "can_be_colorized" => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("monetization", "code");
$data = array("category_id" => $category->getId(), "library_id" => $library->getId(), "icon_id" => $icon_id, "code" => "discount", "name" => "Discount", "model" => "Promotion_Model_Promotion", "desktop_uri" => "promotion/application/", "mobile_uri" => "promotion/mobile_list/", "mobile_view_uri" => "promotion/mobile_view/", "mobile_view_uri_parameter" => "promotion_id", "only_once" => 0, "is_ajax" => 1, "position" => 20, "social_sharing_is_available" => 1);
$option = new Application_Model_Option();
$option->setData($data)->save();
$layouts = array(array("code" => 1, "option_id" => $option->getId(), "name" => "Layout 1", "preview" => "/customization/layout/promotion/layout-1.png", "position" => 1), array("code" => 2, "option_id" => $option->getId(), "name" => "Layout 2", "preview" => "/customization/layout/promotion/layout-2.png", "position" => 2));
foreach ($layouts as $data) {
    $this->_db->insert("application_option_layout", $data);
}
$media_library = new Media_Model_Library();
$media_library->find("Code Scan", "name");
$last_icon = count($media_library->getIcons()) - 1;
$icons = $media_library->getIcons();
$icon_id = $icons[$last_icon]->getId();
$data = array("category_id" => $category->getId(), "library_id" => $media_library->getId(), "icon_id" => $icon_id, "code" => "qr_discount", "name" => "QR Coupons", "model" => "Promotion_Model_Promotion", "desktop_uri" => "promotion/application/", "mobile_uri" => "promotion/mobile_list/", "mobile_view_uri" => "promotion/mobile_view/", "mobile_view_uri_parameter" => "promotion_id", "social_sharing_is_available" => 1, "position" => 25);
$option = new Application_Model_Option();
<?php

$this->query("\n    CREATE TABLE topic (\n        `topic_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `app_id` int(11) unsigned NOT NULL,\n        `description` VARCHAR(250) COLLATE utf8_unicode_ci NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`topic_id`),\n        KEY KEY_VALUE_ID (value_id),\n        KEY option_value (value_id),\n        KEY app_id (app_id)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `topic_category` (\n        `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `topic_id` int(11) unsigned NOT NULL,\n        `parent_id` int(11) unsigned DEFAULT NULL,\n        `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n        `description` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `position` int(11) NOT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`category_id`),\n        KEY `topic_id` (`topic_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `topic_category_message` (\n        `category_message_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `category_id` int(11) unsigned NOT NULL,\n        `message_id` int(11) unsigned NOT NULL,\n        PRIMARY KEY (`category_message_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `topic_subscription` (\n        `subscription_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `category_id` int(11) unsigned NOT NULL,\n        `device_uid` text COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`subscription_id`),\n        KEY `category_id` (`category_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `topic`\n        ADD CONSTRAINT FK_TOPIC_APP_ID\n            FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `topic`\n        ADD CONSTRAINT FK_TOPIC_VALUE_ID\n            FOREIGN KEY (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `topic_category`\n        ADD CONSTRAINT `FK_TOPIC_CATEGORY_TOPIC_ID`\n            FOREIGN KEY (`topic_id`) REFERENCES `topic` (`topic_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `topic_subscription`\n        ADD CONSTRAINT `FK_TOPIC_SUBSCRIPTION_CATEGORY_ID`\n            FOREIGN KEY (`category_id`) REFERENCES `topic_category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Topics')->save();
$icon_paths = array('/topic/topics1.png', '/topic/topics2.png', '/topic/topics3.png', '/topic/topics4.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("contact", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "topic", 'name' => "Topics", 'model' => "Topic_Model_Topic", 'desktop_uri' => "topic/application/", 'mobile_uri' => "topic/mobile_list/", 'only_once' => 1, 'is_ajax' => 1, 'position' => 241);
$option = new Application_Model_Option();
$option->setData($data)->save();
Пример #10
0
<?php

$this->query("\n    CREATE TABLE `application_option_category` (\n        `category_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `code` VARCHAR(50) NOT NULL DEFAULT 1,\n        `name` VARCHAR(50) NOT NULL,\n        `icon` VARCHAR(255) NOT NULL,\n        `position` TINYINT(1) NOT NULL DEFAULT 1,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`category_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$categories = array(array("code" => "social", "name" => "Social", "icon" => "icon-share", "position" => 10, "features" => array("newswall", "fanwall", "social_gaming", "facebook")), array("code" => "media", "name" => "Media", "icon" => "icon-play", "position" => 20, "features" => array("image_gallery", "video_gallery", "music_gallery", "radio", "rss_feed")), array("code" => "contact", "name" => "Contact", "icon" => "icon-phone", "position" => 30, "features" => array("contact", "push_notification", "inapp_messages", "topic", "booking", "form")), array("code" => "monetization", "name" => "Monetization", "icon" => "icon-money", "position" => 40, "features" => array("m_commerce", "discount", "catalog", "set_meal", "loyalty", "qr_discount")), array("code" => "customization", "name" => "Customization", "icon" => "icon-edit", "position" => 50, "features" => array("custom_page", "source_code")), array("code" => "integration", "name" => "Integration", "icon" => "icon-globe", "position" => 60, "features" => array("weblink_mono", "weblink_multi", "wordpress", "magento", "woocommerce", "volusion", "shopify", "prestashop")), array("code" => "events", "name" => "Events", "icon" => "icon-calendar", "position" => 70, "features" => array("calendar")), array("code" => "misc", "name" => "Misc", "icon" => "icon-code", "position" => 80, "features" => array("folder", "padlock", "places", "code_scan")));
$this->query("ALTER TABLE `application_option` ADD `category_id` INT(11) UNSIGNED NOT NULL AFTER `option_id`;");
foreach ($categories as $category_data) {
    $category = new Application_Model_Option_Category();
    $category->setData($category_data)->save();
    foreach ($category_data["features"] as $feature_code) {
        $this->_db->update("application_option", array("category_id" => $category->getId()), array("code = ?" => $feature_code));
    }
}
$option = new Application_Model_Option();
$options = $option->findAll(array("uncategorized" => new Zend_Db_Expr("category_id = 0")));
if ($options->count() > 0) {
    $category = new Application_Model_Option_Category();
    $category->setData(array("code" => "other", "name" => "Other", "icon" => "icon-circle", "position" => 1000))->save();
    $this->_db->update("application_option", array("category_id" => $category->getId()), array("category_id = ?" => "0"));
}
$this->query("\n    ALTER TABLE `application_option`\n        ADD CONSTRAINT `FK_APPLICATION_OPTION_CATEGORY_ID`\n            FOREIGN KEY (`category_id`) REFERENCES `application_option_category` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE;\n");
$this->query("\n    ALTER TABLE `push_gcm_devices`\n        ADD FOREIGN KEY `FK_APPLICATION_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `push_messages`\n        ADD FOREIGN KEY `FK_APPLICATION_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
// Push Notifications
$library = new Media_Model_Library();
$library->setName('Push')->save();
$icon_paths = array('/push_notifications/push1.png', '/push_notifications/push2.png', '/push_notifications/push3.png', '/push_notifications/push4.png', '/push_notifications/push5.png', '/loyalty/loyalty6.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("contact", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "push_notification", 'name' => "Push Notifications", 'model' => "Push_Model_Message", 'desktop_uri' => "push/application/", 'mobile_uri' => "push/mobile_list/", 'only_once' => 1, 'is_ajax' => 1, 'position' => 130);
$option = new Application_Model_Option();
$option->setData($data)->save();
// In-App Message
$library = new Media_Model_Library();
$library->setName('Messages')->save();
$icon_paths = array('/inapp_messages/inapp1.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
<?php

// Créé la table de base
$this->query("\n    CREATE TABLE `form` (\n        `form_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `email` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`form_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `form_field` (\n        `field_id` int(11) NOT NULL AUTO_INCREMENT,\n        `section_id` int(11) NOT NULL,\n        `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `option` text COLLATE utf8_unicode_ci NOT NULL,\n        `required` tinyint(4) NOT NULL DEFAULT '0',\n        `type` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n        `position` smallint(5) NOT NULL DEFAULT '0',\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`field_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `form_section` (\n        `section_id` int(11) NOT NULL AUTO_INCREMENT,\n        `value_id` int(10) unsigned NOT NULL,\n        `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`section_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n");
$library = new Media_Model_Library();
$library->setName('Form')->save();
$icon_paths = array('/form/form1.png', '/form/form2.png', '/form/form3.png', '/calendar/calendar1.png', '/catalog/catalog6.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("contact", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "form", 'name' => "Form", 'model' => "Form_Model_Form", 'desktop_uri' => "form/application/", 'mobile_uri' => "form/mobile_view/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 190);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n    CREATE TABLE `comment` (\n        `comment_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `customer_id` int(11) UNSIGNED,\n        `title` VARCHAR(100) NULL DEFAULT NULL,\n        `subtitle` VARCHAR(255) NULL DEFAULT NULL,\n        `text` TEXT NOT NULL,\n        `image` varchar(255) NULL DEFAULT NULL,\n        `date` VARCHAR(100) NULL DEFAULT NULL,\n        `is_visible` int(11) DEFAULT '1',\n        `latitude` DECIMAL(11,8) NULL DEFAULT NULL,\n        `longitude` DECIMAL(11,8) NULL DEFAULT NULL,\n        `flag` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`comment_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `comment_answer` (\n        `answer_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `comment_id` int(11) UNSIGNED NOT NULL,\n        `customer_id` int(11) NOT NULL,\n        `text` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `flag` tinyint(1) UNSIGNED NOT NULL DEFAULT '0',\n        `is_visible` tinyint(1) NOT NULL DEFAULT '1',\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`answer_id`),\n        KEY `KEY_COMMENT_ID` (`comment_id`),\n        KEY `KEY_CUSTOMER_ID` (`customer_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `comment_like` (\n        `like_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `comment_id` int(11) UNSIGNED NOT NULL,\n        `customer_id` int(11) UNSIGNED DEFAULT NULL,\n        `customer_ip` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `user_agent` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`like_id`),\n        KEY `KEY_COMMENT_ID` (`comment_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `comment_radius` (\n        `radius_id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) UNSIGNED NOT NULL,\n        `radius` decimal(7,2) UNSIGNED DEFAULT 10,\n        PRIMARY KEY (`radius_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `comment`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `comment_answer`\n        ADD FOREIGN KEY `FK_COMMENT_ID` (`comment_id`) REFERENCES `comment` (`comment_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `comment_like`\n        ADD FOREIGN KEY `FK_COMMENT_ID` (`comment_id`) REFERENCES `comment` (`comment_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `comment_radius`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
// NEWSWALL
$library = new Media_Model_Library();
$library->setName("Newswall")->save();
$icon_paths = array("/newswall/newswall1.png", "/newswall/newswall2.png", "/newswall/newswall3.png", "/newswall/newswall4.png");
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array("library_id" => $library->getId(), "link" => $icon_path, "can_be_colorized" => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("social", "code");
$data = array("category_id" => $category->getId(), "library_id" => $library->getId(), "icon_id" => $icon_id, "code" => "newswall", "name" => "Newswall", "model" => "Comment_Model_Comment", "desktop_uri" => "comment/application/", "mobile_uri" => "comment/mobile_list/", "mobile_view_uri" => "comment/mobile_view/", "mobile_view_uri_parameter" => "comment_id", "only_once" => 0, "is_ajax" => 1, "position" => 10, "social_sharing_is_available" => 1);
$option = new Application_Model_Option();
$option->setData($data)->save();
$layouts = array(array("code" => 1, "option_id" => $option->getId(), "name" => "Layout 1", "preview" => "/customization/layout/newswall/layout-1.png", "position" => 1), array("code" => 2, "option_id" => $option->getId(), "name" => "Layout 2", "preview" => "/customization/layout/newswall/layout-2.png", "position" => 2));
foreach ($layouts as $data) {
    $this->_db->insert("application_option_layout", $data);
}
$this->query("\n    CREATE TABLE `weblink` (\n        `weblink_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `type_id` tinyint(1) unsigned NOT NULL DEFAULT '1',\n        `cover` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`weblink_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `weblink_link` (\n        `link_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `weblink_id` int(11) unsigned NOT NULL,\n        `picto` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `title` varchar(40) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `position` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        PRIMARY KEY (`link_id`),\n        KEY `KEY_WEBLINK_ID` (`weblink_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `weblink_link`\n        ADD FOREIGN KEY `FK_WEBLINK_ID` (`weblink_id`) REFERENCES `weblink` (`weblink_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Weblink')->save();
$icon_paths = array('/weblink/link1.png', '/weblink/link2.png', '/weblink/link3.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("integration", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "weblink_mono", 'name' => "Link", 'model' => "Weblink_Model_Type_Mono", 'desktop_uri' => "weblink/application_mono/", 'mobile_uri' => "weblink/mobile_mono/", 'only_once' => 0, 'is_ajax' => 0, 'position' => 150);
$option = new Application_Model_Option();
$option->setData($data)->save();
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "weblink_multi", 'name' => "Links", 'model' => "Weblink_Model_Type_Multi", 'desktop_uri' => "weblink/application_multi/", 'mobile_uri' => "weblink/mobile_multi/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 160);
$option = new Application_Model_Option();
$option->setData($data)->save();
$features = array('Magento' => array('icon_path' => '/magento/magento1.png', 'datas' => array('code' => 'magento', 'name' => 'Magento', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_magento/', 'mobile_uri' => 'weblink/mobile_mono/')), 'WooCommerce' => array('icon_path' => '/woocommerce/woocommerce1.png', 'datas' => array('code' => 'woocommerce', 'name' => 'WooCommerce', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_woocommerce/', 'mobile_uri' => 'weblink/mobile_mono/')), 'Prestashop' => array('icon_path' => '/prestashop/prestashop1.png', 'datas' => array('code' => 'prestashop', 'name' => 'Prestashop', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_prestashop/', 'mobile_uri' => 'weblink/mobile_mono/')), 'Volusion' => array('icon_path' => '/volusion/volusion1.png', 'datas' => array('code' => 'volusion', 'name' => 'Volusion', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_volusion/', 'mobile_uri' => 'weblink/mobile_mono/')), 'Shopify' => array('icon_path' => '/shopify/shopify1.png', 'datas' => array('code' => 'shopify', 'name' => 'Shopify', 'model' => 'Weblink_Model_Type_Mono', 'desktop_uri' => 'weblink/application_shopify/', 'mobile_uri' => 'weblink/mobile_mono/')));
foreach ($features as $feature_name => $feature) {
    $library = new Media_Model_Library();
    $library->setName($feature_name)->save();
    $data = array('library_id' => $library->getId(), 'link' => $feature['icon_path'], 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    $data = array_merge($feature['datas'], array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $image->getId(), 'only_once' => 0, 'is_ajax' => 0, 'position' => 155));
<?php

$this->query("\n    CREATE TABLE `rss_feed` (\n        `feed_id` int(11) NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `title` varchar(20) COLLATE utf8_unicode_ci NOT NULL,\n        `link` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `position` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `picture` tinyint(1) DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`feed_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `rss_feed`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName("RSS Feed")->save();
$icon_paths = array("/rss_feed/rss1.png", "/rss_feed/rss2.png", "/rss_feed/rss3.png", "/newswall/newswall1.png", "/newswall/newswall2.png", "/newswall/newswall3.png", "/newswall/newswall4.png");
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array("library_id" => $library->getId(), "link" => $icon_path, "can_be_colorized" => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("media", "code");
$data = array("category_id" => $category->getId(), "library_id" => $library->getId(), "icon_id" => $icon_id, "code" => "rss_feed", "name" => "RSS Feed", "model" => "Rss_Model_Feed", "desktop_uri" => "rss/application_feed/", "mobile_uri" => "rss/mobile_feed_list/", "mobile_view_uri" => "rss/mobile_feed_view/", "mobile_view_uri_parameter" => "feed_id", "only_once" => 0, "is_ajax" => 1, "position" => 80, "social_sharing_is_available" => 1);
$option = new Application_Model_Option();
$option->setData($data)->save();
$layouts = array();
foreach (array(1, 2, 3) as $layout_code) {
    $layouts[] = array("code" => $layout_code, "option_id" => $option->getId(), "name" => "Layout {$layout_code}", "preview" => "/customization/layout/rss-feed/layout-{$layout_code}.png", "position" => $layout_code);
}
foreach ($layouts as $data) {
    $this->_db->insert("application_option_layout", $data);
}
<?php

// Create the gallery
$library = new Media_Model_Library();
$library->setName('Tip')->save();
// Create the icons
$icons = array("/tip/tip1.png", "/tip/tip2.png");
$icon_id = null;
foreach ($icons as $icon) {
    $data = array('library_id' => $library->getId(), 'link' => $icon, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if (is_null($icon_id)) {
        $icon_id = $image->getId();
    }
}
// Categorization
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'tip', 'name' => 'Tips calculator', 'model' => 'Tip_Model_Tip', 'desktop_uri' => 'tip/application/', 'mobile_uri' => 'tip/mobile_view/', 'only_once' => 0, 'is_ajax' => 1, 'position' => 240, 'social_sharing_is_available' => 0);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n    CREATE TABLE `socialgaming_game` (\n        `game_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` INT(11) UNSIGNED NOT NULL,\n        `period_id` tinyint(1) NOT NULL DEFAULT '0',\n        `name` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\n        `gift` varchar(100) COLLATE utf8_unicode_ci NOT NULL,\n        `end_at` date DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`game_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `socialgaming_game`\n        ADD FOREIGN KEY `FK_APPLICATION_OPTION_VALUE_VALUE_ID` (value_id) references `application_option_value` (`value_id`) ON UPDATE CASCADE ON DELETE CASCADE\n    ;\n");
$library = new Media_Model_Library();
$library->setName('Contest')->save();
$icon_paths = array('/contest/contest1.png', '/contest/contest2.png', '/contest/contest3.png', '/contest/contest4.png', '/contest/contest5.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("social", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "social_gaming", 'name' => "Contest", 'model' => "Socialgaming_Model_Game", 'desktop_uri' => "socialgaming/application/", 'mobile_uri' => "socialgaming/mobile_view/", 'only_once' => 1, 'is_ajax' => 1, 'position' => 60);
$option = new Application_Model_Option();
$option->setData($data)->save();
    CREATE TABLE IF NOT EXISTS `padlock` (
        `padlock_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
        `value_id` INT(11) UNSIGNED NOT NULL,
        `created_at` DATETIME NOT NULL,
        `updated_at` DATETIME NOT NULL,
        PRIMARY KEY (`padlock_id`),
        FOREIGN KEY `FK_PADLOCK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci;
');
$this->query('
    CREATE TABLE IF NOT EXISTS `padlock_value` (
        `padlock_value_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
        `app_id` INT(11) UNSIGNED NOT NULL,
        `value_id` INT(11) UNSIGNED NOT NULL,
        PRIMARY KEY (`padlock_value_id`),
        FOREIGN KEY `FK_PADLOCK_VALUE_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE
    ) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci;
');
// Create the gallery
$library = new Media_Model_Library();
$library->setName('Padlock')->save();
// Create the icon
$data = array("library_id" => $library->getId(), 'link' => "/padlock/padlock.png", "can_be_colorized" => 1);
$image = new Media_Model_Library_Image();
$image->setData($data)->save();
$icon_id = $image->getId();
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "padlock", 'name' => "Padlock", 'model' => "Padlock_Model_Padlock", 'desktop_uri' => "padlock/application/", 'mobile_uri' => "padlock/mobile_view/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 220);
$option = new Application_Model_Option();
$option->setData($data)->save();
$this->query("\n    ALTER TABLE `media_gallery_music_elements`\n        ADD FOREIGN KEY `FK_GALLERY_ID` (`gallery_id`) REFERENCES `media_gallery_music` (`gallery_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_ALBUM_ID` (`album_id`) REFERENCES `media_gallery_music_album` (`album_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_TRACK_ID` (`track_id`) REFERENCES `media_gallery_music_track` (`track_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `media_gallery_music_track`\n        ADD FOREIGN KEY `FK_ALBUM_ID` (`album_id`) REFERENCES `media_gallery_music_album` (`album_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_GALLERY_ID` (`gallery_id`) REFERENCES `media_gallery_music` (`gallery_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
// Image Gallery
$library = new Media_Model_Library();
$library->setName('Images')->save();
$icon_paths = array('/images/image1.png', '/images/image2.png', '/images/image3.png', '/images/image4.png', '/images/image5.png', '/images/image6.png', '/images/image7.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("media", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "image_gallery", 'name' => "Images", 'model' => "Media_Model_Gallery_Image", 'desktop_uri' => "media/application_gallery_image/", 'mobile_uri' => "media/mobile_gallery_image_list/", "mobile_view_uri" => "media/mobile_gallery_image_view/", "mobile_view_uri_parameter" => "gallery_id,offset/0", 'only_once' => 0, 'is_ajax' => 1, 'position' => 90);
$option = new Application_Model_Option();
$option->setData($data)->save();
// Videos Gallery
$library = new Media_Model_Library();
$library->setName('Videos')->save();
$icon_paths = array('/videos/video1.png', '/videos/video2.png', '/videos/video3.png', '/videos/video4.png', '/videos/video5.png', '/videos/video6.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
<?php

$this->query("\n    CREATE TABLE `folder` (\n        `folder_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `root_category_id` int(11) unsigned NOT NULL,\n        PRIMARY KEY (`folder_id`),\n        KEY `KEY_VALUE_ID` (`value_id`),\n        KEY `KEY_CAT_ID` (`root_category_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `folder_category` (\n        `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `parent_id` int(11) unsigned DEFAULT NULL,\n        `type_id` enum('folder') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'folder',\n        `picture` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `title` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `subtitle` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,\n        `pos` int(11) DEFAULT NULL,\n        PRIMARY KEY (`category_id`),\n        KEY `KEY_PARENT_ID` (`parent_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `folder`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE,\n        ADD FOREIGN KEY `FK_ROOT_CATEGORY_ID` (`root_category_id`) REFERENCES `folder_category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `folder_category`\n        ADD FOREIGN KEY `FK_PARENT_ID` (`parent_id`) REFERENCES `folder_category` (`category_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Folders')->save();
$icon_paths = array('/folders/folder1.png', '/folders/folder2.png', '/folders/folder3.png', '/folders/folder4.png', '/folders/folder5.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("misc", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "folder", 'name' => "Folder", 'model' => "Folder_Model_Folder", 'desktop_uri' => "folder/application/", 'mobile_uri' => "folder/mobile_list/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 180);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query("\n    CREATE TABLE `booking` (\n        `booking_id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,\n        `value_id` INT(11) UNSIGNED NOT NULL\n    ) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `booking_store` (\n        `store_id` INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,\n        `booking_id` INT(11) NOT NULL,\n        `store_name` VARCHAR(255) NOT NULL,\n        `email` VARCHAR(255) NOT NULL,\n        KEY `KEY_BOOKING_ID` (`booking_id`)\n    ) ENGINE=InnoDB CHARACTER SET=utf8 COLLATE=utf8_unicode_ci;\n");
$library = new Media_Model_Library();
$library->setName('Booking')->save();
$icon_paths = array('booking1.png', 'booking2.png', 'booking3.png', 'booking4.png', 'booking5.png', 'booking6.png', 'booking7.png', 'booking8.png', 'booking9.png', 'booking10.png', 'booking11.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => '/booking/' . $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("contact", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'booking', 'name' => 'Booking', 'model' => 'Booking_Model_Booking', 'desktop_uri' => 'booking/application/', 'mobile_uri' => 'booking/mobile_view/', "mobile_view_uri" => "booking/mobile_view/", "mobile_view_uri_parameter" => null, 'only_once' => 0, 'is_ajax' => 1, 'position' => 140);
$option = new Application_Model_Option();
$option->setData($data)->save();
<?php

$this->query('
    CREATE TABLE `social_facebook` (
        `facebook_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
        `value_id` int(11) unsigned NOT NULL,
        `fb_user` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
        `created_at` datetime NOT NULL,
        `updated_at` datetime NOT NULL,
        PRIMARY KEY (`facebook_id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
');
$library = new Media_Model_Library();
$library->setName('Facebook')->save();
$icon_paths = array('/social_facebook/facebook1.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $data = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($data)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("social", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "facebook", 'name' => "Facebook", 'model' => "Social_Model_Facebook", 'desktop_uri' => "social/application_facebook/", 'mobile_uri' => "social/mobile_facebook_list/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 210);
$option = new Application_Model_Option();
$option->setData($data)->save();
$this->query("\n\n    CREATE TABLE `application_option` (\n        `option_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `category_id` INT(11) UNSIGNED NOT NULL,\n        `library_id` int(11) unsigned NOT NULL,\n        `icon_id` int(11) NOT NULL,\n        `code` varchar(20) NOT NULL,\n        `name` varchar(25) NOT NULL,\n        `model` varchar(100) NOT NULL,\n        `desktop_uri` varchar(100) NOT NULL,\n        `mobile_uri` varchar(100) NOT NULL,\n        `mobile_view_uri` varchar(100) NULL DEFAULT NULL,\n        `mobile_view_uri_parameter` varchar(100) NULL DEFAULT NULL,\n        `only_once` tinyint(1) NOT NULL DEFAULT '0',\n        `is_ajax` tinyint(1) NOT NULL DEFAULT '1',\n        `position` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `social_sharing_is_available` TINYINT(1) NOT NULL DEFAULT 0,\n        PRIMARY KEY (`option_id`),\n        KEY `KEY_LIBRARY_ID` (`library_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n");
$this->query("\n    CREATE TABLE `application_option_value` (\n        `value_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `app_id` INT(11) UNSIGNED NOT NULL,\n        `option_id` int(11) unsigned NOT NULL,\n        `layout_id` int(11) unsigned NOT NULL DEFAULT '1',\n        `icon_id` int(11) DEFAULT NULL,\n        `folder_id` int(11) unsigned DEFAULT NULL,\n        `folder_category_id` int(11) unsigned DEFAULT NULL,\n        `folder_category_position` int(11) unsigned DEFAULT NULL,\n        `tabbar_name` varchar(30) DEFAULT NULL,\n        `icon` varchar(255) DEFAULT NULL,\n        `background_image` varchar(255) DEFAULT NULL,\n        `is_visible` tinyint(1) NOT NULL DEFAULT '1',\n        `position` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `is_active` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        `social_sharing_is_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,\n        PRIMARY KEY (`value_id`),\n        KEY `KEY_APP_ID` (`app_id`),\n        KEY `KEY_OPTION_ID` (`option_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE IF NOT EXISTS `application_admin` (\n        `app_id` INT(11) UNSIGNED NOT NULL,\n        `admin_id` INT(11) UNSIGNED NOT NULL,\n        `is_allowed_to_add_pages` TINYINT(1) NOT NULL DEFAULT 1,\n        PRIMARY KEY (`app_id`,`admin_id`),\n        KEY `sign_id_idxfk` (`admin_id`)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `application_device` (\n        `device_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `app_id` INT(11) UNSIGNED NOT NULL,\n        `type_id` TINYINT(11) UNSIGNED NOT NULL,\n        `status_id` TINYINT(11) UNSIGNED NULL DEFAULT 1,\n        `admob_id` VARCHAR(50) NULL DEFAULT NULL,\n        `admob_type` enum('banner','interstitial') NOT NULL DEFAULT 'banner',\n        `version` VARCHAR(10) NOT NULL DEFAULT '0.0.1',\n        `developer_account_username` VARCHAR(255) NULL DEFAULT NULL,\n        `developer_account_password` VARCHAR(255) NULL DEFAULT NULL,\n        `use_our_developer_account` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,\n        `store_url` VARCHAR(255) NULL DEFAULT NULL,\n        `store_pass` VARCHAR(10) NULL DEFAULT NULL,\n        `store_app_id` VARCHAR(150) NULL DEFAULT NULL,\n        `banner_store_label` VARCHAR(150) NULL DEFAULT NULL,\n        `banner_store_price` VARCHAR(150) NULL DEFAULT NULL,\n        `key_pass` VARCHAR(10) NULL DEFAULT NULL,\n        `alias` VARCHAR(50) NULL DEFAULT NULL,\n        PRIMARY KEY (`device_id`),\n        KEY `KEY_APP_ID` (`app_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `application_option_layout` (\n        `layout_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `code` TINYINT(1) UNSIGNED NOT NULL DEFAULT 1,\n        `option_id` INT(11) UNSIGNED NOT NULL,\n        `name` VARCHAR(50) NOT NULL,\n        `preview` VARCHAR(255) NOT NULL,\n        `position` TINYINT(1) NOT NULL DEFAULT 1,\n        PRIMARY KEY (`layout_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `application_tc` (\n        `tc_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `app_id` INT(11) UNSIGNED NOT NULL,\n        `type` VARCHAR(50) NOT NULL,\n        `text` LONGTEXT NULL DEFAULT NULL,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`tc_id`),\n        INDEX `IDX_TC_APPLICATION_APP_ID` (`app_id`),\n        UNIQUE `UNIQUE_TC_APPLICATION_APP_ID_TYPE` (`app_id`, `type`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `application_acl_option` (\n        `application_acl_option_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `app_id` int(11) unsigned NOT NULL,\n        `admin_id` int(11) unsigned NOT NULL,\n        `value_id` int(11) unsigned NOT NULL,\n        `resource_code` varchar(50) COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`application_acl_option_id`),\n        KEY value_id (`value_id`)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    CREATE TABLE `application_option_category` (\n        `category_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `code` VARCHAR(50) NOT NULL DEFAULT 1,\n        `name` VARCHAR(50) NOT NULL,\n        `icon` VARCHAR(255) NOT NULL,\n        `position` TINYINT(1) NOT NULL DEFAULT 1,\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`category_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE application_acl_option\n        ADD CONSTRAINT FK_APPLICATION_ACL_OPTION_VALUE_ID\n            FOREIGN KEY (value_id) REFERENCES application_option_value (value_id) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("ALTER TABLE `application` ADD `key` VARCHAR(20) NOT NULL AFTER `bundle_id`;");
$this->query("ALTER TABLE `application` ADD UNIQUE `UNIQUE_APPLICATION_KEY` (`key`);");
$this->query("\n    ALTER TABLE `application_option_value`\n        ADD FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `application_option_value`\n        ADD FOREIGN KEY `FK_OPTION_ID` (`option_id`) REFERENCES `application_option` (`option_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `application_admin`\n        ADD FOREIGN KEY `FK_APPLICATION_APP_ID` (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `application_device`\n        ADD CONSTRAINT `APPLICATION_DEVICE_APP_ID`\n            FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `application_tc`\n        ADD CONSTRAINT `FK_APPLICATION_TC_APP_ID`\n            FOREIGN KEY (`app_id`) REFERENCES `application` (`app_id`) ON UPDATE CASCADE ON DELETE CASCADE;\n");
$this->query("\n    ALTER TABLE `application_option`\n        ADD CONSTRAINT `FK_APPLICATION_OPTION_CATEGORY_ID`\n            FOREIGN KEY (`category_id`) REFERENCES `application_option_category` (`category_id`) ON UPDATE CASCADE ON DELETE CASCADE;\n");
$this->query("ALTER TABLE `log` ADD FOREIGN KEY `FK_APPLICATION_APPLICATION_ID` (app_id) references `application` (`app_id`) ON UPDATE CASCADE ON DELETE CASCADE;");
$datas = array(array('name' => 'Layout 1', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_ALWAYS, 'code' => 'layout_1', 'preview' => '/customization/layout/homepage/layout_1.png', 'use_more_button' => 1, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => 5, 'position' => "bottom", "order" => 1, "is_active" => 1), array('name' => 'Layout 2', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_2', 'preview' => '/customization/layout/homepage/layout_2.png', 'use_more_button' => 1, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => 10, 'position' => "bottom", "order" => 2, "is_active" => 1), array('name' => 'Layout 3', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_3', 'preview' => '/customization/layout/homepage/layout_3.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 3, "is_active" => 1), array('name' => 'Layout 4', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_4', 'preview' => '/customization/layout/homepage/layout_4.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 4, "is_active" => 1), array('name' => 'Layout 5', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_5', 'preview' => '/customization/layout/homepage/layout_5.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 5, "is_active" => 1), array('name' => 'Layout 6', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_6', 'preview' => '/customization/layout/homepage/layout_6.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 6, "is_active" => 1), array('name' => 'Layout 7', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_7', 'preview' => '/customization/layout/homepage/layout_7.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 7, "is_active" => 1), array('name' => 'Layout 8', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_8', 'preview' => '/customization/layout/homepage/layout_8.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "bottom", "order" => 8, "is_active" => 0), array('name' => 'Layout 9', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_TOGGLE, 'code' => 'layout_9', 'preview' => '/customization/layout/homepage/layout_9.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => null, 'position' => "left", "order" => 9, "is_active" => 1), array('name' => 'Layout 3 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_3_h', 'preview' => '/customization/layout/homepage/layout_3-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 0, "number_of_displayed_icons" => 6, 'position' => "bottom", "order" => 10, "is_active" => 1), array('name' => 'Layout 4 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_4_h', 'preview' => '/customization/layout/homepage/layout_4-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 1, "number_of_displayed_icons" => 6, 'position' => "bottom", "order" => 11, "is_active" => 1), array('name' => 'Layout 5 - Horizontal', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_5_h', 'preview' => '/customization/layout/homepage/layout_5-h.png', 'use_more_button' => 0, 'use_horizontal_scroll' => 1, "number_of_displayed_icons" => 4, 'position' => "bottom", "order" => 12, "is_active" => 1), array('name' => 'Layout 10', 'visibility' => Application_Model_Layout_Homepage::VISIBILITY_HOMEPAGE, 'code' => 'layout_10', 'preview' => '/customization/layout/homepage/layout_10.png', 'use_more_button' => 1, 'use_horizontal_scroll' => 0, 'number_of_displayed_icons' => 5, 'position' => 'bottom', "order" => 13, "is_active" => 1));
foreach ($datas as $data) {
    $layout = new Application_Model_Layout_Homepage();
    $layout->setData($data)->save();
}
$categories = array(array("code" => "social", "name" => "Social", "icon" => "icon-share", "position" => 10), array("code" => "media", "name" => "Media", "icon" => "icon-play", "position" => 20), array("code" => "contact", "name" => "Contact", "icon" => "icon-phone", "position" => 30), array("code" => "monetization", "name" => "Monetization", "icon" => "icon-money", "position" => 40), array("code" => "customization", "name" => "Customization", "icon" => "icon-edit", "position" => 50), array("code" => "integration", "name" => "Integration", "icon" => "icon-globe", "position" => 60), array("code" => "events", "name" => "Events", "icon" => "icon-calendar", "position" => 70), array("code" => "misc", "name" => "Misc", "icon" => "icon-code", "position" => 80));
foreach ($categories as $category_data) {
    $category = new Application_Model_Option_Category();
    $category->setData($category_data)->save();
    foreach ($category_data["features"] as $feature_code) {
        $this->_db->update("application_option", array("category_id" => $category->getId()), array("code = ?" => $feature_code));
    }
}
$this->query("\n    ALTER TABLE `catalog_product`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `catalog_product_format`\n        ADD FOREIGN KEY `FK_PRODUCT_ID` (`product_id`) REFERENCES `catalog_product` (`product_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
// CATALOG
$library = new Media_Model_Library();
$library->setName('Catalog')->save();
$icon_paths = array('/catalog/catalog1.png', '/catalog/catalog2.png', '/catalog/catalog3.png', '/catalog/catalog4.png', '/catalog/catalog5.png', '/catalog/catalog6.png', '/catalog/catalog7.png', '/promotion/discount4.png', '/catalog/catalog8.png', '/catalog/catalog9.png', '/catalog/catalog10.png', '/catalog/catalog11.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("monetization", "code");
$datas = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'catalog', 'name' => 'Catalog', 'model' => 'Catalog_Model_Category', 'desktop_uri' => 'catalog/application/', 'mobile_uri' => 'catalog/mobile_category_list/', "mobile_view_uri" => "catalog/mobile_category_product_view/", "mobile_view_uri_parameter" => "product_id", 'only_once' => 0, 'is_ajax' => 1, 'position' => 30, 'social_sharing_is_available' => 1);
$option = new Application_Model_Option();
$option->setData($datas)->save();
$catalog_value_id = $option->getId();
// SET MEAL
$catalog_option = new Application_Model_Option();
$catalog_option->find('catalog', 'code');
$library = new Media_Model_Library();
if (!$catalog_option->getId()) {
    $library->setName('Set Meal')->save();
    $icon_paths = array('/catalog/catalog1.png', '/catalog/catalog2.png', '/catalog/catalog3.png', '/catalog/catalog4.png', '/catalog/catalog5.png', '/catalog/catalog6.png', '/catalog/catalog7.png', '/promotion/discount4.png', '/catalog/catalog8.png', '/catalog/catalog9.png', '/catalog/catalog10.png', '/catalog/catalog11.png');
    $icon_id = 0;
    foreach ($icon_paths as $key => $icon_path) {
        $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
<?php

$this->query("\n    CREATE TABLE `wordpress` (\n        `wp_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `value_id` int(11) unsigned NOT NULL,\n        `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',\n        `created_at` datetime NOT NULL,\n        `updated_at` datetime NOT NULL,\n        PRIMARY KEY (`wp_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `wordpress_category` (\n        `category_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `wp_id` int(11) unsigned NOT NULL,\n        `wp_category_id` int(11) NOT NULL,\n        `position` tinyint(1) unsigned NOT NULL DEFAULT '0',\n        PRIMARY KEY (`category_id`),\n        KEY `KEY_WP_ID` (`wp_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `wordpress`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `wordpress_category`\n        ADD FOREIGN KEY `FK_WP_ID` (`wp_id`) REFERENCES `wordpress` (`wp_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Wordpress')->save();
$icon_paths = array('/wordpress/wordpress1.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("integration", "code");
$data = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => "wordpress", 'name' => "Wordpress", 'model' => "Wordpress_Model_Wordpress", 'desktop_uri' => "wordpress/application/", 'mobile_uri' => "wordpress/mobile_list/", 'only_once' => 0, 'is_ajax' => 1, 'position' => 170, 'social_sharing_is_available' => 1);
$option = new Application_Model_Option();
$option->setData($data)->save();
$layouts = array();
foreach (array(1, 2, 3) as $layout_code) {
    $layouts[] = array("code" => $layout_code, "option_id" => $option->getId(), "name" => "Layout {$layout_code}", "preview" => "/customization/layout/wordpress/layout-{$layout_code}.png", "position" => $layout_code);
}
foreach ($layouts as $data) {
    $this->_db->insert("application_option_layout", $data);
}
$this->query("\n    CREATE TABLE `cms_application_page_block_video_youtube` (\n        `video_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n        `search` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        `youtube` varchar(255) COLLATE utf8_unicode_ci NOT NULL,\n        PRIMARY KEY (`video_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n\n    CREATE TABLE `cms_application_page_block_button` (\n        `button_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,\n        `value_id` INT(11) UNSIGNED NOT NULL,\n        `type_id` ENUM('link','phone') NOT NULL DEFAULT 'phone',\n        `content` VARCHAR(256) NULL DEFAULT NULL,\n        PRIMARY KEY (`button_id`),\n        KEY `KEY_VALUE_ID` (`value_id`)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;\n");
$this->query("\n    ALTER TABLE `cms_application_page`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `application_option_value` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_address`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `cms_application_page_block` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_image`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `cms_application_page_block` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_text`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `cms_application_page_block` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_video`\n        ADD FOREIGN KEY `FK_VALUE_ID` (`value_id`) REFERENCES `cms_application_page_block` (`value_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_video_link`\n        ADD FOREIGN KEY `FK_VIDEO_ID` (`video_id`) REFERENCES `cms_application_page_block_video` (`video_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_video_podcast`\n        ADD FOREIGN KEY `FK_VIDEO_ID` (`video_id`) REFERENCES `cms_application_page_block_video` (`video_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$this->query("\n    ALTER TABLE `cms_application_page_block_video_youtube`\n        ADD FOREIGN KEY `FK_VIDEO_ID` (`video_id`) REFERENCES `cms_application_page_block_video` (`video_id`) ON DELETE CASCADE ON UPDATE CASCADE;\n");
$library = new Media_Model_Library();
$library->setName('Custom Page')->save();
$icon_paths = array('/custom_page/custom1.png', '/loyalty/loyalty6.png', '/newswall/newswall1.png', '/newswall/newswall2.png', '/newswall/newswall3.png', '/newswall/newswall4.png', '/push_notifications/push1.png', '/push_notifications/push2.png', '/catalog/catalog6.png', '/catalog/catalog8.png', '/catalog/catalog9.png');
$icon_id = 0;
foreach ($icon_paths as $key => $icon_path) {
    $datas = array('library_id' => $library->getId(), 'link' => $icon_path, 'can_be_colorized' => 1);
    $image = new Media_Model_Library_Image();
    $image->setData($datas)->save();
    if ($key == 0) {
        $icon_id = $image->getId();
    }
}
$category = new Application_Model_Option_Category();
$category->find("customization", "code");
$datas = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'custom_page', 'name' => 'Custom Page', 'model' => 'Cms_Model_Application_Page', 'desktop_uri' => 'cms/application_page/', 'mobile_uri' => 'cms/mobile_page_view/', "mobile_view_uri" => "cms/mobile_page_view/", "mobile_view_uri_parameter" => null, 'only_once' => 0, 'is_ajax' => 1, 'position' => 70, 'social_sharing_is_available' => 1);
$option = new Application_Model_Option();
$option->setData($datas)->save();
$datas = array(array('type' => 'text', 'position' => 1, 'icon' => 'icon-file-alt', 'title' => 'Text', 'template' => 'cms/application/page/edit/block/text.phtml', 'mobile_template' => 'cms/page/%s/view/block/text.phtml'), array('type' => 'image', 'position' => 2, 'icon' => 'icon-picture', 'title' => 'Image', 'template' => 'cms/application/page/edit/block/image.phtml', 'mobile_template' => 'cms/page/%s/view/block/image.phtml'), array('type' => 'video', 'position' => 3, 'icon' => 'icon-facetime-video', 'title' => 'Video', 'template' => 'cms/application/page/edit/block/video.phtml', 'mobile_template' => 'cms/page/%s/view/block/video.phtml'), array('type' => 'address', 'position' => 4, 'icon' => 'icon-location-arrow', 'title' => 'Address', 'template' => 'cms/application/page/edit/block/address.phtml', 'mobile_template' => 'cms/page/%s/view/block/address.phtml'), array('type' => 'button', 'position' => 5, 'icon' => 'icon-barcode', 'title' => 'Button', 'template' => 'cms/application/page/edit/block/button.phtml', 'mobile_template' => 'cms/page/%s/view/block/button.phtml'));
foreach ($datas as $data) {
    $block = new Cms_Model_Application_Block();
    $block->setData($data)->save();
}