Пример #1
0
 function execute()
 {
     global $ts_config;
     $_Title = 'Quản lý Bài viết';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $id = __post('Id');
     /*===================================*/
     if ($formmode != '') {
         $menu_id = __post("menu_id");
         $title_vi = __post("title_vi");
         $title_en = __post("title_en");
         $short_vi = __post("short_vi");
         $short_en = __post("short_en");
         $content_vi = __post("content_vi");
         $content_en = __post("content_en");
         $keyword_vi = __post("keyword_vi");
         $keyword_en = __post("keyword_en");
         $status = (int) __post("status");
         $result_id = $this->form_add($id, $menu_id, $title_vi, $title_en, $short_vi, $short_en, $content_vi, $content_en, $keyword_vi, $keyword_en, $status);
         if ((int) $id <= 0) {
             $id = $result_id;
         }
         $result = UpLoadMultiFile($ts_config['upload_dir'], 'filenew', $gen_name = false, $title = '', $max_size = 9048576);
         $file_type_id = 7;
         foreach ($result as $k => $va) {
             $sSQL = "insert into ntk_new_files(new_id,file_name,file_path,file_type_id,require_login)\n\t\t\t\t\t\tvalues(" . $id . ",'" . $va['name'] . "','" . $va['file_name'] . "'," . $file_type_id . ",1)\n\t\t\t\t";
             $re = $this->db->query($sSQL, true, "Query failed");
         }
         if ($result_id > 0) {
             $_msg['result'] = 1;
         } else {
             $_msg['result'] = -20;
         }
     }
     $list_form = new XTemplate('Config/News.html');
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     /****** Delete (8) - Export (16) ***********************************/
     $arr_attr_btnmdelete = array('style' => '', 'onclick' => 'sbm_form(8,\'' . $CaptchaText . '\')');
     $inp_btnmdelete = addInput2('button', 'btndelete', $btnmdelete, $arr_attr_btnmdelete, $list_form, 'Xóa');
     if ($mode_inpvl == 'DELETE') {
         $idList = '0';
         foreach ($idchk as $ind => $delvl) {
             $idArr = explode('|', $delvl);
             if ($idArr[1] == $this->md5sum($this->prefix['delete'] . $idArr[0])) {
                 $idList .= ',' . $idArr[0];
             }
         }
         if ($idList != '0') {
             $_msg = $this->form_delete($idList);
         }
     }
     /****** Delete (8) - Export (16) ***********************************/
     if ($this->acl_per(16)) {
         $arr_attr_btnexport = array('style' => '', 'onclick' => 'sbm_form(16,\'' . $CaptchaText . '\')');
         $inp_btnexport = addInput2('button', 'btnexport', $btnexport, $arr_attr_btnexport, $list_form, 'Xuất Excel');
     }
     /*************************************
      *****************/
     $keyword = __post("keyword");
     $selectkeyword = __post("selectkeyword");
     $Attr_keyword = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập Keyword  \'}', 'style' => '');
     $txt_keyword = addInput('text', 'keyword', $keyword, $Attr_keyword, $list_form);
     $infosk[0] = array('t1.title_vi' => 'Tên bài viế(vi)');
     $infosk[1] = array('t1.title_en' => 'Tên bài viế(en)');
     $vlkey = array_keys($infosk[$selectkeyword]);
     //list($vlkey, $vlval) = each();
     $Attr_selectkeyword = array('style' => '');
     $txt_selectkeyword = addSelectList5('selectkeyword', $infosk, NULL, $Attr_selectkeyword, $list_form, $selectkeyword);
     if ($keyword != '' && $vlkey[0] != '') {
         $filter .= ' and ' . $vlkey[0] . " like N'%{$keyword}%'";
     }
     $category_id = (int) __post('category_id');
     $status = __post('status');
     $show_index = __post('show_index');
     if ($category_id > 0) {
         $filter .= ' and t1.cid = ' . $category_id;
     }
     if ($status != "") {
         $filter .= ' and t1.status = ' . (int) $status;
     }
     if ($show_index != "") {
         $filter .= ' and t1.show_index = ' . (int) $show_index;
     }
     //-----------------------------------------//
     $gridview = '';
     $gridview .= $this->PageHeader();
     $gridview .= $this->_AddPageHeader();
     $exportGrid = $this->setHeader();
     $DBList = $this->setList($CaptchaText, $filter, $conpany_list);
     $exportGrid .= $DBList[0];
     $gridview .= $exportGrid;
     $gridview .= $this->setFooter();
     $gridview .= $this->setPaging();
     $arr_info_category_id = $this->getListNewsCategories();
     $Attr_category_id = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn danh mục \'}', 'style' => 'width:400px;');
     $txt_category_id = addSelectList2('category_id', $arr_info_category_id, '-- Danh mục --', $Attr_category_id, $list_form, $category_id);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_status = addSelectList2('status', $arr_info_status, '-- Trạng thái --', $Attr_status, $list_form, $status);
     if ($mode_inpvl === 'EXPORT' && $this->acl_per(16)) {
         $this->ExportToExcel(fnStrConvert($_Title), strip_tags($exportGrid, '<table><tr><td><th>'));
         die;
     }
     //-----------------------------------------//
     setMessage($list_form, $_msg);
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->parse('main');
     $this->html = $list_form->out_return('main');
     echo $this->html;
 }
