Files
cm-web-legacy/application/controllers/admin/delete.later/news_bak190228.php
2020-06-10 06:19:03 +09:00

2032 lines
88 KiB
PHP
Executable File

<?php defined('BASEPATH') OR exit('No direct script access allowed');
header("Content-Type: text/html; charset=UTF-8");
/**
* 인클루드 class
*
* cm_controller: 부모 Class(CI_Controller 확장한 custome class)
*/
include_once(APPPATH.'core/admin/cm_controller.php');
class news extends cm_Controller {
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스설정 - 수정
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function fn_news_setting_reg() {
// contents_setting - news setting 는 1
$news_idx = 1;
# model
$this->load->model('admin/comm/m_contents_setting');
$result = $this->m_contents_setting->contents_setting_select($news_idx);
if(count($result) == 0) {
gf_alert("잘못된 접근입니다.", '/admin/main');
exit;
}
$return_data = $result[0];
# view
return $this->load->view('/admin/news/news_setting_reg', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스설정 - 수정 저장
# CREATE : 2018-02-23
#---------------------------------------------------------------------------
function fn_news_setting_reg_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
$is_duplication = trim($this->input->get_post('is_duplication', TRUE));
$no_duplication_setting = trim($this->input->get_post('no_duplication_setting', TRUE));
$stat_time1 = trim($this->input->get_post('stat_time1', TRUE));
$stat_time2 = trim($this->input->get_post('stat_time2', TRUE));
$stat_time3 = trim($this->input->get_post('stat_time3', TRUE));
$etc_char1 = trim($this->input->get_post('etc_char1', TRUE));
$stat_time = $stat_time1.':'.$stat_time2.':'.$stat_time3;
if($is_duplication=='Y') {
$no_duplication_setting = 0;
}
# update data
$req_data['idx'] = $idx;
$req_data['is_duplication'] = $is_duplication;
$req_data['no_duplication_setting'] = $no_duplication_setting;
$req_data['stat_time'] = $stat_time;
$req_data['etc_char1'] = $etc_char1;
# model
$this->load->model('admin/comm/m_contents_setting');
$return_data = $this->m_contents_setting->contents_setting_update($req_data);
if(!$return_data) {
gf_alert("저장에 실패했습니다.", '/admin/news/news_setting_reg/2');
exit;
}
gf_alert("저장되었습니다.", '/admin/news/news_setting_reg/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스섹션 리스트
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_news_section_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$cateogory_code1 = trim($this->input->get_post('cateogory_code1', TRUE));
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['cateogory_code'] = $cateogory_code1;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - 카테고리 list
$this->load->model('admin/news/m_news_section');
$total_count = $this->m_news_section->news_section_list_total_count($req_data);
$result1 = $this->m_news_section->news_section_list($req_data);
$arr_category = $this->m_news_section->news_section_all_list($req_data);
$result2 = $this->m_news_section->news_section_article_count($req_data);
$result3 = $this->m_news_section->news_section_today_article_count($req_data);
$arr_depth_count= $this->m_news_section->news_section_group_by_depth_count();
$article_count = $result2['article_count'];
$today_article_count = $result3['today_article_count'];
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_section_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['article_count'] = $article_count;
$return_data['today_article_count'] = $today_article_count;
$return_data['search_keyword'] = $search_keyword;
$return_data['cateogory_code1'] = $cateogory_code1;
$return_data['list'] = $result1;
$return_data['arr_category'] = $arr_category;
$return_data['arr_depth_count'] = $arr_depth_count;
# view
return $this->load->view('/admin/news/news_section_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스섹션 - 저장
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function fn_news_section_reg_proc() {
# request
$page = trim($this->input->get_post('page', TRUE));
$mode = trim($this->input->get_post('mode', TRUE));
$category_name = trim($this->input->get_post('category_name', TRUE));
$display_sort = trim($this->input->get_post('display_sort', TRUE));
$p_category_code = trim($this->input->get_post('p_category_code', TRUE));
$category_idx = trim($this->input->get_post('category_idx', TRUE));
$depth = trim($this->input->get_post('depth', TRUE));
$req_data['category_name'] = $category_name;
$req_data['display_sort'] = $display_sort;
if($mode == 'add') {
$depth = $depth+1;
$req_data['p_category_code'] = $p_category_code;
$req_data['depth'] = $depth;
# model - insert
$this->load->model('admin/news/m_news_section');
$result = $this->m_news_section->news_section_insert($req_data);
} else if($mode == 'edit') {
$req_data['idx'] = $category_idx;
# model - insert
$this->load->model('admin/news/m_news_section');
$result = $this->m_news_section->news_section_update($req_data);
}
$msg = "저장되었습니다";
if(!$result) {
$msg = "저장에 실패했습니다. 다시시도해 주세요.";
}
gf_alert($msg, '/admin/news/news_section_list/2/'.$page);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스섹션 카테고리별 count
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_ajax_news_section_code_count() {
# request
$category_code = trim($this->input->get_post('category_code', TRUE));
$req_date['category_code'] = $category_code;
# model - update
$this->load->model('admin/news/m_news');
$count = $this->m_news->news_section_code_count($req_date);
$return_data['result'] = $count;
# view
return $this->load->view('/admin/comm/result_html', $return_data);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스섹션 삭제 - 저장
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_news_section_del_proc() {
# request
$del_key = trim($this->input->get_post('del_key', TRUE));
$req_date['p_category_code']= $del_key;
# model - update
$this->load->model('admin/news/m_news_section');
$this->m_news_section->news_section_is_del_where_category_code_update($req_date);
$this->m_news_section->news_section_is_del_where_p_category_code_update($req_date);
gf_alert("삭제되었습니다.", '/admin/news/news_section_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 뉴스섹션 글이동
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_news_section_article_move_proc() {
# request
$org_category_code = trim($this->input->get_post('org_category_code', TRUE));
$category1 = trim($this->input->get_post('category1', TRUE));
$category2 = trim($this->input->get_post('category2', TRUE));
$category3 = trim($this->input->get_post('category3', TRUE));
$category_code = $category1.$category2.$category3;
$req_date['org_category_code'] = $org_category_code;
$req_date['category_code'] = $category_code;
# model - update
$this->load->model('admin/news/m_news');
$this->m_news->news_category_code_update($req_date);
gf_alert("이동되었습니다.", '/admin/news/news_section_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_news_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_news_type = trim($this->input->get_post('search_news_type', TRUE));
$search_click1 = trim($this->input->get_post('search_click1', TRUE));
$search_click2 = trim($this->input->get_post('search_click2', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
if($sort=='') $sort ='1';
switch ($sort) {
case '1': $sort_column = 'a.display_date'; break;
case '2': $sort_column = 'a.hit_count'; break;
case '3': $sort_column = 'a.review_count1'; break;
case '4': $sort_column = 'a.comment_count'; break;
default : $sort_column = 'a.reg_date'; break;
}
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
$search_category_code = $search_category_code1;
if($search_category_code2!='') $search_category_code = $search_category_code2;
if($search_category_code3!='') $search_category_code = $search_category_code3;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['search_news_type'] = $search_news_type;
$req_data['search_category_code'] = $search_category_code;
$req_data['sort_column'] = $sort_column;
$req_data['search_click1'] = $search_click1;
$req_data['search_click2'] = $search_click2;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - 카테고리 list
$this->load->model('admin/news/m_news');
$total_count = $this->m_news->news_list_total_count($req_data);
$result = $this->m_news->news_list($req_data);
$new_count = $this->m_news->news_new_count($req_data);
$arr_display_count = $this->m_news->news_is_display_group_by_count($req_data);
# 카테고리 리스트
$this->load->model('admin/news/m_news_section');
$arr_category = $this->m_news_section->news_section_all_list();
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['search_news_type'] = $search_news_type;
$return_data['sort'] = $sort;
$return_data['list'] = $result;
$return_data['arr_category'] = $arr_category;
$return_data['new_count'] = $new_count;
$return_data['search_click1'] = $search_click1;
$return_data['search_click2'] = $search_click2;
$return_data['arr_display_count'] = $arr_display_count;
# view
return $this->load->view('/admin/news/news_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리 등록/수정
# CREATE : 2018-02-28
#---------------------------------------------------------------------------
function fn_news_reg() {
# request
$mode = trim($this->input->get_post('mode', TRUE));
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_news_type = trim($this->input->get_post('search_news_type', TRUE));
$search_click1 = trim($this->input->get_post('search_click1', TRUE));
$search_click2 = trim($this->input->get_post('search_click2', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$content_type = '1'; // 뉴스는 1
if($mode == '') $mode = 'add';
# model - 카테고리 (섹션)
$this->load->model('admin/news/m_news_section');
$arr_category = $this->m_news_section->news_section_all_list();
# model - 언론사
$this->load->model('admin/etc_section/m_press');
$arr_press = $this->m_press->press_all_list();
$return_data = array();
$arr_theme = array();
$arr_section = array();
$arr_relation_article = array();
if($mode == 'edit') {
$req_data = array();
$req_data['content_idx'] = $idx;
$req_data['content_type'] = $content_type;
# 테마리스트
$this->load->model('admin/comm/m_theme');
$arr_theme = $this->m_theme->theme_content_idx_select($req_data);
# etc_section
$this->load->model('admin/etc_section/m_etc_section');
$arr_section = $this->m_etc_section->etc_section_content_idx_select($req_data);
# model
$this->load->model('admin/news/m_news');
$result = $this->m_news->news_select($idx);
$return_data['result'] = $result[0];
# 연관기사
$this->load->model('admin/news/m_news');
$arr_relation_article = $this->m_news->relation_article_join_news_list($req_data);
}
$return_data['mode'] = $mode;
$return_data['page'] = $page;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_news_type'] = $search_news_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['search_click1'] = $search_click1;
$return_data['search_click2'] = $search_click2;
$return_data['sort'] = $sort;
$return_data['idx'] = $idx;
$return_data['arr_category'] = $arr_category;
$return_data['arr_press'] = $arr_press;
$return_data['arr_theme'] = $arr_theme;
$return_data['arr_section'] = $arr_section;
$return_data['arr_relation_article'] = $arr_relation_article;
# view
return $this->load->view('/admin/news/news_reg', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리 - 저장
# CREATE : 2018-03-02
#---------------------------------------------------------------------------
function fn_news_reg_proc() {
# request
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_news_type = trim($this->input->get_post('search_news_type', TRUE));
$search_click1 = trim($this->input->get_post('search_click1', TRUE));
$search_click2 = trim($this->input->get_post('search_click2', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$mode = trim($this->input->get_post('mode', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$news_type = trim($this->input->get_post('news_type', TRUE));
$press_idx = trim($this->input->get_post('press_idx', TRUE));
$reporter_name = trim($this->input->get_post('reporter_name', TRUE));
$reporter_email = trim($this->input->get_post('reporter_email', TRUE));
$title = trim($this->input->get_post('title', TRUE));
$sub_title = trim($this->input->get_post('sub_title', TRUE));
$category1 = trim($this->input->get_post('category1', TRUE));
$category2 = trim($this->input->get_post('category2', TRUE));
$category3 = trim($this->input->get_post('category3', TRUE));
$tag = trim($this->input->get_post('tag', TRUE));
$org_url = trim($this->input->get_post('org_url', TRUE));
$content = trim($this->input->get_post('content', FALSE));
$hit_count = trim($this->input->get_post('hit_count', TRUE));
$share_count = trim($this->input->get_post('share_count', TRUE));
$review_count1 = trim($this->input->get_post('review_count1', TRUE));
$review_count2 = trim($this->input->get_post('review_count2', TRUE));
$review_count3 = trim($this->input->get_post('review_count3', TRUE));
$review_count4 = trim($this->input->get_post('review_count4', TRUE));
$review_count5 = trim($this->input->get_post('review_count5', TRUE));
$is_auto_setting = trim($this->input->get_post('is_auto_setting', TRUE));
$relation_idxs = $this->input->get_post('relation_idxs', TRUE);
$theme_type1 = trim($this->input->get_post('theme_type1', TRUE));
$theme_type2 = trim($this->input->get_post('theme_type2', TRUE));
$theme_type3 = trim($this->input->get_post('theme_type3', TRUE));
$theme_type4 = trim($this->input->get_post('theme_type4', TRUE));
$theme_type5 = trim($this->input->get_post('theme_type5', TRUE));
$theme_type6 = trim($this->input->get_post('theme_type6', TRUE));
$section_type1 = trim($this->input->get_post('section_type1', TRUE));
$section_type2 = trim($this->input->get_post('section_type2', TRUE));
$section_type3 = trim($this->input->get_post('section_type3', TRUE));
$section_type4 = trim($this->input->get_post('section_type4', TRUE));
$display_date = trim($this->input->get_post('display_date', TRUE));
$display_hour = trim($this->input->get_post('display_hour', TRUE));
$display_min = trim($this->input->get_post('display_min', TRUE));
$display_sec = trim($this->input->get_post('display_sec', TRUE));
$is_del_img = trim($this->input->get_post('is_del_img', TRUE));
$org_main_img = trim($this->input->get_post('org_main_img', TRUE));
$video_url = trim($this->input->get_post('video_url', TRUE));
$content_type = '1'; // 뉴스는 1
$video_playtime = '';
if($video_url!='') {
$this->load->library('comm_admin');
$video_playtime = $this->comm_admin->fn_youtube_playtime($video_url);
$video_url = 'https://www.youtube.com/embed/'.$video_url;
}
# 이미지 삭제
if($is_del_img=='Y') {
unlink('.'.$org_main_img);
$org_main_img = '';
}
# 이미지업로드
if($_FILES['main_img']['name']!='') {
# image upload
$upload_path = './files/news/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('main_img')) {
$error = array('error' => $this->upload->display_errors());
gf_alert("이미지 업로드에 실패했습니다.", 'back');
exit;
}
$arr_upload_data = $this->upload->data();
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
} else {
$filename = $org_main_img;
}
$category_code = $category3;
if($category_code=='') $category_code = $category2;
# model - press_name
$this->load->model('admin/etc_section/m_press');
$result = $this->m_press->press_select($press_idx);
$press_name = '';
if(count($result) > 0){
$press_name = $result[0]['press_name'];
}
$now_date = date("Y-m-d H:i:s");
if($display_date!='') {
$display_hour = sprintf('%02d',$display_hour);
$display_min = sprintf('%02d',$display_min);
$display_sec = sprintf('%02d',$display_sec);
$display_date = $display_date.' '.$display_hour.':'.$display_min.':'.$display_sec;
} else {
$display_date = $now_date;
}
$is_display = 'Y';
if($display_date > $now_date) {
$is_display = 'N';
}
# tag
$tag = str_replace(' ','', $tag);
$tag = str_replace(',',' ', $tag);
# update data
$req_data = array();
$req_data['category_code'] = $category_code;
$req_data['news_type'] = $news_type;
$req_data['title'] = $title;
$req_data['sub_title'] = $sub_title;
$req_data['main_img'] = $filename;
$req_data['press_idx'] = $press_idx;
$req_data['press_name'] = $press_name;
$req_data['write_name'] = $this->session->userdata('Adm_Name');;
$req_data['write_id'] = $this->session->userdata('Adm_Id');;
$req_data['reporter_name'] = $reporter_name;
$req_data['reporter_email'] = $reporter_email;
$req_data['content'] = $content;
$req_data['org_url'] = $org_url;
$req_data['is_auto_setting']= $is_auto_setting;
$req_data['tag'] = $tag;
$req_data['review_count1'] = $review_count1;
$req_data['review_count2'] = $review_count2;
$req_data['review_count3'] = $review_count3;
$req_data['review_count4'] = $review_count4;
$req_data['review_count5'] = $review_count5;
$req_data['hit_count'] = $hit_count;
$req_data['share_count'] = $share_count;
$req_data['is_display'] = $is_display;
$req_data['display_date'] = $display_date;
$req_data['video_url'] = $video_url;
$req_data['video_playtime'] = $video_playtime;
if($mode=='add') {
# model
$this->load->model('admin/news/m_news');
$idx = $this->m_news->news_insert($req_data);
if(!$idx) {
gf_alert("뉴스등록에 실패했습니다.", 'back');
exit;
}
$url = '/admin/news/news_list/2';
} else if($mode=='edit') {
$req_data['idx'] = $idx;
# model
$this->load->model('admin/news/m_news');
$result = $this->m_news->news_update($req_data);
if(!$result) {
gf_alert("뉴스수정에 실패했습니다.", 'back');
exit;
}
$url = '/admin/news/news_list/2/'.$page.'?search_type='.$search_type.'&search_keyword='.$search_keyword.'&search_news_type='.$search_news_type.'&search_category_code1='.$search_category_code1.'&search_category_code2='.$search_category_code2.'&search_category_code3='.$search_category_code3.'&search_click1='.$search_click1.'&search_click2='.$search_click2.'&sort='.$sort;
}
# tag
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['content_idx'] = $idx;
# model - tag 삭제
$this->load->model('admin/comm/m_tag');
$this->m_tag->tag_delete($req_data);
$arr_tag = explode(" ", $tag);
$arr_tag = array_filter(array_map('trim', $arr_tag));
foreach ($arr_tag as $val) {
$req_data['tag'] = $val;
# model
$tag_count = $this->m_tag->tag_select_where_tag_count($req_data);
if($tag_count==0) { // insert
$result = $this->m_tag->tag_insert($req_data);
}
}
# 관련뉴스
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['content_idx'] = $idx;
# model - 관련뉴스 삭제
$this->load->model('admin/comm/m_relation_article');
$this->m_relation_article->relation_article_delete($req_data);
if($is_auto_setting == 'Y') {
$relation_idxs = array();
//$string = preg_replace("/[#\&\+\-%@=\/\\\:;,\.'\"\^`~\_|\!\?\*$#<>()\[\]\{\}]/i", "", $title);
//$tag = $tag.' '.$string;
$req_data['tag'] = $tag;
# model - 관련뉴스
$this->load->model('admin/news/m_news');
$result = $this->m_news->news_tag_select($req_data);
if(count($result) > 0) {
foreach ($result as $val) {
$relation_idxs[] = $val['idx'];
}
}
}
if(count($relation_idxs) > 0) {
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['content_idx'] = $idx;
$req_data['relation_idxs'] = $relation_idxs;
# model - 수동등록
$result = $this->m_relation_article->relation_article_insert($req_data);
if(!$result) {
gf_alert("관련뉴스등록에 실패했습니다.", 'back');
exit;
}
}
# 테마 등록
for($i=1; $i<=6; $i++) {
$rank = ${"theme_type".$i};
if($rank != '') {
$req_data = array();
$req_data['theme_type'] = $i;
$req_data['content_type'] = $content_type;
$req_data['rank'] = $rank;
$req_data['content_idx'] = $idx;
$req_data['filename'] = $filename;
$req_data['title'] = $title;
$req_data['is_display'] = $is_display;
$this->load->library('comm_admin');
$result = $this->comm_admin->fn_theme_reg($req_data);
if (!$result) {
gf_alert("테마등록에 실패했습니다.", 'back');
exit;
}
}
}
# 기타섹션 등록
for($i=1; $i<=4; $i++) {
$rank = ${"section_type".$i};
if($rank != '') {
$req_data = array();
$req_data['etc_section_type'] = $i;
$req_data['content_type'] = $content_type;
$req_data['rank'] = $rank;
$req_data['content_idx'] = $idx;
$req_data['filename'] = $filename;
$req_data['title'] = $title;
$req_data['is_display'] = $is_display;
$this->load->library('comm_admin');
$result = $this->comm_admin->fn_etc_section_reg($req_data);
if (!$result) {
gf_alert("기타섹션등록에 실패했습니다.", 'back');
exit;
}
}
}
gf_alert("저장되었습니다.", $url);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리 - 삭제
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_reg_del_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
# model
$this->load->model('admin/news/m_news');
// 이미지 삭제
$result1 = $this->m_news->news_select($idx);
if(count($result1) > 0){
if($result1[0]['main_img']!=''){
unlink('.'.$result1[0]['main_img']);
}
}
$req_date[] = $idx;
# model - update
$this->m_news->news_is_del_update($req_date);
gf_alert("삭제되었습니다.", '/admin/news/news_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리 - 삭제 (다중)
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_reg_arr_del_proc() {
# request
$arr_idx = $this->input->get_post('is_del', TRUE); // 삭제할 idx
# model
$this->load->model('admin/news/m_news');
// 이미지 삭제
$result1 = $this->m_news->news_select_in_idx($arr_idx);
if(count($result1) > 0){
foreach ($result1 as $val) {
if($val['main_img']!=''){
unlink('.'.$val['main_img']);
}
}
}
# model - update
$this->m_news->news_is_del_update($arr_idx);
gf_alert("삭제되었습니다.", '/admin/news/news_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 기능별 뉴스관리 - 상태,노출일 변경
# CREATE : 2018-03-05
#---------------------------------------------------------------------------
function fn_ajax_news_is_display_update() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
$is_display = trim($this->input->get_post('is_display', TRUE));
$content_type = 1; // 뉴스
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['content_idx'] = $idx;
$req_data['search_type'] = 'is_display';
$req_data['search_key'] = 'N';
// 테마
$this->load->library('comm_admin');
$this->comm_admin->fn_theme_change_is_display($req_data);
// 기타테마
$this->load->library('comm_admin');
$this->comm_admin->fn_etc_section_change_is_display($req_data);
$req_data = array();
$req_data['idx'] = $idx;
$req_data['is_display'] = $is_display;
# model
$this->load->model('admin/news/m_news');
$result = $this->m_news->news_is_display_update($req_data);
if(!$result){
$return_data['result'] = array('result_code' => '9999');
} else {
$return_data['result'] = array('result_code' => '0000');
}
# view
return $this->load->view('/admin/comm/result_json', $return_data);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_theme_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_theme_type = trim($this->input->get_post('search_theme_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$search_click1 = trim($this->input->get_post('search_click1', TRUE));
$search_click2 = trim($this->input->get_post('search_click2', TRUE));
$content_type = 1; // 뉴스
if($sort=='') $sort ='1';
switch ($sort) {
case '1': $sort_column = 'a.reg_date'; break;
case '2': $sort_column = 'b.hit_count'; break;
case '3': $sort_column = 'b.review_count1'; break;
case '4': $sort_column = 'b.comment_count'; break;
default : $sort_column = 'a.reg_date'; break;
}
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
$search_category_code = $search_category_code1;
if($search_category_code2!='') $search_category_code = $search_category_code2;
if($search_category_code3!='') $search_category_code = $search_category_code3;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['search_theme_type'] = $search_theme_type;
$req_data['search_category_code'] = $search_category_code;
$req_data['sort_column'] = $sort_column;
$req_data['content_type'] = $content_type;
$req_data['search_click1'] = $search_click1;
$req_data['search_click2'] = $search_click2;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - 카테고리 list
$this->load->model('admin/news/m_theme_news');
$total_count = $this->m_theme_news->theme_join_news_list_total_count($req_data);
$result = $this->m_theme_news->theme_join_news_list($req_data);
$new_count = $this->m_theme_news->theme_join_news_new_count($req_data);
$arr_display_count= $this->m_theme_news->theme_join_news_is_display_group_by_count($req_data);
# 카테고리 리스트
$this->load->model('admin/news/m_news_section');
$arr_category = $this->m_news_section->news_section_all_list();
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_theme_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['search_theme_type'] = $search_theme_type;
$return_data['search_click1'] = $search_click1;
$return_data['search_click2'] = $search_click2;
$return_data['sort'] = $sort;
$return_data['list'] = $result;
$return_data['arr_category'] = $arr_category;
$return_data['new_count'] = $new_count;
$return_data['arr_display_count'] = $arr_display_count;
# view
return $this->load->view('/admin/news/news_theme_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 등록/수정
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_theme_list_reg() {
# request
$mode = trim($this->input->get_post('mode', TRUE));
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_theme_type = trim($this->input->get_post('search_theme_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$content_type = 1; // 뉴스
if($mode == '') $mode = 'add';
if($search_theme_type == '') $search_theme_type = '1';
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['theme_type'] = $search_theme_type;
# 테마리스트
$this->load->model('admin/news/m_theme_news');
$arr_theme = $this->m_theme_news->theme_join_news_type_list($req_data);
$return_data = array();
$return_data['mode'] = $mode;
$return_data['page'] = $page;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_theme_type'] = $search_theme_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['sort'] = $sort;
$return_data['content_type'] = $content_type;
$return_data['idx'] = $idx;
$return_data['arr_theme'] = $arr_theme;
# view
return $this->load->view('/admin/news/news_theme_list_reg', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 - 저장
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_theme_list_reg_proc() {
# request
$theme_type = trim($this->input->get_post('theme_type', TRUE));
$content_type = '1'; // 뉴스는 1
include_once ("./static_data/code.php");
$arr_req_data = array();
for($i=1;$i<=$def_arr_news_theme[$theme_type]['count'];$i++){
${"content_idx".$i} = trim($this->input->get_post('content_idx'.$i, TRUE));
${"head_title".$i} = trim($this->input->get_post('head_title'.$i, TRUE));
${"title".$i} = trim($this->input->get_post('title'.$i, TRUE));
${"sub_content".$i} = trim($this->input->get_post('sub_content'.$i, TRUE));
${"img".$i} = trim($this->input->get_post('img'.$i, TRUE));
${"org_img".$i} = trim($this->input->get_post('org_img'.$i, TRUE));
# model
$req_data['theme_type'] = $theme_type;
$req_data['content_type'] = $content_type;
$req_data['rank'] = $i;
$this->load->model('admin/comm/m_theme');
$rank_count = $this->m_theme->theme_rank_count($req_data);
if(${"title".$i}!=''){
# 이미지업로드
if($_FILES['theme_img'.$i]['name']!='') {
# image upload
$upload_path = './files/theme/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('theme_img'.$i)) {
$error = array('error' => $this->upload->display_errors());
gf_alert("이미지 업로드에 실패했습니다.", 'back');
exit;
}
$arr_upload_data = $this->upload->data();
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
$is_file_copy = 'N';
} else {
if(${"img".$i}=='') {
$filename = ${"org_img".$i};
$is_file_copy = 'N';
} else {
$filename = ${"img".$i};
$is_file_copy = 'Y';
}
}
$req_data['theme_type'] = $theme_type;
$req_data['content_type'] = $content_type;
$req_data['rank'] = $i;
$req_data['content_idx'] = ${"content_idx".$i};
$req_data['filename'] = $filename;
$req_data['is_file_copy'] = $is_file_copy;
$req_data['is_display'] = 'Y';
$req_data['title'] = ${"title".$i};
$req_data['head_title'] = ${"head_title".$i};
$req_data['sub_content'] = ${"sub_content".$i};
$this->load->library('comm_admin');
$result = $this->comm_admin->fn_theme_reg($req_data);
if (!$result) {
gf_alert("테마등록에 실패했습니다.", 'back');
exit;
}
}
}
gf_alert("저장되었습니다.", "/admin/news/news_theme_list/2");
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 수정
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_theme_edit() {
# request
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_theme_type = trim($this->input->get_post('search_theme_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$content_type = 1; // 뉴스
# model
$this->load->model('admin/news/m_theme_news');
$result = $this->m_theme_news->theme_join_news_select($idx);
$return_data = array();
$return_data['page'] = $page;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_theme_type'] = $search_theme_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['sort'] = $sort;
$return_data['idx'] = $idx;
$return_data['result'] = $result[0];
$return_data['content_type'] = $content_type;
# view
return $this->load->view('/admin/news/news_theme_edit', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 - 수정
# CREATE : 2018-03-22
#---------------------------------------------------------------------------
function fn_news_theme_edit_proc() {
# request
$content_idx = trim($this->input->get_post('content_idx', TRUE));
$head_title = trim($this->input->get_post('head_title', TRUE));
$title = trim($this->input->get_post('title', TRUE));
$sub_content = trim($this->input->get_post('sub_content', TRUE));
$img = trim($this->input->get_post('img', TRUE));
$org_img = trim($this->input->get_post('org_img', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
# 이미지업로드
if($_FILES['theme_img']['name']!='') {
# image upload
$upload_path = './files/theme/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('theme_img')) {
$error = array('error' => $this->upload->display_errors());
gf_alert("이미지 업로드에 실패했습니다.", 'back');
exit;
}
$arr_upload_data = $this->upload->data();
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
} else {
if($img!='') {
# image upload
$upload_path = './files/theme/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$arr_new_file = explode('/', $img);
copy('.'.$img, $upload_path.'/'.$arr_new_file[5]);
$filename = '/files/theme/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];
} else {
$filename = $org_img;
}
}
$req_data['content_idx'] = $content_idx;
$req_data['head_title'] = $head_title;
$req_data['title'] = $title;
$req_data['sub_content'] = $sub_content;
$req_data['theme_img'] = $filename;
$req_data['idx'] = $idx;
$this->load->model('admin/comm/m_theme');
$this->m_theme->theme_where_idx_update($req_data);
gf_alert("저장되었습니다.", "/admin/news/news_theme_list/2");
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 - 삭제
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_theme_reg_del_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
# model
$this->load->model('admin/comm/m_theme');
// 이미지 삭제
$result1 = $this->m_theme->theme_select($idx);
if(count($result1) > 0){
if($result1[0]['theme_img']!=''){
unlink('.'.$result1[0]['theme_img']);
}
}
$req_date[] = $idx;
# model - update
$this->m_theme->theme_is_del_update($req_date);
gf_alert("삭제되었습니다.", '/admin/news/news_theme_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 테마별 뉴스관리 - 삭제 (다중)
# CREATE : 2018-03-06
#---------------------------------------------------------------------------
function fn_news_theme_reg_arr_del_proc() {
# request
$arr_idx = $this->input->get_post('is_del', TRUE); // 삭제할 idx
# model
$this->load->model('admin/comm/m_theme');
// 이미지 삭제
$result1 = $this->m_theme->theme_select_in_idx($arr_idx);
if(count($result1) > 0){
foreach ($result1 as $val) {
if($val['theme_img']!=''){
unlink('.'.$val['theme_img']);
}
}
}
# model - update
$this->m_theme->theme_is_del_update($arr_idx);
gf_alert("삭제되었습니다.", '/admin/news/news_theme_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹별 뉴스관리
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_ranking_type = trim($this->input->get_post('search_ranking_type', TRUE));
$search_click1 = trim($this->input->get_post('search_click1', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$content_type = 1; // 뉴스
if($sort=='') $sort ='1';
switch ($sort) {
case '1': $sort_column = 'reg_date'; break;
case '2': $sort_column = 'hit_count'; break;
case '3': $sort_column = 'review_count1'; break;
case '4': $sort_column = 'comment_count'; break;
default : $sort_column = 'reg_date'; break;
}
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
$search_category_code = $search_category_code1;
if($search_category_code2!='') $search_category_code = $search_category_code2;
if($search_category_code3!='') $search_category_code = $search_category_code3;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['search_ranking_type'] = $search_ranking_type;
$req_data['search_category_code'] = $search_category_code;
$req_data['sort_column'] = $sort_column;
$req_data['content_type'] = $content_type;
$req_data['search_click1'] = $search_click1;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - 카테고리 list
$this->load->model('admin/news/m_ranking');
$total_count = $this->m_ranking->ranking_join_news_list_total_count($req_data);
$result = $this->m_ranking->ranking_join_news_list($req_data);
$new_count = $this->m_ranking->ranking_join_news_new_count($req_data);
# 카테고리 리스트
$this->load->model('admin/news/m_news_section');
$arr_category = $this->m_news_section->news_section_all_list();
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_ranking_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['search_ranking_type'] = $search_ranking_type;
$return_data['search_click1'] = $search_click1;
$return_data['sort'] = $sort;
$return_data['list'] = $result;
$return_data['arr_category'] = $arr_category;
$return_data['new_count'] = $new_count;
# view
return $this->load->view('/admin/news/news_ranking_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹관리 송출관리 등록/수정
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_list_reg() {
# request
$mode = trim($this->input->get_post('mode', TRUE));
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_ranking_type = trim($this->input->get_post('search_ranking_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$content_type = 1; // 뉴스
if($mode == '') $mode = 'add';
if($search_ranking_type == '') $search_ranking_type = '1';
$req_data = array();
$req_data['content_type'] = $content_type;
$req_data['ranking_type'] = $search_ranking_type;
# 테마리스트
$this->load->model('admin/news/m_ranking');
$arr_ranking = $this->m_ranking->ranking_join_news_type_list($req_data);
$return_data = array();
$return_data['mode'] = $mode;
$return_data['page'] = $page;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_ranking_type'] = $search_ranking_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['sort'] = $sort;
$return_data['content_type'] = $content_type;
$return_data['idx'] = $idx;
$return_data['arr_ranking'] = $arr_ranking;
# view
return $this->load->view('/admin/news/news_ranking_list_reg', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹 뉴스관리 - 저장
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_list_reg_proc() {
# request
$ranking_type = trim($this->input->get_post('ranking_type', TRUE));
$content_type = '1'; // 뉴스는 1
include_once ("./static_data/code.php");
for($i=1;$i<=$def_arr_ranking[$ranking_type]['count'];$i++){
${"content_idx".$i} = trim($this->input->get_post('content_idx'.$i, TRUE));
${"head_title".$i} = trim($this->input->get_post('head_title'.$i, TRUE));
${"title".$i} = trim($this->input->get_post('title'.$i, TRUE));
${"sub_content".$i} = trim($this->input->get_post('sub_content'.$i, TRUE));
${"img".$i} = trim($this->input->get_post('img'.$i, TRUE));
${"org_img".$i} = trim($this->input->get_post('org_img'.$i, TRUE));
if($ranking_type == '1') ${"hit_count".$i} = trim($this->input->get_post('hit_count'.$i, TRUE));
if($ranking_type == '3') ${"review_count".$i} = trim($this->input->get_post('review_count'.$i, TRUE));
# model
$req_data['ranking_type'] = $ranking_type;
$req_data['content_type'] = $content_type;
$req_data['rank'] = $i;
$this->load->model('admin/comm/m_ranking');
$rank_count = $this->m_ranking->ranking_rank_count($req_data);
if(${"title".$i}!=''){
# 이미지업로드
if($_FILES['main_img'.$i]['name']!='') {
# image upload
$upload_path = './files/ranking/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('main_img'.$i)) {
$error = array('error' => $this->upload->display_errors());
gf_alert("이미지 업로드에 실패했습니다.", 'back');
exit;
}
$arr_upload_data = $this->upload->data();
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
} else {
if(${"img".$i}!='') {
# image upload
$upload_path = './files/ranking/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$arr_new_file = explode('/', ${"img".$i});
copy('.'.${"img".$i}, $upload_path.'/'.$arr_new_file[5]);
$filename = '/files/ranking/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];
} else {
$filename = ${"org_img".$i};
}
}
$arr_req_data = array('ranking_type'=> $ranking_type, 'content_type'=> $content_type, 'rank'=>$i, 'content_idx' => ${"content_idx".$i}, 'head_title' => ${"head_title".$i}, 'title' => ${"title".$i}, 'sub_content' => ${"sub_content".$i}, 'main_img' => $filename);
if($rank_count == 0) {
$this->m_ranking->ranking_insert($arr_req_data);
} else {
$this->m_ranking->ranking_update($arr_req_data);
}
if($ranking_type == '1' && ${"hit_count".$i} > 0) {
$insert_data['idx'] = ${"content_idx".$i};
$insert_data['hit_count'] = ${"hit_count".$i};
$this->load->model('admin/news/m_news');
$this->m_news->news_hit_count_update($insert_data);
} else if($ranking_type == '3' && ${"review_count".$i} > 0) {
$insert_data['idx'] = ${"content_idx".$i};
$insert_data['review_count1'] = ${"review_count".$i};
$this->load->model('admin/news/m_news');
$this->m_news->news_review_count1_update($insert_data);
}
} else {
if($rank_count > 0) {
$this->m_ranking->ranking_rank_is_del_update($req_data);
}
}
}
gf_alert("저장되었습니다.", "/admin/news/news_ranking_list/2");
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹관리 수정
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_edit() {
# request
$page = trim($this->input->get_post('page', TRUE));
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_ranking_type = trim($this->input->get_post('search_ranking_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$content_type = 1; // 뉴스
# model
$this->load->model('admin/news/m_ranking');
$result = $this->m_ranking->ranking_join_news_select($idx);
$return_data = array();
$return_data['page'] = $page;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_ranking_type'] = $search_ranking_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['sort'] = $sort;
$return_data['idx'] = $idx;
$return_data['result'] = $result[0];
$return_data['content_type'] = $content_type;
# view
return $this->load->view('/admin/news/news_ranking_edit', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹 뉴스관리 - 저장
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_edit_proc() {
# request
$ranking_type = trim($this->input->get_post('ranking_type', TRUE));
$content_idx = trim($this->input->get_post('content_idx', TRUE));
$head_title = trim($this->input->get_post('head_title', TRUE));
$title = trim($this->input->get_post('title', TRUE));
$sub_content = trim($this->input->get_post('sub_content', TRUE));
$img = trim($this->input->get_post('img', TRUE));
$org_img = trim($this->input->get_post('org_img', TRUE));
$idx = trim($this->input->get_post('idx', TRUE));
$hit_count = trim($this->input->get_post('hit_count', TRUE));
$review_count = trim($this->input->get_post('review_count', TRUE));
# 이미지업로드
if($_FILES['main_img']['name']!='') {
# image upload
$upload_path = './files/ranking/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$config['upload_path'] = $upload_path;
$config['allowed_types'] = 'gif|jpg|png';
$config['encrypt_name'] = TRUE;
$this->load->library('upload');
$this->upload->initialize($config);
if ( ! $this->upload->do_upload('main_img')) {
$error = array('error' => $this->upload->display_errors());
gf_alert("이미지 업로드에 실패했습니다.", 'back');
exit;
}
$arr_upload_data = $this->upload->data();
$filename = str_replace($_SERVER['DOCUMENT_ROOT'], '', $arr_upload_data['full_path']);
} else {
if($img!='') {
# image upload
$upload_path = './files/ranking/'.date("Y")."/".date("m");
if (!is_dir($upload_path)) {
mkdir($upload_path, 0777, TRUE);
}
$arr_new_file = explode('/', $img);
copy('.'.$img, $upload_path.'/'.$arr_new_file[5]);
$filename = '/files/ranking/'.date("Y").'/'.date("m").'/'.$arr_new_file[5];
} else {
$filename = $org_img;
}
}
$req_data = array();
$req_data['content_idx'] = $content_idx;
$req_data['head_title'] = $head_title;
$req_data['title'] = $title;
$req_data['sub_content'] = $sub_content;
$req_data['main_img'] = $filename;
$req_data['idx'] = $idx;
$this->load->model('admin/comm/m_ranking');
$this->m_ranking->ranking_where_idx_update($req_data);
# news 에 조회수, 공유수 업데이트
$update_date = array();
if($ranking_type == '1' && $hit_count > 0) {
$update_date['idx'] = $content_idx;
$update_date['hit_count'] = $hit_count;
$this->load->model('admin/news/m_news');
$this->m_news->news_hit_count_update($update_date);
} else if($ranking_type == '3' && $review_count > 0) {
$update_date['idx'] = $content_idx;
$update_date['review_count1'] = $review_count;
$this->load->model('admin/news/m_news');
$this->m_news->news_review_count1_update($update_date);
}
gf_alert("저장되었습니다.", "/admin/news/news_ranking_list/2");
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹관리 - 삭제
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_reg_del_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
# model
$this->load->model('admin/comm/m_ranking');
// 이미지 삭제
$result1 = $this->m_ranking->ranking_select($idx);
if(count($result1) > 0){
if($result1[0]['main_img']!=''){
unlink('.'.$result1[0]['main_img']);
}
}
$req_date[] = $idx;
# model - update
$this->m_ranking->ranking_is_del_update($req_date);
gf_alert("삭제되었습니다.", '/admin/news/news_ranking_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 랭킹관리 - 삭제 (다중)
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_reg_arr_del_proc() {
# request
$arr_idx = $this->input->get_post('is_del', TRUE); // 삭제할 idx
# model
$this->load->model('admin/comm/m_ranking');
// 이미지 삭제
$result1 = $this->m_ranking->ranking_select_in_idx($arr_idx);
if(count($result1) > 0){
foreach ($result1 as $val) {
if($val['main_img']!=''){
unlink('.'.$val['main_img']);
}
}
}
# model - update
$this->m_ranking->ranking_is_del_update($arr_idx);
gf_alert("삭제되었습니다.", '/admin/news/news_ranking_list/2');
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스관리 > 지난 랭킹별 뉴스관리
# CREATE : 2018-03-07
#---------------------------------------------------------------------------
function fn_news_ranking_log_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_year = trim($this->input->get_post('search_year', TRUE));
$search_month = trim($this->input->get_post('search_month', TRUE));
$search_day = trim($this->input->get_post('search_day', TRUE));
$search_ranking_type = trim($this->input->get_post('search_ranking_type', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$content_type = 1; // 뉴스
if($sort=='') $sort ='1';
switch ($sort) {
case '1': $sort_column = 'reg_date'; break;
case '2': $sort_column = 'hit_count'; break;
case '3': $sort_column = 'like_count'; break;
case '4': $sort_column = 'comment_count'; break;
case '5': $sort_column = 'share_count'; break;
default : $sort_column = 'reg_date'; break;
}
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
$search_category_code = $search_category_code1;
if($search_category_code2!='') $search_category_code = $search_category_code2;
if($search_category_code3!='') $search_category_code = $search_category_code3;
if($search_year=='') $search_year = date("Y");
if($search_month=='') $search_month = date("m");
if($search_day=='') $search_day = date("d");
$search_date = $search_year.'-'.$search_month.'-'.$search_day;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['search_ranking_type'] = $search_ranking_type;
$req_data['search_category_code'] = $search_category_code;
$req_data['search_date'] = $search_date;
$req_data['sort_column'] = $sort_column;
$req_data['content_type'] = $content_type;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - 카테고리 list
$this->load->model('admin/comm/m_ranking_log');
$total_count = $this->m_ranking_log->ranking_log_list_total_count($req_data);
$result = $this->m_ranking_log->ranking_log_list($req_data);
# 카테고리 리스트
$this->load->model('admin/news/m_news_section');
$arr_category = $this->m_news_section->news_section_all_list();
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_ranking_log_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['search_ranking_type'] = $search_ranking_type;
$return_data['sort'] = $sort;
$return_data['sort'] = $sort;
$return_data['list'] = $result;
$return_data['search_year'] = $search_year;
$return_data['search_month'] = $search_month;
$return_data['search_day'] = $search_day;
$return_data['arr_category'] = $arr_category;
# view
return $this->load->view('/admin/news/news_ranking_log_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 댓글관리
# CREATE : 2018-03-12
#---------------------------------------------------------------------------
function fn_news_comment_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$search_news_type = trim($this->input->get_post('search_news_type', TRUE));
$search_comment_type = trim($this->input->get_post('search_comment_type', TRUE));
$search_category_code1 = trim($this->input->get_post('search_category_code1', TRUE));
$search_category_code2 = trim($this->input->get_post('search_category_code2', TRUE));
$search_category_code3 = trim($this->input->get_post('search_category_code3', TRUE));
$search_theme_type = trim($this->input->get_post('search_theme_type', TRUE));
$search_today = trim($this->input->get_post('search_today', TRUE));
$search_today_best = trim($this->input->get_post('search_today_best', TRUE));
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
if($search_comment_type == '') $search_comment_type = 'N';
$search_category_code = $search_category_code1;
if($search_category_code2!='') $search_category_code = $search_category_code2;
if($search_category_code3!='') $search_category_code = $search_category_code3;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['search_comment_type'] = $search_comment_type;
$req_data['search_news_type'] = $search_news_type;
$req_data['search_category_code'] = $search_category_code;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
$req_data['search_theme_type'] = $search_theme_type;
$req_data['content_type'] = DEF_NEWS_CODE;
$req_data['search_today_best'] = $search_today_best;
$req_data['search_today'] = $search_today;
# model - 카테고리 list
$this->load->model('admin/news/m_news_comment');
$total_count = $this->m_news_comment->news_comment_list_total_count($req_data);
$result = $this->m_news_comment->news_comment_list($req_data);
$new_count = $this->m_news_comment->news_comment_new_count($req_data);
$best_count = $this->m_news_comment->news_comment_is_best_count($req_data);
$best_new_count = $this->m_news_comment->news_comment_is_best_new_count($req_data);
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_comment_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['search_news_type'] = $search_news_type;
$return_data['search_comment_type'] = $search_comment_type;
$return_data['search_theme_type'] = $search_theme_type;
$return_data['search_category_code1'] = $search_category_code1;
$return_data['search_category_code2'] = $search_category_code2;
$return_data['search_category_code3'] = $search_category_code3;
$return_data['list'] = $result;
$return_data['new_count'] = $new_count;
$return_data['best_count'] = $best_count;
$return_data['best_new_count'] = $best_new_count;
$return_data['search_today'] = $search_today;
$return_data['search_today_best'] = $search_today_best;
# view
return $this->load->view('/admin/news/news_comment_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 칼럼댓글 삭제
# CREATE : 2018-03-08
#---------------------------------------------------------------------------
function fn_column_comment_del_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
# 검색
$req_data = array();
$req_data['idx'] = $idx;
$req_data['comment_status'] = '6'; // 관리자삭제
# model
$this->load->model('admin/column/m_column_comment');
$this->m_column_comment->column_comment_is_del_update($req_data);
gf_alert("삭제되었습니다.", '/admin/column/column_comment_list/3');
}
#---------------------------------------------------------------------------
# PURPOSE : 태그관리
# CREATE : 2018-03-12
#---------------------------------------------------------------------------
function fn_news_tag_list() {
# request
$page = $this->uri->segment(5);
$search_type = trim($this->input->get_post('search_type', TRUE));
$search_keyword = trim($this->input->get_post('search_keyword', TRUE));
$sort = trim($this->input->get_post('sort', TRUE));
$content_type = DEF_NEWS_CODE;
if($sort=='') $sort ='1';
switch ($sort) {
case '1': $sort_column = 'reg_date'; break;
case '2': $sort_column = 'hit_count'; break;
default : $sort_column = 'reg_date'; break;
}
# paging 설정
if($page == '') $page = 1;
$limit = PAGE_SIZE;
$offset = ($page-1) * $limit;
# 검색
$req_data = array();
$req_data['search_type'] = $search_type;
$req_data['search_keyword'] = addslashes($search_keyword);
$req_data['sort_column'] = $sort_column;
$req_data['content_type'] = $content_type;
$req_data['offset'] = $offset;
$req_data['limit'] = $limit;
# model - list
$this->load->model('admin/comm/m_tag');
$total_count = $this->m_tag->tag_list_total_count($req_data);
$result = $this->m_tag->tag_list($req_data);
# pagination
$req_data = array();
$req_data['total_count'] = $total_count;
$req_data['limit'] = $limit;
$req_data['base_url'] = '/admin/news/news_tag_list/2' ;
$req_data['suffix'] = '?'.$_SERVER['QUERY_STRING'];
$this->load->library('comm_admin');
$pagination = $this->comm_admin->fn_pagination($req_data);
# view data
$return_data['pagination'] = $pagination;
$return_data['page'] = $page;
$return_data['limit'] = $limit;
$return_data['total_count'] = $total_count;
$return_data['search_type'] = $search_type;
$return_data['search_keyword'] = $search_keyword;
$return_data['sort'] = $sort;
$return_data['list'] = $result;
# view
return $this->load->view('/admin/news/news_tag_list', $return_data, true);
}
#---------------------------------------------------------------------------
# PURPOSE : 뉴스 댓글 삭제
# CREATE : 2018-03-08
#---------------------------------------------------------------------------
function fn_news_comment_del_proc() {
# request
$idx = trim($this->input->get_post('idx', TRUE));
$comment = '관리자에 의해 삭제된 댓글입니다.';
# 검색
$req_data = array();
$req_data['idx'] = $idx;
$req_data['comment_status'] = '6'; // 관리자삭제
$req_data['comment'] = $comment; // 관리자삭제
# model
$this->load->model('admin/news/m_news_comment');
$this->m_news_comment->news_comment_is_del_update($req_data);
gf_alert("삭제되었습니다.", '/admin/news/news_comment_list/2');
}
}
?>