Activity.class.php 4.29 KB
<?php
class Controller_Admin_Activity extends Controller_Admin_Base
{
	public function indexAction()
	{
		$this->_view['activityInfos'] = Facade_Activity::getActivityInfo();
	}
	
	public function createAction()
	{
		$id = intval($this->_request->id);
		$info = array(
				 'id' => 0,
				'content'=> '',
				'title'=> '',
				'client_content'=>'',
			);
		if($id)
		{
			$info = Facade_Activity::getActivityInfoById($id);
		}
		$this->_view['isMobile'] = false;
		if(strpos($info['title'], '客户端') !== false)
		{
			$this->_view['isMobile'] = true;
		}
		$this->_view['info'] = $info;
	}
	
	public function doAction()
	{
		$id = intval($this->_request->id);
		$data = $_POST;
		if($id)
		{
			//更新
			Facade_Activity::setActivityInfoById($id, trim($data['title']), $data['content'], $data['client_content']);
			return $this->returnJson(true, 200, array('url' => url('activity/index')));
		}
		else
		{
			//新建
			Facade_Activity::setActivityInfo($data['title'], trim($data['content']), $data['client_content']);
			return $this->returnJson(true, 200, array('url' => url('activity/index')));
		}
		
	}
	
	public function delAction()
	{
		$id = $this->_request->query('id');
		$status = Facade_Activity::delActivityInfo($id);
		if($status)
		{
			return $this->returnJson(true, 200);
		}
		else
		{
			return $this->returnJson(false, 403);
		}
	}
	
	/**
	 * 现场活动计划
	 */
	public function planAction()
	{
		$this->_view['key'] = Lib_Images::genKey('fragmentimg');
		$parent_id = $this->_request->query('parent_id', 0);
		$topicInfo = array('title'=> '', 'id' => '0');
		$plans = array();
		if(!empty($parent_id))
		{
			$plans = Facade_Activity::getActivityPlanByParentId($parent_id);
			$topicInfo = Facade_Activity::getActivityTopicId($parent_id);
		}
		$this->_view['plans'] = $plans;
		$this->_view['topicInfo'] = $topicInfo;
	}
	
	/**	
	 * 设置现场活动计划
	 */
	public function setactivityplanAction()
	{
		$title = $this->_request->query('title', '');
		$content = $this->_request->query('content', '');
		$pic = $this->_request->query('pic', '');
		$start_time = $this->_request->query('start_time', '');
		$end_time = $this->_request->query('end_time', '');
		$place = $this->_request->query('place', '');
		$id = $this->_request->query('id', '');
		$parent_id = $this->_request->query('parent_id', 0);
		if(!empty($id))
		{
			$status = Facade_Activity::setActivityPlanById($id, $parent_id, $title, $content, $pic, $place, $start_time, $end_time);
		}
		else
		{
			$status = Facade_Activity::setActivityPlan($parent_id, $title, $content, $pic, $place, $start_time, $end_time);
		}
		if($status)
		{
			return $this->returnJson(true, 200);
		}
		else
		{
			return $this->returnJson(false, 403);
		}
	}
	
	/**
	 * 删除现场活动计划
	 */
	public function delactivityplanAction()
	{
		$id = $this->_request->query('id');
		$status = Facade_Activity::delActivityPlan($id);
		if($status)
		{
			return $this->returnJson(true, 200);
		}
		else
		{
			return $this->returnJson(false, 403);
		}
	}
	
	/**
	 * 现场活动主题
	 */
	public function plantopicAction()
	{
	    $limit = 15;
	    $total = Facade_Activity::getActivityTopicTotal();
	    $pagination = new Lib_Helper_Pagination($total, $limit);
		$this->_view['topics'] = Facade_Activity::getActivityTopicList($pagination->getOffset(), $limit);
		$this->_view['pagination'] = $pagination->getPagination();
	}

	/**
	 * 设置现场主题
	 */
	public function setactivitytopicAction()
	{
		$title = $this->_request->query('title', '');
		$place = $this->_request->query('place', '');
		$id = $this->_request->query('id', '');
		$start_time = $this->_request->query('start_time', '');
		$end_time = $this->_request->query('end_time', '');
		if(!empty($id))
		{
			$status = Facade_Activity::setActivityTopicById($id, $title, $place, $start_time, $end_time);
		}
		else
		{
			$status = Facade_Activity::setActivityTopic($title, $place, $start_time, $end_time);
		}
		if($status)
		{
			return $this->returnJson(true, 200);
		}
		else
		{
			return $this->returnJson(false, 403);
		}
	}
	
	
	/**
	 * 删除现场活动主题
	 */
	public function delactivitytopicAction()
	{
		$id = $this->_request->query('id');
		$status = Facade_Activity::delActivityTopic($id);
		if($status)
		{
			return $this->returnJson(true, 200);
		}
		else
		{
			return $this->returnJson(false, 403);
		}
	}
	
}