Beispiel #1
0
 public function getDetail($seo)
 {
     $content_obj = new \HaiQuan\Backend\Models\CtgTintuc();
     $result = $content_obj->findFirst(array("tt_seo_link = :seo: and tt_status !=0 ", "bind" => array("seo" => $seo), "order" => "tt_id DESC"));
     if ($result) {
         $result = $result->toArray();
     }
     return $result;
 }
Beispiel #2
0
 public function editContentAction()
 {
     //Set Layout
     if ($this->request->isPost()) {
         $data_edit = $this->request->getPost("data", null, false);
         $response = array("status" => 0, "message" => "Không Thành Công");
         $content_obj = new \HaiQuan\Backend\Models\CtgTintuc();
         if (!empty($data_edit)) {
             $firt_character = substr($data_edit["tt_images"], 0, 1);
             if ($firt_character == "/") {
                 $data_edit["tt_images"] = substr($data_edit["tt_images"], 1, strlen($data_edit["tt_images"]));
             }
             $data_edit["tt_edit_date"] = date("Y-m-d H:i:s");
             //                if (isset($data_edit["co_is_link"]) && $data_edit["co_is_link"] == "on")
             //                {
             //                    $data_edit["co_is_link"] = 1;
             //                }
             //                else
             //                {
             //                    $data_edit["co_is_link"] = 0;
             //                }
             $data_edit["tt_seo_link"] = \library\Util::get_seo($data_edit["tt_title"]);
             $data_edit["tt_user_id"] = $this->user['us_id'];
             if (empty($data_edit["tt_end_date"])) {
                 $data_edit["tt_end_date"] = "0000-00-00 00:00:00";
             }
             if (!isset($data_edit["tt_id"]) || empty($data_edit["tt_id"])) {
                 //Insert
                 unset($data_edit["tt_id"]);
                 $data_edit["tt_create_date"] = date("Y-m-d H:i:s");
                 $result = $content_obj->save($data_edit);
             } else {
                 $result = $content_obj->updateTintucByID($data_edit, $data_edit["tt_id"]);
             }
             if ($result) {
                 $response["status"] = 1;
             } else {
                 $response["message"] = implode(";", $content_obj->getMessages());
             }
             $data_edit["tt_id"] = $content_obj->tt_id;
             $response["data"] = $data_edit;
         }
         echo json_encode($response);
         exit;
     } else {
         $this->view->header_title = "Edit Content - Managed";
         $this->assets->addCss($this->config['GAME_URL'] . 'public/css/admin/plugin/datetimepicker.css');
         $this->assets->collection("inline")->addJs($this->config['GAME_URL'] . 'public/js/admin/view/edit-content.js');
         $this->assets->collection("head")->addJs($this->config['GAME_URL'] . 'public/js/admin/plugin/bootstrap-datetimepicker.min.js');
         $this->assets->collection("head")->addJs($this->config['GAME_URL'] . 'public/js/admin/plugin/ckeditor/ckeditor.js');
         $this->assets->collection("head")->addJs($this->config['GAME_URL'] . 'public/js/admin/plugin/ckeditor/adapters/jquery.js');
         $this->assets->collection("head")->addJs($this->config['GAME_URL'] . 'public/js/admin/plugin/ckfinder/ckfinder.js');
         $co_id = $this->request->getQuery("id", "int", false);
         $content_obj = new \HaiQuan\Backend\Models\CtgTintuc();
         $content = array();
         if (!empty($co_id)) {
             $content = $content_obj->findFirst("tt_id=" . $co_id)->toArray();
         }
         if (empty($content)) {
             $content = $content_obj->toArray();
         }
         if (empty($content["tt_images"])) {
             $content["tt_images"] = "public/uploads/images/Banner/banner-detail-news.jpg";
         }
         $this->view->content = $content;
     }
 }