<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>添加自由列表</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
		<link rel="stylesheet" href="/static/web/css/codemirror.css">
		<script src="/static/web/js/jquery.min.js"></script>
		<script src="/static/web/js/bootstrap.min.js"></script>
		<script src="/static/web/js/codemirror.js"></script>
		<script src="/static/web/js/mode/xml/xml.js"></script>
		<script src="/static/web/js/mode/javascript/javascript.js"></script>
		<script src="/static/web/js/mode/css/css.js"></script>
		<script src="/static/web/js/mode/htmlmixed/htmlmixed.js"></script>
		<script src="/static/web/js/admin.main.js"></script>
	</head>
	<body>
		<div class="container-fluid">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
				<li class="breadcrumb-item"><a href="freelist_main.php">自由列表管理</a></li>
				<li class="breadcrumb-item active">添加自由列表</li>
			</ol>
			<div class="card shadow-sm">
				<div class="card-header">添加自由列表</div>
				<div class="card-body">
					<div class="alert alert-info">freelist标签基本等同于arclist标签，区别是freelist标签支持分页，按自定义排序规则的文档列表，且自由列是独立编译的，轻松的实现统一化管理</div>
					<div id="list1" style="display:none"><p><a href="[field:arcurl/]">[field:title/]</a></p></div>
					<div id="list2" style="display:none"><p>[field:typelink/] - <a href="[field:arcurl/]">[field:title/]</a></p></div>
					<div id="list3" style="display:none"><p>[field:imglink/]</p><p>[field:textlink/]</p></div>
					<div id="list4" style="display:none"><p><a href="[field:arcurl/]">[field:title/]</a></p><p><a href="[field:arcurl/]">[field:description/]</a></p><p><span>日期：[field:pubdate function="MyDate('Y-m-d', @me)"/]</span><span>浏览：[field:click/]</span><span>好评：[field:scores/]</span></p></div>
					<form name="form1" action="freelist_add.php" method="post">
						<input type="hidden" name="dopost" value="save">
						<div class="table-responsive">
							<table class="table table-borderless">
								<tbody>
									<tr>
										<td colspan="4">
											<label><input type="radio" name="liststyle" onclick="ChangeListStyle();" value="1" checked><img src="/static/web/img/g_t2.jpg"></label>
											<label><input type="radio" name="liststyle" onclick="ChangeListStyle();" value="2"><img src="/static/web/img/g_t1.jpg"></label>
											<label><input type="radio" name="liststyle" onclick="ChangeListStyle();" value="3"><img src="/static/web/img/g_t3.jpg"></label>
											<label><input type="radio" name="liststyle" onclick="ChangeListStyle();" value="4"><img src="/static/web/img/g_t4.jpg"></label>
										</td>
									</tr>
									<tr>
										<td width="160">自由列表标题</td>
										<td width="550"><input type="text" name="title" id="title" class="admin-input-lg" required></td>
										<td width="160">列表生成目录</td>
										<td><input type="text" name="listdir" id="listdir" value="{cmspath}/a/freelist/" class="admin-input-lg"></td>
									</tr>
									<tr>
										<td>默认页名称</td>
										<td>
											<input type="text" name="defaultpage" id="defaultpage" value="index.html" class="admin-input-lg">
											<label><input type="checkbox" name="nodefault" id="nodefault" value="1"> 不使用默认首页</label>
										</td>
										<td>命名规则</td>
										<td><input type="text" name="namerule" id="namerule" value="{listdir}/index_{listid}_{page}.html" class="admin-input-lg">（{listdir}列表存放目录）</td>
									</tr>
									<tr>
										<td>列表模板</td>
										<td>
											<input type="text" name="templet" id="templet" value="{style}/list_free.htm" class="admin-input-lg">
											<button type="button" onclick="SelectTemplets('form1.templet');" class="btn btn-success btn-sm">选择</button>
										</td>
										<td>最大列出页数</td>
										<td><input type="text" name="maxpage" id="maxpage" value="100" class="admin-input-sm"></td>
									</tr>
									<tr>
										<td>列表关键词</td>
										<td><input type="text" name="keywords" id="keywords" class="admin-input-lg"></td>
										<td>列表描述</td>
										<td><textarea name="description" id="description" class="admin-textarea-sm"></textarea></td>
									</tr>
									<tr>
										<td>调用栏目</td>
										<td>
											<?php
											echo "<select name='typeid' class='admin-input-sm'>";
											echo "<option value='0'>不限栏目</option>";
											$dsql->SetQuery("SELECT id,typename, channeltype FROM `#@__arctype`");
											$dsql->Execute();
											while($lrow = $dsql->GetObject()){
												$disable = '';
												if ($lrow->channeltype < -1) {
													$disable = 'disabled';
												}
													echo "<option value='{$lrow->ID}' $disable>{$lrow->typename}</option>";
												}
												echo "</select>";
											?>
										</td>
										<td>限定模型</td>
										<td>
											<?php
											echo "<select name='channel' class='admin-input-sm'>";
											echo "<option value='0' selected>不限模型</option>";
											$dsql->SetQuery("SELECT id,typename FROM `#@__channeltype` WHERE id > 0");
												$dsql->Execute();
												while($row = $dsql->GetObject())
												{
													echo "<option value='{$row->ID}'>{$row->typename}</option>";
												}
												echo "</select>";
											?>
										</td>
									</tr>
									<tr>
										<td>附加属性</td>
										<td>
											<?php
											echo "<select name='att' class='admin-input-sm'>";
											echo "<option value='0' selected>不限</option>";
											$dsql->SetQuery("SELECT * FROM `#@__arcatt`");
											$dsql->Execute();
											while($row = $dsql->GetObject())
											{
												echo "<option value='{$row->att}'>{$row->attname}</option>";
											}
											echo "</select>";
											?>
										</td>
										<td>发布天数</td>
										<td><input type="text" name="subday" id="subday2" value="0" class="admin-input-sm">（0表示不限）</td>
									</tr>
									<tr>
										<td>每页记录数</td>
										<td><input type="text" name="pagesize" id="pagesize" value="30" class="admin-input-sm"></td>
										<td>显示列数</td>
										<td><input type="text" name="col" id="col3" value="1" class="admin-input-sm"></td>
									</tr>
									<tr>
										<td>标题长度</td>
										<td><input type="text" name="titlelen" id="titlelen" value="60" class="admin-input-sm">（1字节=0.5个中文字）</td>
										<td>高级筛选</td>
										<td>
											<label><input type="checkbox" name="types[]" id="type1" value="image"> 带缩略图</label>
											<label><input type="checkbox" name="types[]" id="type2" value="commend"> 推荐</label>
											<label><input type="checkbox" name="types[]" id="type3" value="spec"> 专题</label>
										</td>
									</tr>
									<tr>
										<td>关键词</td>
										<td><input type="text" name="keywordarc" id="keywordarc">（英文逗号隔开）</td>
										<td>排列顺序</td>
										<td>
											<select name="orderby" id="orderby" class="admin-input-sm">
												<option value="sortrank">置顶权限值</option>
												<option value="pubdate" selected>发布时间</option>
												<option value="senddate">录入时间</option>
												<option value="click">点击量</option>
												<option value="id">文档id</option>
												<option value="lastpost">最后评论时间</option>
												<option value="postnum">评论总数</option>
											</select>
											<label><input type="radio" name="order" value="desc" checked> 由高到低</label>
											<label><input type="radio" name="order" value="asc"> 由低到高</label>
										</td>
									</tr>
									<tr>
										<td colspan="4">
											<textarea name="innertext" id="myinnertext" class="admin-textarea-xl"></textarea>
										</td>
									</tr>
									<tr>
										<td colspan="4" align="center">
											<button type="submit" class="btn btn-success btn-sm">保存</button>
											<button type="reset" class="btn btn-outline-success btn-sm">重置</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
				</div>
			</div>
		</div>
		<script>
			function ChangeListStyle() {
				var itxt = document.getElementById("myinnertext");
				var myems = document.getElementsByName("liststyle");
				if (myems[0].checked) editor.setValue(document.getElementById("list1").innerHTML);
				else if (myems[1].checked) editor.setValue(document.getElementById("list2").innerHTML);
				else if (myems[2].checked) editor.setValue(document.getElementById("list3").innerHTML);
				else if (myems[3].checked) editor.setValue(document.getElementById("list4").innerHTML);
				editor.setValue(editor.getValue().replace("<br>", "<br>"));
				editor.setValue(editor.getValue().toLowerCase());
			}
			function ShowHide(objname) {
				var obj = document.getElementById(objname);
				if (obj.style.display == "block" || obj.style.display == "")
					obj.style.display = "none";
				else
					obj.style.display = "block";
			}
			function SelectTemplets(fname) {
				var pos = GetWinPos(800,600);
				window.open("./dialog/select_templets.php?&activepath=<?php echo urlencode($cfg_templets_dir)?>&f=" + fname, "poptempWin", "scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=" + pos.left + ", top=" + pos.top);
			}
			document.form1.innertext.value = document.getElementById("list1").innerHTML.toLowerCase();
			var editor = CodeMirror.fromTextArea(document.getElementById("myinnertext"), {
				lineNumbers: true,
				lineWrapping: true,
				mode: 'text/html',
			});
		</script>
	</body>
</html>