<!DOCTYPE html>
<html>
<head>
  <meta charset="<?php echo $cfg_soft_lang; ?>">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
  <title>修改自由列表</title>
  <link rel="stylesheet" href="../static/web/css/bootstrap.min.css">
  <link rel="stylesheet" href="../static/web/font/css/font-awesome.min.css">
  <link rel="stylesheet" href="../static/web/css/admin.css">
  <script src="../static/web/js/jquery.min.js"></script>
  <script src="../static/web/js/bootstrap.bundle.min.js"></script>
  <script src="js/main.js"></script>
  <script>
    function ChangeListStyle() {
      var itxt = document.getElementById("myinnertext");
      var myems = document.getElementsByName("liststyle");
      if (myems[0].checked) itxt.value = document.getElementById("list1").innerHTML;
      else if (myems[1].checked) itxt.value = document.getElementById("list2").innerHTML;
      else if (myems[2].checked) itxt.value = document.getElementById("list3").innerHTML;
      else if (myems[3].checked) itxt.value = document.getElementById("list4").innerHTML;
      itxt.value = itxt.value.replace("<br>", "<br>");
      itxt.value = itxt.value.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);
    }
    function CheckSubmit() {
      if (document.form1.title.value == "") {
        ShowMsg("自由列表标题标题不能为空");
        document.form1.title.focus();
        return false;
      }
      return true;
    }
  </script>
  <link rel="stylesheet" href="css/codemirror.css">
  <script src="js/codemirror.js"></script>
  <script src="js/mode/xml/xml.js"></script>
  <script src="js/mode/javascript/javascript.js"></script>
  <script src="js/mode/css/css.js"></script>
  <script src="js/mode/htmlmixed/htmlmixed.js"></script>
