<?php
/*
  欢迎使用DM企业建站系统，本系统由www.demososo.com开发。
*/
if(!defined('IN_DEMOSOSO')) {
  exit('this is wrong page,please back to homepage');
}

 if($act=='insert')
 {
    if ($abc1 == '') {
      echo '请输入标题';  
      exit;
    }
    

 //$sql = "SELECT id from ".TABLE_STYLE." where htmldir='$abc2' and pidname<>'$pidname'  limit 1";
  // if(getnum($sql)>0){
      //alert('出错，模板目录 '.$abc2.' 已使用。(包括其他语言)');
      // jump($jumpv);

     // exit;
  // }  

 
  $htmldir = $abc2;
 
  $mbpidname='style'.$bshou;
   
      $sqllayout = "SELECT * from ".TABLE_STYLE."  where pidname='mbpidname'   $andlangbh order by id limit 1";
   if(getnum($sqllayout)==0){
       $arr_styleblockidV = 'bsheaderlogo:##common/20220508_102426_2095.png==#==bsheaderlogomobi:##==#==mbhome:##region20190416_1019376635==#==mbhomemob:##==#==header_pc:##jthome_headerpc/right01/right01==#==header_mobi:##jthome_headermobi/mobi01/mobi01==#==pidmenu:##menu20161129_1804453928==#==mbbannerhome:##vblock20191203_1659306310==#==mbbannerhome_img:##==#==mbbannercomm:##jthome_banner/banner_bgtall==#==mbbannercomm_img:##common/20190718_180006_8297.jpg==#==bannerhidetitle:##n==#==bssidebar:##group20170921_1137442079==#==bsfooter:##region20190819_1238263094==#==bsfootermob:##vblock20181221_1033067548==#==color:##==#==bsblock404:##vblock20160510_1000376089==#==bsfooterlast:##group20170920_1717255504==#==mbbz1:##==#==mbbz2:##==#==mbbz3:##==#==mbbz4:##==#==mbbz5:##==#==mbbz6:##==#==mbbz7:##==#==mbbz8:##==#==php_cssjs_h:##==#==php_cssjs_f:##';

       $ss = "insert into ".TABLE_STYLE." (pidname,pbh,pid,title,lang,htmldir,style_blockid) values ('$mbpidname','$user2510','0','$abc1','".LANG."','$htmldir','$arr_styleblockidV')";
        
      //echo $ss;exit;
        iquery($ss);
  }

   //----add common layout----------
  
    $sqllayout = "SELECT * from ".TABLE_LAYOUT."  where pid='common' and pidstylebh='$mbpidname' and type='common'  $andlangbh order by id limit 1";
         //cancel and stylebh='$stylebh'
         // echo $sqllayout; exit;
           if(getnum($sqllayout)==0){

$pidname='layout'.$bshou;
              $arr_layoutcanhome = 'sidebarlayout:##left==#==banner:##20190718_180006_8297.jpg==#==bannermobi:##==#==bannereffect:##banner_bg.php==#==bannercssname:##==#==bannertext:##==#==bannertextstyle:##==#==bannerbg:##==#==bannerbgtmd:##0.0==#==breadposi:##r==#==breadtext:##==#==sidebartop:##==#==sidebar:##==#==sidebarbot:##group20170921_1137442079==#==contenttop:##==#==content:##==#==contentbot:##==#==pagetop:##==#==pagebot:##';

              $ss = "insert into ".TABLE_LAYOUT." (pid,pidname,pidstylebh,pbh,lang,type,layoutcan) values ('common','$pidname','$mbpidname','$user2510','".LANG."','common','$arr_layoutcanhome')";
              iquery($ss);
            }
   //------------

 
    jump($jumpv);
    
 }
  
 
 

 
 if($act=='add')
 {
 
 $jumpv_insert = $jumpv_f.'&act=insert';

?>
 
<form  onsubmit="javascript:return checkhere(this)" action="<?php echo $jumpv_insert;?>" method="post"  enctype="multipart/form-data">
  <table class="formtab">
    <tr>
      <td width="20%" class="tr">模板的标题：</td>
      <td  > <input name="name" type="text"  value="<?php echo $name;?>" class="form-control" />
      <?php echo $xz_must?>
 
   </td>
   </tr> 

    <tr>
      <td class="tr">模板目录：</td>
      <td> 
   <select name="selefolder" class="form-control">
         <option value="">请选择</option> 
<?php 
$arrtpltemplateroot = dmgetDir(TEMPLATEROOT);
//pre($arrtpltemplateroot);
foreach ($arrtpltemplateroot as $k => $v) {
  if($v<>'base'){
    $htmldirv = '';
     
      //$sql = "SELECT id from ".TABLE_STYLE." where   htmldir='$v' limit 1"; 
      //if(getnum($sql)==0) echo '<option '.$htmldirv.' value="'.$v.'">'.$v.'</option>';
    echo '<option '.$htmldirv.' value="'.$v.'">'.$v.'</option>';

}
}
     ?>
</select>
  <p class="cgray">
请先在DMYI-template创建一个模板目录。
</p>
        </td>
    </tr>

 
 
   


  <tr>
      <td></td>
      <td>
      <input  class="mysubmit" type="submit" name="Submit" value="添加"></td>
    </tr>
    </table>
</form>
 

<?php
}
?>

<script>
function checkhere(thisForm) {
   if ($.trim(thisForm.name.value)=="")
  {
    alert("请输入标题");
    thisForm.name.focus();
    return (false);
  } 
    if (thisForm.selefolder.value=="")
  {
    alert("请选择模板目录");
    thisForm.selefolder.focus();
    return (false);
  } 
 


}

</script>
