public function saveAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             $delete_features = array();
             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()) {
                     throw new Exception($this->_('An error occurred while adding the option'));
                 }
                 unset($datas['value_id']);
             }
             // Ajoute les données
             $option_value->addData(array('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(), 'admin_view_default', 'application/customization/features/list/options/li.phtml')->setOptionValue($option_value)->setIsSortable(1)->toHtml();
             $html = array('success' => 1, 'page_html' => $row, '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->getLayout()->setHtml(Zend_Json::encode($html));
     }
 }
 public function setisactiveAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['value_id'])) {
                 throw new Exception($this->_('An error occurred while saving'));
             }
             // 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']);
             if (isset($datas['is_active'])) {
                 $option_value->setIsActive($datas['is_active']);
             } else {
                 if (isset($datas['is_social_sharing_active'])) {
                     $option_value->setSocialSharingIsActive($datas['is_social_sharing_active']);
                 } else {
                     throw new Exception($this->_('An error occurred while saving'));
                 }
             }
             $option_value->save();
             $html = array('success' => 1, 'option_id' => $option_value->getId(), 'is_folder' => (int) ($option_value->getCode() == 'folder'));
         } catch (Exception $e) {
             $html = array('message' => $this->_('An error occurred while saving'), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->_sendHtml($html);
     }
 }