gusucode.com > 2030网博士成品网站管理系统 PHP网站源码程序 > 2030/dingcan/module/DingCanWeekMenu.php

    <?php

/*
	[插件名称] 本周菜单
	[适用范围] 全站
*/

function DingCanWeekMenu(){

	global $fsql,$msql;
	
	$coltitle=$GLOBALS["PLUSVARS"]["coltitle"];
	$tempname=$GLOBALS["PLUSVARS"]["tempname"];
	
	$getmonth=$_REQUEST["m"];
	$getday=$_REQUEST["d"];

	//根据模板名判断所要显示的天数,从而计算所要显示的月份信息
	$daynums=substr($tempname,-6,2);  //可能取值为14,21,28
	
	//日期处理
	$nowtime=time();
	$nowday=date("d", $nowtime);
	$nowweek=date("w", $nowtime);
	
	if($nowweek==0){$nowweek=7;}

	$mondaytime=$nowtime-(($nowweek-1)*24*3600);
	if($daynums!=14 && $daynums!=21 && $daynums!=28){
		$daynums=7;
		$sundaytime=$nowtime+((7-$nowweek)*24*3600);
	}else{
		$sundaytime=$nowtime+((7-$nowweek)*24*3600)+(($daynums-7)*24*3600);
	}
	$nowmonth1=date("m", $mondaytime);
	$nowmonth2=date("m", $sundaytime);
	
	if($nowmonth1==$nowmonth2){
		$monthinfo=$nowmonth1;
	}else{
		$monthinfo=$nowmonth1."/".$nowmonth2;
	}
	
	for($i=1; $i<=$daynums; $i++){
		$timeinfo=$mondaytime+(($i-1)*24*3600);
		
		$cpday=date("d", $timeinfo);
		$cpmonth=date("m", $timeinfo);
		
		if($cpmonth==$getmonth && $cpday==$getday){
			$nowriqiclassinfo="nowriqiclass";
		}else{
			$nowriqiclassinfo="puriqiclass";
		}
		
		$cpid=0;
		$fsql->query("select * from {P}_dingcan_caipu where month='$cpmonth' and day='$cpday' and iffb='1'");
		if($fsql->next_record()){
			$cpid=$fsql->f('id');
		}
		
		$link=ROOTPATH."dingcan/caipu.php?m=".$cpmonth."&d=".$cpday;
		
		if($i%7==1){
			$cpstr.="<tr>";
		}
		
		$cpstr.="<td class='riqi'><a href='".$link."' class='".$nowriqiclassinfo."'>".$cpday."</a></td>";
		
		if($i%7==0){
			$cpstr.="</tr>";
		}
		
	}
	
	//模板解释
	$Temp=LoadTemp($tempname);
	$TempArr=SplitTblTemp($Temp);
	
	$var=array(
		'coltitle' => $coltitle,
		'monthinfo' => $monthinfo,
		'cpstr' => $cpstr
	);
		
	$str=ShowTplTemp($TempArr["start"],$var);
	
	$str.=$TempArr["end"];
		
	return $str;


}

?>