public function findallAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id')) {
         try {
             $category_id = $this->getRequest()->getParam('category_id');
             $current_category = new Folder_Model_Category();
             if ($category_id) {
                 $current_category->find($category_id, 'category_id');
             }
             $object = $this->getCurrentOptionValue()->getObject();
             if (!$object->getId() or $current_category->getId() and $current_category->getRootCategoryId() != $object->getRootCategoryId()) {
                 throw new Exception($this->_('An error occurred during process. Please try again later.'));
             }
             if (!$current_category->getId()) {
                 $current_category = $object->getRootCategory();
             }
             $data = array("folders" => array());
             $subcategories = $current_category->getChildren();
             foreach ($subcategories as $subcategory) {
                 $data["folders"][] = array("title" => $subcategory->getTitle(), "subtitle" => $subcategory->getSubtitle(), "picture" => $subcategory->getPictureUrl(), "url" => $this->getPath("folder/mobile_list", array("value_id" => $value_id, "category_id" => $subcategory->getId())));
             }
             $pages = $current_category->getPages();
             $color = $this->getApplication()->getBlock('background')->getImageColor();
             foreach ($pages as $page) {
                 $data["folders"][] = array("title" => $page->getTabbarName(), "subtitle" => "", "picture" => $this->_getColorizedImage($page->getIconId(), $color), 'is_link' => !$page->getIsAjax(), "url" => $page->getPath(null, array('value_id' => $page->getId()), false), "code" => $page->getCode(), "is_locked" => $page->isLocked());
             }
             $data["cover"] = array("title" => $current_category->getTitle(), "subtitle" => $current_category->getSubtitle(), "picture" => $current_category->getPictureUrl());
             $data["page_title"] = $current_category->getTitle();
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }
 public function findchildrenAction()
 {
     if ($category_id = $this->getRequest()->getParam('category_id')) {
         try {
             $current_category = new Folder_Model_Category();
             $current_category->find($category_id, 'category_id');
             $object = $this->getCurrentOptionValue()->getObject();
             if (!$current_category->getId() or !$object->getId() or $current_category->getRootCategoryId() != $object->getRootCategoryId()) {
                 throw new Exception($this->_('An error occurred during process. Please try again later.'));
             }
             $html = $this->getLayout()->addPartial('category_' . $current_category->getCategoryId(), 'core_view_mobile_default', 'folder/l1/view/category.phtml')->setCurrentOptionValue($this->getCurrentOptionValue())->setCurrentCategory($current_category)->setId($current_category->getId() == $object->getRootCategoryId() ? $object->getValueId() : 'subcategory_' . $current_category->getId())->toHtml();
             $html = array('html' => mb_convert_encoding($html, 'UTF-8', 'UTF-8'), 'title' => $current_category->getTitle());
             if ($this->getCurrentOptionValue()->getCode() == 'm_commerce') {
                 $html = array_merge($html, array('next_button_title' => $this->_('Cart'), 'next_button_arrow_is_visible' => 1));
             }
             if ($url = $this->getCurrentOptionValue()->getBackgroundImageUrl()) {
                 $html['background_image_url'] = $url;
             }
         } catch (Exception $e) {
             $html = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($html);
     }
 }
 public function deletecategoryAction()
 {
     if ($datas = $this->getRequest()->getParams()) {
         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']);
             $parent_id = $category->getParentId();
             $category->delete();
             $value_ids = array();
             $option_value = new Application_Model_Option_Value();
             $option_values = $option_value->findAll(array('a.app_id' => $this->getApplication()->getId()), 'position ASC');
             foreach ($option_values as $option_value) {
                 if ($option_value->getFolderId() or $option_value->getCode() == "folder") {
                     continue;
                 }
                 $value_ids[] = $option_value->getId();
             }
             $html = array('success' => 1, 'parent_id' => $parent_id, 'value_ids' => $value_ids);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
 public function settabbarnameAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             // Test les données
             if (empty($datas['option_value_id']) or empty($datas['tabbar_name'])) {
                 throw new Exception($this->_('An error occurred while saving your page name.'));
             }
             // Charge l'option_value
             $option_value = new Application_Model_Option_Value();
             $option_value->setApplication($this->getApplication());
             $option_value->find($datas['option_value_id']);
             // Test s'il n'y a pas embrouille entre l'id de l'application dans l'option_value et l'id de l'application en session
             if (!$option_value->getId()) {
                 throw new Exception($this->_('An error occurred while saving your page name.'));
             }
             $option_folder = new Application_Model_Option();
             $option_folder->find(array('code' => 'folder'));
             $option_folder_id = $option_folder->getOptionId();
             if ($option_value->getOptionId() == $option_folder_id) {
                 $folder = new Folder_Model_Folder();
                 $folder->find($datas['option_value_id'], 'value_id');
                 $category = new Folder_Model_Category();
                 $category->find($folder->getRootCategoryId(), 'category_id');
                 $category->setTitle($datas['tabbar_name'])->save();
             }
             if (in_array($option_value->getId(), array('customer_account', 'more_items'))) {
                 $code = $option_value->getId() == 'customer_account' ? 'tabbar_account_name' : 'tabbar_more_name';
                 $this->getApplication()->setData($code, $datas['tabbar_name'])->save();
             } else {
                 $option_value->setTabbarName($datas['tabbar_name'])->save();
             }
             // Renvoie OK
             $html = array('success' => 1);
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
Exemple #5
0
 public function copyTo($option)
 {
     $root_category = new Folder_Model_Category();
     $root_category->find($this->getRootCategoryId());
     $this->copyCategoryTo($option, $root_category);
     $this->setId(null)->setValueId($option->getId())->setRootCategoryId($root_category->getId())->save();
     return $this;
 }