<?php

/*
	[插件名称] 文章图片介绍检索 - 替换模版的{#modNewsPicQuery#}
	[适用范围] 文章分类检索页
	[文 件 名] NewsPicQuery.php
	[更新时间] 2006/12/3
*/


function NewsPicQuery(){

	global $fsql,$msql,$charset,$tbl_news_con,$PagesInfo,$ShowPages,$htmlstr,$CatchOpen;
	global $NowCatid,$NowMenuid,$NowFold,$MenuInfo;

	$catid=$NowCatid;
	
	$PSET=PlusSet("modNewsPicQuery");
	
	$shownums=PlusDef($PSET["shownums"],"10");
	$hangnums=PlusDef($PSET["hangnums"],"1");
	$smallw=PlusDef($PSET["smallw"],"100");
	$smallh=PlusDef($PSET["smallh"],"100");
	$ord=PlusDef($PSET["ord"],"id");
	$sc=PlusDef($PSET["sc"],"desc");
	$cutword=PlusDef($PSET["cutword"],"0");
	$target=PlusDef($PSET["target"],"_self");
	$tempname=PlusDef($PSET["tempname"],"tpl_newspicquery.htm");
	

	$key=$_GET["key"];
	$showtj=$_GET["showtj"];
	$page=$_GET["page"];
	$showhot=$_GET["showhot"];

	$htmlstr=$catid.".html";

	$tdwidth=ceil(100/$hangnums);

	//模版解释
	$Temp=LoadTemp(ROOTPATH."templates/".$MenuInfo["skin"]."/".$tempname);
	$TempArr=SplitTblTemp($Temp);

	$propstr=$TempArr["list"];

	$str=$TempArr["start"];


	$scl=" menuid='$NowMenuid' and iffb='1' ";

	if($catid!="0" && $catid!=""){
		$fmdpath=fmpath($catid);
		$scl.=" and catpath regexp '$fmdpath' ";

	}

	if($showtj!="" && $showtj!="all"){
	$scl.=" and tj='$showtj' ";

	}
	if($author!="" && $author!="all"){
	$scl.=" and author='$author' ";

	}

	if($showhot=="1"){
	
		$ord="cl";
	}

	if($key!=""){
		
		$scl.=" and (title regexp '$key' or body regexp '$key') ";
	}
	
	
	include(ROOTPATH."includes/func/pages.inc.php");
	$pages=new pages;

	$totalnums=TblCount($tbl_news_con,"id",$scl);
	
	$pages->setvar(array("showtj" => $showtj,"showhot" => $showhot,"key" => $key));

	$pages->set($shownums,$totalnums);		                          
		
	$pagelimit=$pages->limit();	  


	$kk=1;
	$fsql->query("select * from $tbl_news_con where $scl order by $ord $sc limit $pagelimit");

	while($fsql->next_record()){
		
		$id=$fsql->f('id');
		$title=$fsql->f('title');
		$catpath=$fsql->f('catpath');
		$catid=$fsql->f('catid');
		$dtime=$fsql->f('dtime');
		$nowcatid=$fsql->f('catid');
		$ifbold=$fsql->f('ifbold');
		$ifred=$fsql->f('ifred');
		$author=$fsql->f('author');
		$source=$fsql->f('source');
		$type=$fsql->f('type');
		$src=$fsql->f('src');
		$cl=$fsql->f('cl');
		$memo=$fsql->f('memo');

		$memo=str_replace("\n","<br>",$memo);

		if($src==""){
				$src="images/nopic.gif";
		}
		$src=ROOTPATH.$src;
		
		if($CatchOpen=="1"){
			$link="../html/".$id.".html";
		}else{
			$link="../html/?".$id.".html";
		}


		if($cutword!="0"){$title=csubstr($title,0,$cutword,$charset);}
		if($smallw=="-1"){$xsmallw="";}else{$xsmallw="width='$smallw' ";}
		if($smallh=="-1"){$xsmallh="";}else{$xsmallh="height='$smallh' ";}

		if($kk==1){

			$str.=$TempArr["rowstrat"];
		}

		$var=array (
		'tdwidth' => $tdwidth, 
		'title' => $title, 
		'memo' => $memo, 
		'dtime' => $dtime, 
		'src' => $src, 
		'smallw' => $xsmallw, 
		'smallh' => $xsmallh, 
		'author' => $author, 
		'source' => $source,
		'cl' => $cl, 
		'link' => $link,
		'target' => $target


		);
		

		$str.=ShowTplTemp($TempArr["menu"],$var);
		
		if($kk==$hangnums){
				$str.=str_replace("{#hangnums#}",$hangnums,$TempArr["rowend"]);
				$kk=0;
		}
		
	$kstr="";
	$kk++;
	}
	
	//补充空的td

	if($kk!=1){
		$needtd=$hangnums-$kk+1;
		for($u=1;$u<=$needtd;$u++){
			$str.=$TempArr["blank"];
		}
			$str.=$TempArr["rowend"];
	}

	$str.=$TempArr["end"];

	$PagesInfo=$pages->ShowNow();
	$ShowPages=$pages->output(1);


	return $str;


}
?>