Beispiel #1
0
 public function delete()
 {
     $category_option = new Application_Model_Option_Value();
     $option_values = $category_option->findAll(array('folder_category_id' => $this->getId()));
     if ($option_values->count()) {
         foreach ($option_values as $option_value) {
             $option_value->setFolderId(null)->setFolderCategoryId(null)->setFolderCategoryPosition(null)->save();
         }
     }
     foreach ($this->getChildren() as $child) {
         $child->delete();
     }
     return parent::delete();
 }
 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 deleteAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['value_id'])) {
                 throw new Exception($this->_('An error occurred while deleting the option'));
             }
             // Récupère les données de l'application pour cette option
             $option_value = new Application_Model_Option_Value();
             $option_value->find($datas['value_id']);
             // Option folder
             if (isset($datas['category_id'])) {
                 // Récupère l'option_value en cours
                 $category_option_value = new Application_Model_Option_Value();
                 $category_option_value->find($datas['value_id']);
                 $category_option_value->setFolderCategoryId(null)->setFolderCategoryPosition(null)->save();
                 foreach (Core_View_Default::getBlocks() as $block) {
                     if ($block->getCode() == 'area') {
                         $colorized_block = $block;
                     }
                 }
                 $icon_url = $category_option_value->getImage()->getCanBeColorized() ? Siberian_View::getColorizedImage($category_option_value->getIconId(), $colorized_block->getColor()) : $category_option_value->getIconUrl();
                 $html['folder'] = array('id' => $category_option_value->getId(), 'name' => $category_option_value->getShortTabbarName(), 'icon_url' => $icon_url, 'value_id' => $datas['value_id'], 'category_id' => $datas['category_id']);
             } else {
                 // Récupère l'id
                 $id = $option_value->getId();
                 // Récupère l'option
                 $option = new Application_Model_Option();
                 $option->find($option_value->getOptionId());
                 $option_folder = new Application_Model_Option();
                 $option_folder->find(array('code' => 'folder'));
                 $was_folder = 0;
                 //Folder, supprime les cat id des options
                 if ($option_value->getOptionId() == $option_folder->getOptionId()) {
                     $folder = new Folder_Model_Folder();
                     $folder->find($id, 'value_id');
                     $root_category = new Folder_Model_Category();
                     $root_category->find($folder->getRootCategoryId());
                     $categories_options = $root_category->deleteChildren($folder->getRootCategoryId());
                     $category_option = new Application_Model_Option_Value();
                     $option_values = $category_option->findAll(array('folder_category_id' => $folder->getRootCategoryId()));
                     $categories_options[$folder->getRootCategoryId()] = array();
                     foreach ($option_values as $ov) {
                         $ov->setFolderCategoryId(null)->setFolderCategoryPosition(null)->save();
                         $categories_options[$folder->getRootCategoryId()][] = $ov->getValueId();
                     }
                     $folder->delete();
                     $was_folder = 1;
                 }
                 // Supprime l'option de l'application
                 $option_value->delete();
                 // Renvoi le nouveau code HTML
                 $this->getLayout()->setBaseRender('content', 'application/customization/page/list.phtml', 'admin_view_default');
                 $html = array('success' => 1, 'option_id' => $id, 'use_user_account' => $this->getApplication()->usesUserAccount());
                 if ($option->onlyOnce()) {
                     $html['page'] = array('id' => $option->getId(), 'name' => $option->getName(), 'icon_url' => $option->getIconUrl());
                 }
                 if ($was_folder == 1) {
                     $html['was_folder'] = 1;
                     $html['categories_options'] = $categories_options;
                 }
             }
         } catch (Exception $e) {
             $html = array('message' => $this->_('An error occurred while deleting the option'), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
Beispiel #4
0
 public function getPages($samples = 0)
 {
     if (empty($this->_pages)) {
         $option = new Application_Model_Option_Value();
         $this->_pages = $option->findAll(array('remove_folder' => new Zend_Db_Expr('folder_category_id IS NULL'), 'is_visible' => 1));
     }
     if ($this->_pages->count() == 0 and $samples > 0) {
         $color = str_replace('#', '', $this->getDesignBlock('tabbar')->getImageColor());
         $dummy = new Application_Model_Option();
         $dummy->find('newswall', 'code');
         $dummy->setTabbarName('Sample')->setIsDummy(1)->setIconUrl(parent::getUrl('template/block/colorize', array('id' => $dummy->getIconId(), 'color' => $color)));
         for ($i = 0; $i < $samples; $i++) {
             $this->_pages->addRow($this->_pages->count(), $dummy);
         }
     }
     return $this->_pages;
 }
Beispiel #5
0
 public function copyCategoryTo($option, $category, $parent_id = null)
 {
     $children = $category->getChildren();
     $category_option = new Application_Model_Option_Value();
     $option_values = $category_option->findAll(array('app_id' => $option->getAppId(), 'folder_category_id' => $category->getId()), array('folder_category_position ASC'));
     $category->setId(null)->setParentId($parent_id)->save();
     foreach ($option_values as $option_value) {
         $option_value->setFolderCategoryId($category->getId())->save();
     }
     foreach ($children as $child) {
         $this->copyCategoryTo($option, $child, $category->getId());
     }
     return $this;
 }
 public function getPages($samples = 0)
 {
     if (empty($this->_pages)) {
         $option = new Application_Model_Option_Value();
         $this->_pages = $option->findAll(array("a.app_id" => $this->getId(), 'remove_folder' => new Zend_Db_Expr('folder_category_id IS NULL'), 'is_visible' => 1));
     }
     if ($this->_pages->count() == 0 and $samples > 0) {
         $dummy = Application_Model_Option_Value::getDummy();
         for ($i = 0; $i < $samples; $i++) {
             $this->_pages->addRow($this->_pages->count(), $dummy);
         }
     }
     return $this->_pages;
 }