<?php
/*	欢迎使用DM企业建站系统，本系统由www.demososo.com开发。
*/
require_once '../config_a/common.inc2010.php';
$switchlanglink = 'mod_region/mod_mainregion.php?ppid=common';


ifhave_lang(LANG);//TEST if have lang,if no ,then jump

//$menuactive_block = 'nav-active';


if($pidname<>'') {ifhaspidname(TABLE_REGION,$pidname);}


if($pid<>'') {ifhasrecord(TABLE_REGION,$pid,'pidname','no pid');}
else{echo 'need pid';exit;}

if(is_numeric($tid)) {   ifhasid(TABLE_REGION,$tid);}



$ppidarr= get_fieldarr(TABLE_REGION,$pid,'pidname');
$ppid = $ppidarr['pidstylebh'];

$pptid = $ppidarr['id'];

//echo $ppid;

 if($act <> "pos") zb_insert($_POST);



if($file=='') $file='list';
$filearr =  array("list", "add","editcan","editcnt","editcfg","move");
if(!in_array($file,$filearr))   {echo 'file is error.';exit;}




$jumpv='../mod_region/mod_region.php?lang='.LANG.'&pid='.$pid;

$jumpvf=$jumpv.'&file='.$file;
$jumpvp=$jumpv.'&pidname='.$pidname;
$jumpvpf=$jumpvf.'&pidname='.$pidname;



$jumpvp_edit =  '../mod_region/mod_region_edit.php?lang='.LANG;
//------------------

    $nameparent = get_field(TABLE_REGION,'name',$pid,'pidname');

    $nameparentLink ='<a href="../mod_region/mod_region.php?lang=cn&pid='.$pid.'">'.$nameparent.'</a>';
    $tidname = '';
if($tid<>'') $tidname = get_field(TABLE_REGION,'name',$tid,'id');

$title2='';
 if($file=='add')    $title2 =' - 添加行';
 //else  $title2 =' - '.$tidname;
 //else if($file=='editcan')  $title2 =' - '.$tidname.' - <span>修改参数</span>';
 //else if($file=='editcfg')  $title2 =' - '.$tidname.' - <span>修改样式</span>';
 // else if($file=='move')  $title2 =' - 复制';

  $title =$nameparent;

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

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



//-----------------------
if($act == "del")
{
  $ifdel1 = ifcandel_field(TABLE_COLUMN,'pid',$pidname,'eq','出错，请先把列删除！',$jumpv);


 //$ifdel1 = ifcandel(TABLE_REGION,$pidname,'区域有区块，请先删除。',$jumpv);// back is fail
  if($ifdel1) {
   // $kv = get_field(TABLE_REGION,'kv',$pidname,'pidname');
    //if($kv<>'noid')  p2030_delimg($kv,'y','n');

    // delpriimgfg($pidname);
    // ifsuredel(TABLE_REGION,$pidname,$jumpv);
     
     $ss = "delete from ".TABLE_REGION." where pidname='$pidname' and pid='$pid' $andlangbh limit 1";
    // echo $ss;
      iquery($ss);
      jump($jumpv);


  }

}




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

if($file =='add' || $act =='insert') require_once HERE_ROOT.'mod_common/tpl_header_iframe.php';
else require_once HERE_ROOT.'mod_common/tpl_header.php';

?>

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

$title5 = '页面区域管理';

 if($file<>'list') $title='页面区域：<a style="font-size:20px" href="'.$jumpv.'">返回'.$title.'</a>';
 else $title='<a style="font-size:20px" href="../mod_region/mod_mainregion.php?lang='.LANG.'&ppid='.$ppid.'">'.$title5.'</a> - '.$nameparent;


$editpid = ' <a  href="../mod_region/mod_mainregion.php?lang='.LANG.'&ppid='.$ppid.'&file=addedit&act=edit&tid='.$pptid.'">编辑</a> ';
echo $title.$title2.$editpid;

//$linkview = fronturl('dmlink-blockview-'.$pid.'-1.html');
 // echo ' <a  class="but4" target="_blank" href="'.$linkview.'"><span><i class="fa fa-link"></i> 预览</span></a>';

echo adm_previewlink($pid);

?>


</h4>
                   
                    <div class="clearfix"></div>
                 </div>
                  <!--End Page Title-->          
           
           
                  <!--Start row-->
                  <div class="row">
                    <div class="col-md-12">
                       <div class="white-box">



<?php
  if($file=='list'){
?>
  <div class="contenttop">
  <a class="needpopup" href="<?php echo $jumpv?>&file=add"><i class="fa fa-plus-circle"></i> 添加行</a>
  &nbsp; &nbsp; &nbsp;
  <?php
  // echo  adm_previewlink($pid);
   ?>


</div>
<?php
  }
?>

        <?php

          require_once HERE_ROOT.'mod_region/tpl_region_'.$file.'.php';

        ?>
 </div> </div> </div>
<?php
if($file =='add' || $act =='insert') require_once HERE_ROOT.'mod_common/tpl_footer_iframe.php';
else require_once HERE_ROOT.'mod_common/tpl_footer.php';
?>
