<? defined('ROOT_PHPLEFT') or exit(require '../../../404.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gbk"/>
<title>管理中心 - Powered By phpleft.com</title>
 <script type="text/javascript" src="<?=PL_URL?>js/common.js"></script>
 <link href="css/main.css" type="text/css" rel="stylesheet">

</head>
<body bottommargin="0" leftmargin="0" topmargin="0" rightmargin="0">
<div class="tpis"><img src="images/icos.gif" align="absmiddle"/>当前位置：基础设置 > 模型管理</div>
<table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
        <tr>
            <th colspan="7">提示信息</th>
        </tr>
    
    </table>
    <div class="tsc">
1. 请谨慎删除模型，删除模型管后，数据不可恢复 <br>
2. 模型可以自由编辑字段，之后创建的模块同模型一样。
</div>
<? include inTemplate(menu);?>
<? if(!$table){?>
<? if ($show==""){?>

    <table class="usertableborder bb" cellspacing="0" cellpadding="3" width="100%" align="center"
        border="0">

        <tr align="center" class="title">
          <td widtd="100" height="30" valign="top">
          模块文件夹
          </td>
          <td widtd="85" height="30">模块名称</td>
         
            <td widtd="93" height="30">创建日期</td>
            <td widtd="74" height="30">作者</td>
             <td widtd="102" height="30">是否可复制</td>
             <td widtd="249" height="30">模块管理</td>
              <td widtd="263" height="30">&nbsp;</td>
             
        </tr>

         <?php foreach($filelist as $id=>$m) { ?>
        <tr align="center" class="list<?php if($id%2==1) echo '1'?>">
          <td width="100" height="30" valign="top" style="padding-right:10px;" align="left"><img src="file/folder.gif" align="absmiddle"> <?=$m?>
          </td>
          <td width="85" height="30"><?=$phplefts[$m]['modulename']?></td>
         
            <td width="93" height="30"><?=$phplefts[$m]['moduledate']?></td>
            <td width="74" height="30"><a href="<?=$phplefts[$m]['moduleurl']?>" target="_blank">
            <?=$phplefts[$m]['moduleuser']?>
            </a></td>
             <td width="102" height="30"><?php if($phplefts[$m]['moduleis']==1){?>是<? } else { ?>否<? } ?></td>
             <td width="249" height="30"><?php if(admin::module_install($m)=='1'){?><a href="phpleft.php?file=module&show=key&modulename=<?=$m?>"><img src="<?=PL_URL?>ico/plus.png" align="absmiddle" alt="添加字段" border="0"></a>&nbsp;<a href="phpleft.php?file=module&table=<?=$m?>"><img src="<?=PL_URL?>ico/database.png" align="absmiddle" alt="管理字段" border="0"></a><? }else{?><a href="phpleft.php?file=module&post=install&install=<?=$m?>"><img src="<?=PL_URL?>ico/publish.png" align="absmiddle" alt="开始安装" border="0">开始安装</a> <? }?>&nbsp;<a href="?file=post_center&post=module&input=delete&delete=<?=$m?>" onClick="if(!confirm('删除后将无法使用该模块所有栏目，请谨慎操作！确定删除?')) return false;" ><img src="<?=PL_URL?>ico/del.png" align="absmiddle" alt="删除模块" border="0"></a></td>
              <td height="30">&nbsp;</td>
             
        </tr>
       <?php } ?>
    </table>
     <?
	 }elseif ($show=="module"){
	  msg('创建模型系统未完全完善，等待后期开放....', 'phpleft.php?file=module',0,5,1,'n');
	}elseif ($show=="key"){
	?>
 <?
  if ($thisid<>""){
  ?>
<form action="?file=post_center&post=module&input=keyb" method="post" style="margin:0px; padding:0px;" onsubmit="return check();">  
  <?
  }else {
  ?>
<form action="?file=post_center&post=module&input=key" method="post" style="margin:0px; padding:0px;" onsubmit="return check();">
<?
  }
  ?>
<input name="alladd[module]" type="hidden" value="<?=$modulename?>">
  <?
  if ($thisid<>""){
  ?>
 <input name="alladd[keylist]" type="hidden" value="<?=$alladd[keylist]?>">
<input name="id" type="hidden" value="<?=$thisid?>">
<?
  }
  ?>
    <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
        <tr>
            <th colspan="3">
                <?
  if ($thisid<>""){
  ?>编辑字段<? }else{?>添加字段<? }?></th>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>当前模型</strong></td>
        <td width="383" height="30"><?=$modulename?><input name="alladd[moduleid]" type="hidden" id="moduleid" value="<?=$modulename?>" size="23"></td>
            <td height="30"></td>
        </tr>
   <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段名称</strong></td>
<td width="383" height="30"><input name="alladd[name]" type="text" id="name" value="<?=$alladd[name]?>" size="23"></td>
            <td height="30"><span id="cname">建议使用中文</span></td>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段</strong></td>
        <td width="383" height="30" class="usertablerow1"><input name="alladd[thiskeys]" type="text" id="thiskeys" value="<?=$alladd[thiskeys]?>" size="23"></td>
            <td height="30" class="usertablerow1"><span id="cthiskeys">小写字母(a-z),数字(0-9) 推荐使用字母,不能以数字开头</span></td>
        </tr>
      
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>提示信息</strong></td>
        <td width="383" height="30" class="usertablerow1"><input name="alladd[note]" type="text" id="note" value="<?=$alladd[note]?>" size="50" /></td>
            <td height="30" class="usertablerow1"></td>
        </tr>
        <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段类型</strong></td>
            <td width="383" height="30">
<select name="alladd[keystype]" onChange="keystype(this.value)">
<option value="varchar"<? if($alladd[keystype]=="varchar" or $alladd[type]=="") echo 'selected'?>>字符(Varchar)</option>
<option value="int"<? if($alladd[keystype]=="int") echo 'selected'?>>整数(Int)</option>
<option value="float"<? if($alladd[keystype]=="float") echo 'selected'?>>小数(Float)</option>
<option value="text"<? if($alladd[keystype]=="text") echo 'selected'?>>文本(Text)</option>
</select></td>
            <td height="30">&nbsp;</td>
        </tr>
        </table>
        <? if ($alladd[keystype]<>'float' and $alladd[keystype]<>"text"){?>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0" id="length_td">
         <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>字段长度</strong></td>
          <td width="383" height="30"><input name="alladd[length]" type="text" id="length" size="20" value="<? if ($thisid=="") echo '255';?><?=$alladd[length]?>"/></td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        </table>
        <? }?>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
         <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>默认值</strong></td>
          <td width="383" height="30" class="usertablerow1"><input name="alladd[default_value]" type="text" value='<?=$alladd[default_value]?>' size="40" /></td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
              <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>表单类型</strong></td>
            <td width="383" height="30"><select name="alladd[type]" onChange="typey(this.value)">
<option value="text"<? if($alladd[type]=="text" or $alladd[type]=="") echo 'selected'?>>单行文本(text)</option>
<option value="textarea"<? if($alladd[type]=="textarea") echo 'selected'?>>多行文本(textarea)</option>
<option value="select"<? if($alladd[type]=="select") echo 'selected'?>>下拉框(select)</option>
<option value="radio"<? if($alladd[type]=="radio") echo 'selected'?>>单选框(radio)</option>
<option value="checkbox"<? if($alladd[type]=="checkbox") echo 'selected'?>>多选框(checkbox)</option>
<option value="hidden"<? if($alladd[type]=="hidden") echo 'selected'?>>隐藏域(hidden)</option>
<option value="date"<? if($alladd[type]=="date") echo 'selected'?>>日期选择</option>
<option value="thumb"<? if($alladd[type]=="thumb") echo 'selected'?>>缩略图上传</option>
<option value="file"<? if($alladd[type]=="file") echo 'selected'?>>文件上传</option>
</select></td>
            <td height="30">&nbsp;</td>
        </tr></table>
        <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0" id="tvalue_td" style="display:none">
              <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>选项值</strong></td>
            <td width="383" height="30"><textarea name="alladd[typevalue]" style="width:250px;height:80px;overflow:visible;"><?=$alladd[typevalue]?></textarea><br/>
一行一个 选项值|选项名称</td>
            <td height="30" class="usertablerow1"></td>
        </tr>
        </table>
         <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
          <tr>
            <td width="159" height="30" class="text" style="padding-right:10px; text-align:right"><strong>附加内容</strong></td>
            <td width="383" height="30" class="usertablerow1"><input name="alladd[add_js]" type="text" size="60" value='<?=$alladd[add_js]?>' id="add_js" /> </td>
            <td height="30" class="usertablerow1">可以添加表单属性、JS事件或CSS样式 如果有单引号请加 \</td>
        </tr>
         <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>输入限制</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[geton]" type="text" id="geton" value="<?=$alladd[geton]?>" size="40" />
<select onChange="$('geton').value=this.value">
<option value=""<? if($alladd[geton]=="") echo 'selected'?>>无限制</option>
<option value="不能为空"<? if($alladd[geton]=="不能为空") echo 'selected'?>>不能为空</option>
</select></td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        
        <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>前台发布是否显示</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[qis_or]" type="radio" id="radio" value="1" class="no"<? if ($alladd[qis_or]==1 or $thisid==""){ ?> checked<? }?>>
            是&nbsp;  <input name="alladd[qis_or]" type="radio" id="radio" class="no" value="0"<? if ($alladd[qis_or]==0 and $thisid<>""){ ?> checked<? }?>>
            否&nbsp;  <input name="alladd[qis_or]" type="radio" id="radio" class="no" value="2"<? if ($alladd[qis_or]==2 and $thisid<>""){ ?> checked<? }?>>
            显示不可编辑 </td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        <tr>
            <td height="30" class="text" style="padding-right:10px; text-align:right"><strong>后台发布是否显示</strong></td>
            <td height="30" class="usertablerow1"><input name="alladd[is_or]" type="radio" id="radio" value="1" class="no"<? if ($alladd[is_or]==1 or $thisid==""){ ?> checked<? }?>>
            是&nbsp;  <input name="alladd[is_or]" type="radio" id="radio" class="no" value="0"<? if ($alladd[is_or]==0 and $thisid<>""){ ?> checked<? }?>>
            否 </td>
            <td height="30" class="usertablerow1">&nbsp;</td>
        </tr>
        
          <tr>
          <td height="30" class="text" style="padding-right:10px; text-align:right"></td>
            <td height="30"><input type="submit" name="button" id="button" value=" 确 认 "></td>
            <td height="30">&nbsp;</td>
        </tr>
</table>
    </form>
    <? }  }else{ ?>
    <form action="?file=post_center&post=module&input=paixu&table=<?=$table?>" method="post">
    <table class="usertableborder input" cellspacing="1" cellpadding="3" width="100%" align="center"
        border="0">
      <tr>
        <th colspan="7"> 模块管理</th>
      </tr>
      <tr align="center" class="list1">
        <td width="96" height="30" valign="top"> 排序 </td>
        <td width="90" height="30" valign="top"> 字段名称 </td>
        <td width="110" height="30">字段</td>
        <td width="101" height="30">字段类型</td>
        <td width="91" height="30">是否显示</td>
        <td width="110" height="30">字段管理</td>
        <td width="368" height="30">&nbsp;</td>
      </tr>
      <tr align="center" class="list0">
        <td width="96" height="30" valign="top"><input name="" type="text" id="keylist" value="-1" size="3" style="text-align:center"></td>
        <td width="90" height="30" valign="top">排序</td>
        <td width="110" height="30">id</td>
        <td width="101" height="30">自动增加</td>
        <td width="91" height="30">否</td>
        <td width="110" height="30">系统</td>
        <td height="30"></td>
      </tr>
      <?php 
	  $ii =0;
	  foreach($tablelist as $id=>$t) { 
	  $ii=$ii+1;
	  ?>
      
      <tr align="center" class="list<?php if($ii%2==1) echo '1'?>">
        <td width="96" height="30" valign="top"><input name="inid[]" type="hidden" id="id" value="<?=$t['id']?>" size="3" style="text-align:center"><input name="keylist[]" type="text" id="keylist" value="<?=$t['keylist']?>" size="3" style="text-align:center"></td>
        <td width="90" height="30" valign="top"><?=$t['name']?></td>
        <td width="110" height="30"><?=$t['thiskeys']?></td>
        <td width="101" height="30"><?=$t['keystype']?><? if ($t['keystype']<>'text'){?>(<?=$t['length']?>)<? }?></td>
        <td width="91" height="30"><? if($t['is_or']==0){?>
          否
          <? }else{?>
          是
          <? }?></td>
        <td width="110" height="30"><a href="phpleft.php?file=module&show=key&modulename=<?=$table?>&thisid=<?=$t['id']?>"><img src="<?=PL_URL?>ico/edit.png" align="absmiddle" alt="编辑字段" border="0"></a> <a href="?file=post_center&post=module&input=del&modulename=<?=$table?>&deltab=<?=$t['id']?>" onClick="if(!confirm('删除该字段！')) return false;" ><img src="<?=PL_URL?>ico/del.png" align="absmiddle" alt="删除字段" border="0"></a></td>
        <td height="30">&nbsp;</td>
      </tr>
      <?php } ?>
      <tr>
        <td height="30" style="padding-right:10px; text-align:right"><input type="submit" value=" 更新排序 "></td>
        <td height="30"></td>
        <td height="30" colspan="5">&nbsp;</td>
      </tr>
    </table></form>
    <?	
	
	}
	
	?>
  <script type="text/javascript">
function typey(id) {
	if(id == 'select' || id == 'radio' || id == 'checkbox') {
		$('tvalue_td').style.display = 'block';		
	}else{
		$('tvalue_td').style.display = 'none';		
	}
	if(id == 'text') {
		$('add_js').value = 'size=\"30\"';
	} else if(id == 'textarea') {
		$('add_js').value = 'rows=\"5\" cols=\"80\"';
	} else {
		$('add_js').value = '';
	}
}

function keystype(id) {
	if(id == 'varchar') {
		$('length_td').style.display = 'block';
		$('length').value = '255';
	} else if(id == 'int') {
		$('length_td').style.display = 'block';
		$('length').value = '10';
	} else if(id == 'float') {
		$('length_td').style.display = 'none';
		$('length').value = '';
	} else if(id == 'text') {
		$('length_td').style.display = 'none';
		$('length').value = '';
	}
}
function check() {
	if($('name').value == '') {
    msg('请输入字段名称','cname','right_r');
		return false;
	}
	if($('thiskeys').value == '') {
    msg('请输入字段名','cthiskeys','right_r');
		return false;
	}
	return true;
}
</script>  

</body>
</html>
