<?php
/*
秀影EasyFramework框架
qq:24498936
msn:jdzcn_net@hotmail.com
website:http://www.vodcms.com
*/
class AfficheController extends Easy_Controller_Action {
	public function Init(){
		$this->_Affiche = new AfficheModel();
	}
	public function IndexAction(){
		$this->_View->affiche = $this->_Affiche->getAll();
	}
	public function AddAction(){
		if ($this->_Request->isPost()){
			if ($this->_Affiche->AddAffiche($this->_Request->getPost()) === false){
				$this->_View->message[] = _('公告发布失败!');
				$this->_View->message[] = $this->_Affiche->error;
				exit($this->_View->render('message'));
			}else {
				$this->_View->message = _('公告发布成功!');
				exit($this->_View->render('message'));
			}
		}
	}
	public function ModifyAction(){
		$this->_View->modify = $this->_Affiche->getRow(array('id'=> (int)$this->_Request->getParam('id')));
		if ($this->_Request->isPost()){
			$this->_Affiche->modifyAffiche($this->_Request->getPost());
			$this->_View->message = _('公告修改成功!');
			exit($this->_View->render('message'));
		}elseif ($this->_Request->getParam('do')=='locked'){
			$this->_Affiche->lockedAffiche('id='. (int)$this->_Request->getParam('id'));
			$this->_View->message = _('设置成功!');
			exit($this->_View->render('message'));
		}
	}
	public function deleteAction(){
		$this->_Affiche->delete('id='.$this->_Request->getParam('id'));
		$this->_View->message = _('删除成功!');
		exit($this->_View->render('message'));
	}
}