<?php

class tagAction  extends BackendAction
{

    public function _initialize() {
        parent::_initialize();
        $this->_mod = D('tag');
    }

    public function _before_index() {
        $big_menu = array(
            'title' => '添加标签',
            'iframe' => U('tag/add'),
            'id' => 'add',
            'width' => '400',
            'height' => '130'
        );
        $this->assign('big_menu', $big_menu);
    }
    
	
    protected function _search() {
        $map = array();		
        ($keyword = $this->_request('keyword', 'trim')) && $map['k'] = array('like', '%'.$keyword.'%');
        $this->assign('search', array(
            'keyword' => $keyword			
        ));
        return $map;
    }

    protected function _before_insert($data) {
        if($this->_mod->where(array('k'=>$data['k']))->find()){
		$this->ajaxReturn(0, '数据重复添加！');		
		}else{
		return $data;	
		}
        
    }

    
}