public function plugin($parameter1 = NULL, $parameter2 = NULL)
 {
     switch ($parameter1) {
         case 'showall':
             $return = '';
             $available_plugin = json_decode(available_plugin(), TRUE);
             $plugins = $available_plugin['plugins'];
             foreach ($plugins as $key => $val) {
                 if (is_plugin_active($key)) {
                     $key = '[active] ' . $key;
                 } else {
                     $key = '[deactive] ' . $key;
                 }
                 $return[] = "\t" . $key . "\n";
             }
             return implode('', $return);
             break;
         case 'active':
             if (isset($parameter2)) {
                 $return = disable_plugin('1', $parameter2);
                 $args = json_decode($return, TRUE);
                 return $args['mes'];
             } else {
                 $return = '';
                 $active_plugin = json_decode(list_plugin(1), TRUE);
                 foreach ($active_plugin as $key => $val) {
                     $return[] = "\t" . $val . "\n";
                 }
                 return implode('', $return);
             }
             break;
         case 'deactive':
             if (isset($parameter2)) {
                 return disable_plugin('0', $parameter2);
                 $args = json_decode($return, TRUE);
                 return $args['mes'];
             } else {
                 $return = '';
                 $active_plugin = json_decode(list_plugin(0), TRUE);
                 foreach ($active_plugin as $key => $val) {
                     $return[] = "\t" . $val . "\n";
                 }
                 return implode('', $return);
             }
             break;
         case 'drop':
             if (isset($parameter2)) {
                 return drop_plugin($parameter2);
                 $args = json_decode($return, TRUE);
                 return $args['mes'];
             } else {
                 $mes = _('Vui lòng nhập plugin key muốn xóa');
                 return $mes;
             }
             break;
         default:
             $help = "\tplugin showall : " . _('Hiển thị tất cả plugin hiện có') . "\n" . "\tplugin active : " . _('Hiển thị tất cả plugin đang chạy') . "\n" . "\tplugin active [pluginkey] : " . _('Kích hoạt plugin [pluginkey]') . "\n" . "\tplugin deactive : " . _('Hiển thị tất cả plugin đang tắt') . "\n" . "\tplugin deactive [pluginkey] : " . _('Tắt plugin [pluginkey]') . "\n" . "\tplugin drop [pluginkey]: " . _('Xóa plugin [pluginkey]') . "\n" . "" . "\n";
             return $help;
     }
 }
Example #2
0
/* ------------------------------------------------------ */
if ($_REQUEST['act'] == 'install') {
    /* 安装所有插件 */
    install_plugins();
}
/* ------------------------------------------------------ */
// - 异步 - 插件安装
/* ------------------------------------------------------ */
if ($_REQUEST['act'] == 'uninstall') {
    /* 卸载所有插件 */
    uninstall_plugins();
}
/* ------------------------------------------------------ */
// - 异步 - 插件列表
/* ------------------------------------------------------ */
$tpl['list'] = list_plugin();
/* 加载视图 */
make_json_response(empty($tpl['list']['data']) ? -1 : 0, '', tpl_fetch('sysplugin.html', $tpl));
?>

<?php 
/**
 * 获取所有插件
 * 过滤没有配置文件或者无效配置信息的插件
 */
function all_plugin()
{
    global $_CFG;
    /* 初始化 */
    $plugins = array();
    $fdgroups = array('php', 'javascript');