Files
cm-web-legacy/application/views/admin/etc_section/channel_edit.php
2020-06-10 06:19:03 +09:00

242 lines
8.7 KiB
PHP
Executable File

<?php
include_once ("./static_data/code.php");
$category_code1 = $result1['category_idx'];
$category_code2 = $result1['channel_idx'];
$etc_section_type = $result1['etc_section_type'];
$rank = $result1['rank'];
$life_etc_section_idx = $idx;
$menu_code = '67';
require_once (APPPATH.'views/skin/admin/_content_comm.php');
$arr_etc_section_detail_rank = array();
foreach ($result2 as $val) {
$arr_etc_section_detail_rank[$val['rank']] = array('idx'=>$val['idx'], 'main_img'=> $val['main_img'], 'head_title'=> $val['head_title'], 'title'=> $val['title'], 'content_idx'=> $val['content_idx'], 'hit_count'=>$val['hit_count'], 'editor_name'=>$val['editor_name']);
}
?>
<form name="input_form" id="input_form" action="/admin/etc_section/channel_edit_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_category" name="search_category" value="<?=$search_category?>">
<input type="hidden" id="search_etc_section_type" name="search_etc_section_type" value="<?=$search_etc_section_type?>">
<input type="hidden" id="etc_section_type" name="etc_section_type" value="<?=$etc_section_type?>">
<input type="hidden" id="sort" name="sort" value="<?=$sort?>">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="key" name="key">
<div class="common_table news">
<h2 class="subtitle"><?=$def_arr_channel_etc_section[$etc_section_type]['name']?></h2>
<table>
<tr><th colspan="2">채널 <?=$rank?>위</th></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_category1) > 0) {
foreach ($arr_category1 as $val) {?>
<option value="<?=$val['idx']?>" <? if($category_code1==$val['idx']) { echo 'selected'; }?>><?=$val['category_name']?></option>
<? }
} ?>
</select>
</td>
</tr>
<tr>
<th>채널선택</th>
<td class="tl">
<select name="category2" id="category2" class="type01" onchange="change_category(2, this.value)">
<option value="">선택</option>
<? if(count($arr_category2) > 0 && $category_code2!='') {
foreach ($arr_category2 as $val) {?>
<option value="<?=$val['idx']?>" <? if($category_code2==$val['idx']) { echo 'selected'; }?>><?=$val['channel_name']?></option>
<? }
} ?>
</select>
</td>
</tr>
<?
for($z=1;$z<=$def_arr_channel_etc_section[$etc_section_type]['detail_count'];$z++) {
$head_title = '';
$title = '';
$title = '';
$main_img_txt = '';
$main_img = '';
$editor_name = '';
$hit_count = '';
$content_idx = '';
$list_idx = '';
if(isset($arr_etc_section_detail_rank[$z])== true) {
$head_title = $arr_etc_section_detail_rank[$z]['head_title'];
$head_title = htmlspecialchars($head_title);
$title = $arr_etc_section_detail_rank[$z]['title'];
$title = htmlspecialchars($title);
$content_idx = $arr_etc_section_detail_rank[$z]['content_idx'];
$main_img = $arr_etc_section_detail_rank[$z]['main_img'];
$hit_count = $arr_etc_section_detail_rank[$z]['hit_count'];
$editor_name = $arr_etc_section_detail_rank[$z]['editor_name'];
$list_idx = $arr_etc_section_detail_rank[$z]['idx'];
if($main_img!='') $main_img_txt = '<img src="'.$main_img.'" width=250>';
}
switch($etc_section_type) {
case '1': $rowspan = '4';break;
case '2': $rowspan = '5';break;
case '3': $rowspan = '5';break;
default : $rowspan = '4';break;
}
?>
<tr>
<th rowspan="<?=$rowspan?>"><?=$z?>위</th>
<td class="tl">
<input type="hidden" name="list_idx_<?=$z?>" id="list_idx_<?=$z?>" value="<?=$list_idx?>">
<input type="hidden" name="content_idx_<?=$z?>" id="content_idx_<?=$z?>" value="<?=$content_idx?>">
<input type="text" name="head_title_<?=$z?>" id="head_title_<?=$z?>" class="type02" size="20" placeholder="말머리" value="<?=$head_title?>">
<input type="text" name="title_<?=$z?>" id="title_<?=$z?>" size="50" class="type00" placeholder="제목을 입력해주세요." value="<?=$title?>">
</td>
</tr>
<tr>
<td class="tl">
<input type="text" name="editor_name_<?=$z?>" id="editor_name_<?=$z?>" class="type02" size="20" placeholder="에디터" value="<?=$editor_name?>" readonly>
</td>
</tr>
<tr>
<td class="tl">이미지첨부
<div id="img_view_<?=$z?>"><?=$main_img_txt?></div>
<input type="hidden" name="img_<?=$z?>" id="img_<?=$z?>">
<input type="hidden" name="org_img_<?=$z?>" id="org_img_<?=$z?>" value="<?=$main_img?>">
<input type="file" name="main_img_<?=$z?>" id="main_img_<?=$z?>" class="input00" size="20" accept="image/*">
</td>
</tr>
<? if($etc_section_type != '1') {?>
<tr>
<td class="tl">
<input type="text" name="hit_count_<?=$z?>" id="hit_count_<?=$z?>" class="type02" size="20" placeholder="조회수" value="<?=$hit_count?>">
</td>
</tr>
<?}?>
<tr>
<td class="tl">
<button type="button" class="btn_black" style="width:100px" onclick="open_search_article('<?=$z?>');" style="cursor: pointer;">컨텐츠검색</button>
</td>
</tr>
<?
}
?>
</table>
</div>
<div class="write_btn tc">
<a href="javascript:channel_edit_proc();">저장하기</a>
<a href="/admin/etc_section/channel_list/6/<?=$page?>?search_type=<?=$search_type?>&search_keyword=<?=$search_keyword?>&search_category=<?=$search_category?>&search_etc_section_type=<?=$search_etc_section_type?>&sort=<?=$sort?>">목록으로</a>
</div>
</form>
<?
$content_type = '3';
require_once(APPPATH."views/admin/search/search_article_inc.php");
?>
<script type="text/javascript">
function change_category(depth, val){
reset();
if(depth == 1) {
var json_category = '<?=json_encode($arr_category2)?>';
json_category = eval(json_category);
$('#category2').empty();
var option = "<option value=''>선택</option>";
$('#category2').append(option);
for(key in json_category) {
if(json_category[key]['category_idx'] == val) {
option = "<option value='"+json_category[key]['idx']+"'>"+json_category[key]['channel_name']+"</option>";
$('#category2').append(option);
}
}
}
}
var etc_detail_count = "<?=$def_arr_channel_etc_section[$etc_section_type]['detail_count']?>";
function reset(){
for(z=1;z<=etc_detail_count;z++) {
$("#content_idx_"+z).val('');
$("#head_title_"+z).val('');
$("#title_"+z).val('');
$("#editor_name_"+z).val('');
$("#img_"+z).val('');
$("#org_img_"+z).val('');
$("#main_img_"+z).val('');
$("#img_view_"+z).empty();
$("#hit_count_"+z).empty();
}
}
function open_search_article(key){
$("#key").val("_"+key);
$("#article_keyword").val('');
commonLayerOpen('search_article');
$("#article_keyword").focus();
}
var etc_detail_count = "<?=$def_arr_channel_etc_section[$etc_section_type]['detail_count']?>";
function channel_edit_proc(){
if($("#category1").val()==''){
alert("카테고리를 선택해주세요.");
return false;
}
if($("#category2").val()==''){
alert("채널을 선택해주세요.");
return false;
}
for(z=1;z<=etc_detail_count;z++) {
if($("#title_"+z).val()!='') {
if($("#content_idx_"+z).val()==''){
alert("기사를 선택해주세요.");
return false;
}
if($("#main_img_"+z).val()=='' && $("#img_"+z).val()=='' && $("#org_img_"+z).val()=='') {
alert("이미지를 입력해주세요.");
return false;
}
}
}
$("#input_form").submit();
}
</script>