コード例 #1
0
 public function saveAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $delete_features = array();
             $app_id = $this->getApplication()->getId();
             if (empty($datas['option_id'])) {
                 throw new Exception($this->_('An error occurred while adding the option'));
             }
             // Récupère l'option
             $option_id = $datas['option_id'];
             unset($datas['option_id']);
             $option = new Application_Model_Option();
             $option->find($option_id);
             if (!$option->getId()) {
                 throw new Exception($this->_('An error occurred while adding the option'));
             }
             // Récupère les données de l'application pour cette option
             $option_value = new Application_Model_Option_Value();
             if (!empty($datas['value_id'])) {
                 $option_value->find($datas['value_id']);
                 // Test s'il n'y a pas embrouille entre les ids passés en paramètre et l'application en cours customization
                 if ($option_value->getId() and ($option_value->getOptionId() != $option->getId() or $option_value->getAppId() != $app_id)) {
                     throw new Exception($this->_('An error occurred while adding the option'));
                 }
                 unset($datas['value_id']);
             }
             // Ajoute les données
             $option_value->addData(array('app_id' => $app_id, 'option_id' => $option->getId(), 'position' => $option_value->getPosition() ? $option_value->getPosition() : 0, 'is_visible' => 1))->addData($datas);
             // Sauvegarde
             $option_value->save();
             $id = $option_value->getId();
             $option_value = new Application_Model_Option_Value();
             $option_value->find($id);
             $option_value->getObject()->prepareFeature($option_value);
             if ($option->onlyOnce()) {
                 $delete_features[] = $option->getId();
             }
             // Renvoi le nouveau code HTML
             //                $this->getLayout()->setBaseRender('content', 'application/customization/page/list.phtml', 'admin_view_default');
             $row = $this->getLayout()->addPartial('row_' . $option_value->getId(), 'application_view_customization_features_list_options', 'application/customization/features/list/options/li.phtml')->setOptionValue($option_value)->setIsSortable(1)->toHtml();
             $html = array('success' => 1, 'page_html' => $row, 'path' => $option_value->getPath(null, array(), "mobile"), 'delete_features' => $delete_features, 'page_id' => $option_value->getOptionId(), 'use_user_account' => $this->getApplication()->usesUserAccount());
         } catch (Exception $e) {
             $html = array('message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->_sendHtml($html);
     }
 }
コード例 #2
0
ファイル: Folder.php プロジェクト: bklein01/siberian_cms_2
 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();
                 }
             }
         }
     }
 }