<?php
class FlashController extends Easy_Controller_Action {
	public function init(){
		$this->_Flash = new FlashModel();
	}
	public function indexAction(){
		$this->_View->rows = $this->_Flash->getAll();
	}
	public function AddAction(){
		if ($this->_Request->isPost()){
			if ( $this->_Flash->add($this->_Request->getPost())===false ){
				$this->_View->message = $this->_Flash->error;
			}else{
				$this->_View->message = _('发布成功!');
			}
			exit($this->_View->render('message'));
		}
	}
	public function deleteAction(){
		$this->_Flash->delete($this->_Request->getParam('id'));
		$this->_View->message = _('删除成功!');
		exit($this->_View->render('message'));
	}
	public function lockedAction(){
		$this->_Flash->locked($this->_Request->getParam('id'));
		$this->_View->message = _('设置成功!');
		exit($this->_View->render('message'));	
	}
	public function modifyAction(){
		if ($this->_Request->isPost()){
			if ( $this->_Flash->modify($this->_Request->getPost())===false ){
				$this->_View->subject = _('修改失败!');
				$this->_View->message = $this->_Flash->error;
			}else{
				$this->_View->message = _('修改成功!');
			}
			exit($this->_View->render('message'));
		}
		$this->_View->modify = $this->_Flash->getRow($this->_Request->getParam('id'));
	}
}?>