Activity.class.php 2.92 KB
<?php
/**
 * 活动页面
 */
class Controller_Activity extends Controller_Abstract
{
	
	/**
	 * 活动介绍
	 */
	public function indexAction()
	{
		$this->_view['activityInfos'] = Facade_Activity::getActivityInfo();
	}
	
	/**
	 * 现场活动
	 */
	public function planAction()
	{
		$topics = Facade_Activity::getActivityTopic();
		$currentday = $this->_request->query('currentday', '');
		$list = array();
		$planList = array();
		$topicIds = array();
		//导航
		$navList = array();
		$today = strtotime(date('Y-m-d', time()));
        $firstCurrentday = 0;
		foreach($topics as $topic)
		{
			$startTime = strtotime(date('Y-m-d', $topic['start_time']));
			$list[$startTime][] = $topic;
			$year = date('Y', $topic['start_time']);
			if(!isset($navList[$year]))
			{
			    $navList[$year] = array();
			}
			$enable  = 0;
			//导航
			if(!in_array($startTime, array_keys($navList[$year])))
			{
			    $enable = $today >= $startTime ? 1 : 0;
			    if($enable && empty($firstCurrentday))
			    {
			        $firstCurrentday = $startTime;
			    }
			    $navList[$year][$startTime] = array('timestamp' => $startTime,'enable' => $enable);
			}
			//第一次,没有时间
			if(empty($currentday))
			{
			    $currentday = $firstCurrentday;
			}
			if($startTime == $currentday)
			{
				$topicIds[] = $topic['id'];
			}
		}
		foreach($topicIds as $topicId)
		{
		    $planList[$topicId] = Facade_Activity::getActivityPlanByParentId($topicId);
		}	
		krsort($list);
		krsort($navList);
		$this->_view['plans'] = $planList;
		$this->_view['topics'] = $list[$currentday];
		$this->_view['navs'] = $navList;
		$this->_view['currentday'] = $currentday;
	}
	
	/**
	 * 活动介绍客户端的html5
	 */
	public function introduceAction()
	{
		$this->_view['activityInfos'] = Facade_Activity::getActivityInfo();
		$this->_view['title'] = trim($this->_request->query('title', ''));
		$this->_viewname = 'introducemobile';
	}
	
	/**
	 * 移动端问答
	 */
	public function qaAction()
	{
		$this->_viewname = 'qamobile';
	}
	
	/**
	 * 往期视频
	 */	
	public function videoAction()
	{
	    $tag = '视频';
	    $datetime = '2015-01-01 00:00:00';
		$total = Facade_News::getTotalBeforeTime($tag, $datetime);
		$page = new Lib_Helper_Pagination($total, 24);
		$page->setOptions(array('afterAppend' => 'setLayout'));
		list($offset, $limit) = $page->getLimit();
		$list = Facade_News::getListBeforeTime($tag, $datetime, $offset, $limit);
		$this->_view['video'] = $list;
		$this->_view['pagination'] = $page->getPagination();
	}
	
	/**
	 * 赞助商
	 */
	public function partnerAction()
	{
	    $partnerList = Facade_Partner::getPartner();
	    $partnerGroups = array();
	    foreach($partnerList as $partner)
	    {
	        foreach(Facade_Partner::$types as $key => $type)
	        {
	            if($partner['type'] == $key)
	            {
	                $partnerGroups[$type][] = $partner;
	            }
	        }
	    }
	    $this->_view['partnerGroups'] = $partnerGroups;
	}
}