<?php 
$layout_polls = array();
if($layout['eifrtf_act'] == 'edit_base') {
    $layout_polls = $clComArticle->getPollByArticleId($layout['eifrtf_selectid']);
}
$layout_pollIds = '';
foreach ($layout_polls as $row) {
    $layout_pollIds .= ',' . $row['id'];
}
$layout_pollIds = removeCommaHeadTail($layout_pollIds);
$poll_type = dbGetFieldValue(TB_POLL,'type',"article_id='".$layout['eifrtf_selectid']."'");
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo SYS_CHARSET ?>">
<title>edit article</title>
<link href="<?php echo SYS_ADMIN_STYLE_PATH ?>style/common.css" rel="stylesheet" type="text/css">
<link href="<?php echo SYS_ADMIN_STYLE_PATH ?>style/jqModal.css" type="text/css" rel="stylesheet">
<link href="<?php echo SYS_ADMIN_STYLE_PATH ?>style/calendar.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/validate.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/calendar.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/calendar-setup.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/calendar-en.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/titlestyle.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/jqModal.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/jqModal.init.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/common.js"></script>
<script type="text/javascript" src="<?php echo SYS_ADMIN_STYLE_PATH ?>js/article.js"></script>
<script type="text/javascript" src="<?php echo DIR_INSTALL ?>plugins/kindeditor/kindeditor.js"></script>
<script language="javascript">
    KindEditor.eifrEditorData = new Array();
    KindEditor.eifrEditorData[0] = {editorObj:new Object(), fieldName:'intro'}
    KindEditor.ready(function(K) {
            KindEditor.eifrEditorData[0].editorObj = K.create('textarea[name="intro_html"]', {
            resizeType : 1,
            allowImageUpload : true,
            allowFileManager : true
        });
        
        var editor = K.editor({
            allowFileManager : true
        });
        K('#btn_upfile').click(function() {
            editor.loadPlugin('image', function() {
                editor.plugin.imageDialog({
                    imageUrl : K('#fileurl').val(),
                    clickFn : function(url, title, width, height, border, align) {
                        K('#fileurl').val(url);
                        editor.hideDialog();
                    }
                });
            });
        });
    });

function addPoll()
{
	var oSpan=document.getElementById('poll_select_input');
	var oItem=document.createElement("input");
	oItem.className = "input_text";
	oItem.type = "text";
	oItem.name="poll_title[]";
	oItem.value = "";
	oItem.size = "40";
	oSpan.appendChild(oItem);
	
	oItem=document.createElement("br");
	oSpan.appendChild(oItem);
	
}

function addPoll1()
{
	document.getElementById("poll_select_input").innerHTML += "<input type='text' name='poll_title[]' class='input_text' size='40' value=''><br />";
}
</script>
</head>

<body onLoad="init()">
<table class="nav_table" cellpadding="0" cellspacing="0">	
	<tr>
		<td class="nav_td"><?php echo $layout['eifrtf_menu_nav'] ?></td>
	</tr>	
</table>

<table class="toolbar_table" cellpadding="0" cellspacing="0">
    <tr>
        <td class="toolbar_td"><?php echo $layout['eifrtf_toolbar'] ?></td>
    </tr>
</table>

<form name="editForm" method="post" action="">
	<input type="hidden" name="selectid" id="selectValue" value="<?php echo $layout['eifrtf_selectid'] ?>">
	<input type="hidden" name="selectValue" id="selectValue" value="<?php echo $layout['eifrtf_selectid'] ?>">
    <input type="hidden" name="poll_list" id="poll_list" value="<?php echo $layout_pollIds ?>">
    <input type="hidden" name="type" id="type" value="<?php echo $layout['type'] ?>" >
    <input type="hidden" name="intro" id="intro" value="">
<table cellpadding="0" cellspacing="0" class="edit_tb">
    <tr> 
      <td colspan="2" class="edit_subtitle">
      	<img src="<?php echo SYS_ADMIN_STYLE_PATH ?>images/edit.gif" align="absmiddle">&nbsp;<span class="edit_subtitle_txt">基本信息</span>
      	<input type="checkbox" id="chk_base" checked value="1" onClick="showDisplayHidden('chk_base','area_base')">
      </td>
    </tr>
    <tr id="area_base" style="display:"> 
      <td colspan="2">
      	<table cellpadding="0" cellspacing="0" width="100%" border="0" >
			    <tr id="article_title"> 
			      <td width="20%" class="edit_td_txt">标题:</td>
			      <td width="80%"  class="edit_td_input">
			      	<input type="text" name="title" id="title" class="input_text" size="40" value="<?php echo $layout['title'] ?>" dataType="LimitB" min="1" max="255"  msg="[1,255]个字符之内" style="<?php echo $layout['title_style'] ?> width: 500px;">*
			      </td>
			    </tr>  
