<?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);
}
<?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();
$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\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();
<?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();
        `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();
$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();
}