<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2005-2010 GV32.COM，并保留所有权利。
 * 网站地址: http://www.gv32.com；
 * 作者: GV32.COM
 *----------------------------------------------------------------------------*
**/
class Index
{
 
	function Index()
	{
		
		//缓存
		if($GLOBALS["WebConfig"]["webtmp"]==1)
		{
			$GLOBALS['Templ'] -> caching = true;
			if($GLOBALS["WebConfig"]["webtmptime"] > 0 ){
				$GLOBALS['Templ'] -> cache_lifetime = $GLOBALS["WebConfig"]["webtmptime"] ;  //60 *  60 * 24
			}else{
				$GLOBALS['Templ'] -> cache_lifetime = 3600 ;  //60 *  60 * 24
			}
			$GLOBALS['Templ'] -> cache_dir = ROOT_PATH.$GLOBALS['cache_path'];
		}	
		
		$getmenu 	 = $GLOBALS['Helpe'] -> get_menu();
		$getprosort  = $GLOBALS['Helpe'] -> get_prosort();
		$getads 	 = $GLOBALS['Helpe'] -> get_ads( $instr = '1,2,3,4,5,6,7,8,9,10' );

		$getuserlink = $GLOBALS['WebSe'] -> getuserlink();
		
		$comInfo 	 = $this -> cominfo();
		$artInfo 	 = $this -> artinfo();
		$proInfo 	 = $this -> proinfo();
		
		
		$GLOBALS['Templ'] -> assign('getmenu',$getmenu);
		$GLOBALS['Templ'] -> assign('getprosort',$getprosort);
		$GLOBALS['Templ'] -> assign('getads',$getads);
		$GLOBALS['Templ'] -> assign('getuserlink',$getuserlink);
		$GLOBALS['Templ'] -> assign('comInfo',$comInfo);
		$GLOBALS['Templ'] -> assign('artInfo',$artInfo);
		$GLOBALS['Templ'] -> assign('proInfo',$proInfo);
		$GLOBALS['Templ'] -> display('index_tpl.html');
	}
	
	function cominfo()
	{
		//公司简介
		$sqlinfo = " SELECT art_id,art_title ,art_description ,art_pic  FROM  ".SQL_PREFIX."artlice   WHERE art_sysfile = 'company'  LIMIT 1  ";
		
		$info = $GLOBALS['MySql'] -> selectOne($sqlinfo);
		$comInfo = array();	
		if ($info['art_id'])
		{ 

		   		$comInfo["art_title"] 			= $info["art_title"];
				$comInfo["art_description"] 	= nl2br($info["art_description"]);
				$comInfo["art_pic"] 			= $info["art_pic"];
				$comInfo["art_id"] 				= $info["art_id"] ;	
		}
		return $comInfo;
	}
	
	function artinfo()
	{
		//新闻动态查询10个以内
		$sql = " SELECT a.art_id, a.art_title,a.art_uptime,s.ars_name FROM ".SQL_PREFIX."artlice as a left join ".SQL_PREFIX."artsort as s on s.ars_id = a.ars_id WHERE a.art_enabled = 1 and s.ars_enabled = 1 and a.art_sysfile = '' and a.ars_id not in ( 2 ) and  a.ars_id not in ( select `ars_id` from ".SQL_PREFIX."artsort where ars_enabled = 2 )  GROUP BY a.art_id ORDER BY  a.art_list , a.art_uptime desc  LIMIT 10 ";
		$info 	 = $GLOBALS['MySql'] -> selectInfo($sql);
		$artInfo = array();
		

		 foreach ((array)$info as $row)
		 {
				$artInfo[$row["art_id"]]['art_id'] 		= $row["art_id"] ; 
				$artInfo[$row["art_id"]]['art_title'] 	= $row["art_title"] ;
				//$artInfo[$row["art_id"]]['relurl'] = '<a href="'.WEB_URL.'/index.php/art/detail/'.$row["art_id"].'" >'.$row["art_title"].'</a>' ;
				$artInfo[$row["art_id"]]["get_url"]= $GLOBALS['Helpe']  -> buildUrl( $valid = $row["art_id"],'art');
				$artInfo[$row["art_id"]]['art_uptime']  = date("Y-m-d",$row["art_uptime"]) ; 
		 }

		return $artInfo;
	}
	
	function proinfo()
	{
		//商品查询8个以内
		
		$sql = " SELECT  pro_id, pro_name, pro_img  FROM  ".SQL_PREFIX."product  WHERE pro_enabled = 1   GROUP BY pro_id ORDER BY  pro_uptime desc  LIMIT 8 ";  //, paddtime 
		
		$info 	 = $GLOBALS['MySql'] -> selectInfo($sql);
		
		$proInfo = array();	

		foreach ((array)$info as $pkey => $row)
		{
				$proInfo[$pkey]["pro_img"] 	= $GLOBALS['Helpe'] -> buildImg( $row["pro_img"] ) ; 
				$proInfo[$pkey]["pro_name"] = $row["pro_name"];
				$proInfo[$pkey]["pro_id"] 	= $row["pro_id"];
				$proInfo[$pkey]["get_url"]	= $GLOBALS['Helpe']  -> buildUrl( $valid = $row["pro_id"],'pro');
				//$proInfo[$row["pro_id"]]['proimg'] = '<a href="'.WEB_URL.'/index.php/pro/detail/'.$row["pro_id"].'"  border="0"><img  src="'.WEB_URL.$row["pro_img"].'" width="150" border="0" ></a>' ;
				///$proInfo[$row["pro_id"]]['prourl'] = '<a href="'.WEB_URL.'/index.php/pro/detail/'.$row["pro_id"].'" >'.$row["pro_name"].'</a>' ; 
		}

		
		return $proInfo;
	}

	

}

$Index = new Index();

?>