Пример #2
0
 function execute()
 {
     global $ts_config;
     $_Title = 'Quản lý Bài viết';
     $_msg = null;
     $captcha = new SimpleCaptcha();
     $formmode = $_POST["formmode"];
     $mode_inpvl = __post('mode_inpvl');
     $captchatxt = __post('captcha');
     $captchaForm = __post('captchaForm');
     $idchk = $_POST["chk"];
     $flagCaptcha = $captcha->CaptchaValidate($captchatxt);
     $flagCaptchaForm = $captcha->CaptchaValidate($captchaForm);
     $Id = __post2("Id");
     $token = __post2("token");
     if ($Id > 0) {
         if ($token != $this->md5sum('edit' . $Id)) {
             die('Do not have permission to access page!');
         }
     }
     $list_form = new XTemplate('Config/NewsAdd.html');
     if ($mode_inpvl == 'ADD') {
         $menu_id = __post("menu_id");
         $title_vi = __post("title_vi");
         $title_en = __post("title_en");
         $short_vi = __post("short_vi");
         $short_en = __post("short_en");
         $content_vi = __post("content_vi");
         $content_en = __post("content_en");
         $keyword_vi = __post("keyword_vi");
         $keyword_en = __post("keyword_en");
         $status = (int) __post("status");
         $result_id = $this->form_add($Id, $menu_id, $title_vi, $title_en, $short_vi, $short_en, $content_vi, $content_en, $keyword_vi, $keyword_en, $status);
         if ((int) $Id <= 0) {
             $Id = $result_id;
         }
         $result = UpLoadMultiFile($ts_config['upload_dir'], 'filenew', false, '', $max_size = 9048576);
         $file_type_id = 7;
         foreach ($result as $k => $va) {
             if ($va['result'] == 1) {
                 $sSQL = "insert into ntk_new_files(new_id,file_name,file_path,file_type_id,require_login)\n\t\t\t\t\t\tvalues(" . $Id . ",'" . $va['name'] . "','" . $va['file_name'] . "'," . $file_type_id . ",1)\n\t\t\t\t\t";
                 $re = $this->db->query($sSQL, true, "Query failed");
             }
         }
         if ($result_id > 0) {
             $_msg['result'] = 1;
         } else {
             $_msg['result'] = -20;
         }
     }
     if ((int) $Id > 0) {
         $data = $this->getDetail($Id);
         foreach ($data as $key => $value) {
             ${$key} = $value;
         }
         $sSQL = "select * from ntk_new_files where new_id = " . (int) $Id;
         $result = $this->db->query($sSQL, true, "Query failed");
         while ($aR = $this->db->fetchByAssoc($result)) {
             $list_form->assign('file', $aR);
             $list_form->parse('main.file');
         }
     }
     $left_menu = $this->rmenu();
     $list_form->assign('slide_bar', $this->slide_bar($left_menu));
     $list_form->assign('tabs', $this->set_tabs());
     $list_form->assign('dialog_title', 'thành viên');
     $CaptchaText = $captcha->CreateText();
     $arr_info_menu_id = $this->getListNewsCategories();
     $Attr_menu_id = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn danh mục \'}', 'style' => 'width:400px;');
     $txt_menu_id = addSelectList2('menu_id', $arr_info_menu_id, NULL, $Attr_menu_id, $list_form, $cid);
     $arr_info_status = array(1 => 'Active', 0 => 'InActive');
     $Attr_status = array('rel' => '{Require:\'R\',Alert:\'Vui lòng chọn trạng thái \'}', 'style' => '');
     $txt_status = addSelectList2('status', $arr_info_status, NULL, $Attr_status, $list_form, $status);
     $Attr_psttitle_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập tiêu đề tiếng việt \'}', 'style' => 'width:400px;');
     $txt_psttitle_vi = addInput('text', 'title_vi', $title_vi, $Attr_psttitle_vi, $list_form);
     $Attr_psttitle_en = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập tiêu đề tiếng anh \'}', 'style' => 'width:400px;');
     $txt_psttitle_en = addInput('text', 'title_en', $title_en, $Attr_psttitle_en, $list_form);
     $class_input = 'ckeditor';
     $Attr_short_vi = array('class' => $class_input, 'rel' => '{Require:\'R\',Alert:\'Vui lòng nhập mô tả ngắn tiếng việt  \'}', 'style' => 'width:400px;');
     $txt_short_vi = addTextarea('short_vi', 3, 30, $short_vi, $Attr_short_vi, $list_form);
     $Attr_short_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập role_name  \'}', 'style' => 'width:400px;');
     $txt_short_en = addTextarea('short_en', 3, 30, $short_en, $Attr_short_en, $list_form);
     $Attr_content_vi = array('class' => $class_input, 'rel' => '{Require:\'R\',Alert:\'Vui lòng nhập Nội dung tiếng việt  \'}', 'style' => 'width:400px;');
     $txt_content_vi = addTextarea('content_vi', 3, 30, $content_vi, $Attr_content_vi, $list_form);
     $Attr_content_en = array('class' => $class_input, 'rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập Nội dung tiếng anh  \'}', 'style' => 'width:400px;');
     $txt_content_en = addTextarea('content_en', 3, 30, $content_en, $Attr_content_en, $list_form);
     $Attr_pstkeyword_vi = array('rel' => '{Require:\'R\',Alert:\'Vui lòng nhập từ khóa tiếng việt \'}', 'style' => 'width:400px;');
     $txt_pstkeyword_vi = addInput('text', 'keyword_vi', $keyword_vi, $Attr_pstkeyword_vi, $list_form);
     $Attr_pstkeyword_en = array('rel1' => '{Require:\'R\',Alert:\'Vui lòng nhập từ khóa tiếng anh\'}', 'style' => 'width:400px;');
     $txt_pstkeyword_en = addInput('text', 'keyword_en', $keyword_en, $Attr_pstkeyword_en, $list_form);
     if ($this->acl_per(2)) {
         //$arr_attr_btnadd = array('style'=>'color:blue;','onclick'=>'sbm_form(2,\''.$CaptchaText.'\')');
         $arr_attr_btnadd = array('style' => 'color:blue;', 'onclick' => 'add()');
         $inp_btnadd = addInput2('button', 'btnadd', $btnadd, $arr_attr_btnadd, $list_form, 'LƯU');
     }
     $list_form->assign('Id', $Id);
     $list_form->assign('token', $token);
     //$list_form->parse('main');
     //	$html = $list_form->out_return('main');
     $list_form->assign('title', $_Title);
     $list_form->assign('_error_', $error);
     $list_form->assign('gridview', $gridview);
     $list_form->parse('main');
     $this->html = $list_form->out_return('main');
     echo $this->html;
 }