<?php
/*项目入口根模块*/
class AllAction extends Action{
    //构造函数
    public function _initialize(){
        header("Content-Type:text/html; charset=utf-8");
    }
	// 产品多分类筛选变量定义
	public function Lable_Chanpin_Type($param){
		$array['sid'] = 1;
		$array['type_id'] = $param['id'];
		$array['type_year'] = $param['year'];
		$array['type_langaue'] = $param['langaue'];
		$array['type_area'] = $param['area'];
		$array['type_letter'] = $param['letter'];
		$array['type_actor'] = $param['actor'];
		$array['type_director'] = $param['director'];
		//
		$array['type_wd'] = $param['wd'];
		$array['type_page'] = $param['page'];
		$array['type_order'] = $param['order'];
		$array['type_skin'] = getlistname($param['id'],'list_skin_type');
		$array['type_pid'] = getlistname($param['id'],'list_pid');
		if (empty($array['type_skin'])) {
			$array['type_skin'] = 'Home:gxl_chanpintype';
		}
		return $array;
    }
	// 产品栏目页变量定义
	public function Lable_Chanpin_List($param,$array_list){
		$array_list['sid'] = 1;
		$array_list['list_page'] = $param['page'];
		if ($param['page'] > 1) {
			$array_list['title'] = $array_list['list_name'].'-第'.$param['page'].'页'.'-'.C('site_name');
		}else{
			$array_list['title'] = $array_list['list_name'].'-'.C('site_name');
		}
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = 'Home:gxl_chanpinlist';
		}
		return $array_list;
    }
	/*****************产品内容,播放页公用变量定义******************************
	* @$array/具体的内容信息
	* @$array_play 为解析播放页
	* @返回赋值后的arrays 多维数组*/
	public function Lable_Chanpin_Read($array,$array_play=false){
		$array_list = list_search(F('_GxlcmsQY/list'),'list_id='.$array['chanpin_cid']);
		$array['sid'] = 1;
		$array['title'] = $array['chanpin_name'].'-'.C('site_name');		
		$array['chanpin_readurl'] = ff_data_url('chanpin',$array['chanpin_id'],$array['chanpin_cid'],$array['chanpin_name'],1,$array['chanpin_jumpurl']);
		$array['chanpin_playurl'] = ff_play_url($array['chanpin_id'],0,1,$array['chanpin_cid'],$array['chanpin_name']);
		$array['chanpin_picurl'] = ff_img_url($array['chanpin_pic'],$array['chanpin_content']);
		$array['chanpin_picurl_small'] = ff_img_url_small($array['chanpin_pic'],$array['chanpin_content']);
		$array['chanpin_rssurl'] = UU('Home-map/rss',array('id'=>$array['chanpin_id']),false,true);
		$array['chanpin_hits_insert'] = ff_get_hits('chanpin','insert',$array);
		$array['chanpin_hits_month'] = ff_get_hits('chanpin','chanpin_hits_month',$array);
		$array['chanpin_hits_week'] = ff_get_hits('chanpin','chanpin_hits_week',$array);
		$array['chanpin_hits_day'] = ff_get_hits('chanpin','chanpin_hits_day',$array);
		if($array['chanpin_skin']){
			$array['chanpin_skin_detail'] = 'Home:'.trim($array['chanpin_skin']);
			$array['chanpin_skin_play'] = 'Home:'.trim($array['chanpin_skin']).'_play';
		}else{
			$array['chanpin_skin_detail'] = !empty($array_list['list_skin_detail']) ? 'Home:'.$array_list['list_skin_detail'] : 'Home:gxl_chanpin';
			$array['chanpin_skin_play'] = !empty($array_list['list_skin_play']) ? 'Home:'.$array_list['list_skin_play'] : 'Home:gxl_play';
		}
		//播放列表解析
		$array['chanpin_playlist'] = $this->ff_playlist_all($array);
		$array['chanpin_playcount'] = count($array['chanpin_playlist']);
		$array['chanpin_player'] = 'var ff_urls=\''.$this->ff_playlist_json(array($array['chanpin_name'],$array_list[0]['list_name'],$array_list[0]['list_url']),$array['chanpin_playlist']).'\';';
		//按顺序排列
		ksort($array['chanpin_playlist']);
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;
		return $arrays;
	}
	/*****************产品播放页变量定义 适用于动态与合集为一个播放页******************************<br />
	* @$array 内容页解析好后的内容页变量 arrays['read']
	* @$array_play 为播放页URL参数 array('id'=>558,'sid'=>1,'pid'=>1)
	* @返回$array 内容页重新组装的数组*/
	public function Lable_Chanpin_Play($array,$array_play,$createplayone){
		$player = C('play_player');
		$player_here = explode('$$$',$array['chanpin_play']);
		$array['chanpin_sid'] = $array_play['sid'];
		$array['chanpin_pid'] = $array_play['pid'];
		$array['chanpin_playname'] = $player_here[$array_play['sid']];
		$array['chanpin_playername'] = $player[$array['chanpin_playname']][1];
		$array['chanpin_playerkey'] = $player[$array['chanpin_playname']][0];
		$array['chanpin_jiname'] = $array['chanpin_playlist'][$array['chanpin_playerkey'].'-'.$array_play['sid']]['son'][$array_play['pid']-1]['playname'];
		$array['chanpin_playpath']= $array['chanpin_playlist'][$array['chanpin_playerkey'].'-'.$array_play['sid']]['son'][$array_play['pid']-1]['playpath'];
		$array['chanpin_nextpath']= $array['chanpin_playlist'][$array['chanpin_playerkey'].'-'.$array_play['sid']]['son'][$array_play['pid']]['playpath'];
		$array['chanpin_count'] = $array['chanpin_playlist'][$array['chanpin_playerkey'].'-'.$array_play['sid']]['son'][0]['playcount'];
		$array['title'] = '正在播放 '.$array['chanpin_name'].'-'.$array['chanpin_jiname'].'-'.C('site_name');
		//播放器调用
		if($createplayone){
			//适用于静态网页生成每一集
			$player_jsdir = C('site_path').ff_play_url_dir($array['chanpin_id'],0,1,$array['chanpin_cid'],$array['chanpin_name']).'.js?'.uniqid();
			$array['chanpin_player'] = '<script charset="utf-8" src="'.$player_jsdir.'"></script><script charset="utf-8" src="'.C('site_path').'Runtime/Player/play.js"></script><script charset="utf-8" src="'.C('site_path').'Public/player2.9/play.js"></script>'."\n";
		}else{
			$array['chanpin_player'] = '<script language="javascript">'.$array['chanpin_player'].'</script><script charset="utf-8" src="'.C('site_path').'Runtime/Player/play.js"></script><script charset="utf-8" src="'.C('site_path').'Public/player2.9/play.js?"></script>'."\n";
		}
		//点击数调用
		$array['chanpin_hits_month'] = ff_get_hits('chanpin','chanpin_hits_month',$array,C('url_html_play'));
		$array['chanpin_hits_week'] = ff_get_hits('chanpin','chanpin_hits_week',$array,C('url_html_play'));
		$array['chanpin_hits_day'] = ff_get_hits('chanpin','chanpin_hits_day',$array,C('url_html_play'));
		return $array;
	}
	//组合播放地址组列表为二维数组
	public function ff_playlist_all($array){
		if(empty($array['chanpin_url'])){return false;}
		$playlist = array();
		$array_server = explode('$$$',$array['chanpin_server']);
		$array_player = explode('$$$',$array['chanpin_play']);
		$array_urllist = explode('$$$',$array['chanpin_url']);
		$player = C('play_player');
		$server = C('play_server');
		foreach($array_player as $sid=>$val){
			$playlist[$player[$val][0].'-'.$sid] = array('servername' => $array_server[$sid],'serverurl' => $server[$array_server[$sid]],'playername'=>$player[$val][1],'playname'=>$val,'son' => $this->ff_playlist_one($array_urllist[$sid],$array['chanpin_id'],$sid,$array['chanpin_cid'],$array['chanpin_name']));
		}
		//ksort($playlist);
	    return $playlist;
	}
	//分解单组播放地址链接
	public function ff_playlist_one($urlone,$id,$sid,$cid,$name){
		$urllist = array();
	    $array_url = explode(chr(13),str_replace(array("\r\n", "\n", "\r"),chr(13),$urlone));
		foreach($array_url as $key=>$val){
		    if (strpos($val,'$') > 0) {
		        $ji = explode('$',$val);
			    $urllist[$key]['playname'] = trim($ji[0]);
			    $urllist[$key]['playpath'] = trim($ji[1]);
			}else{
			    $urllist[$key]['playname'] = '第'.($key+1).'集';
			    $urllist[$key]['playpath'] = trim($val);
			}
			$urllist[$key]['playurl'] = ff_play_url($id,$sid,$key+1,$cid,$name);
			$urllist[$key]['playcount'] = count($array_url);
		}
	    return $urllist;
	}
	//生成播放列表字符串
	public function ff_playlist_json($chanpin_info_array,$chanpin_url_array){
		//json数组创建
		$key = 0;
		foreach($chanpin_url_array as $val){
			$array_urls[$key]['servername'] = $val['servername'];
			$array_urls[$key]['playname'] = $val['playname'];
			foreach($val['son'] as $keysub=>$valsub){
				$array_urls[$key]['playurls'][$keysub] = array($valsub['playname'], $valsub['playpath'], $valsub['playurl']);
			}
			$key++;
		}
		return json_encode(array('Chanpin'=>$chanpin_info_array,'Data'=>$array_urls));
	}
	//资讯栏目页变量定义
	public function Lable_News_List($param,$array_list){
		$array_list['sid'] = 2;
		$array_list['list_wd'] = $param['wd'];	
		$array_list['list_page'] = $param['page'];
		$array_list['list_letter'] = $param['letter'];
		$array_list['list_order'] = $param['order'];
		if ($param['page'] > 1) {
			$array_list['title'] = $array_list['list_name'].'-第'.$param['page'].'页';
		}else{
			$array_list['title'] = $array_list['list_name'];
		}
		$array_list['title'] = $array_list['title'].'-'.C('site_name');
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = 'gxl_newslist';
		}
		return $array_list;
    }	
	//资讯内容页变量定义
	public function Lable_News_Read($array,$array_play = false){
		$array_list = list_search(F('_GxlcmsQY/list'),'list_id='.$array['news_cid']);
		$array['sid'] = 2;
		$array['title'] = $array['news_name'].'-'.C('site_name');
		$array['news_readurl'] = ff_data_url('news',$array['news_id'],$array['news_cid'],$array['news_name'],1,$array['news_jumpurl']);
		$array['news_picurl'] = ff_img_url($array['news_pic'],$array['news_content']);
		$array['news_picurl_small'] = ff_img_url_small($array['news_pic'],$array['news_content']);
		$array['news_hits_insert'] = ff_get_hits('news','insert',$array);
		$array['news_hits_month'] = ff_get_hits('news','news_hits_month',$array);
		$array['news_hits_week'] = ff_get_hits('news','news_hits_week',$array);
		$array['news_hits_day'] = ff_get_hits('news','news_hits_day',$array);
		if($array['news_skin']){
			$array['news_skin_detail'] = 'Home:'.trim($array['news_skin']);
		}else{
			$array['news_skin_detail'] = !empty($array_list['list_skin_detail']) ? 'Home:'.$array_list['list_skin_detail'] : 'Home:gxl_news';
		}		
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;		
		return $arrays;
	}
		//招聘栏目页变量定义
		public function Lable_Zhaopin_List($param,$array_list){
		$array_list['sid'] = 10;
		$array_list['list_wd'] = $param['wd'];	
		$array_list['list_page'] = $param['page'];
		$array_list['list_letter'] = $param['letter'];
		$array_list['list_order'] = $param['order'];
		if ($param['page'] > 1) {
			$array_list['title'] = $array_list['list_name'].'-第'.$param['page'].'页';
		}else{
			$array_list['title'] = $array_list['list_name'];
		}
		$array_list['title'] = $array_list['title'].'-'.C('site_name');
		if (empty($array_list['list_skin'])) {
			$array_list['list_skin'] = 'gxl_zhaopinlist';
		}
		return $array_list;
    }	
	//招聘内容页变量定义
	public function Lable_Zhaopin_Read($array,$array_play = false){
		$array_list = list_search(F('_GxlcmsQY/list'),'list_id='.$array['zhaopin_cid']);
		$array['sid'] = 2;
		$array['title'] = $array['zhaopin_name'].'-'.C('site_name');
		$array['zhaopin_readurl'] = ff_data_url('zhaopin',$array['zhaopin_id'],$array['zhaopin_cid'],$array['zhaopin_name'],1,$array['zhaopin_jumpurl']);
		$array['zhaopin_picurl'] = ff_img_url($array['zhaopin_pic'],$array['zhaopin_content']);
		$array['zhaopin_picurl_small'] = ff_img_url_small($array['zhaopin_pic'],$array['zhaopin_content']);
		$array['zhaopin_hits_insert'] = ff_get_hits('zhaopin','insert',$array);
		$array['zhaopin_hits_month'] = ff_get_hits('zhaopin','zhaopin_hits_month',$array);
		$array['zhaopin_hits_week'] = ff_get_hits('zhaopin','zhaopin_hits_week',$array);
		$array['zhaopin_hits_day'] = ff_get_hits('zhaopin','zhaopin_hits_day',$array);
		if($array['zhaopin_skin']){
			$array['zhaopin_skin_detail'] = 'Home:'.trim($array['zhaopin_skin']);
		}else{
			$array['zhaopin_skin_detail'] = !empty($array_list['list_skin_detail']) ? 'Home:'.$array_list['list_skin_detail'] : 'Home:gxl_zhaopin';
		}		
		$arrays['show'] = $array_list[0];
		$arrays['read'] = $array;		
		return $arrays;
	}
	//专题列表页变量定义
	public function Lable_Special_List($param){
		$array_list = array();
		$array_list['sid'] = 3;
		$array_list['special_skin'] = 'gxl_speciallist';
		$array_list['special_page'] = $param['page'];
		$array_list['special_order'] = 'special_'.$param['order'];
		if ($param['page'] > 1) {
			$array_list['title'] = '专题列表-第'.$param['page'].'页'.'-'.C('site_name');
		}else{
			$array_list['title'] = '专题列表'.'-'.C('site_name');
		}
		return $array_list;
    }
	//专题内容页变量定义
	public function Lable_Special_Read($array,$array_play = false){
		$array_ids = array();$where = array();
		$array['special_readurl'] = ff_data_url('special',$array['special_id'],0,$array['special_name'],1,0);
		$array['special_logo'] = ff_img_url($array['special_logo'],$array['special_content']);
		$array['special_banner'] = ff_img_url($array['special_banner'],$array['special_content']);
		$array['special_hits_insert'] = ff_get_hits('special','insert',$array);
		$array['special_hits_month'] = ff_get_hits('special','special_hits_month',$array);
		$array['special_hits_week'] = ff_get_hits('special','special_hits_week',$array);
		$array['special_hits_day'] = ff_get_hits('special','special_hits_day',$array);
		$array['special_skin'] = !empty($array['special_skin']) ? 'Home:'.$array['special_skin'] : 'Home:gxl_special';
		$array['title'] = $array['special_name'].'-专题-'.C('site_name');
		$array['sid'] = 3;
		//收录产品
		$rs = D('TopicchanpinView');
		$where['topic_sid'] = 1;
		$where['topic_tid'] = $array['special_id'];
		$list_chanpin = $rs->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_chanpin as $key=>$val){
			$list_chanpin[$key]['list_id'] = $list_chanpin[$key]['chanpin_cid'];
			$list_chanpin[$key]['list_name'] = getlistname($list_chanpin[$key]['list_id'],'list_name');
			$list_chanpin[$key]['list_url'] = getlistname($list_chanpin[$key]['list_id'],'list_url');
			$list_chanpin[$key]['chanpin_readurl'] = ff_data_url('chanpin',$list_chanpin[$key]['chanpin_id'],$list_chanpin[$key]['chanpin_cid'],$list_chanpin[$key]['chanpin_name'],1,$list_chanpin[$key]['chanpin_jumpurl']);
			$list_chanpin[$key]['chanpin_playurl'] = ff_play_url($list_chanpin[$key]['chanpin_id'],0,1,$list_chanpin[$key]['chanpin_cid'],$list_chanpin[$key]['chanpin_name']);
			$list_chanpin[$key]['chanpin_picurl'] = ff_img_url($list_chanpin[$key]['chanpin_pic'],$list_chanpin[$key]['chanpin_content']);
			$list_chanpin[$key]['chanpin_picurl_small'] = ff_img_url_small($list_chanpin[$key]['chanpin_pic'],$list_chanpin[$key]['chanpin_content']);		
		}
		//收录资讯
		$rs = D('TopicnewsView');
		$where['topic_sid'] = 2;
		$where['topic_tid'] = $array['special_id'];
		$list_news = $rs->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_news as $key=>$val){
			$list_news[$key]['list_id'] = $list_news[$key]['news_cid'];
			$list_news[$key]['list_name'] = getlistname($list_news[$key]['list_id'],'list_name');
			$list_news[$key]['list_url'] = getlistname($list_news[$key]['list_id'],'list_url');
			$list_news[$key]['news_readurl'] = ff_data_url('news',$list_news[$key]['news_id'],$list_news[$key]['news_cid'],$list_news[$key]['news_name'],1,$list_news[$key]['news_jumpurl']);
			$list_news[$key]['news_picurl'] = ff_img_url($list_news[$key]['news_pic'],$list_news[$key]['news_content']);
			$list_news[$key]['news_picurl_small'] = ff_img_url_small($list_news[$key]['news_pic'],$list_news[$key]['news_content']);		
		}
		//收入招聘信息
		$rs = D('TopiczhaopinView');
		$where['topic_sid'] = 10;
		$where['topic_tid'] = $array['special_id'];
		$list_zhaopin = $rs->where($where)->order('topic_oid desc,topic_did desc')->select();
		foreach($list_zhaopin as $key=>$val){
			$list_zhaopin[$key]['list_id'] = $list_zhaopin[$key]['zhaopin_cid'];
			$list_zhaopin[$key]['list_name'] = getlistname($list_zhaopin[$key]['list_id'],'list_name');
			$list_zhaopin[$key]['list_url'] = getlistname($list_zhaopin[$key]['list_id'],'list_url');
			$list_zhaopin[$key]['zhaopin_readurl'] = ff_data_url('zhaopin',$list_zhaopin[$key]['zhaopin_id'],$list_zhaopin[$key]['zhaopin_cid'],$list_zhaopin[$key]['zhaopin_name'],1,$list_zhaopin[$key]['zhaopin_jumpurl']);
			$list_zhaopin[$key]['zhaopin_picurl'] = ff_img_url($list_zhaopin[$key]['zhaopin_pic'],$list_zhaopin[$key]['zhaopin_content']);
			$list_zhaopin[$key]['zhaopin_picurl_small'] = ff_img_url_small($list_zhaopin[$key]['zhaopin_pic'],$list_zhaopin[$key]['zhaopin_content']);		
		}
		$arrays['read'] = $array;
		$arrays['list_chanpin'] = $list_chanpin;
		$arrays['list_news'] = $list_news;
		$arrays['list_zhaopin'] = $list_zhaopin;
		return $arrays;
	}			
	//搜索页变量定义
	public function Lable_Search($param,$sidname = 'chanpin'){
		$array_search = array();
		if($sidname == 'chanpin'){
			$array_search['search_actor'] = $param['actor'];
			$array_search['search_director'] = $param['director'];			
			$array_search['search_area'] = $param['area'];
			$array_search['search_langaue'] = $param['langaue'];
			$array_search['search_year'] = $param['year'];
			$array_search['sid'] = 1;
		}else{
			$array_search['sid'] = 2;
		}
		$array_search['search_wd'] = $param['wd'];
		$array_search['search_name'] = $param['name'];
		$array_search['search_title'] = $param['title'];
		$array_search['search_page'] = $param['page'];
		$array_search['search_letter'] = $param['letter'];
		$array_search['search_order'] = $param['order'];
		$array_search['search_skin'] = 'gxl_'.$sidname.'search';
		if ($param['page'] > 1) {
			$array_search['title'] = $array_search['search_wd'].'-第'.$param['page'].'页';
		}else{
			$array_search['title'] = $array_search['search_wd'];
		}
		$array_search['title'] = $array_search['search_area'].$array_search['search_langaue'].$array_search['search_actor'].$array_search['search_director'].$array_search['title'].'-'.C('site_name');
		return $array_search;
    }	
	//Tag页变量定义
	public function Lable_Tags($param){
		$array_tag = array();
		$array_tag['tag_name'] = $param['wd'];
		$array_tag['tag_url'] = ff_tag_url($param['wd']);
		$array_tag['tag_page'] = $param['page'];
		if ($param['page'] > 1) {
			$array_tag['title'] = $array_tag['tag_name'].'-第'.$param['page'].'页-'.C('site_name');
		}else{
			$array_tag['title'] = $array_tag['tag_name'].'-'.C('site_name');
		}
		return $array_tag;
    }	
	//首页标签定义
	public function Lable_Index(){
		$array = array();
		$array['title'] = C('site_name');
		$array['model'] = 'index';
		return $array;
	}
	//地图页标签定义
	public function Lable_Maps($mapname,$limit,$page){
		$rs = M("Chanpin");
		$list = $rs->order('chanpin_addtime desc')->limit($limit)->page($page)->select();
		if($list){
			foreach($list as $key=>$val){
				$list[$key]['chanpin_readurl'] = ff_data_url('chanpin',$list[$key]['chanpin_id'],$list[$key]['chanpin_cid'],$list[$key]['chanpin_name'],1,$list[$key]['chanpin_jumpurl']);
				$list[$key]['chanpin_playurl'] = ff_play_url($list[$key]['chanpin_id'],0,1,$list[$key]['chanpin_cid'],$list[$key]['chanpin_name']);
			}
			return $list;			
		}
		return false;
    }
	//全局标签定义
	public function Lable_Style(){
		$array = array();
		$array['model'] = strtolower(MODULE_NAME);
		$array['action'] = strtolower(ACTION_NAME);	
		C('TOKEN_ON',false);//C('TOKEN_NAME','form_'.$array['model']);取消前端的表单令牌
		$array['root'] = __ROOT__.'/';
		$array['tpl'] = $array['root'].str_replace('./','',TEMPLATE_PATH).'/';
		$array['css'] = '<link rel="stylesheet" type="text/css" href="'.$array['tpl'].'style.css">'."\n";
		$array['sitename'] = C('site_name');
		$array['gs_name'] = C('gs_name');//公司名称
		$array['gsjc_name'] = C('gsjc_name');//公司简称
		$array['gsdz_name'] = C('gsdz_name');//公司地址
		$array['qq1'] = C('qq1');//首页QQ
		$array['qq2'] = C('qq2');//首页QQ
		$array['qq3'] = C('qq3');//首页QQ
		$array['s40'] = C('s40');//首页QQ
		$array['siteurl'] = C('site_url');
		$array['sitehot'] = ff_hot_key(C('site_hot'));
		$array['keywords'] = C('site_keywords');
		$array['description'] = C('site_description');
		$array['email'] = C('site_email');
		$array['copyright'] = C('site_copyright');
		$array['tongji'] = C('site_tongji');
		$array['icp'] = C('site_icp');
		$array['hotkey']   = ff_hot_key(C('site_hot'));
		//$array['username'] = $_COOKIE['bd_username'];
		//$array['userid'] = intval($_COOKIE['bd_userid']);
		$array['url_tag'] = UU('Home-tag/show','',false,true);		
		$array['url_guestbook'] = UU('Home-gb/show','',false,true);
		$array['url_special'] = ff_special_url(1);
		$array['url_map_rss'] = ff_map_url('rss');
		$array['url_map_baidu'] = ff_map_url('baidu');
		$array['url_map_google'] = ff_map_url('google');
		$array['url_map_soso'] = ff_map_url('soso');
		$array['list_slide'] = F('_GxlcmsQY/slide');
		$array['list_link'] = F('_GxlcmsQY/link');
		$array['list_menu'] = F('_GxlcmsQY/listtree');		
		return $array;		
	}					
}
?>