/** * IS: Parameter id terdeklarasi * FS: Mengirimkan ke viewer: form, rel_poi, poi_id * Desc: Mengatur aksi yang dilakukan untuk halaman edit */ public function editAction() { $langId = $this->_getParam('lang'); //print_r($langId); $form = new Admin_Form_ArticleForm(array('languageId' => 1)); $form->draft->setLabel('Draft'); if ($this->_userInfo->canApprove) { $form->submit->setLabel('Update'); } else { $form->submit->setLabel('Update for review'); } $table_article = new Model_DbTable_Article(); $table_article_description = new Model_DbTable_ArticleDescription(); $article_id = $this->_getParam('id'); $table_related_article_attraction = new Model_DbTable_RelatedArticleAttraction(); /* set form element value */ if ($this->getRequest()->isPost()) { if ($form->isValid($_POST)) { $title = preg_replace("/'/", "'", $_POST['ArticleTitle']); $content = preg_replace("/'/", "'", $_POST['ArticleContent']); if ($langId != 1) { $indo = $table_article_description->checkForIndo($article_id); if ($indo == null) { $data = array('article_id' => $article_id, 'language_id' => $langId, 'title' => $title, 'content' => $content); $table_article_description->insertArticleDescription($data); } else { $data = array('article_id' => $article_id, 'language_id' => 2, 'title' => $title, 'content' => $content); $table_article_description->updateArticleDescription($data, $article_id, $langId); } } else { if ($_POST['ArticleMainImage'] == '') { $this->_flash->addMessage('3\\Warning: Data is saved without image!'); } else { $main_image = preg_replace("/'/", "'", $_POST['ArticleMainImage']); } $status = Model_DbTable_Article::DRAFT; if ($this->getRequest()->getPost('action') == 'Update' || $this->getRequest()->getPost('action') == 'Update for review') { if ($this->_userInfo->canApprove) { $status = Model_DbTable_Article::PUBLISH; } else { $status = Model_DbTable_Article::PENDING; } } $data = array('status' => $status, 'main_image' => $main_image, 'sort_order' => $_POST['articleSortOrder'], 'category' => $_POST['category'], 'updated_by' => $this->_userInfo->id, 'updated_at' => date('Y-m-d H:i:s')); $table_article->updateArticle($data, $article_id); $data = array('article_id' => $article_id, 'language_id' => 1, 'title' => $title, 'content' => $content); $table_article_description->updateArticleDescription($data, $article_id, $langId); } //$this->_helper->layout()->disableLayout(); //$this->_helper->viewRenderer->setNoRender(true); /* update related article */ //param // this part add related if ($_POST['counterRelated'] > 0) { $counter = $_POST['counterRelated']; for ($i = 1; $i <= $counter; $i++) { //echo $_POST['link'.$i]; //cek existing label and link in database // if $cek having value = false, then data will be saved if (isset($_POST['label' . $i])) { $cek = $table_related_article_attraction->cek_existing($_POST['label' . $i], $_POST['link' . $i]); if (!$cek or $cek == false) { $data = array('article_id' => $article_id, 'label' => $_POST['label' . $i], 'link' => $_POST['link' . $i], 'language_id' => $language_id); $table_related_article_attraction->insertRelated($data); } } } } //here part delete related, (if there are request) if ($_POST['counterDel'] > 0) { $counterDel = $_POST['counterDel']; for ($i = 1; $i <= $counterDel; $i++) { //cek existing label and link in database // if found, data will be removed if (isset($_POST['labeldel' . $i])) { $cek = $table_related_article_attraction->cek_existing_forDel($_POST['labeldel' . $i], $_POST['linkdel' . $i]); } } } $this->loggingaction('attraction', 'edit', $article_id); $this->_flash->addMessage('1\\Article Update Success!'); $this->_redirect($this->view->rootUrl('/admin/article/')); } } $new_translate = false; if ($langId != 1) { $indo = $table_article_description->checkForIndo($article_id); if ($indo) { $data = $table_article->getAllWithDescByLanguageId($article_id, $langId); $form->article_poi_id->setValue($data['poi_id']); $form->article_status->setValue($data['status']); $form->articleSortOrder->setValue($data['sort_order']); $form->article_main_image->setValue($data['main_image']); $form->article_title->setValue(html_entity_decode($data['title'])); $form->article_content->setValue(html_entity_decode($data['content'])); $form->category_select->setValue($data['category']); $this->view->rel_poi = $data['poi_id']; $this->view->poi_id = $data['poi_id']; } } else { $data = $table_article->getAllWithDescByLanguageId($article_id, $langId); $form->article_poi_id->setValue($data['poi_id']); $form->article_status->setValue($data['status']); $form->articleSortOrder->setValue($data['sort_order']); $form->article_main_image->setValue($data['main_image']); $form->article_title->setValue(html_entity_decode($data['title'])); $form->article_content->setValue($data['content']); $form->category_select->setValue($data['category']); $this->view->rel_poi = $data['poi_id']; $this->view->poi_id = $data['poi_id']; } //get realated article data // @param = article_id $ralated_article = $table_related_article_attraction->getByArticleId($article_id, $langId); $this->view->edit = 1; $this->view->ralated_article = $ralated_article; $this->view->article_id = $article_id; $this->view->languageID = 2; $this->view->form = $form; $this->view->langid_id = $langId; }
/** * IS: Parameter articleId terdeklarasi * FS: Mengirimkan ke viewer: article, pageTitle * Desc: Fungsi untuk menampilkan attraction */ public function detailInDestAction() { $this->_helper->layout->setLayout('one-column'); //$this->_helper->layout()->disableLayout(); //$this->_helper->viewRenderer->setNoRender(true); $exurl = explode('/', $this->view->currentUrl()); $newUrl = array_splice($exurl, 0, 9); $url = implode("/", $newUrl); //echo $url; //print_r($newUrl); //echo $url; // Param $articleId = $this->_getParam('articleId'); $destId = $this->_getParam('destId'); $this->view->pageViewer = $this->countView($destId); // Model $articleDb = new Model_DbTable_Article(); // Data $article = $articleDb->getAllWithDescByLanguageId($articleId, $this->_languageId, true); //if content is empty, will be redirecting to list of article if ($article['description']) { $article['description'] = str_replace("../../../../", "../../../../../../", $article['content']); // Breadrumb $pageTitle = $this->view->HtmlDecode($article['name']); $this->_generateDescBreadcrumb($pageTitle); // Passing ke view $this->view->pageTitle = $pageTitle; $this->view->article = $article; $this->view->main_images = $article['image']; //realated link $linkModel = new Model_DbTable_RelatedArticleAttraction(); $this->view->related_link = $linkModel->getByArticleId($articleId, $this->_languageId); } else { $this->_redirector->gotoUrl($url); } }