php可扩展的百度熊掌号推送插件,在onethink中实现的插件
基于thinkphp开发的onethink文章管理系统,想要实现推送文章到百度熊掌号,所以直接利用onethink插件创建功能快速的弄出来了,发送文章逻辑已经写过一篇文章了。
应用介绍
插件名称:文章推送
插件标识:Document(和系统文章系统模型名称同名,不影响)
插件基本信息(创建插件的时候会自动生成,没有过多自定义配置,需要更复杂功能自行下载扩展):
return array(
'random'=>array(//配置在表单中的键名 ,这个会是config[random]
'title'=>'是否开启随机:',//表单的文字
'type'=>'radio',//表单的类型:text、textarea、checkbox、radio、select等
'options'=>array(//select 和radion、checkbox的子选项
'1'=>'开启',//值=>文字
'0'=>'关闭',
),
'value'=>'1', //表单的默认值
),
);
插件路径:
public $addon_path = './Addons/Document/';
插件信息(插件标识,插件名称,插件描述,插件状态,插件作者,插件版本):
public $info = array(
'name'=>'Document',
'title'=>'文章推送',
'description'=>'文章推送插件',
'status'=>1,
'author'=>'无名',
'version'=>'0.1'
);
插件后台列表模板配置:
public $custom_adminlist = 'adminlist.html';
插件配置列表页面数组信息:
/**
* 配置列表页面
* @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)
),
);
插件模型内容:
<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ischambers <979898167.qq.com> <http://www.dianthink.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;
}
}
插件控制器内容:
<?php
/**
* @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);
}
}
©软件著作权归作者所有。本站所有软件均来源于网络,仅供学习使用,请支持正版!
转载请注明出处: 我的网站 » php可扩展的百度熊掌号推送插件,在onethink中实现的插件
发表评论 取消回复