</head>
<body>
  <center>
    <table width="98%" cellpadding="1" cellspacing="1" align="center" class="table maintable mt-3 mb-3">
      <form action="freelist_edit.php" method="post" name="form1" onSubmit="return CheckSubmit();">
        <input type="hidden" name="dopost" value="save">
        <input type="hidden" name="aid" value="<?php echo $row['aid']?>">
        <tr>
          <td bgcolor="#f8f8f8">
            <table width="98%" cellpadding="0" cellspacing="0" class="table-borderless">
              <tr>
                <td width="30%"><a href="freelist_main.php">自由列表管理</a> &gt; 修改自由列表</td>
                <td width="70%" align="right"></td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td style="padding:0">
            <table width="100%" align="right" cellpadding="0" cellspacing="1" class="table-borderless">
              <tr>
                <td style="padding:0">
                  <table width="100%" cellspacing="1" cellpadding="0">
                    <tr>
                      <td colspan="2" align="left"><i class="fa fa-question-circle" title="帮助"></i> 自由列表标记的说明：自由列表标记（freelist）的功能基本等同于arclist标记，区别是freelist标记支持分页，这让生成Google Map、生成按自定义排序规则的文章列表（如按标题拼音部首排序等）等轻松的实现统一化管理，并且自由列是独立编译的，不与其它模板混在一起，这样不会影响系统生成网页或访问速度</td>
                    </tr>
                    <tr>
                      <td width="260" align="left">自由列表标题：</td>
                      <td align="left"><input type="text" name="title" id="title" value="<?php echo $row['title']?>" style="width:260px"></td>
                    </tr>
                    <tr>
                      <td align="left">列表HTML存放目录：</td>
                      <td align="left"><input type="text" name="listdir" id="listdir" value="<?php echo $row['listdir']?>" style="width:260px"> {listdir}变量的值</td>
                    </tr>
                    <tr>
                      <td align="left">目录默认页名称：</td>
                      <td align="left">
                        <input type="text" name="defaultpage" id="defaultpage" value="<?php echo $row['defaultpage']?>" style="width:260px">
                        <label><input type="checkbox" name="nodefault" id="nodefault" value="1" <?php if($row['nodefault']==1) echo "checked"; ?>> 不使用目录默认主页</label>
                      </td>
                    </tr>
                    <tr>
                      <td align="left">命名规则：</td>
                      <td align="left"><input type="text" name="namerule" id="namerule" value="<?php echo $row['namerule']?>" style="width:260px"></td>
                    </tr>
                    <tr>
                      <td height="36" align="left">列表模板：</td>
                      <td align="left">
                        <input type="text" name="templet" id="templet" value="<?php echo $row['templet']?>" style="width:260px">
                        <button type="button" name="set4" onClick="SelectTemplets('form1.templet');" class="btn btn-success btn-sm">浏览</button>
                      </td>
                    </tr>
                    <tr>
                      <td align="left">最大列出页数：</td>
                      <td align="left"><input type="text" name="maxpage" id="maxpage" value="<?php echo $row['maxpage']; ?>" style="width:60px"></td>
                    </tr>
                    <tr>
                      <td align="left"></td>
                      <td align="left">以下选项用于模板里的 &lt;meta name=&quot;keywords|description&quot; content=&quot;&quot;&gt; 描述</td>
                    </tr>
                    <tr>
                      <td align="left">关键词：</td>
                      <td align="left"><input type="text" name="keywords" id="keywords" value="<?php echo $row['keywords']; ?>" style="width:260px"></td>
                    </tr>
                    <tr>
                      <td align="left">列表描述：</td>
                      <td align="left"><textarea name="description" id="description" style="width:360px;height:50px"><?php echo $row['description']?></textarea></td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr>
                <td align="left" style="background:#F8FCF1">列表样式：这里是定义自由列表模板里的{dede:freelist/}标记的样式和属性</td>
              </tr>
              <tr>
                <td align="left">限定栏目：
                  <?php
                  $typeid = $ctag->GetAtt('typeid');
                  echo "<select name='typeid' style='width:160px'>";
                  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';
                  	}
               	    if($lrow->id==$typeid) echo "<option value='{$lrow->id}' selected $disable>{$lrow->typename}</option>";
               	    else echo "<option value='{$lrow->id}' $disable>{$lrow->typename}</option>";
                  }
                  echo "</select>";
		              ?>
                </td>
              </tr>
              <tr>
                <td align="left">限定频道：
                  <?php
                  $channel  = $ctag->GetAtt('channel');
                  echo "<select name='channel' style='width:160px'><option value='0'>不限</option>";
                  $dsql->SetQuery("Select id,typename From #@__channeltype where id>0");
                  $dsql->Execute();
                  while($nrow = $dsql->GetObject())
                  {
                  	if($nrow->id==$channel) echo "<option value='{$nrow->id}' selected>{$nrow->typename}</option>";
                  	else echo "<option value='{$nrow->id}'>{$nrow->typename}</option>";
                  }
                  echo "</select>";
                  ?>（如果限定了频道内容模型，则允许使用附加表指定的列表字段作为底层变量）
                </td>
              </tr>
              <tr>
                <td align="left">附加属性：
                  <?php
                  $att  = $ctag->GetAtt('att');
                  echo "<select name='att' style='width:160px'>";
                  echo "<option value='0'>不限</option>";
                  $dsql->SetQuery("Select * From #@__arcatt");
                  $dsql->Execute();
                  while($nrow = $dsql->GetObject())
                  {
                  	if($att==$nrow->att)
                  	{
                  		echo "<option value='{$nrow->att}' selected>{$nrow->attname}</option>";
                  	} else {
                  		echo "<option value='{$nrow->att}'>{$nrow->attname}</option>";
                  	}
                  }
                  echo "</select>";
		              ?>
                  文档发布时间：<input type="text" name="subday" id="subday" size="6" value="<?php echo $ctag->GetAtt('subday')?>"> 天以内（0表示不限）
                </td>
              </tr>
              <tr>
                <td align="left">
                  每页记录数：<input type="text" name="pagesize" id="pagesize" value="<?php echo $ctag->GetAtt('pagesize')?>" size="4">
                  显示列数：<input type="text" name="col" id="col" value="<?php  $col = $ctag->GetAtt('col'); $v = ( empty($col) ? '1' :  $col ); echo $v; ?>" size="4">
                  标题长度：<input type="text" name="titlelen" id="titlelen" value="<?php echo $ctag->GetAtt('titlelen')?>" size="4">（1字节 = 0.5个中文字）
                </td>
              </tr>
              <tr>
                <td align="left">
                  <?php
                	$setype = $ctag->GetAtt('type');
                	if($setype=='') $setype = 'X';
                	?>
                  高级筛选：
                  <label><input type="checkbox" name="types[]" id="type1" value="image" <?php if(preg_match("#image#i",$setype)) echo ' checked'; ?>> 带缩略图</label>
                  <label><input type="checkbox" name="types[]" id="type2" value="commend" <?php if(preg_match("#commend#i", $setype)) echo ' checked'; ?>> 推荐</label>
                  <label><input type="checkbox" name="types[]" id="type3" value="spec" class="inputbut" <?php if(preg_match("#spec#i", $setype)) echo ' checked'; ?>> 专题</label>
                  关键词：<input type="text" name="keywordarc" id="keywordarc" value="<?php echo $ctag->GetAtt('keyword')?>">（&quot;,&quot;逗号分开）
                </td>
              </tr>
              <tr>
                <td align="left">排列顺序：
                  <?php
                  $orderby = $ctag->GetAtt('orderby');
                  $sorta = "sortrank,置顶权限值;pubdate,发布时间;senddate,录入时间;click,点击量;id,文档ＩＤ,lastpost,最后评论时间;postnum,评论总数;rand,随机获取";
                  $sortas = explode(';',$sorta);
                  foreach($sortas as $v)
                  {
                  	$vs = explode(',',$v);
                  	$vs[0] = trim($vs[0]);
                  	$sortarrs[$vs[0]] = $vs[1];
                  }
                  ?>
                  <select name="orderby" id="orderby" style="width:160px">
                    <?php
                  	echo "<option value=\"$orderby\" selected>{$sortarrs[$orderby]}</option>";
                  	?>
                    <option value="sortrank">置顶权限值</option>
                    <option value="pubdate">发布时间</option>
                    <option value="senddate">录入时间</option>
                    <option value="click">点击量</option>
                    <option value="id">文档ＩＤ</option>
                    <option value="lastpost">最后评论时间</option>
                    <option value="postnum">评论总数</option>
                  </select>
                  <label><input type="radio" name="order" value="desc" <?php if($ctag->GetAtt('orderway')=='desc') echo "checked"; ?>> 由高到低</label>
                  <label><input type="radio" name="order" value="asc" <?php if($ctag->GetAtt('orderway')=='asc') echo "checked"; ?>> 由低到高</label>
                </td>
              </tr>
              <tr>
                <td align="left">循环内的单行记录样式(InnerText)：[<a href='javascript:ShowHide("innervar");'><i class="fa fa-question-circle" title="帮助"></i> 底层变量field参考</a>]</td>
              </tr>
              <tr>
                <td height="80" align="left">
                  <textarea name="innertext" cols="80" rows="6" id="myinnertext" style="width:80%;height:120px"><?php echo $ctag->GetInnerText()?></textarea>
                </td>
              </tr>
              <tr>
                <td height="80" align="left" id="innervar" style="display:none">
                  <span><i class="fa fa-question-circle" title="帮助"></i> 支持字段（底层变量[field:varname/])：id,title,color,typeid,ismake,description,pubdate,senddate,arcrank,click,litpic,typedir,typename,arcurl,typeurl,<br>stime(pubdate 的&quot;0000-00-00&quot;格式）,textlink,typelink,imglink,image普通字段直接用[field:字段名/]表示<br>·Pubdate发布时间的调用参数 [field:pubdate function=MyDate('Y--%d H:i:s',@me)/]</span>
                </td>
              </tr>
              <tr>
                <td align="center" class="py-3"><button name="Submit2" type="submit" id="Submit2" class="btn btn-success btn-sm">保存</button></td>
              </tr>
            </table>
          </td>
        </tr>
      </form>
    </table>
  </center>
  <script>
    var editor = CodeMirror.fromTextArea(document.getElementById('myinnertext'), {
      lineNumbers: true,
      lineWrapping: true,
      mode: 'text/html'
    });
  </script>
</body>
</html>