<?php
if(!defined('IN_DEMOSOSO')) {
	exit('this is wrong page,please back to homepage');
}
?>
<?php
function block($pidname){
$pidname = trim($pidname);
if($pidname<>''){
	global $attach_type;global $reqfile;global $curstyle;	global $andlangbh;

//block,dhvh,chpr
//custom/devp_***.php
//2013/***/.jpg or .swf
  $pidstring = substr($pidname,0,4);
   $pidifimg = gl_imgtype($pidname);


   if($pidstring=='hide') {
		return '';
	}

	elseif($pidstring=='vblo') {
   		$reqfile = 'vblock.php';
   		 $effect ='vblock';
   		//echo $reqfile;
   		 $edittype = 'vblock'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}
	elseif($pidstring=='vide') {
   		//$reqfile = 'video.php';
   		$reqfile = 'video/'.get_field(TABLE_VIDEO,'effect',$pidname,'pidname');
   		 $effect ='video';
   		//echo $reqfile;
   		 $edittype = 'video'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}
	elseif($pidstring=='albu') {
   		$reqfile = 'album/vv_album.php';
   		 $effect ='album';
   		//echo $reqfile;
   		 $edittype = 'album'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}
	elseif($pidstring=='musi') {
   		$reqfile = 'music/vv_music.php';
   		 $effect ='music';
   		//echo $reqfile;
   		 $edittype = 'music'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}

	// elseif($pidstring=='imgt') {
 //   		$reqfile = 'imgtext/vv_imgtext.php';
 //   		 $effect ='imgtext';
 //   		//echo $reqfile;
 //   		 $edittype = 'imgtext'; //use for edit linktype
 //   		require(SYSBLOCKROOT.'block_otherlay.php');
	// }


	elseif($pidstring=='form') {
   		//$reqfile = 'form.php';
   		//$reqfile = get_field(TABLE_FIELD,'effect',$pidname,'pidname');
   		$reqfile = 'form/vv_form.php';
   		 $effect ='form';
   		//echo $reqfile;
   		 $edittype = 'form'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}

 

	elseif($pidstring=='prog') {
        $reqfile = 'prog/'.$pidname.'.php';  $effect ='prog';
         $edittype = 'prog'; //use for edit linktype
   		 require(SYSBLOCKROOT.'block_otherlay.php');

	}
	
	elseif($pidstring=='mypr') { //myprog
           $reqfile = 'myprog/'.$pidname.'.php';  $effect ='myprog';
           $edittype = 'myprog'; //use for edit linktype
   		  require(SYSBLOCKROOT.'block_otherlay.php');

	 }
	
	   	elseif(substr($pidname,0,7)=='jthome_') { 
 			  $reqfile = 'jthome/'.$pidname.'.php';  
			  $effect ='jthome';          
			  $edittype = 'jthome'; //use for edit linktype 
			 require(SYSBLOCKROOT.'block_otherlay.php');
	}

	 	elseif(substr($pidname,0,8)=='jtblock_') { 	
 			  $reqfile = 'jtblock/'.$pidname.'.php';  
			  $effect ='jtblock';          
			  $edittype = 'jtblock'; 
			 require(SYSBLOCKROOT.'block_otherlay.php');
	}
	 elseif(substr($pidname,0,7)=='mbhome_') { 
 			  $reqfile = 'selfblock/mbhome/'.$pidname.'.php';  
			  $effect ='mbhome';          
			  $edittype = 'mbhome'; //use for edit linktype 
			 require(SYSBLOCKROOT.'block_otherlay.php');
	}



    elseif($pidstring=='regi') {		
		 $regionpidname = $pidname;
	      $effectv = SYSBLOCKROOT.'region/vv_region.php';
		 if(checkfile($effectv)) require ($effectv); 		 
	  			 
	}
	 

	  elseif($pidstring=='grou') {
	  			return group($pidname);
	}

 

	elseif(in_array($pidifimg,$attach_type)){
		//echo '<div class="bannerimg"><img src="'.UPLOADPATHIMAGE.$pidname.'" alt="" /></div>';
		 $reqfile = 'imgfj'; $effect = 'imgfj';
		  $edittype = 'imgfj'; //use for edit linktype
   		require(SYSBLOCKROOT.'block_otherlay.php');
	}


	else{echo '<p class="errorfont">error  block -- '.$pidname.'</p>';}
	// $menu_kz = substr($menu,-3);
       // if($menu_kz=='swf') {
      //      get_flash($menu,'transparent');//opaque
      // }
}//pidname not null
}//end func

 