<?php if($layout['eifrtf_is_manage']) :?>
			    <tr id="article_title_style"> 
			      <td width="20%" class="edit_td_txt" >标题样式:</td>
			      <td width="80%"  class="edit_td_input">
			      	<select name="fontcolor" id="fontcolor" onChange="settitlestyle();" style="width: 80px;background-color: #000000">

	   			   <option value="" selected="selected">default</option>
				</select> 
				文字大小
			     	<select name="fontsize" id="fontsize" onChange="settitlestyle();">
	   			   <option value="" selected="selected">default</option>
	   			   <option value="12px">12px</option>
	   			   <option value="13px">13px</option>
	   			   <option value="14px">14px</option>
	   			   <option value="16px">16px</option>
	   			   <option value="18px">18px</option>
	   			   <option value="24px">24px</option>
	   			   <option value="36px">36px</option>
	   			   <option value="48px">48px</option>
	   			   <option value="72px">72px</option>

	   			 </select>
			     <img src="<?php echo SYS_ADMIN_STYLE_PATH ?>images/ti.gif" /><input type="checkbox" name="em" id="em" value="italic" onClick="settitlestyle();" />
			     <img src="<?php echo SYS_ADMIN_STYLE_PATH ?>images/tb.gif" /><input type="checkbox" name="strong" id="strong" value="bold" onClick="settitlestyle();" />
			     <img src="<?php echo SYS_ADMIN_STYLE_PATH ?>images/tu.gif" /><input type="checkbox" name="underline" id="underline" value="underline" onClick="settitlestyle();" />
				<script type="text/javascript" type="text/javascript">makeselectcolor('fontcolor');loadtitlestyle();</script>
			      </td>
			    </tr>
