Files
2020-06-10 06:19:03 +09:00

778 lines
26 KiB
PHP
Executable File

<?php
include_once ("./static_data/code.php");
$arr_theme_reg = array();
for($i=1;$i<=10;$i++) {
$arr_theme_reg[$i] = '';
}
$arr_section_reg = array();
for($i=1;$i<=10;$i++) {
$arr_section_reg[$i] = '';
}
if($mode=='edit') {
$title = $result['title'];
$title = htmlspecialchars($title);
$content = htmlentities($result['content']);
$category_code = $result['category_code'];
$press_idx = $result['press_idx'];
$reporter_name = $result['reporter_name'];
$reporter_email = $result['reporter_email'];
$sub_title = $result['sub_title'];
$sub_title = htmlspecialchars($sub_title);
$tag = $result['tag'];
$org_url = $result['org_url'];
$hit_count = $result['hit_count'];
$review_count1 = $result['review_count1'];
$review_count2 = $result['review_count2'];
$review_count3 = $result['review_count3'];
$review_count4 = $result['review_count4'];
$review_count5 = $result['review_count5'];
$is_auto_setting = $result['is_auto_setting'];
$reg_date = $result['reg_date'];
$display_date = $result['display_date'];
$is_display = $result['is_display'];
$main_img = $result['main_img'];
$news_type = $result['news_type'];
$video_url = $result['video_url'];
$video_url = str_replace('https://www.youtube.com/embed/','', $video_url);
$category_code1 = substr($category_code, 0, 2);
$category_code2 = substr($category_code, 0, 4);
$category_code3 = substr($category_code, 0, 6);
$arr_display_date = explode(' ', $display_date);
$display_date = $arr_display_date[0];
$arr_display_time = explode(':', $arr_display_date[1]);
$display_hour = $arr_display_time[0];
$display_min = $arr_display_time[1];
$display_sec = $arr_display_time[2];
$tag = str_replace(' ', ',', $tag);
foreach ($arr_theme as $val) {
$arr_theme_reg[$val['theme_type']] = $val['rank'];
}
foreach ($arr_section as $val) {
$arr_section_reg[$val['etc_section_type']] = $val['rank'];
}
$relation_news_style = "none";
if($is_auto_setting=='N') {
$relation_news_style = "block";
}
} else {
$category_code1 = '';
$category_code2 = '';
$category_code3 = '';
$title = '';
$content = '';
$press_idx = '';
$reporter_name = '';
$reporter_email = '';
$sub_title = '';
$tag = '';
$org_url = '';
$hit_count = 0;
$review_count1 = 0;
$review_count2 = 0;
$review_count3 = 0;
$review_count4 = 0;
$review_count5 = 0;
$is_auto_setting= 'Y';
$display_date = '';
$display_hour = '';
$display_min = '';
$display_sec = '';
$main_img = '';
$news_type = $search_news_type;
$video_url = '';
if($news_type == '') $news_type = '1';
$relation_news_style = "none";
}
$arr_category_add1 = array();
$arr_category_add2 = array();
$arr_category_add3 = array();
foreach ($arr_category as $key=>$val) {
if($val['depth'] == '1') {
$arr_category_add1[] = array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name'], 'p_category_code'=> $val['p_category_code']);
} else if($val['depth'] == '2') {
$arr_category_add2[] = array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name'], 'p_category_code'=> $val['p_category_code']);
} else if($val['depth'] == '3') {
$arr_category_add3[] = array('category_code'=>$val['category_code'], 'category_name'=>$val['category_name'], 'p_category_code'=> $val['p_category_code']);
}
}
?>
<link rel="stylesheet" href="<?=DIR_CSS?>/jquery-ui.min.css" />
<script src="<?=DIR_JS?>/jquery-ui.min.js"></script>
<script src="<?=DIR_JS?>/admin/jquery.multiselect.js"></script>
<link href="<?=DIR_CSS?>/admin/jquery.multiselect.css" rel="stylesheet">
<script src="/ckeditor/ckeditor.js"></script>
<?
$menu_code = '23';
require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>
<form name="input_form" id="input_form" action="/admin/news/news_reg_proc" method="post" enctype="multipart/form-data">
<input type="hidden" name="idx" id="idx" value="<?=$idx?>">
<input type="hidden" id="search_type" name="search_type" value="<?=$search_type?>">
<input type="hidden" id="search_keyword" name="search_keyword" value="<?=$search_keyword?>">
<input type="hidden" id="search_news_type" name="search_news_type" value="<?=$search_news_type?>">
<input type="hidden" id="search_category_code1" name="search_category_code1" value="<?=$search_category_code1?>">
<input type="hidden" id="search_category_code2" name="search_category_code2" value="<?=$search_category_code2?>">
<input type="hidden" id="search_category_code3" name="search_category_code3" value="<?=$search_category_code3?>">
<input type="hidden" id="search_click1" name="search_click1" value="<?=$search_click1?>">
<input type="hidden" id="search_click2" name="search_click2" value="<?=$search_click2?>">
<input type="hidden" id="sort" name="sort" value="<?=$sort?>">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="mode" name="mode" value="<?=$mode?>">
<input type="hidden" id="img_path" name="img_path">
<div class="common_table news">
<table>
<tr>
<th>기능</th>
<td class="tl">
<input type="radio" name="news_type" value="1" <? if($news_type=='1') { echo 'checked';}?>> 일반뉴스&nbsp;&nbsp;
<input type="radio" name="news_type" value="2" <? if($news_type=='2') { echo 'checked';}?>> 포토뉴스&nbsp;&nbsp;
<input type="radio" name="news_type" value="3" <? if($news_type=='3') { echo 'checked';}?>> 동영상뉴스&nbsp;&nbsp;
<input type="radio" name="news_type" value="4" <? if($news_type=='4') { echo 'checked';}?>> 영상링크뉴스
</td>
</tr>
<tr>
<th>언론사</th>
<td class="tl">
<select name="press_idx" id="press_idx" class="type01">
<option value="">선택</option>
<? foreach ($arr_press as $val) {?>
<option value="<?=$val['idx']?>" <? if($press_idx==$val['idx']) { echo 'selected';}?>><?=$val['press_name']?></option>
<? }?>
</select>
</td>
</tr>
<tr>
<th>기자</th>
<td class="tl">
<input type="text" name="reporter_name" id="reporter_name" class="type01" value="<?=$reporter_name?>">
</td>
</tr>
<tr>
<th>기자이메일</th>
<td class="tl">
<input type="text" name="reporter_email" id="reporter_email" class="type01" value="<?=$reporter_email?>">
</td>
</tr>
<tr>
<th>뉴스제목</th>
<td class="tl">
<input type="text" name="title" id="title" value="<?=$title?>">
</td>
</tr>
<tr>
<th>부제목</th>
<td class="tl">
<input type="text" name="sub_title" id="sub_title" value="<?=$sub_title?>">
</td>
</tr>
<tr>
<th>메인이미지</th>
<td class="tl">
<input type="file" name="main_img" id="main_img" class="input00" size="100">
<? if($main_img!='') { ?>
<input type="checkbox" name="is_del_img" value="Y">삭제
<img src="<?=$main_img?>" width="100px"></br>
<? } else {
$main_img = '';
}
?>
<input type="hidden" name="org_main_img" id="org_main_img" value="<?=$main_img?>">
</td>
</tr>
<tr>
<th>카테고리</th>
<td class="tl">
<select name="category1" id="category1" onchange="change_category(1, this.value)" class="type01">
<option value="">선택</option>
<? if(count($arr_category_add1) > 0) {
foreach ($arr_category_add1 as $val) {?>
<option value="<?=$val['category_code']?>" <? if($category_code1==$val['category_code']) { echo 'selected'; }?>><?=$val['category_name']?></option>
<? }
} ?>
</select>
<select name="category2" id="category2" onchange="change_category(2, this.value)" class="type01">
<option value="">선택</option>
<? if(count($arr_category_add2) > 0) {
foreach ($arr_category_add2 as $val) {?>
<option value="<?=$val['category_code']?>" <? if($category_code2==$val['category_code']) { echo 'selected'; }?>><?=$val['category_name']?></option>
<? }
} ?>
</select>
<select name="category3" id="category3" class="type01">
<option value="">선택</option>
<? if(count($arr_category_add3) > 0) {
foreach ($arr_category_add3 as $val) {?>
<option value="<?=$val['category_code']?>" <? if($category_code3==$val['category_code']) { echo 'selected'; }?>><?=$val['category_name']?></option>
<? }
} ?>
</select>
</td>
</tr>
<tr>
<th>태그</th>
<td class="tl">
<input type="text" name="tag" id="tag" class="type01" value="<?php echo $tag ? $tag: str_replace('-', ',', cleanUrl($title))?>"> 최대 5개까지 입력 가능(,로 구분해주세요.)
</td>
</tr>
<tr>
<th>기사원본주소</th>
<td class="tl">
기사의 원본 주소를 입력하면 기사 클릭시 기사원본의 주소로 이동합니다.</br>
<input type="text" name="org_url" id="org_url" class="input00" value="<?=$org_url?>">
</td>
</tr>
<tr>
<th>youtube 주소</th>
<td class="tl">
https://youtu.be/<input type="text" name="video_url" id="video_url" class="input00" value="<?=$video_url?>" style="width:200px"> (키만 넣어주세요.)
</td>
</tr>
<tr>
<th>기사본문</th>
<td>
<textarea name="content" id="ir1" style="width:100%; height:500px;" /><?=$content?></textarea>
</td>
</tr>
<tr>
<th>조회수</th>
<td class="tl">
<input type="text" name="hit_count" id="hit_count" class="type03" value=""> (관리자가 임의적으로 조회수를 설정할 수 있습니다.)
</td>
</tr>
<tr>
<th>리뷰수</th>
<td class="tl">
<? $arr_review_txt = array('좋아요', '훈훈해요', '슬퍼요', '화나요', '후속기사원해요');
for($i=1;$i<=5;$i++) { ?>
<img style='vertical-align:middle;margin-right:7px;width:35px;margin-left:30px;border:2px solid #ded239;border-radius:50%;' src="/img/web/img_reaction<?=$i?>.png" alt="">
<input type="text" name="review_count<?=$i?>" id="review_count<?=$i?>" value="<?=${"review_count".$i}?>" class="type03" placeholder="<?=$arr_review_txt[$i-1]?>">
<? } ?>
<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(관리자가 임의적으로 리뷰수를 설정할 수 있으나 리뷰 합산 수가 조회수 이상이 될 수는 없습니다)
</td>
</tr>
<tr>
<th>관련뉴스</th>
<td class="tl">
<input type="radio" name="is_auto_setting" id="is_auto_setting" onclick="click_relation_news_auto_setting('Y');" value="Y" <? if($is_auto_setting=='Y') { echo 'checked';}?>> 자동설정&nbsp;&nbsp;
<input type="radio" name="is_auto_setting" id="is_auto_setting" onclick="click_relation_news_auto_setting('N');" value="N" <? if($is_auto_setting=='N') { echo 'checked';}?>> 수동설정
<div class="two_box_type01 clearfix" id="no_auto_setting_content" style="display:<?=$relation_news_style?>; margin-top:10px;">
<div class="con">
<div class="searh_area fn mb10">
<input type="text" name="article_keyword" id="article_keyword" class="input00" size="20" placeholder="검색어 입력" onkeypress="if( event.keyCode==13 ){search_article();}">
<a href="javascript:search_article();" class="btn"><i class="fa moving_all fa-search" style="margin-left:8px;"></i></a>
</div>
<div class="mb10">
<input type="radio" name="article_sort" id="article_sort" value="1" onclick="search_article();" checked>&nbsp;최신순&nbsp;
<input type="radio" name="article_sort" id="article_sort" value="2" onclick="search_article();">&nbsp;오래된순&nbsp;
&nbsp;&nbsp;&nbsp;검색결과&nbsp; <span class="mark" id="result_count">0</span>건
</div>
<div class="list scs">
<ul id="result">
</ul>
</div>
</div>
<div class="con">
<h3 class="mb10">선택된 뉴스 항목</h3>
<div class="list type02 scs">
<ul id="selected_news">
<? $i=1;
foreach ($arr_relation_article as $val) { ?>
<li><input type="checkbox" name="relation_idxs[]" id="relation_idx_<?=$i?>" value="<?=$val['relation_article_idx']?>" onclick="delete_article('<?=$i?>');" checked><a href="/web/news/news_view/<?=$val['relation_article_idx']?>" target="_blank"><?=$val['title']?></a></li>
<?
$i++;
} ?>
</ul>
</div>
</div>
</div>
</td>
</tr>
</table>
<h2 class="subtitle"><span>PC</span>뉴스테마설정</h2>
<table>
<tr>
<th>헤드라인뉴스<br />(모바일공통)</td>
<td class="tl">
<div class="two_box_type01 clearfix headline">
<div class="con thum_wrap">
<div class="thumil on">
<img src="/img/admin/news_1.png" alt="">
</div>
</div>
</div>
<? for($i=1;$i<=$def_arr_news_theme[1]['count'];$i++){?>
<input type="radio" name="theme_type1" value="<?=$i?>" <? if($arr_theme_reg[1] == $i) { echo 'checked';}?>> <?=$i?>위&nbsp;&nbsp;
<? }?>
</td>
</tr>
<tr>
<th>주요뉴스</th>
<td class="tl">
<div class="opt_box">
<select name="theme_type2" class="type01">
<option value="">순위설정</option>
<? for($i=1;$i<=$def_arr_news_theme[2]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_theme_reg[2] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_2.png" width="200px">
</td>
</tr>
<tr>
<th>이 시간 추천뉴스<br />(모바일공통)</th>
<td class="tl">
<div class="opt_box">
<select name="theme_type3" class="type01">
<option value="">순위선택</option>
<? for($i=1;$i<=$def_arr_news_theme[3]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_theme_reg[3] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_3.png" width="400px">
</td>
</tr>
<tr>
<th>오늘의 포토뉴스</th>
<td class="tl">
<div class="opt_box">
<select name="theme_type4" class="type01">
<option value="">순위선택</option>
<? for($i=1;$i<=$def_arr_news_theme[4]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_theme_reg[4] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_4.png" width="600px">
</td>
</tr>
</table>
<h2 class="subtitle"><span>모바일</span>뉴스테마설정</h2>
<table>
<tr>
<th>메인(빅원)</td>
<td class="tl">
<div class="opt_box">
<select name="theme_type5" class="type01">
<option value="">순위선택</option>
<? for($i=1;$i<=$def_arr_news_theme[5]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_theme_reg[5] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_5.png" width="400px">
</td>
</tr>
<tr>
<th>뷰(추천기사)</td>
<td class="tl">
<div class="opt_box">
<select name="theme_type6" class="type01">
<option value="">순위설정</option>
<? for($i=1;$i<=$def_arr_news_theme[6]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_theme_reg[6] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_6.png" width="400px">
</td>
</tr>
</table>
<h2 class="subtitle">기타섹션 <span>(모바일공통)</span></h2>
<table>
<tr>
<th>인기영상</td>
<td class="tl">
<div class="opt_box">
<select name="section_type1" class="type01">
<option value="">순위선택</option>
<? for($i=1;$i<=$def_arr_etc_section[1]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_section_reg[1] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/section1.png" width="300px">
</td>
</tr>
<tr>
<th>인기포토</td>
<td class="tl">
<div class="opt_box">
<select name="section_type2" class="type01">
<option value="">순위설정</option>
<? for($i=1;$i<=$def_arr_etc_section[2]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_section_reg[2] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/section1.png" width="300px">
</td>
</tr>
<tr>
<th>은혜로운영상<br />(모바일전용)</td>
<td class="tl">
<div class="opt_box">
<select name="section_type3" class="type01">
<option value="">순위설정</option>
<? for($i=1;$i<=$def_arr_etc_section[3]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_section_reg[3] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/section2.png" width="250px">
</td>
</tr>
<tr>
<th>카드뉴스</td>
<td class="tl">
<div class="opt_box">
<select name="section_type4" class="type01">
<option value="">순위설정</option>
<? for($i=1;$i<=$def_arr_etc_section[4]['count'];$i++){?>
<option value="<?=$i?>" <? if($arr_section_reg[4] == $i) { echo 'selected';}?>><?=$i?>위</option>
<? }?>
</select>
</div>
<img src="/img/admin/news_10.png" width="250px">
</td>
</tr>
</table>
<h2 class="subtitle">등록일시설정</h2>
<table>
<tr>
<th>등록일시</th>
<td class="tl">
<? if($mode=='add') {?>
<input type="text" name="display_date" id="display_date" value="<?=$display_date?>" class="type02" size="10" placeholder="예약일">
<input type="text" name="display_hour" id="display_hour" value="<?=$display_hour?>" class="type03" size="3" placeholder="시">:<input type="text" name="display_min" id="display_min" value="<?=$display_min?>" class="type03" size="3" placeholder="분">:<input type="text" name="display_sec" id="display_sec" value="<?=$display_sec?>" class="type03" size="3" placeholder="초">
<?} else {?>
<? if($is_display=='N') {?>
<input type="text" name="display_date" id="display_date" value="<?=$display_date?>" class="type02" size="10" placeholder="예약일">
<input type="text" name="display_hour" id="display_hour" value="<?=$display_hour?>" class="type03" size="3" placeholder="시">:<input type="text" name="display_min" id="display_min" value="<?=$display_min?>" class="type03" size="3" placeholder="분">:<input type="text" name="display_sec" id="display_sec" value="<?=$display_sec?>" class="type03" size="3" placeholder="초">
<? } else {?>
<input type="hidden" name="display_date" value="<?=$display_date?>">
<input type="hidden" name="display_hour" value="<?=$display_hour?>">
<input type="hidden" name="display_min" value="<?=$display_min?>">
<input type="hidden" name="display_sec" value="<?=$display_sec?>">
<?=$display_date?> <?=$display_hour?>:<?=$display_min?>:<?=$display_sec?>
<? }
}
?>
</td>
</tr>
</table>
</div>
<div class="write_btn tc">
<a href="javascript:news_reg_proc();">저장하기</a>
<a href="/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?>&sort=<?=$sort?>&search_click1=<?=$search_click1?>&search_click2=<?=$search_click2?>">취소하기</a>
<?if($mode=='edit') {?>
<!-- <a class="del_news" href="javascript:news_del_proc();">삭제하기</a> -->
<?}?>
</div>
</form>
<!-- <script type="text/javascript">
function news_del_proc() {
var link =`/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?>&sort=<?=$sort?>&search_click1=<?=$search_click1?>&search_click2=<?=$search_click2?>`;
let post_data = <?=$result['idx']?>;
if(confirm("글이 삭제됩니다. 삭제하시겠습니까?") == true) { //확인
$.post({
url:'/admin/news/news_del_proc_ajax',
data:post_data,
success:function(data){
console.log(data);
// location.href=url;
}
});
}else{ //취소
return;
}
}
</script> -->
<script type="text/javascript">
var oEditors = [];
var oEditors2 = [];
$(function(){
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: "ir1",
sSkinURI: "/smarteditor/SmartEditor2Skin.html",
htParams : {
bUseToolbar : true,
bUseVerticalResizer : true,
bUseModeChanger : true,
fOnBeforeUnload : function(){
}
},
fOnAppLoad : function(){
},
fCreator: "createSEditor2"
});
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors2,
elPlaceHolder: "ir2",
sSkinURI: "/smarteditor/SmartEditor2Skin.html",
htParams : {
bUseToolbar : true,
bUseVerticalResizer : true,
bUseModeChanger : true,
fOnBeforeUnload : function(){
}
},
fOnAppLoad : function(){
},
fCreator: "createSEditor2"
});
});
</script>
<script type="text/javascript">
function news_reg_proc(){
oEditors.getById["ir1"].exec("UPDATE_CONTENTS_FIELD", []);
if($("#press_idx").val()=='') {
alert("언론사를 선택해주세요.");
return false;
}
if($("#reporter_name").val()=='') {
alert("기자를 입력해주세요.");
return false;
}
if($("#title").val()=='') {
alert("제목을 입력해주세요.");
return false;
}
if($("#main_img").val()=='' && $("#org_main_img").val()=='') {
alert("메인이미지를 입력해주세요.");
return false;
}
if($("#category1").val()=='') {
alert("1차 섹션을 선택해주세요.");
return false;
}
// if($("#category2").val()=='') {
// alert("2차 섹션을 선택해주세요.");
// return false;
// }
if($("#ir1").val()=='' || $("#ir1").val()=='null' || $("#ir1").val()=='&nbsp;' || $("#ir1").val()=='<p>&nbsp;</p>') {
alert("기사본문을 입력해주세요.");
oEditors.getById["ir1"].exec("focus");
return false;
}
var hit_count = parseInt($("#hit_count").val());
var review_count = parseInt($("#review_count1").val()) + parseInt($("#review_count2").val()) + parseInt($("#review_count3").val()) + parseInt($("#review_count4").val()) + parseInt($("#review_count5").val());
if(review_count > hit_count) {
alert("리뷰수가 조회수 이상이 될수 없습니다.");
return false;
}
var is_auto_setting = $("input[type=radio][id=is_auto_setting]:checked").val();
if(is_auto_setting == 'Y' && $("#tag").val()=='') {
alert("관련뉴스를 자동설정 하시려면 tag가 필요합니다.");
return false;
}
$("#input_form").submit();
}
function change_category(depth, val){
if(depth == 1) {
var json_category = '<?=json_encode($arr_category_add2)?>';
json_category = eval(json_category);
$('#category2').empty();
$('#category3').empty();
var option = "<option value=''>선택</option>";
$('#category2').append(option);
$('#category3').append(option);
for(key in json_category) {
if(json_category[key]['p_category_code'] == val) {
option = $("<option value='"+json_category[key]['category_code']+"'>"+json_category[key]['category_name']+"</option>");
$('#category2').append(option);
}
}
} else {
var json_category = '<?=json_encode($arr_category_add3)?>';
json_category = eval(json_category);
$('#category3').empty();
var option = "<option value=''>선택</option>";
$('#category3').append(option);
for(key in json_category) {
if(json_category[key]['p_category_code'] == val) {
option = $("<option value='"+json_category[key]['category_code']+"'>"+json_category[key]['category_name']+"</option>");
$('#category3').append(option);
}
}
}
}
function click_relation_news_auto_setting(type){
if(type == 'Y') {
$("#no_auto_setting_content").hide();
} else {
$("#no_auto_setting_content").show();
$("#article_keyword").focus();
}
}
// 칼럼 검색
function search_article(){
var article_keyword = $("#article_keyword").val();
var article_sort = $(":input:radio[name=article_sort]:checked").val();
if(article_keyword == '') {
alert("검색어를 입력해주세요");
return false;
}
var form_data = {
"content_type" : "<?=DEF_NEWS_CODE?>",
"article_keyword" : article_keyword,
"sort" : article_sort,
"type" : 'JSON'
};
$.ajax({
url: '/admin/search/search_article_list',
async : false,
type : 'POST',
dataType : 'JSON',
data : form_data,
success: function (rtnJson) {
if(rtnJson.result_code == '0000') {
if(article_sort==1) {
data = sortJSON(rtnJson.result_data.list,'reg_date', '321'); // 123 or 321
} else {
data = sortJSON(rtnJson.result_data.list,'reg_date', '123'); // 123 or 321
}
$('#result_count').html(rtnJson.result_data.count);
$('#result').empty();
if(rtnJson.result_data.count == 0) {
$('#result').html("<li>검색된 내용이 없습니다.</li>");
} else {
for(key in data) {
var title = data[key]['title'];
title = title.replace(/'/g, "&#039;");
title = title.replace(/"/g, '&quot;');
console.log(title);
$('#result').append('<li class="title"><a href="javascript:;" onclick="select_article(\''+data[key]['idx']+'\', \''+title+'\');">'+title+'</a></li>');
}
}
} else {
alert("뉴스검색에 실패했습니다.");
return false;
}
},
error: function(jqXHR, exception) {
console.log(jqXHR);
}
});
}
function select_article(idx, title){
var index = ($("input[name=\"relation_idxs[]\"]").length)+1;
$('#selected_news').append('<li><input type="checkbox" name="relation_idxs[]" id="relation_idx_'+index+'" value="'+idx+'" onclick="delete_article('+index+');"><a href="/web/news/news_view/'+idx+'" target="_blank">'+title+'</a></li>');
$("input[name='relation_idxs[]'][value=" + idx + "]").attr("checked", true);
}
function delete_article(idx) {
var checkbox_id = 'relation_idx_'+idx;
if($('input:checkbox[id=checkbox_id]').is(":checked") == false){
$("#"+checkbox_id).parent().remove();
}
}
// jquery datepicker
$("#display_date").datepicker({
inline: true,
dateFormat: 'yy-mm-dd',
buttonImage:"/img/admin/btn_date.jpg",
showOn: "both",
buttonImageOnly: true
});
$('img.ui-datepicker-trigger').css({'cursor':'pointer', 'width':'30px'}); //아이콘(icon) 위치
</script>