<?php
/*	欢迎使用DM企业建站系统，本系统由www.demososo.com开发。
*/
require_once '../config_a/common.inc2010.php';
//
 if($act <> "pos") zb_insert($_POST);
 
 if($pidname<>'') {
  ifhaspidname(TABLE_STYLE,$pidname);
 
}

 
//ifhaspidname(TABLE_NODE,$pid);
//ifhaspidname(TABLE_CATE,$catpid);
ifhave_lang(LANG);//TEST if have lang,if no ,then jump

 $leftsidecollapsed='-y';//not del


$jumpv='mod_style.php?lang='.LANG;
$jumpv_p=$jumpv.'&pidname='.$pidname;
$jumpv_f=$jumpv.'&file='.$file;
$jumpv_pf=$jumpv_p.'&file='.$file;
$jumpv_pf2=$jumpv_p.'&file='.$file.'&file2='.$file2;

//----
$submenu='basic';
$title = '模板管理';

$edit_cur =$editdaoin_cur =$editdaoout_cur =$editcss_cur=$editblockid_cur=$editlayout_cur=$editcssdesp_cur=$editcsssql_cur=$editcssactive_cur='';
$editcustomcss_cur=$editcssfile_cur='';
$title2='';
 $mbname = '';
 if(substr($file,0,4)=='edit') $mbname = get_field(TABLE_STYLE,'title',$pidname,'pidname');
 

if($file=='add') { $title2=' - 添加模板';}
if($file=='edit_can') { $title2 =' - 修改模板 ('.$mbname.') ';$edit_cur ='active';}
if($file=='edit_blockid') { $title2=' - 修改标识 ('.$mbname.') ';$editblockid_cur ='active';}
if($file=='edit_newcustomcss') { $title2=' - 修改样式 ('.$mbname.') ';  $editcustomcss_cur ='active';}
if($file=='edit_newcssfile') { $title2=' - 样式文件 ('.$mbname.') ';  $editcssfile_cur ='active';}

/*


if($file=='edit_cssdesp') { $title='修改自定义样式';$editcss_cur =$editcssdesp_cur ='active';}
if($file=='edit_csssql') { $title='修改数据库样式';$editcss_cur =$editcsssql_cur ='active';}
if($file=='edit_cssactive') { $title='开启数据库样式';$editcss_cur =$editcssactive_cur ='active';}



if($file=='edit_layout') { $title='修改公共布局';$editlayout_cur ='active';}
if($file=='edit_daoin') { $title='导入';$editdaoin_cur ='active';}
if($file=='edit_daoout') { $title='导出';$editdaoout_cur ='active';}
 */




 if($act == "pos")
{
     
      dmnodepos($_POST,TABLE_STYLE);
      jump($jumpv);
}

if($act == "sta")
{ 
   $v = htmlentitdm($v);
     $ss = "update ".TABLE_STYLE." set sta_visible='$v' where id=$tid $andlangbh limit 1";   
     iquery($ss);
    jump($jumpv); 
}


if($act=='activatestyle'){

  $ss = "update ".TABLE_LANG." set curstyle='$pidname' where lang='".LANG."' limit 1";
 
    iquery($ss);

//alert('启动成功，请到前台去查看效果。');
jump($jumpv);
}


if($act == "del")
{ 
 
$stylearr = get_fieldarr(TABLE_STYLE,$pidname,'pidname');
 
$kv = $stylearr['kv'];
 if($kv<>'') p2030_delimg($kv,'y','n');

//------------

 
  //del layout

  ifsuredel_fieldmore(TABLE_LAYOUT,'pidstylebh',$pidname,'equal','noback');

  
  $ifdel3 =  ifcandel_field(TABLE_BLOCK,'pidstylebh',$pidname,'equal','出错，这个模板下还有区块，请先到 区块管理->当前模板 删除。',$jumpv);

  if($ifdel3) ifsuredel_field(TABLE_STYLE,'pidname',$pidname,'eq',$jumpv);

   
}

//-----------

require_once HERE_ROOT.'mod_common/tpl_header.php'; 

?>


<div class="page-title-box">
                    <h4 class="page-title">
                    <?php 

   $titlelink=$title;
   if($pidname==$curstyle)  $title2=$title2.'<span class="cred">[前台正在使用这个模板]</span>';
       if($file<>'list')  $titlelink='<a style="font-size:20px" href="'.$jumpv.'">'.$title.'</a>'; 
       
      echo  $titlelink.$title2; 
        ?>
          
        </h4>

<div class="clearfix"></div>
                 </div>

 <div class="row">
      <div class="col-md-12">
        <div class="white-box">

  <?php   
 if($act=='list') { } 
 else if($act=='add') { } 
 else require_once HERE_ROOT.'mod_style/tpl_style_tab.php';
    ?>

      
        <?php   
        if($file=='edit_cssdesp' || $file=='edit_csssql' || $file=='edit_cssactive')     $file =  HERE_ROOT.'mod_style/tpl_style_edit_cssPAGE.php';
          else  $file = HERE_ROOT.'mod_style/tpl_style_'.$file.'.php';

          if(checkfile($file)) require_once $file;
        ?>
 </div></div></div>
<?php
require_once HERE_ROOT.'mod_common/tpl_footer.php';

?>





<?php

function check_blockid_here($biaoshi,$htmldir){
      global $andlangbh; global $attach_img;
      $editlink = '';
    
    $firstzm=substr($biaoshi,0,4);

    if($firstzm=='mypr') { //myprog
      $profile = TEMPLATEROOT.$htmldir.'/selfblock/myprog/'.$biaoshi.'.php';
      checkfile($profile);
      echo '<span class="cgray">位于当前模板目录 '.$htmldir.'/selfblock/myprog</span>';
      }
      else check_blockid($biaoshi);

  }

?>