function group($grouppidname){
Global $andlangbh;
$sql2 = "SELECT cssname,sta_width_cnt from ".TABLE_BLOCKGROUP." where pidname='$grouppidname'  $andlangbh order by id limit 1";

if(getnum($sql2)>0){
	$row2 = getrow($sql2);
	$cssname =  $row2['cssname'];
	$sta_width_cnt = $row2['sta_width_cnt'];
	//$cssnamev = $cssname<>''?' class="'.$cssname.'"':'';
echo '<div class="c blockgroup '.$cssname.'">';
if($sta_width_cnt=='n') echo '<div class="container">';
//-----------------------
columnecho($grouppidname);
 //-----------------------
if($sta_width_cnt=='n') echo '</div>';

 echo '</div>';
  }

else{ echo  '<p class="errorfont">出错，没有这个组合区块： '.$grouppidname.'</p>';
}

}//end func




?>
<?php

 function dmeditlink($pidname,$tid,$type){
 	global $curstyle;

 	$urlhere = BASEURL.ADMINDIR;


 if($type=='regionblock'){
 			$typefirst=substr($pidname,0,11);
 		  $typereg='common';
      if($typefirst=='regionindex') $typereg='index';

 		  $linkv = $urlhere.'/mod_region/mod_region.php?lang='.LANG.'&pid='.$pidname.'&file=editcan&act=edit&tid='.$tid;

 		  echo  '<div style="position:relative"><a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit dmeditregion">编辑区域</a></div>';

 		//return $_SESSION['isadmin'];
 		//return $_SESSION['admindir'];
 	}

 	if($type=='group----'){

//mod_regcommon/mod_regcommon.php?lang=cn&pid=regcommon20160822_1126481127&file=addedit&act=edit&tid=319
 $linkv = $urlhere.'/mod_blockgroup/mod_group.php?lang='.LANG.'&pid='.$pidname.'&file=addedit&act=edit&tid='.$tid;

 		  echo  '<div style="position:relative"><a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit dmeditregion">编辑组合区块</a></div>';
//mod_regcommon/mod_regcommon.php?lang=cn&type=common&pidname=regcommon20160509_1200413359&file=subaddedit&act=edit&tid=109
 		//return $_SESSION['isadmin'];
 		//return $_SESSION['admindir'];
 	}


 	if($type=='vblock'){
 		//vblock have 3: 1 region,2 group, 3,block

         $nodetype =  get_field(TABLE_BLOCK,'pid',$pidname,'pidname');
         $pidcolumn =  get_field(TABLE_BLOCK,'pidcolumn',$pidname,'pidname');
         $pidcolumn_pid =  get_field(TABLE_COLUMN,'pid',$pidcolumn,'pidname');

         $fourof_pidcolumn_pid = substr($pidcolumn_pid,0,4);

      //mod_column/mod_column.php?lang=cn&pid=sregion20160923_1305203022&type=region&file=editcnt&pidname=colu20170914_1813504419';
			$editv = '编辑区块';
         $classv="dmedit_".$nodetype;
         if($nodetype=='bknode') $editv = '编辑内容区块';
         else if($nodetype=='bkblockdh') $editv = '编辑效果区块'; 
         else $editv = '编辑自定义区块'; 
          if($fourof_pidcolumn_pid=='sreg')
          	{
          		$linkv = $urlhere.'/mod_column/mod_column.php?lang='.LANG.'&pid='.$pidcolumn_pid.'&type=region&file=editcnt&pidname='.$pidcolumn;
          		$editv = '编辑列';
          		$classv="dmeditcolumn";
          	}
          elseif ($fourof_pidcolumn_pid=='grou') {
          	$linkv = $urlhere.'/mod_column/mod_column.php?lang='.LANG.'&pid='.$pidcolumn_pid.'&type=group&file=editcnt&pidname='.$pidcolumn;
          	$editv = '编辑列';
						$classv="dmeditcolumn";
          }
         else
         {
          $linkv = $urlhere.'/mod_block/mod_block.php?lang='.LANG.'&act=edit&type='.$nodetype.'&pidname='.$pidname;
          }

  		 echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit '.$classv.'">'.$editv.'</a>';

 	 }


	if($type=='video'){
 		 	 //mod_video/mod_video.php?lang=cn&pidname=video20180524_1839345521&act=edit

		$arr =  get_fieldarr(TABLE_VIDEO,$pidname,'pidname');

		if($arr<>'no'){
			  $tid=$arr['id']; 
			  $type=$arr['type']; 
			  if($type=='block') {
 			 	$linkv = $urlhere.'/mod_video/mod_video.php?lang='.LANG.'&pid=0&type=block&tid='.$tid.'&act=edit';
		   	 	echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑视频</a>';
			}
		}

		$linkv = $urlhere.'/mod_video/mod_video.php?lang='.LANG.'&pidname='.$pidname.'&act=edit';
		  echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑视频</a>';


	 }
	 if($type=='album'){
		    $langto =  get_fieldnolang(TABLE_ALBUM,'lang',$pidname,'pidname'); //for multilang
		     
 				 $linkv = $urlhere.'/mod_album/mod_album.php?lang='.$langto.'&pid='.$pidname;
				 echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑相册</a>';
				//}
	 }
	  if($type=='music'){ 
		   $arr =  get_fieldarr(TABLE_MUSIC,$pidname,'pidname'); 
		   	if($arr<>'no'){
		 		$tid=$arr['id']; 
				//mod_album/mod_mainalbum.php?lang=cn&page=0&tid=241&act=edit
 				 $linkv = $urlhere.'/mod_music/mod_mainmusic.php?lang='.LANG.'&tid='.$tid.'&act=edit';
				 echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑音乐</a>';
				}
	 }
	
	


 if($type=='form'){
      //mod_form/mod_form.php?lang=cn&pid=block&type=block&file=addedit&act=edit&pidname=form20181219_1421366828
 		 
  $linkv = $urlhere.'/mod_form/mod_form.php?lang='.LANG.'&pid=block&type=block&file=addedit&act=edit&pidname='.$pidname;
		 echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑表单</a>';

	 }



	if($type=='imgfj'){

		   if(is_int(strpos($pidname,'|'))){
              $arrimg = explode('|',$pidname); 
              $pidname2 = $arrimg[2];
          }
          else  $pidname2 = $pidname;


       $tid =  get_field(TABLE_IMGFJ,'id',$pidname2,'kv');
	 	 ///mod_imgfj/mod_imgfj.php?lang=cn&pid=name&file=edit&act=edit&tid=51
 		$linkv = $urlhere.'/mod_imgfj/mod_imgfj.php?lang='.LANG.'&pid=name&file=edit&act=edit&tid='.$tid;
 		 echo  '<a style="display:none" target="_blank" href="'.$linkv.'" class="dmedit">编辑附件</a>';

	 }


	   if($type=='prog' || $type=='jthome' || $type=='jtblock' || $type=='mbhome'){
	    
         echo  '<a style="display:none;cursor:default" target="_blank" href="javascript:void(0)" style="cursor:default" class="dmedit dmedit_'.$type.'">请编辑 '.$pidname.'</a>';

	 	}
	 	 
	 //-----------

//------------------
}




