12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- <?php
- // +----------------------------------------------------------------------
- // | Yzncms [ 御宅男工作室 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2018 http://yzncms.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
- // +----------------------------------------------------------------------
- // | Author: 御宅男 <530765310@qq.com>
- // +----------------------------------------------------------------------
-
- // +----------------------------------------------------------------------
- // | 聚合推送插件
- // +----------------------------------------------------------------------
- namespace addons\weburlpush;
-
- use addons\weburlpush\library\Push;
- use app\common\library\Menu;
- use think\Addons;
-
- class Weburlpush extends Addons
- {
- /**
- * 插件安装方法
- * @return bool
- */
- public function install()
- {
- $menu = [
- [
- "name" => "weburlpush",
- "title" => "百度推送",
- "sublist" => [
- ["name" => "weburlpush/index", "title" => "查看"],
- ["name" => "weburlpush/baidu", "title" => "百度推送"],
- ["name" => "weburlpush/shenma", "title" => "神马推送"],
- ],
- ],
- ];
- Menu::create($menu);
- return true;
- }
-
- /**
- * 插件卸载方法
- * @return bool
- */
- public function uninstall()
- {
- Menu::delete("weburlpush");
- return true;
- }
-
- /**
- * 插件启用方法
- * @return bool
- */
- public function enable()
- {
- Menu::enable("weburlpush");
- return true;
- }
-
- /**
- * 插件禁用方法
- * @return bool
- */
- public function disable()
- {
- Menu::disable("weburlpush");
- return true;
- }
-
- public function weburlpush(Push $push, $params, $extra = null)
- {
- $config = $this->getAddonConfig();
- $urls = is_string($params) ? [$params] : $params;
- $extra = $extra ? $extra : 'push';
- $status = explode(',', $config['status']);
- try {
- foreach ($status as $index => $item) {
- if ($extra == 'push') {
- $push->channel($item)->push($urls);
- }
- }
- } catch (\Exception $e) {
- //$this->error("推送失败:" . $e->getMessage());
- }
- }
-
- }
|