<?php endif; ?>  
			    <tr id="article_channel"> 
			    	<td colspan="2" width="100%">
			    		<table cellpadding="0" cellspacing="0" width="100%" border="0">	
								<tr>
									<td width="20%" class="edit_td_txt">系统频道:</td>
			      			<td width="80%" class="edit_td_input">
			      				<input type="text" name="channel_id_show" id="channel_id_show" class="input_text" value="<?php echo $layout['eifrtf_channel_title'] ?>" dataType="LimitB" min="0" max="255"  msg="不能为空">
			      				<input type="button" class="btn_jqm" name="btn_select_channel_id" id="btn_select_channel_id"  title="选择系统频道" value="选择..." onClick="openChannelSelect('channel_id','')" >
			      				<input type="hidden" name="channel_id" id="channel_id" value="<?php echo $layout['channel_id'] ?>">
			      			</td>	      
								</tr>	
							</table>
			    	</td>
			    </tr>   
				<tr id="article_channels"> 
			    	<td colspan="2" width="100%">
			    		<table cellpadding="0" cellspacing="0" width="100%" border="0">	
							<tr>
							<td width="20%" class="edit_td_txt">副频道:</td>
			      			<td width="80%" class="edit_td_input">
			      				<input type="text" name="channel_ids" id="channel_ids" class="input_text" size="30" value="<?php echo $layout['channel_ids'] ?>" require="false" dataType="LimitB" min="0" max="255"  msg="不能为空">
			      				<input type="button" class="btn_jqm" name="btn_select_channel_ids" id="btn_select_channel_ids" title="选择副频道" value="选择..." onClick="openChannelSelect('channel_ids','multiselect')" >
			      			</td>	      
							</tr>	
						</table>
			    	</td>
			    </tr> 				
			    <tr id="article_img"> 
			      <td class="edit_td_txt">标题图片:</td>
			      <td class="edit_td_input">
			      	<input type="text" name="fileurl" id="fileurl" class="input_text" size="40" value="<?php echo $layout['fileurl'] ?>" require="false" dataType="LimitB" min="0" max="255"  msg="[0,255]个字符之内">
			        <input name="btn_upfile" type="button" value="上传图片" id="btn_upfile">
			        &nbsp;&nbsp;<span id="show_img_fileurl"><img src="<?php echo CSafeData::getImgSrc($layout['fileurl']) ?>" align='absmiddle'></span>
			      </td>
			    </tr> 
                <tr id="tr_poll_type" > 
			      <td width="20%" class="edit_td_txt">投票类型:</td>
			      <td width="80%"  class="edit_td_input">
			      	<input type="radio" name="poll_type" value="1" <?php if($poll_type==1) echo 'checked' ?>>单选&nbsp;
			      	<input type="radio" name="poll_type" value="2" <?php if($poll_type==2) echo 'checked' ?>>多选&nbsp;
			      </td>
			    </tr>  
			    <tr id="tr_poll_select" > 
                    <td width="20%" class="edit_td_txt">投票选项:</td>
                    <td width="80%"  class="edit_td_input" >
                    <?php foreach($layout_polls as $row): ?>
                    <input type='text' name='poll_title[]' class='input_text' size='40' value='<?php echo $row['title'] ?>'>
                    <input type='hidden' name='poll_id[]' value='<?php echo $row['id'] ?>'> <br />
				    <?php endforeach; ?>
			      	<span id="poll_select_input"></span>
			      	<input type="button" name="poll_add" value="添加选项" onClick="addPoll()">
                    </td>
			    </tr>  
				<tr> 
				      <td width="20%"  class="edit_td_txt">属性:</td>
				      <td width="80%"  class="edit_td_input"><?php echo $layout['eifrtf_attribute'] ?></td>
				</tr>
                <tr id="article_source"> 
			    	<td colspan="2" width="100%">
			    		<table cellpadding="0" cellspacing="0" width="100%" border="0">	
							<tr>
							<td width="20%" class="edit_td_txt">来源名称:</td>
			      			<td width="20%" class="edit_td_input">
			      				<input type="text" name="sourcename" class="input_text" value="<?php echo $layout['sourcename'] ?>" require="false" dataType="LimitB" min="0" max="50"  msg="[0,50]个字符之内">
			      			</td>
							<td width="20%" class="edit_td_txt">来源地址:</td>
						    <td class="edit_td_input">
						      	<input type="text" name="sourceurl" size="30" class="input_text" value="<?php echo $layout['sourceurl'] ?>" require="false" dataType="Url" msg="非法的Url">
						    </td>		      
							</tr>	
						</table>
			    	</td>
			    </tr>
                <tr id="article_issue"> 
			    	<td colspan="2" width="100%">
			    		<table cellpadding="0" cellspacing="0" width="100%" border="0">	
							<tr>
							<td width="20%" class="edit_td_txt">发布人:</td>
			      			<td width="20%" class="edit_td_input">
				      			<input type="text" name="username" id="username" class="input_text" value="<?php echo $layout['eifrtf_username'] ?>" onClick="openSelectWin('../mod_user/user_select.php')">
				      			<input type="hidden" name="uid" id="uid" value="{uid}">
			      			</td>
							<td width="20%" class="edit_td_txt">发布时间:</td>
						    <td class="edit_td_input">
						      	<input type="text" name="issuetime" id="issuetime" class="input_text" value="<?php echo getDateTimeMk($layout['issuetime']) ?>">
						      	<script>
                                    function catcalc(cal)
                                    {
                                        document.getElementById("issuetime").value = cal.date.print("%Y-%m-%d %H:%M:%S");
                                    }
                                    Calendar.setup({
                                        inputField: "issuetime",
                                        ifFormat:"%Y-%m-%d %H:%M:%S",
                                        onUpdate:catcalc,
                                        showsTime:true
                                    });
								</script>
						      </td>		      
							</tr>	
						</table>
			    	</td>
			    </tr>
			    <tr> 
			      <td width="20%" class="edit_td_txt">是否打开评论:</td>
			      <td width="80%"  class="edit_td_input"><?php echo $layout['eifrtf_is_comment'] ?></td>
			    </tr>
                <tr> 
			      <td width="20%" class="edit_td_txt">状 态:</td>
			      <td width="80%"  class="edit_td_input"><?php echo $layout['eifrtf_status'] ?></td>
			    </tr>
                <tr> 
			      <td width="20%"  class="edit_td_txt">信息关联方式:</td>
			      <td width="80%"  class="edit_td_input">
			      	<input type="radio" name="relation_type" id="relation_type_1" value="1" <?php if($layout['relation_type']==1) echo 'checked' ?> onClick="showRelation(1)">关键字&nbsp;
			      	<input type="radio" name="relation_type" id="relation_type_2" value="2" <?php if($layout['relation_type']==2) echo 'checked' ?> onClick="showRelation(2)">选择文章
			      </td>
			    </tr>
			    <tr id="article_relation_1" style="display:none"> 
			      <td width="20%"  class="edit_td_txt"></td>
			      <td width="80%"  class="edit_td_input">
			      	<input type="text" size="40" name="relation_info" id="relation_info" class="input_text" value="<?php if($layout['relation_type']==1) echo $layout['relation_info'] ?>" > 多个关键字用  <font color="red">空格</font> 分隔,如"eifr 易孚"
			      </td>
			    </tr>
			    <tr id="article_relation_2" style="display:none"> 
			      <td width="20%" class="edit_td_txt"></td>
			      <td width="80%" class="edit_td_input">
			      	<table width="100%" cellpadding="0" cellspacing="0" border="0">	
								<tr>
									<td>
										<select size="3" multiple="multiple" name="article_list[]" id="article_list">
                                        <?php echo Common::createArticleSelect($layout['relation_info']) ?>
                                        </select>
									</td>
			      			<td>
			      				<input type="button" name="btn_add" value="添加..." onClick="openSelectWin('article_select.php?act=insert')">
			      				<input type="button" name="btn_delete" value="删除所选项" onClick="referencebrowser_removeReference('article_list',1)">
										<input type="button" name="btn_preview" value="预览所选项" onClick="referencebrowser_openBrowser('article_list','article_view.php?selectid=')">
										<input type="button" name="btn_selectAll" value="全选" onClick="referencebrowser_selectAllReference('article_list',1)">
			      			</td>     
								</tr>	
							</table>
			      </td>
			    </tr>
