<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Webmenu
{
	function Webmenu()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
		//$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/login/actlogin");
		
		$urlAddArray = array();
		
		//说明是伪静态页面
		if($GLOBALS["WebConfig"]["webhtml"]==1)
		{
			
			$urlAddArray[0]["url"]  = "/pro.html";
			$urlAddArray[0]["name"] = "产品中心";
	
			$urlAddArray[1]["url"]  = "/art.html";
			$urlAddArray[1]["name"] = "资讯中心";
			
			$urlAddArray[2]["url"]  = "/invite.html";
			$urlAddArray[2]["name"] = "人才招聘";
	
			$urlAddArray[3]["url"]  = "/contactus.html";
			$urlAddArray[3]["name"] = "联系我们";
			
			
			$urlAddArray[4]["url"]  = "/link.html";
			$urlAddArray[4]["name"] = "友情链接";
	
			$urlAddArray[5]["url"]  = "/message.html";
			$urlAddArray[5]["name"] = "在线咨询";
			
			$urlAddArray[6]["url"]  = "/copyright.html";
			$urlAddArray[6]["name"] = "版权声明";
	
			$urlAddArray[7]["url"]  = "/map.html";
			$urlAddArray[7]["name"] = "网站地图";
			
			
			$urlAddArray[8]["url"]  = "/download.html";
			$urlAddArray[8]["name"] = "下载中心";
			
			$urlAddArray[9]["url"]  = "/pic.html";
			$urlAddArray[9]["name"] = "图片中心";
	
			$urlAddArray[10]["url"]  = "/vid.html";
			$urlAddArray[10]["name"] = "视频中心";
			
			$urlAddArray[11]["url"]  = "/vote.html";
			$urlAddArray[11]["name"] = "投票中心";
			
			$urlAddArray[12]["url"]  = "/aboutus.html";
			$urlAddArray[12]["name"] = "关于我们";
			
		
		}else{
			$urlAddArray[0]["url"]  = "/?load=pro";
			$urlAddArray[0]["name"] = "产品中心";
	
			$urlAddArray[1]["url"]  = "/?load=art";
			$urlAddArray[1]["name"] = "资讯中心";
			
			$urlAddArray[2]["url"]  = "/?load=invite";
			$urlAddArray[2]["name"] = "人才招聘";
	
			$urlAddArray[3]["url"]  = "/?load=contactus";
			$urlAddArray[3]["name"] = "联系我们";
			
			
			$urlAddArray[4]["url"]  = "/?load=link";
			$urlAddArray[4]["name"] = "友情链接";
	
			$urlAddArray[5]["url"]  = "/?load=message";
			$urlAddArray[5]["name"] = "在线咨询";
			
			$urlAddArray[6]["url"]  = "/?load=copyright";
			$urlAddArray[6]["name"] = "版权声明";
	
			$urlAddArray[7]["url"]  = "/?load=map";
			$urlAddArray[7]["name"] = "网站地图";

			$urlAddArray[8]["url"]  = "/?load=download";
			$urlAddArray[8]["name"] = "下载中心";
			
			$urlAddArray[9]["url"]  = "/?load=pic";
			$urlAddArray[9]["name"] = "图片中心";
	
			$urlAddArray[10]["url"]  = "/?load=vid";
			$urlAddArray[10]["name"] = "视频中心";
			
			$urlAddArray[11]["url"]  = "/?load=vote";
			$urlAddArray[11]["name"] = "投票中心";
			
			$urlAddArray[12]["url"]  = "/?load=aboutus";
			$urlAddArray[12]["name"] = "关于我们";
		}

		///var_dump($urlAddArray);


		$GLOBALS['Templ']->assign('urlAddArray',$urlAddArray);
		
	}
	
	function infolist()
	{
		$pageSize = 160 ;
		$pageNumval 	= $GLOBALS['Reque'] -> reqval["pageNum"];
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
			
		$sqlQuery = " SELECT web_id, web_name, web_url, web_enabled, web_place,web_list FROM  ".SQL_PREFIX."webmenu  WHERE  web_place in ( 'top','middle','bottom' ) GROUP BY web_id ORDER BY web_list , `web_id` LIMIT  $LIMITnum , $pageSize ";

		$infosm = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		

		if( $infosm !='')
		{
			//top
			foreach( $infosm as $ikey => $ival )
			{

					$info[$ival["web_place"]][] = $ival;
			}
		}
		//var_dump( $info );
		
		$sqlQuery = " SELECT count(1) as LNUM  FROM  ".SQL_PREFIX."webmenu  WHERE web_place in ( 'top','middle','bottom' )   ORDER BY `web_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		//var_dump();
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=webmenu&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["LNUM"]);
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('webmenu_tpl.html');
		
	}
	
	function add(  )
	{
		//$GLOBALS['Templ'] -> caching = true;
		//$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24
		
		//添加栏目可选地址
		
		//产品分类列表
		
		//资讯分类列表

		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=add");
		$GLOBALS['Templ']->display('webmenuadd_tpl.html');
	}
	
	function addinfo()
	{
		$web_nameval 	= $GLOBALS['Reque'] -> funpost("web_name");
		$web_urlval 	= $GLOBALS['Reque'] -> funpost("web_url");
		$web_enabledval = $GLOBALS['Reque'] -> funpost("web_enabled");
		$web_listval 	= $GLOBALS['Reque'] -> funpost("web_list");
		$web_placeval 	= $GLOBALS['Reque'] -> funpost("web_place");
		$web_targetvalval = $GLOBALS['Reque'] -> funpost("web_targetval"); 
		
		if($web_nameval and $web_urlval)
		{
			$sqlQuery = " SELECT count(1) as LNUM  FROM  ".SQL_PREFIX."webmenu  WHERE web_name = '".$web_nameval."' and web_place = '".$web_placeval."' ORDER BY `web_id` ";	
			$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
			
			if( $info["LNUM"] < 1 )
			{
				$insertsql =" INSERT INTO `".SQL_PREFIX."webmenu` (`web_name` , `web_url` , `web_enabled` , `web_list` , `web_targetval` ,`web_place`) VALUES (  '$web_nameval', '$web_urlval', '$web_enabledval', '$web_listval', '$web_targetvalval','$web_placeval')";
				
				$GLOBALS['MySql'] -> querySql($insertsql);
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=infolist");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}else{
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_isrealyerror']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=add");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}
			
		}else{
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=add");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');		}
		//var_dump($_REQUEST);
	}
	
	function del( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		$insertip = " DELETE FROM `".SQL_PREFIX."webmenu` WHERE `web_id` in ( $infoid ) ";
		$GLOBALS['MySql'] -> querySql($insertip);
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function info(  )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$sqlQuery = " SELECT *  FROM  ".SQL_PREFIX."webmenu  WHERE web_id = '".$infoid."' ORDER BY `web_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		//var_dump($info);
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('webmenuedit_tpl.html');
	
	}
	
	
	function editinfo( )
	{	
		$web_idval 		  = $GLOBALS['Reque'] -> funpost("web_id");
		$web_nameval 	  = $GLOBALS['Reque'] -> funpost("web_name");
		$web_urlval 	  = $GLOBALS['Reque'] -> funpost("web_url");
		$web_enabledval   = $GLOBALS['Reque'] -> funpost("web_enabled");
		$web_listval 	  = $GLOBALS['Reque'] -> funpost("web_list");
		$web_placeval 	  = $GLOBALS['Reque'] -> funpost("web_place");
		$web_targetvalval = $GLOBALS['Reque'] -> funpost("web_targetval"); 
		
		if($web_nameval !='' and $web_urlval !='' and $web_idval !='')
		{
			
			$updatewebmenu = "UPDATE `".SQL_PREFIX."webmenu` SET  web_name = '".$web_nameval."' , web_url = '".$web_urlval."' , web_enabled = '".$web_enabledval."', web_list = '".$web_listval."',web_place = '".$web_placeval."' ,web_targetval = '".$web_targetvalval."' WHERE  web_id = '".$web_idval."' ";
			
			$GLOBALS['MySql'] -> querySql( $updatewebmenu );
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=webmenu&act=info&id=".$web_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
		
	}
		
}

//nmon_x86_rhel4
$Webmenu = new Webmenu();

?>