插件配置列表页面数组信息:
/**
* 配置列表页面
* @var unknown_type
*/
public $admin_list = array(
'listKey' => array(
'title'=>'标题',
'create_time'=>'创建时间',
'push_status' =>'推送状态',
),
'model'=>'Document',
'order'=>'id desc',
'map' =>array(
'id' => array('gt', 0),
'status' => array('eq', 1),
'push_status' => array('eq', 0)
),
);
插件模型内容:
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ischambers <979898167.qq.com>
// +----------------------------------------------------------------------
namespace Addons\Document\Model;
use Think\Model;
/**
* 分类模型
*/
class DocumentModel extends Model{
/* 自动完成规则 */
protected $_auto = array(
array('create_time', 'getCreateTime', self::MODEL_BOTH,'callback'),
array('push_status', 'getStatus', self::MODEL_BOTH, 'callback'),
);
protected function _after_find(&$result,$options) {
$result['create_time'] = date('Y-m-d', $result['create_time']);
$result['push_status'] = $result['push_status']?'已经推送':'未推送';
}
protected function _after_select(&$result,$options){
foreach($result as &$record){
$this->_after_find($record,$options);
}
}
/* 时间处理规则 */
protected function getCreateTime(){
$create_time = I('post.create_time');
return $create_time?strtotime($create_time):NOW_TIME;
}
}
插件控制器内容:
/**
* @Author: ischambers
* @Date: 2018-01-05 03:54:22
* @Last Modified by: Administrator
* @Last Modified time: 2018-01-11 00:08:08
*/
namespace Addons\Document\Controller;
use Admin\Controller\AddonsController;
class DocumentController extends AddonsController{
public function push(){
$ids = I('request.ids');
if(empty($ids)){
$this->error('请选择要操作的数据');
}
$map['id'] = array('in',$ids);
}
}