i漂泊

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 3782|回复: 0

[升级计划] 好团队插件开发工具之组件升级脚本书写方法

[复制链接]
TA的礼物信息
  • 收到:0
  • 送出:2
发表于 2015-12-16 09:26:11 | 显示全部楼层 |阅读模式
  我们为了满足开发者对组件模块的需求,特在
  1. check.php
复制代码
放置了一个函数来为开发者提供升级 脚本需求:
  1. CheckModule($plugname);
复制代码


那么我们现在来看下他的完整代码:
  1. function CheckModule($plugname, $infiles) {
  2.     if (!check_developer($plugname)) {
  3.         haoteam_validator($plugname . '.plugin', 0, array('check', 'install', 'upgrade', 'vars.func'));
  4.     }
  5.     $dir = DISCUZ_ROOT . 'source/plugin/' . $plugname . '/install';
  6.     if (!isset($infiles))
  7.         $infiles = array('install_import_module');
  8.     $file = FileLists($dir, $infiles);
  9.     if (is_array($file)) {
  10.         foreach ($file as $value) {
  11.             if (file_exists($value))
  12.                 require_once $value;
  13.             if ($piaobo_upgrade)
  14.                 @unlink($value);
  15.         }
  16.     }else {
  17.         if (file_exists($file))
  18.             require_once $file;
  19.         if ($piaobo_upgrade)
  20.             @unlink($file);
  21.     }
  22. }
复制代码
这段代码说明我们的组件升级脚本必须放置在install目录中文件名必须含有
  1. install_import_module
复制代码
同时我们在install文件夹下放置了案例代码:
  1. source\admincp\drk_tool\install\install_import_module.php
复制代码

大致书写代码为:
  1. <?php

  2. /*
  3. * CopyRight  : [Discuz!] (C)2001-2099 HaoTeam Inc.
  4. * Document   : install_xx.php
  5. * Created on : 2014-3-20,19:54:48
  6. * Author     : 51漂泊(51piaobo) www.51piaobo.com $
  7. * Remarks    :安装时存在模块的
  8. * Description: This is NOT a freeware, use is subject to license terms.
  9. *              这即使是一个免费软件,使用时也请遵守许可证条款,得到当时人书面许可。
  10. *              未经书面许可,不得翻版,翻版必究;版权归属51漂泊;
  11. */

  12. if (!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  13.     exit('Access Denied');
  14. }

  15. global $_G;
  16. //Start 创建数据表
  17. /*
  18. $table = DB::table('piaobo_im_task');
  19. if (!check_table_is_exist($table)) {
  20.     $table_tmp = str_ireplace($_G['config']['db'][1]['tablepre'], '', $table);
  21.     $tmp = explode('_', $table);
  22.     if ($_G['config']['db'][1]['tablepre'] == $tmp[0])
  23.         $table_tmp = $tmp[0] . $table_tmp;
  24.     require_once DISCUZ_ROOT . 'source/plugin/' . $pname . '/install/install_' . $table_tmp . '.php';
  25.     if ($piaobo_install)
  26.         @unlink(DISCUZ_ROOT . 'source/plugin/' . $pname . '/install/install_' . $table_tmp . '.php');
  27. }
  28. loadcache($pname . '_tables');
  29. $tbs = $_G['cache'][$pname . '_tables'];
  30. array_push($tbs, $table);
  31. savecache($pname . '_tables', $tbs);
  32. */
  33. //End 创建数据表

  34. //Start 导入数据
  35. /*
  36. $table = DB::table('piaobo_im_nav');
  37. $sql1 = <<< EOF
  38. INSERT INTO `$table` (`id`,`parentid`,`name`,`keyword`,`path`,`type`,`available`,`displayorder`,`exp`,`isextcredit`,`extcredit`) VALUES ('33','8', '手机归属查询', 'SJ', 'SJ', '3', '1', '8', '~SJ 15800000000', 0, 0);
  39. EOF;
  40. runquery($sql1);
  41. */
  42. //End 导入数据

  43. //Start 导入模块
  44. /*
  45. $sql = C::t('common_plugin')->fetch_by_identifier($plugin['identifier']);
  46. $modules = dunserialize($sql['modules']);
  47. $module = array('name'=>'bulletin',
  48.                 'param'=>'',
  49.                 'menu'=>'@全体',
  50.                 'url'=>'',
  51.                 'type'=>3,
  52.                 'adminid'=>0,
  53.                 'displayorder'=>8,
  54.                 'navtitle'=>'',
  55.                 'navicon'=>'',
  56.                 'navsubname'=>'',
  57.                 'navsuburl'=>''
  58.         );
  59. array_push($modules,$module);
  60. C::t('common_plugin')->update($pluginid,$modules);
  61. */
  62. //End 导入模块

  63. //Start 导入参数
  64. /*
  65. C::t('common_pluginvar')->insert(array('pluginid',
  66.                                         'displayorder',
  67.                                         'title',
  68.                                         'description',
  69.                                         'variable',
  70.                                         'type',
  71.                                         'value',
  72.                                         'extra'
  73.                                     ));
  74. */
  75. //End 导入参数
  76. ?>
复制代码

回复

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

QQ|小黑屋|手机版|IPiaoBo Inc. ( 渝ICP备17002826号 )

GMT+8, 2024-4-27 11:43 , Processed in 0.078115 second(s), 47 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表