public function action_add() { $user_id = $this->user->id; if (empty($user_id)) { $this->redirect('/'); } $article = new Model_Article(); $article->title = Arr::get($_POST, 'title'); $article->description = Arr::get($_POST, 'description'); $article->text = Arr::get($_POST, 'text'); $cover = Arr::get($_FILES, 'cover'); $errors = FALSE; $table_values = array(); if ($article->title != '') { $table_values['title'] = array('value' => $article->title); } else { $errors = TRUE; } if ($article->description != '') { $table_values['description'] = array('value' => $article->description); } else { $errors = TRUE; } if ($article->text != '') { $table_values['text'] = array('value' => $article->text); } else { $errors = TRUE; } if (!Upload::valid($cover) or !Upload::not_empty($cover) or !Upload::type($cover, array('jpg', 'jpeg', 'png')) or !Upload::size($cover, '10M')) { $table_values['cover'] = TRUE; $errors = TRUE; } if ($errors) { // $this->view["editor"] = View::factory('templates/articles/editor', array("storedNodes" => $table_values['text']['value'])); $content = View::factory('templates/articles/new', $this->view); $this->template->content = View::factory("templates/articles/wrapper", array("active" => "newArticle", "content" => $content)); return false; } // getting new name for cover $article->cover = $this->methods->save_cover($cover); $article->user_id = $user_id; $article->is_published = true; // FIXME изменить, когда будет доступны режимы публикации $article->insert(); // redirect to new article $this->redirect('/article/' . $article->id); }
$companyWebsite = html_entity_decode($_pgR[global_mapping::CompanyWebsite], ENT_COMPAT, 'UTF-8'); $companyPhone = html_entity_decode($_pgR[global_mapping::CompanyPhone], ENT_COMPAT, 'UTF-8'); $adType = html_entity_decode($_pgR[global_mapping::AdType], ENT_COMPAT, 'UTF-8'); $startDate = html_entity_decode($_pgR[global_mapping::StartDate], ENT_COMPAT, 'UTF-8'); $endDate = html_entity_decode($_pgR[global_mapping::EndDate], ENT_COMPAT, 'UTF-8'); $happyDays = html_entity_decode($_pgR[global_mapping::HappyDays], ENT_COMPAT, 'UTF-8'); $startHappyHour = html_entity_decode($_pgR[global_mapping::StartHappyHour], ENT_COMPAT, 'UTF-8'); $endHappyHour = html_entity_decode($_pgR[global_mapping::EndHappyHour], ENT_COMPAT, 'UTF-8'); $addresses = html_entity_decode($_pgR[global_mapping::Addresses], ENT_COMPAT, 'UTF-8'); $dictricts = html_entity_decode($_pgR[global_mapping::Dictricts], ENT_COMPAT, 'UTF-8'); $cities = html_entity_decode($_pgR[global_mapping::Cities], ENT_COMPAT, 'UTF-8'); $fileName = html_entity_decode($_pgR[global_mapping::FileName], ENT_COMPAT, 'UTF-8'); $status = 1; if ($_pgR["act"] == model_Article::ACT_ADD) { $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objArticle->insert($title, $fileName, $content, null, $tags, $catalogueID, $createdBy, $renewedNum, $companyName, $companyAddress, $companyWebsite, $companyPhone, $adType, $startDate, $endDate, $happyDays, $startHappyHour, $endHappyHour, $addresses, $dictricts, $cities, $status); if ($resultID) { $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, 'Đăng bài viết thành công'), array(0, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { $modifiedBy = $c_userInfo[global_mapping::UserID]; $articleID = html_entity_decode($_pgR[global_mapping::ArticleID], ENT_COMPAT, 'UTF-8'); $currentArticle = $objArticle->getArticleByID($articleID); $resultID = $objArticle->update($articleID, null, $title, $fileName, $catalogueID, $content, null, $tags, null, null, $currentArticle[global_mapping::CreatedBy], $currentArticle[global_mapping::CreatedDate], $modifiedBy, global_common::nowSQL(), null, null, 0, null, null, $currentArticle[global_mapping::RenewedDate], $currentArticle[global_mapping::RenewedNum], $companyName, $companyAddress, $companyWebsite, $companyPhone, $adType, $startDate, $endDate, $happyDays, $startHappyHour, $endHappyHour, $addresses, $dictricts, $cities); if ($resultID) {
$sectionID = global_editor::rteSafe(html_entity_decode($sectionID, ENT_COMPAT, 'UTF-8')); $numView = $_pgR['NumView']; $numView = global_editor::rteSafe(html_entity_decode($numView, ENT_COMPAT, 'UTF-8')); $numComment = $_pgR['NumComment']; $numComment = global_editor::rteSafe(html_entity_decode($numComment, ENT_COMPAT, 'UTF-8')); $status = $_pgR['Status']; $status = global_editor::rteSafe(html_entity_decode($status, ENT_COMPAT, 'UTF-8')); $comments = $_pgR['comments']; $comments = global_editor::rteSafe(html_entity_decode($comments, ENT_COMPAT, 'UTF-8')); $renewedDate = $_pgR['RenewedDate']; $renewedDate = global_editor::rteSafe(html_entity_decode($renewedDate, ENT_COMPAT, 'UTF-8')); $renewedNum = $_pgR['RenewedNum']; $renewedNum = global_editor::rteSafe(html_entity_decode($renewedNum, ENT_COMPAT, 'UTF-8')); //$strName = $_pgR['name']; //$strName = global_editor::rteSafe(html_entity_decode($strName,ENT_COMPAT ,'UTF-8' )); $resultID = $objArticle->insert($articleID, $prefix, $title, $fileName, $articleType, $content, $notificationType, $tags, $catalogueID, $sectionID, $numView, $numComment, $status, $comments, $renewedDate, $renewedNum); if ($resultID) { $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf"), array(1, $result), array(0, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { echo global_common::convertToXML($arrHeader, array("rs", 'info'), array(0, global_common::STRING_REQUIRE_LOGIN), array(0, 1)); } return; } elseif ($_pgR['act'] == model_Article::ACT_UPDATE) { if (global_common::isCLogin()) {