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); } }