<?php
class KeywordController extends Easy_Controller_Action {
	public function Init(){
		$this->_Keyword = new KeywordModel();
	}
	public function indexAction(){
		$this->_View->keyword = $this->_Keyword->getAll();
		$this->_View->printpage = $this->_Keyword->PrintPage;
	}
	public function AddAction(){
		if ($this->_Request->isPost()){
			if ($this->_Keyword->Add($this->_Request->getPost())===false){
				$this->_View->message = $this->_Keyword->error;
			}else{
				$this->_View->message = _('添加成功!');
			}
			exit($this->_View->render('message'));
		}
	}
	public function deleteAction(){
		if ($this->_Request->getParams('id')){
			$this->_Keyword->delete($this->_Request->getParams('id'));
			$this->_View->message = _('删除成功!');
			exit($this->_View->render('message'));
		}
	}
	public function modifyAction(){
		$id = $this->_Request->getParam('id');
		$this->_View->modify = $this->_Keyword->getRow(array('id'=>$id));
		if ($this->_Request->isPost()){
			if ($this->_Keyword->modify($this->_Request->getPost())===false){
				$this->_View->message = $this->_Keyword->error;
			}else{
				$this->_View->message = _('修改成功!');
			}
			exit($this->_View->render('message'));
		}
	}
}?>