/** * IS: Parameter id terdeklarasi * FS: Mengirimkan ke viewer: form, parent * Desc: Mengatur aksi yang dilakukan untuk halaman edit */ public function editAction() { $language_id = $this->_getParam('lang'); $activity_id = $this->_getParam('id'); $form = new Admin_Form_ActivityForm(); $form->setCategoryParent($language_id); $table_category = new Model_DbTable_Category(); $table_category_desc = new Model_DbTable_CategoryDescription(); $table_categorytopoi = new Model_DbTable_CategoryToPoi(); //if this is a POST request if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { if ($language_id != 2) { $indo = $table_category_desc->checkForEnglish($activity_id); if ($indo) { $data = array('category_id' => $activity_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']); $table_category_desc->updateCategory($data, $activity_id, 1); } else { $data = array('category_id' => $activity_id, 'language_id' => $language_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']); $table_category_desc->insertCategory($data); } } else { $data = array('parent_id' => $_POST['categoryParent'], 'image' => $_POST['categoryPicture']); $table_category->updateCategory($data, $activity_id); $data2 = array('category_id' => $activity_id, 'name' => $_POST['categoryName'], 'description' => $_POST['categoryDescription']); $table_category_desc->updateCategory($data2, $activity_id, 2); } $this->loggingaction('activity', 'edit', $activity_id, $language_id); $this->_flash->addMessage('1\\Activity Update Success!'); $this->_redirect($this->view->rootUrl('/admin/activityindo/')); } } //get the activity data if ($language_id != 2) { $indo = $table_category_desc->checkForEnglish($activity_id); if ($indo) { $category_data = $table_category->getAllWithDescByIdLang($activity_id, $language_id); } } else { $category_data = $table_category->getAllWithDescByIdLang($activity_id, $language_id); } //set element value $form->categoryParent->setValue($category_data['parent_id']); $form->categoryName->setValue($category_data['name']); $form->categoryPicture->setValue($category_data['image']); $form->categoryDescription->setValue($category_data['description']); //send variables to the view $this->view->parent = $category_data['parent_id']; $this->view->form = $form; $this->view->langId = $language_id; }