From 589b5f9e19adaa407e267b0d285e29d10be6d9ba Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Mon, 11 Feb 2019 23:09:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=94=A8=E9=85=8D=E7=BD=AE=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/controller/Plugins.php | 2 +- .../Commontopmaxpicture.php | 19 +++--- application/service/PluginsService.php | 58 +++++++++++++++---- application/tags.php | 8 +-- config/shopxo.sql | 11 +--- 5 files changed, 65 insertions(+), 33 deletions(-) diff --git a/application/admin/controller/Plugins.php b/application/admin/controller/Plugins.php index f5b1eacaf..34be1ea91 100644 --- a/application/admin/controller/Plugins.php +++ b/application/admin/controller/Plugins.php @@ -80,7 +80,7 @@ class Plugins extends Common ); $data = PluginsService::PluginsList($data_params); $this->assign('data_list', $data['data']); - + return $this->fetch(); } diff --git a/application/plugins/commontopmaxpicture/Commontopmaxpicture.php b/application/plugins/commontopmaxpicture/Commontopmaxpicture.php index ffbafa3cf..0b8c43ee1 100644 --- a/application/plugins/commontopmaxpicture/Commontopmaxpicture.php +++ b/application/plugins/commontopmaxpicture/Commontopmaxpicture.php @@ -123,23 +123,24 @@ class Commontopmaxpicture extends Controller { // 基础信息 $base = [ - 'author' => 'Devil', - 'blog' => 'http://gong.gg', 'name' => '顶部广告', + 'author' => 'Devil', + 'author_url' => 'https://shopxo.net/', 'version' => '1.0.0', + 'desc' => '顶部大图广告,突破视觉', + 'apply_terminal'=> ['pc'], + 'apply_version' => ['1.3.0'], 'sales_amount' => 0, ]; - // 控制器钩子 - $control_hook = [ - 'plugins_control_hook' => [ - 'plugins_common_top' => ['app\\plugins\\commontopmaxpicture\\CommonTopMaxPicture'], - ], + // 钩子 + $hook = [ + 'plugins_common_top' => ['app\\plugins\\commontopmaxpicture\\Commontopmaxpicture'], ]; return [ - 'base' => $base, - 'control_hook' => $control_hook, + 'base' => $base, + 'hook' => $hook, ]; } diff --git a/application/service/PluginsService.php b/application/service/PluginsService.php index 838d54854..dcbc35de7 100644 --- a/application/service/PluginsService.php +++ b/application/service/PluginsService.php @@ -55,21 +55,36 @@ class PluginsService */ private static function PluginsDataHandle($data) { + $result = []; if(!empty($data)) { - foreach($data as &$v) + foreach($data as $v) { - // 基础数据 - $v['logo_old'] = $v['logo']; - $v['logo'] = ResourcesService::AttachmentPathViewHandle($v['logo']); - $v['apply_terminal'] = empty($v['apply_terminal']) ? '' : json_decode($v['apply_terminal'], true); - - // 时间 - $v['add_time_time'] = date('Y-m-d H:i:s', $v['add_time']); - $v['add_time_date'] = date('Y-m-d', $v['add_time']); + $config = self::GetPluginsConfig($v['plugins']); + if($config !== false) + { + $base = $config['base']; + $result[] = [ + 'id' => $v['id'], + 'plugins' => $v['plugins'], + 'logo_old' => $v['logo'], + 'logo' => ResourcesService::AttachmentPathViewHandle($v['logo']), + 'is_enable' => $v['is_enable'], + 'name' => isset($base['name']) ? $base['name'] : '', + 'author' => isset($base['author']) ? $base['author'] : '', + 'author_url' => isset($base['author_url']) ? $base['author_url'] : '', + 'version' => isset($base['version']) ? $base['version'] : '', + 'desc' => isset($base['desc']) ? $base['desc'] : '', + 'apply_version' => isset($base['apply_version']) ? $base['apply_version'] : [], + 'apply_terminal'=> isset($base['apply_terminal']) ? $base['apply_terminal'] : [], + 'add_time_time' => date('Y-m-d H:i:s', $v['add_time']), + 'add_time_date' => date('Y-m-d', $v['add_time']), + ]; + } } } - return $data; + + return $result; } /** @@ -234,5 +249,28 @@ class PluginsService return DataReturn('删除失败或资源不存在', -100); } + + /** + * 获取应用配置信息 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2018-09-17 + * @desc description + * @param [string] $plugins [应用名称] + */ + private static function GetPluginsConfig($plugins) + { + $plugins = '\app\plugins\\'.$plugins.'\\'.ucfirst($plugins); + if(class_exists($plugins)) + { + $obj = new $plugins(); + if(method_exists($obj, 'config')) + { + return $obj->config(); + } + } + return false; + } } ?> \ No newline at end of file diff --git a/application/tags.php b/application/tags.php index 46d2a6d22..bac468623 100755 --- a/application/tags.php +++ b/application/tags.php @@ -1,12 +1,12 @@ +// | Author: Devil // +---------------------------------------------------------------------- // 应用行为扩展定义文件 @@ -27,6 +27,6 @@ return [ 'app_end' => [], // 钩子测试 - 'plugins_common_top' => ['app\\plugins\\commontopmaxpicture\\CommonTopMaxPicture'], + 'plugins_common_top' => ['app\\plugins\\commontopmaxpicture\\Commontopmaxpicture'], ]; ?> \ No newline at end of file diff --git a/config/shopxo.sql b/config/shopxo.sql index e004c12ad..78517900d 100644 --- a/config/shopxo.sql +++ b/config/shopxo.sql @@ -9,7 +9,7 @@ Target Server Version : 50716 File Encoding : utf-8 - Date: 02/09/2019 14:49:20 PM + Date: 02/11/2019 23:08:30 PM */ SET NAMES utf8; @@ -808,16 +808,9 @@ CREATE TABLE `s_payment` ( DROP TABLE IF EXISTS `s_plugins`; CREATE TABLE `s_plugins` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增id', - `name` char(30) NOT NULL COMMENT '名称', `plugins` char(60) NOT NULL DEFAULT '' COMMENT '唯一标记', `logo` char(255) NOT NULL DEFAULT '' COMMENT 'logo', - `version` char(255) NOT NULL DEFAULT '' COMMENT '版本', - `apply_version` char(255) NOT NULL DEFAULT '' COMMENT '适用系统版本', - `desc` char(255) NOT NULL DEFAULT '' COMMENT '描述', - `author` char(255) NOT NULL DEFAULT '' COMMENT '作者', - `author_url` char(255) NOT NULL DEFAULT '' COMMENT '作者主页', `data` text COMMENT '应用数据', - `apply_terminal` char(255) NOT NULL COMMENT '适用终端 php一维数组json字符串存储(pc, wap, app, alipay, weixin, baidu)', `is_enable` tinyint(1) unsigned NOT NULL DEFAULT '1' COMMENT '是否启用(0否,1是)', `add_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '添加时间', `upd_time` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', @@ -830,7 +823,7 @@ CREATE TABLE `s_plugins` ( -- Records of `s_plugins` -- ---------------------------- BEGIN; -INSERT INTO `s_plugins` VALUES ('1', '顶部大图广告', 'commontopmaxpicture', 'http://tp5-dev.com/static/upload/images/plugins_commontopmaxpicture/2019/02/09/1549671733987654.png', '1.0.0', '1.3.0', '顶部大图广告,突破视觉', 'Devil', 'https://shopxo.net/', '{\"images\":\"http:\\/\\/tp5-dev.com\\/static\\/upload\\/images\\/plugins_commontopmaxpicture\\/2019\\/02\\/09\\/1549671733978860.jpg\",\"bg_color\":\"#ce0000\",\"url\":\"https:\\/\\/shopxo.net\",\"is_new_window_open\":\"1\",\"is_overall\":\"1\",\"time_start\":\"\",\"time_end\":\"\"}', '{\\\"pc\\\"}', '1', '0', '1549694936'); +INSERT INTO `s_plugins` VALUES ('1', 'commontopmaxpicture', 'http://tp5-dev.com/static/upload/images/plugins_commontopmaxpicture/2019/02/09/1549671733987654.png', '{\"images\":\"http:\\/\\/tp5-dev.com\\/static\\/upload\\/images\\/plugins_commontopmaxpicture\\/2019\\/02\\/09\\/1549671733978860.jpg\",\"bg_color\":\"#ce0000\",\"url\":\"https:\\/\\/shopxo.net\",\"is_new_window_open\":\"1\",\"is_overall\":\"1\",\"time_start\":\"\",\"time_end\":\"\"}', '0', '0', '1549897473'); COMMIT; -- ----------------------------