<?php if($layout['eifrtf_is_manage']) :?>
			    <tr id="template_layout"> 
			      <td width="20%" class="edit_td_txt">板块位置:</td>
			      <td width="80%" class="edit_td_input">
			      	<table width="100%" cellpadding="0" cellspacing="0" border="0">	
								<tr>
									<td>
										<?php echo $layout['eifrtf_layout_select'] ?>
									</td>
			      			<td>
			      				<input type="button" name="btn_add" value="添加..." onClick="openSelectWin('../mod_template/template_layout_select.php?act=insert&type=0')">
			      				<input type="button" name="btn_delete" value="删除所选项" onClick="referencebrowser_removeReference('layout_id',1)">
										<input type="button" name="btn_preview" value="预览所选项" onClick="referencebrowser_openBrowser('layout_id','../mod_template/template_view.php?layout_id=')">
										<input type="button" name="btn_selectAll" value="全选" onClick="referencebrowser_selectAllReference('layout_id',1)">
			      			</td>     
								</tr>	
							</table>
			      </td>
			    </tr>
				<tr id="article_template"> 
			      <td width="20%" class="edit_td_txt">模板选择:</td>
			      <td width="80%"  class="edit_td_input">
			      	<input type="text" name="template_id_show" id="template_id_show" class="input_text" value="<?php echo $layout['eifrtf_template_title'] ?>" >
			      	<input type="button" name="btn_select_channel_id"  value="选择..." onClick="openTemplateSelect('article.php')" >
			      	<input type="hidden" name="template_id" id="template_id" value="<?php echo $layout['template_id'] ?>">
			      </td>
			    </tr>
<?php endif; ?>
			    <tr> 
			    	<td colspan="2" width="100%">
			    		<table cellpadding="0" cellspacing="0" width="100%" border="0">	
								<tr>
									<td width="20%" class="edit_td_txt">添加时间:</td>
			      			<td width="20%" class="edit_td_input"><?php echo getDateTimeMk($layout['addtime']) ?></td>
									<td width="20%" class="edit_td_txt">IP:</td>
						      <td class="edit_td_input"><?php echo $layout['ip'] ?></td>		      
								</tr>	
							</table>
			    	</td>
			    </tr>
                <tr> 
                  <td colspan="2" class="edit_subtitle">
                    <img src="<?php echo SYS_ADMIN_STYLE_PATH ?>images/edit_detail.gif" align="absmiddle">&nbsp;<span class="edit_subtitle_txt">介绍</span>
                    <input type="checkbox" id="chk_content" checked value="1" onClick="showDisplayHidden('chk_content','area_content')">
                  </td>
                </tr>
                <tr id="area_content" style="display:"> 
                  <td colspan="2">
                    <table cellpadding="3" cellspacing="0" width="100%" border="0">	
                    <tr>
                        <td id="area_content_edit">
                        <textarea id="intro_html" name="intro_html" rows="10" cols="80" style="width: 100%; height: 300px"><?php echo $layout['intro'] ?></textarea>
                        </td>	   
                    </tr>	
                </table>
                  </td>
                </tr> 
            </table>
      </td>
    </tr> 
</table>
</form>

<div id="modalWindow" class="jqmWindow">
<div id="jqmTitle">
<button class="jqmClose">X</button>
<span id="jqmTitleText">选择频道</span>
</div>
<iframe id="jqmContent" src=""></iframe>
</div>

</body>
</html>