<?php
/**
 * ---------------------------------------
 * DESC: 视频列表 | video/list.php
 * ---------------------------------------
 * $Date: 2011-11-14 (星期一) 
 */
include_once(dirname(dirname(__FILE__))."/comm.inc.php");
include_once(libs.'/video.lib.php');
$Model = new video();

$_REQUEST['video'] = $_REQUEST['video']?$_REQUEST['video']:0;

$kw = $_REQUEST['kw']&&$_REQUEST['kw']!='请输入关键词'?urlencode($_REQUEST['kw']):0;
$shoes = $_REQUEST['shoes']?intval($_REQUEST['shoes']):0;
$video = $_REQUEST['video']?$_REQUEST['video']:0;
$page = $_REQUEST['page']?$_REQUEST['page']:1;
$pagesize = 18;
$table = '`corp_video`';
$where = "1";

if (empty($kw)) {
	if ($shoes) {
		$where .= " AND `shoes_type` like '%$shoes%'  AND `is_state`='y'";
		$order	= "`pubtime` DESC";
	}elseif ($video){
		switch ($video){
			case "1":
			case "2":
			case "3":
			case "4":
				$where .= " AND `type`='{$_REQUEST['video']}' AND `is_state`='y'";
				$order	= "`pubtime` DESC";
				break;
			case "5":
				$where .= " AND `is_state`='y'";
				$order	= "`pnum` DESC";
			case '6':
				$where .= " AND `is_state`='y'";
				$order	= "`commentnum` DESC";
		}
	}else {
		$where .= " AND `is_state`='y'";
		$order	= "`pubtime` DESC";
	}
}else {

	$where .= " AND `title` like '%".urldecode($kw)."%'";
	$order	= "`pubtime` DESC";
}

$param	= "list-$shoes-$video-$kw-";
$tpl->assign('Video', $Model->getVideoListPage($table,$where, $order, $page, $pagesize));
$navi_cM = $Model->Navi_Page($table, $pagesize, $where, $page, $param);
$tpl->assign('navi_cM',$navi_cM);

// 右侧数据缓存
include_once(libs.'/cache.lib.php');
$cache = new mcache($dataDir.'/video');
if(!$cache->read($optionArray, "Video_List_Right_Cache"))
{
	$optionArray = array();
	// 广告ads
	$optionArray['ads'] = $Model->selectDefaultList('`ad_name`,`ad_images`,`ad_url`,`domain`','`web_ad`','`ad_sort`=\'VIDEOV\' AND `ad_commend`=\'1\'','`ad_arrange` ASC','3');
	// 视频推荐
	$statevideo = $Model->getVideoList('`is_commend`=\'1\' AND `is_state`=\'y\'','`id` DESC','10');
	foreach ($statevideo as $key => $value){
		$company = $Model->getCompanyName($value['cid']);
		$statevideo[$key]['company'] = $company['company_name'];
	}
	$optionArray['commVideo'] = $statevideo;	
	// 品牌新闻
	$optionArray['brandNews'] = $Model->getBrandNews(12);

	$cache->set($optionArray, "Video_List_Right_Cache", 10800);
}

$tpl->assign('ads',$optionArray['ads']);	
$tpl->assign('commVideo', $optionArray['commVideo']);
$tpl->assign('brandNews',$optionArray['brandNews']);
// 最新评论
$tpl->assign('newComment',$Model->getNewCommentList('10'));

$tpl->display('video/list.tpl');
?>