function columnecho($pidname){
  global $andlangbh;
     $sqlbcolumn = "SELECT * from ".TABLE_COLUMN." where pid='$pidname'  and sta_visible='y'  $andlangbh order by pos desc,id";
    // echo $sqlbcolumn;
	 if(getnum($sqlbcolumn)>0){

	 	$rescol = getall($sqlbcolumn);
		     foreach ($rescol as $v) {
		     	 //pre($v);
		     	$width=$v['width'];
		     	$pidcolumn=$v['pidname'];
		     	$floattype=$v['floattype'];
		     	$onlyposi=$v['onlyposi'];
		     	$blockpidname = get_field(TABLE_BLOCK,'pidname',$pidcolumn,'pidcolumn');

		      if($floattype=='clear') 	echo '<div class="c"> </div>';
		      else {
		      	if($floattype=='fl' || $floattype=='fr' ) $floattype = 'col'.$floattype; //use colfl replace fl.because col_1f...has fl.
		      	echo '<div class="'.$width.' '.$floattype.'">';

		      	if($onlyposi=='y') echo '&nbsp;&nbsp;';
		      	else {

		      		if($blockpidname<>'noid') block($blockpidname);

		      	}
		        echo '</div>';
		 	 }

		     }//end foreach

		}

}


function editcate_goadm($cate,$curcate,$detailid){  //for node content...
 
    $urlhere = BASEURL.ADMINDIR;
	
	$catetype = substr($curcate,0,4);
	//mod_layout/mod_layout.php?lang=qing&pid=cate20150805_1125344029&catid=cate20150805_1125344029&type=cate
	//mod_layout/mod_layout.php?lang=qing&pid=csub20150805_1128542682&catid=cate20150805_1125344029&type=cate
	$catelayout = $urlhere.'/mod_layout/mod_layout.php?lang='.LANG.'&pid='.$cate.'&type=cate&catid='.$cate;
	$sublayout = $urlhere.'/mod_layout/mod_layout.php?lang='.LANG.'&pid='.$curcate.'&type=cate&catid='.$cate;
	
	//mod_category/mod_category.php?lang=qing&catid=cate20150805_1125344029&file=edit&act=edit
	//mod_subcate.php?lang=qing&catid=cate20150805_1125344029&file=edit&act=edit&pidname=csub20150805_1127279495
	$catelink = $urlhere.'/mod_category/mod_category.php?lang='.LANG.'&catid='.$cate.'&file=edit&act=edit';
	$sublink = $urlhere.'/mod_category/mod_subcate.php?lang='.LANG.'&catid='.$cate.'&file=edit&act=edit&pidname='.$curcate;
	
	//mod_node/mod_node_edit.php?lang=qing&act=editdesp&tid=575&file=editdesp
	
	$detlink = $urlhere.'/mod_node/mod_node_edit.php?lang='.LANG.'&tid='.$detailid.'&file=editdesp&act=editdesp';
	 if(dmlogin()){
	 echo '<div class="dmeditnode">';
		    if($detailid<>''){
				 echo  '<a   target="_blank" href="'.$detlink.'">编辑详情页</a>';
			}
			 
				//if($catetype=='cate'){
					echo  '<a class="cate" target="_blank" href="'.$catelink.'">编辑主类</a>';
					echo  '<a class="cate" target="_blank" href="'.$catelayout.'">主类布局</a>';
			//	}
				if($catetype<>'cate'){

					echo  '<a class="cate" target="_blank" href="'.$sublink.'">编辑子分类</a>';
					echo  '<a class="cate" target="_blank" href="'.$sublayout.'">子分类布局</a>';
				}
			 
		echo '</div>';
	 }
//------------------------
//}
//-------------------
}//end func


function editpage_goadm($tid,$pidname){  //for node content...

//mod_page/mod_page_edit.php?lang=qing&file=edit_desp&act=edit&tid=107
//mod_layout/mod_layout.php?lang=qing&pid=page20150805_1138522811&type=page

    $urlhere = BASEURL.ADMINDIR;
	$pagelink = $urlhere.'/mod_page/mod_page_edit.php?lang='.LANG.'&file=edit_desp&act=edit&tid='.$tid;
	$layoutlink = $urlhere.'/mod_layout/mod_layout.php?lang='.LANG.'&pid='.$pidname.'&type=page';
	
	 if(dmlogin()){
	 echo '<div class="dmeditnode">';
		   
          echo  '<a target="_blank" href="'.$pagelink.'">编辑单页面</a>';
		  echo  '<a target="_blank" href="'.$layoutlink.'">单页面布局</a>';

		echo '</div>';
	 }
//------------------------
//}
//-------------------
}//end func


?>
