public function find($id, $field = null) { parent::find($id, $field); $this->addOptionDatas(); $this->prepareUri(); return $this; }
public function getDummy() { $color = str_replace('#', '', $this->getApplication()->getBlock('tabbar')->getImageColor()); $option = new Application_Model_Option(); $option->find('newswall', 'code'); $dummy = new self(); $dummy->addData($option->getData())->setTabbarName('Sample')->setIsDummy(1)->setIsActive(1)->setIconUrl(Core_Model_Url::create("template/block/colorize", array('id' => $dummy->getIconId(), 'color' => $color)))->setId(0); return $dummy; }
public function findallAction() { $preview = new Preview_Model_Preview(); $previews = $preview->findAll(null, array("group_by" => "aop.preview_id")); $data = array(); foreach ($previews as $preview) { $option = new Application_Model_Option(); $option->find($preview->getOptionId()); $data[] = array("id" => $preview->getId(), "title" => $preview->getTitle(), "feature" => $preview->getOptionId(), "feature_name" => $option->getName()); } $this->_sendHtml($data); }
public function createDummyContents($option_value, $design, $category) { $dummy_content_xml = $this->_getDummyXml($design, $category); foreach ($dummy_content_xml->folders->folder as $folder) { $root_category = new Folder_Model_Category(); $root_category->addData((array) $folder->category->main->content)->save(); if ($folder->category->main->features) { $i = 1; foreach ($folder->category->main->features->feature as $feature) { $option = new Application_Model_Option(); $option->find((string) $feature->code, "code")->getObject(); $option_value_obj = new Application_Model_Option_Value(); $icon_id = NULL; if ((string) $feature->icon) { $icon = new Media_Model_Library_Image(); $icon->find((string) $feature->icon, "link"); if (!$icon->getData()) { $icon->setLibraryId($option->getLibraryId())->setLink((string) $feature->icon)->setOptionId($option->getId())->setCanBeColorized($feature->colorizable ? (string) $feature->colorizable : 1)->setPosition(0)->save(); } $icon_id = $icon->getId(); } $datas = array("tabbar_name" => (string) $feature->name ? (string) $feature->name : NULL, "icon_id" => $icon_id, "app_id" => $this->getApplication()->getId(), "option_id" => $option->getId(), "layout_id" => $this->getApplication()->getLayout()->getId(), "folder_id" => $option_value->getId(), "folder_category_id" => $root_category->getId(), "folder_category_position" => $i++); $option_value_obj->addData($datas)->save(); } } $this->unsData(); $this->setValueId($option_value->getId())->setRootCategoryId($root_category->getId())->save(); foreach ($folder->category->subcategory as $subcategory) { $sub_root_category = new Folder_Model_Category(); $sub_root_category->addData((array) $subcategory->content)->setParentId($root_category->getId())->save(); if ($folder->category->subcategory->features) { $i = 1; foreach ($folder->category->subcategory->features->children() as $feature) { $option = new Application_Model_Option(); $option->find((string) $feature->code, "code")->getObject(); $option_value_obj = new Application_Model_Option_Value(); $icon_id = NULL; if ((string) $feature->icon) { $icon = new Media_Model_Library_Image(); $icon->find((string) $feature->icon, "link"); if (!$icon->getData()) { $icon->setLibraryId($option->getLibraryId())->setLink((string) $feature->icon)->setOptionId($option->getId())->setCanBeColorized(1)->setPosition(0)->save(); } $icon_id = $icon->getId(); } $datas = array("tabbar_name" => (string) $feature->name ? (string) $feature->name : NULL, "icon_id" => $icon_id, "app_id" => $this->getApplication()->getId(), "option_id" => $option->getId(), "layout_id" => $this->getApplication()->getLayout()->getId(), "folder_id" => $option_value->getId(), "folder_category_id" => $sub_root_category->getId(), "folder_category_position" => $i++); $option_value_obj->addData($datas)->save(); } } } } }
public function createDummyContents($option_value, $design, $category) { $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $dummy_content_xml = $this->_getDummyXml($design, $category); if ($option->getCode() == 'places' && $dummy_content_xml->places) { foreach ($dummy_content_xml->places->children() as $content) { $this->unsData(); $blocks = array(); $i = 1; foreach ($content->block as $block_content) { $block = new Cms_Model_Application_Block(); $block->find((string) $block_content->type, "type"); $data = (array) $block_content; if ($block_content->image_url) { $data['image_url'] = (array) $block_content->image_url; $data['image_fullsize_url'] = (array) $block_content->image_fullsize_url; } $data["block_id"] = $block->getId(); $blocks[$i++] = $data; } $this->addData((array) $content->content)->setBlock($blocks)->setValueId($option_value->getId())->save(); } } else { $blocks = array(); $i = 1; foreach ($dummy_content_xml->blocks->children() as $content) { $block = new Cms_Model_Application_Block(); $block->find((string) $content->type, "type"); $data = (array) $content; if ($content->image_url) { $data['image_url'] = (array) $content->image_url; $data['image_fullsize_url'] = (array) $content->image_fullsize_url; } $data["block_id"] = $block->getId(); $blocks[$i++] = $data; } $this->setValueId($option_value->getId())->setBlock($blocks)->save(); } }
public function findaccessAction() { if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) { try { if (empty($data["admin_id"]) or empty($data["app_id"])) { throw new Exception($this->_("An error occurred while saving. Please try again later.")); } $admin = new Admin_Model_Admin(); $admin->find($data["admin_id"]); $app = new Application_Model_Application(); $app->find($data["app_id"]); $app_acl_option = new Application_Model_Acl_Option(); $forbidden_options = $app_acl_option->findAllByAppId($data["app_id"], $data["admin_id"]); $option_tmp = array(); foreach ($forbidden_options as $option) { $option_tmp[] = $option->getValueId(); } $forbidden_options = $option_tmp; $data = array("app_name" => $app->getName(), "user_name" => $admin->getData("firstname") . " " . $admin->getData("lastname"), "can_add_page" => $admin->isAllowedToAddPages($data["app_id"]), "options" => array()); foreach ($app->getOptions() as $option) { $option_is_allowed = !in_array($option->getValueId(), $forbidden_options); $option_obj = new Application_Model_Option(); $option_obj->find($option->getOptionId()); if ($option_obj->getId()) { $icon_url = $option_obj->getIconUrl(); } else { $icon_url = null; } $data["options"][] = array("value_id" => $option->getValueId(), "icon_url" => $icon_url, "name" => $option->getTabbarName() ? $option->getTabbarName() : $option->getName(), "code" => $option->getCode(), "is_allowed" => $option_is_allowed); } } catch (Exception $e) { $data = array("error" => 1, "message" => $e->getMessage()); } $this->_sendHtml($data); } }
public function addfeatureAction() { if ($datas = $this->getRequest()->getPost()) { try { // Test s'il y a un value_id if (empty($datas['value_id'])) { throw new Exception($this->_('An error occurred while saving')); } // Récupère l'option_value en cours $option_value = new Application_Model_Option_Value(); $option_value->find($datas['value_id']); $category = new Folder_Model_Category(); $category->find($datas['category_id'], 'category_id'); // Récupère l'option_value en cours $category_option_value = new Application_Model_Option_Value(); $category_option_value->find($datas['category_value_id']); $next_positon = $category_option_value->getNextFolderCategoryPosition($datas['category_id']); $option_folder = new Application_Model_Option(); $option_folder->find(array('code' => 'folder')); $option_folder_id = $option_folder->getOptionId(); if ($category_option_value->getFolderCategoryId() == $datas['category_id'] || $category_option_value->getOptionId() == $option_folder_id) { throw new Exception($this->_('You cannot add this feature')); } $category_option_value->setFolderId($datas['value_id'])->setFolderCategoryPosition($next_positon)->setFolderCategoryId($category->getCategoryId())->save(); $html = array('success' => 1, 'folder_id' => $datas['value_id']); } catch (Exception $e) { $html = array('message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
<?php $option = new Application_Model_Option(); $option->find("calendar", "code"); $option->setMobileUri("event/mobile_list/")->save();
public function setbackgroundimageAction() { if ($datas = $this->getRequest()->getPost()) { try { $option_value = new Application_Model_Option_Value(); $option_value->find($datas['option_id']); if (!$option_value->getId()) { throw new Exception($this->_("An error occurred while saving your picture. Please try againg later.")); } // Récupère l'option $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $save_path = '/feature/' . $option->getId() . '/background/'; $relative_path = Application_Model_Application::getImagePath() . $save_path; $folder = Application_Model_Application::getBaseImagePath() . $save_path; $datas['dest_folder'] = $folder; $uploader = new Core_Model_Lib_Uploader(); $file = $uploader->savecrop($datas); $option_value->setBackgroundImage($save_path . $file)->save(); $datas = array('success' => 1, 'file' => $relative_path . $file); } catch (Exception $e) { $datas = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($datas)); } }
<?php $fields = array_keys($this->_db->describeTable("application_option")); if (!in_array("mobile_view_uri", $fields)) { $this->query("\n ALTER TABLE `application_option` ADD `mobile_view_uri` varchar(100) NULL DEFAULT NULL AFTER `mobile_uri`;\n ALTER TABLE `application_option` ADD `mobile_view_uri_parameter` varchar(100) NULL DEFAULT NULL AFTER `mobile_view_uri`;\n "); } $mobile_view_uris = array("booking" => array("mobile_view_uri" => "booking/mobile_view/", "mobile_view_uri_parameter" => null), "calendar" => array("mobile_view_uri" => "event/mobile_view/", "mobile_view_uri_parameter" => "event_id"), "catalog" => array("mobile_view_uri" => "catalog/mobile_category_product_view/", "mobile_view_uri_parameter" => "product_id"), "custom_page" => array("mobile_view_uri" => "cms/mobile_page_view/", "mobile_view_uri_parameter" => null), "discount" => array("mobile_view_uri" => "promotion/mobile_view/", "mobile_view_uri_parameter" => "promotion_id"), "fanwall" => array("mobile_view_uri" => "comment/mobile_view/", "mobile_view_uri_parameter" => "comment_id"), "image_gallery" => array("mobile_view_uri" => "media/mobile_gallery_image_view/", "mobile_view_uri_parameter" => "gallery_id,offset/0"), "m_commerce" => array("mobile_view_uri" => "mcommerce/mobile_product/", "mobile_view_uri_parameter" => "product_id"), "music_gallery" => array("mobile_view_uri" => "media/mobile_api_music_playlist/", "mobile_view_uri_parameter" => "playlist_id"), "newswall" => array("mobile_view_uri" => "comment/mobile_view/", "mobile_view_uri_parameter" => "comment_id"), "qr_discount" => array("mobile_view_uri" => "promotion/mobile_view/", "mobile_view_uri_parameter" => "promotion_id"), "rss_feed" => array("mobile_view_uri" => "rss/mobile_feed_view/", "mobile_view_uri_parameter" => "feed_id"), "set_meal" => array("mobile_view_uri" => "catalog/mobile_setmeal_view/", "mobile_view_uri_parameter" => "set_meal_id"), "video_gallery" => array("mobile_view_uri" => "media/mobile_gallery_video_view/", "mobile_view_uri_parameter" => "gallery_id,offset/1")); foreach ($mobile_view_uris as $option_code => $option_uris) { $application_option = new Application_Model_Option(); $application_option->find($option_code, "code"); if ($application_option->getId()) { $application_option->setMobileViewUri($option_uris["mobile_view_uri"]); $application_option->setMobileViewUriParameter($option_uris["mobile_view_uri_parameter"]); $application_option->save(); } }
<?php $option = new Application_Model_Option(); $option->find("image_gallery", "code"); $option->setMobileUri("media/mobile_gallery_image_list/")->save(); $option = new Application_Model_Option(); $option->find("video_gallery", "code"); $option->setMobileUri("media/mobile_gallery_video_list/")->save();
<?php $option = new Application_Model_Option(); $option->find("catalog", "code"); $option->setModel("Catalog_Model_Category")->save();
<?php $this->query("ALTER TABLE `promotion` ADD `picture` VARCHAR(255) NULL DEFAULT NULL AFTER `title`"); $promotion = new Application_Model_Option(); $promotion->find("discount", "code"); $layouts = array(array("code" => 1, "option_id" => $promotion->getId(), "name" => "Layout 1", "preview" => "/customization/layout/promotion/layout-1.png", "position" => 1), array("code" => 2, "option_id" => $promotion->getId(), "name" => "Layout 2", "preview" => "/customization/layout/promotion/layout-2.png", "position" => 2)); foreach ($layouts as $data) { $this->_db->insert("application_option_layout", $data); }
<?php $option = new Application_Model_Option(); $option->find("social_gaming", "code"); $option->setMobileUri("socialgaming/mobile_view/")->save();
<?php $option = new Application_Model_Option(); $option->find("catalog", "code"); $option->setMobileUri("catalog/mobile_category_list/")->save(); $option = new Application_Model_Option(); $option->find("set_meal", "code"); $option->setMobileUri("catalog/mobile_setmeal_list/")->save();
<?php $option = new Application_Model_Option(); $option->find("wordpress", "code"); $option->setMobileUri("wordpress/mobile_list/")->save();
<?php $fields = array_keys($this->_db->describeTable("comment")); $field = in_array("customer_id", $fields) ? "customer_id" : "value_id"; $this->query("\n ALTER TABLE `comment`\n ADD `title` VARCHAR(100) NULL DEFAULT NULL AFTER `{$field}`,\n ADD `subtitle` VARCHAR(255) NULL DEFAULT NULL AFTER `title`,\n ADD `date` VARCHAR(100) NULL DEFAULT NULL AFTER `image`\n ;\n"); $newswall = new Application_Model_Option(); $newswall->find("newswall", "code"); $layouts = array(array("code" => 1, "option_id" => $newswall->getId(), "name" => "Layout 1", "preview" => "/customization/layout/newswall/layout-1.png", "position" => 1), array("code" => 2, "option_id" => $newswall->getId(), "name" => "Layout 2", "preview" => "/customization/layout/newswall/layout-2.png", "position" => 2)); foreach ($layouts as $data) { $this->_db->insert("application_option_layout", $data); }
public function getPage($code) { $dummy = new Application_Model_Option(); $dummy->find($code, 'code'); $page_sought = new Application_Model_Option_Value(); return $page_sought->find(array('option_id' => $dummy->getId())); }
<?php $option = new Application_Model_Option(); $option->find("folder", "code"); $option->setMobileUri("folder/mobile_list/")->save();
$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(); } } } else { $library->find($catalog_option->getLibraryId()); $icons = $library->getIcons(); $icons->next(); $icon_id = $icons->current()->getId(); } $datas = array('category_id' => $category->getId(), 'library_id' => $library->getId(), 'icon_id' => $icon_id, 'code' => 'set_meal', 'name' => 'Set Meal', 'model' => 'Catalog_Model_Product', 'desktop_uri' => 'catalog/application_menu/', 'mobile_uri' => 'catalog/mobile_setmeal_list/', "mobile_view_uri" => "catalog/mobile_setmeal_view/", "mobile_view_uri_parameter" => "set_meal_id", 'only_once' => 0, 'is_ajax' => 1, 'position' => 35, 'social_sharing_is_available' => 1); $option = new Application_Model_Option(); $option->setData($datas)->save(); $set_meal_value_id = $option->getId(); $layout_data = array(array("value_id" => $catalog_value_id, "image_path" => "/customization/layout/catalog"), array("value_id" => $set_meal_value_id, "image_path" => "/customization/layout/set-meal")); foreach ($layout_data as $data) { $layouts = array(); $option = new Application_Model_Option(); $option->find($data["value_id"]); foreach (array(1, 2, 3) as $layout_code) { $layouts[] = array("code" => $layout_code, "option_id" => $option->getId(), "name" => "Layout {$layout_code}", "preview" => "{$data["image_path"]}/layout-{$layout_code}.png", "position" => $layout_code); } foreach ($layouts as $data) { $this->_db->insert("application_option_layout", $data); } }
<?php $option = new Application_Model_Option(); $option->find("rss_feed", "code"); $option->setMobileUri("rss/mobile_feed_list/")->save();
<?php $option = new Application_Model_Option(); $option->find('loyalty', 'code'); $option->setOnlyOnce(1)->save();
<?php $application_option = new Application_Model_Option(); $application_option->find("topic", "code"); $application_option->setMobileUri("topic/mobile_list/")->save();
<?php $this->query("ALTER TABLE `contact`\n ADD `latitude` DECIMAL(11,8) NULL DEFAULT NULL AFTER `country`,\n ADD `longitude` DECIMAL(11,8) NULL DEFAULT NULL AFTER `latitude`;\n"); $option = new Application_Model_Option(); $option->find("contact", "code"); $option->setMobileUri("contact/mobile_view/")->save();
<?php $option = new Application_Model_Option(); $option->find("custom_page", "code"); $option->setMobileUri("cms/mobile_page_view/")->save();
<?php $option = new Application_Model_Option(); $option->find("loyalty", "code"); $option->setMobileUri("loyaltycard/mobile_view/")->save();
public function createDummyContents($option_value, $design, $category) { $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $dummy_content_xml = $this->_getDummyXml($design, $category); if ($option->getCode() == "catalog") { foreach ($dummy_content_xml->catalog->children() as $categories) { $this->unsData(); //check si la category existe sur cette app $category_data = array("name" => $categories->name, "value_id" => $option_value->getId()); $category_id = $this->find($category_data)->getCategoryId(); if (!$category_id) { $this->setName((string) $categories->name)->setValueId($option_value->getId())->save(); $category_id = $this->getId(); } foreach ($categories->products->children() as $product) { $product_model = new Catalog_Model_Product(); if ($product->attributes()->subcategory) { $sub_category_model = new Catalog_Model_Category(); //check si la sous category existe sur cette app $subcategory_data = array("name" => $product->attributes()->subcategory, "value_id" => $option_value->getId()); $sub_category_model->find($subcategory_data); if (!$sub_category_model->getCategoryId()) { $sub_category_model->setName($product->attributes()->subcategory)->setValueId($option_value->getId())->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } else { $sub_category_model->setParentId($category_id)->save(); $product_model->setCategoryId($sub_category_model->getId()); } } else { $product_model->setCategoryId($category_id); } foreach ($product->content->children() as $key => $value) { $product_model->addData((string) $key, (string) $value); } if ($product->formats) { $format_option = array(); foreach ($product->formats->children() as $format) { foreach ($format as $key => $val) { $format_option[$format->getName()][(string) $key] = (string) $val; } } $product_model->setOption($format_option); } $product_model->setValueId($option_value->getId())->save(); } } } }
public function createDummyContents($option_value, $design, $category) { $option = new Application_Model_Option(); $option->find($option_value->getOptionId()); $dummy_content_xml = $this->_getDummyXml($design, $category); if ($option->getCode() == "set_meal") { foreach ($dummy_content_xml->set_meal->children() as $content) { $this->unsData(); $this->addData((array) $content)->setValueId($option_value->getId())->save(); } } }
<?php $option = new Application_Model_Option(); $option->find("facebook", "code"); $option->setMobileUri("social/mobile_facebook_list/")->save();
<?php $option = new Application_Model_Option(); $option->find("discount", "code"); $option->setMobileUri("promotion/mobile_list/")->save();