Пример #1
0
 public function install()
 {
     $u = new Utility();
     $u->dbRunQuery(trim($this->installSql));
     $this->addon->pasteBenchEntry('接入第三方微信平台', 'connect/weixin', '可以用于对接已有的第三方微信公众号平台');
     return true;
 }
Пример #2
0
 public function remove($id)
 {
     $platform = $this->getOne($id);
     if (empty($platform)) {
         return error(-1, '访问错误');
     }
     $this->table('__BR_BRIDGES__')->where("`id`='{$id}'")->delete();
     return $this->addon->unRegister($id);
 }
Пример #3
0
 public static function run($params)
 {
     C('FRAME_ACTIVE', 'addons');
     $params['Addon'] = parse_name($params['Addon'], 1);
     $params['Entry'] = parse_name($params['Entry'], 1);
     $params['Controller'] = parse_name($params['Controller'], 1);
     $params['Action'] = parse_name($params['Action'], 1);
     $a = new Addon($params['Addon']);
     define('ADDON_NAME', $params['Addon']);
     define('ADDON_CURRENT_PATH', MB_ROOT . "addons/{$params['Addon']}/");
     C('ADDON_INSTANCE', $a);
     C('TMPL_PARSE_STRING.__ADDON_PUBLIC__}', __SITE__ . "addons/{$params['Addon']}/static/");
     Addon::autoload();
     $class = "Addon\\{$params['Addon']}\\{$params['Entry']}\\Controller\\{$params['Controller']}Controller";
     if (class_exists($class)) {
         $instance = new $class($params, $a);
         $method = $params['Action'] . C('ACTION_SUFFIX');
         if (method_exists($instance, $method)) {
             call_user_func(array($instance, $method));
         } else {
             return error(-2, "访问的操作 {$params['Addon']}\\{$params['Entry']}\\{$params['Controller']}Controller\\{$params['Action']} 不存在.");
         }
     } else {
         return error(-1, "访问的控制器 {$params['Addon']}\\{$params['Entry']}\\{$params['Controller']}Controller 不存在.");
     }
 }
 public function _empty()
 {
     $pieces = explode('/', __INFO__, 6);
     if (count($pieces) >= 5 && $pieces[0] == 'bench' && $pieces[1] == 'extend') {
         $params = array();
         list($params['Entry'], $action, $params['Addon'], $params['Controller'], $params['Action'], $params['Stuff']) = $pieces;
         unset($_GET[$params['Controller']]);
         $ret = Addon::run($params);
         if (is_error($ret)) {
             $this->error($ret['message']);
         }
         return;
     }
     $name = parse_name(ACTION_NAME, 1);
     $a = new Addon($name);
     $entries = $a->getEntries(Addon::ENTRY_BENCH);
     $this->assign('entity', $a->getCurrentAddon());
     $this->assign('entries', $entries);
     C('FRAME_ACTIVE', 'extend');
     C('FRAME_CURRENT', U('bench/extend/' . ACTION_NAME));
     $this->display('Extend/addon');
 }
 public function _empty()
 {
     $pieces = explode('/', __INFO__, 5);
     if (count($pieces) >= 4 && $pieces[0] == 'extend') {
         $params = array();
         $params['Entry'] = 'App';
         list($action, $params['Addon'], $params['Controller'], $params['Action'], $params['Stuff']) = $pieces;
         unset($_GET[$params['Controller']]);
         $ret = Addon::run($params);
         if (is_error($ret)) {
             $this->error($ret['message']);
         }
         return;
     }
 }
 private function route($message)
 {
     // session 启动会话支持
     $sessionid = md5($message['from'] . $message['to']);
     session_id($sessionid);
     session_start();
     Addon::autoload();
     $p = new Processor();
     if ($message['type'] == Platform::MSG_TEXT) {
         $packet = $p->procText($message);
     } else {
         $packet = $p->procOther($message);
     }
     //Log::write(var_export($packet, true), Log::INFO);
     $resp = $this->platform->response($packet);
     exit($resp);
 }
 public function addonsAction()
 {
     $addons = array();
     $path = MB_ROOT . 'addons/';
     if (is_dir($path)) {
         if ($handle = opendir($path)) {
             while (false !== ($addonpath = readdir($handle))) {
                 if ($addonpath != '.' && $addonpath != '..') {
                     $define = Addon::getAddon($addonpath, true);
                     if (!is_error($define)) {
                         $addons[] = $define;
                     }
                 }
             }
         }
     }
     if (IS_POST) {
         $a = I('post.addon');
         $addons = coll_key($addons, 'name');
         $addon = $addons[$a];
         if (!empty($addon)) {
             $zip = new \ZipArchive();
             $tmpFile = ADDON_CURRENT_PATH . 'Data/package.zip';
             @unlink($tmpFile);
             $zip->open($tmpFile, \ZipArchive::CREATE);
             $root = MB_ROOT . "addons/{$a}";
             $files = File::tree($root);
             foreach ($files as $file) {
                 $local = substr($file, strlen($root));
                 if (substr($local, -4) == '.php') {
                     if (I('post.trim') != '') {
                         $content = $this->trimComments($file, I('post.license'));
                     }
                     $zip->addFromString("{$a}{$local}", $content);
                 } else {
                     $zip->addFile($file, "{$a}{$local}");
                 }
             }
             $zip->close();
             $version = MB_VERSION;
             $filename = "{$a}-v{$addon['version']} (for MB-{$version})";
             header('content-type: application/zip');
             header('content-disposition: attachment; filename="' . $filename . '.zip"');
             readfile($tmpFile);
             @unlink($tmpFile);
         }
     }
     $this->assign('addons', $addons);
     $this->display('addons');
 }
Пример #8
0
 public function U($url = '', $vars = '')
 {
     $entry = strtolower(MODULE_NAME);
     return $this->addon->U($entry, $url, $vars);
 }
 public function run(&$params)
 {
     Site::loadSettings();
     if (MODULE_NAME == 'Bench') {
         $theme = I('cookie.template_theme');
         $themes = array('cerulean', 'cyborg', 'simplex', 'darkly', 'lumen', 'slate', 'spacelab', 'united');
         if (!empty($theme) && in_array($theme, $themes)) {
             C('TMPL_PARSE_STRING.{__TEMPLATE_THEME__}', '-' . $theme);
         }
         $frames = $this->getBenchFrames();
         $name = C('FRAME_ACTIVE');
         $names = array();
         $names[] = 'summary';
         $names[] = 'cms';
         $names[] = 'uc';
         $names[] = 'extend';
         $names[] = 'addons';
         $names[] = 'analyze';
         $name = in_array($name, $names) ? $name : 'summary';
     }
     if (MODULE_NAME == 'Control') {
         $frames = $this->getControlFrames();
         $name = C('FRAME_ACTIVE');
         $names = array();
         $names[] = 'common';
         $names[] = 'webapp';
         $names[] = 'member';
         $names[] = 'access';
         $names[] = 'extend';
         $names[] = 'addons';
         $names[] = 'store';
         $name = in_array($name, $names) ? $name : 'common';
     }
     $allAddons = array();
     if ($name == 'extend') {
         $types = Addon::types();
         foreach ($types as $type) {
             $addons = Addon::getAddons($type['name']);
             $allAddons = array_merge($allAddons, coll_key($addons, 'name'));
             $items = array();
             if (!empty($addons)) {
                 foreach ($addons as $a) {
                     $addon = new Addon($a);
                     $entryType = strtolower(MODULE_NAME);
                     $entries = $addon->getEntries($entryType);
                     if (!empty($entries)) {
                         $addonName = parse_name($a['name']);
                         $items[] = array('icon' => 'plus', 'title' => $a['title'], 'url' => U("/{$entryType}/extend/{$addonName}"));
                     }
                 }
             }
             if (!empty($items)) {
                 $frames['extend'][] = array('title' => $type['title'], 'items' => $items);
             }
         }
     }
     if ($name == 'addons') {
         if (defined('ADDON_NAME')) {
             $a = C('ADDON_INSTANCE');
             $addon = $a->getCurrentAddon();
             $entries = $a->getEntries(strtolower(MODULE_NAME));
             $items = array();
             foreach ($entries as $entry) {
                 $items[] = array('icon' => 'plus', 'url' => $entry['url'], 'title' => $entry['title']);
             }
             $frames['addons'][] = array('title' => $addon['title'], 'items' => $items);
         }
     }
     C('FRAME_ACTIVE', $name);
     $set = $frames[$name];
     $url = C('FRAME_CURRENT');
     if (empty($url)) {
         $url = $_SERVER['REQUEST_URI'];
         C('FRAME_CURRENT', $url);
     }
     foreach ($set as &$row) {
         foreach ($row['items'] as &$item) {
             if ($item['url'] == $url) {
                 $item['current'] = true;
                 if (!C('FRAME_TITLE')) {
                     C('FRAME_TITLE', $item['title']);
                 }
             }
             if (!empty($item['items'])) {
                 foreach ($item['items'] as &$sub) {
                     if ($sub['url'] == $url) {
                         $sub['current'] = true;
                         if (!C('FRAME_TITLE')) {
                             C('FRAME_TITLE', $sub['title']);
                         }
                     }
                 }
             }
         }
     }
     C('FRAME_SETS', $set);
 }
Пример #10
0
 public function install()
 {
     $this->addon->pasteControlEntry('发布微构系统', 'publish/exec', '将当前运行代码发行为特定版本');
     $this->addon->pasteControlEntry('发布扩展', 'publish/addons', '打包指定的模块');
     return true;
 }
 public function uninstallAction()
 {
     $a = I('get.addon');
     if (empty($a)) {
         $this->error('访问错误');
     }
     $addon = new Addon($a);
     Addon::autoload();
     $class = "Addon\\{$a}\\Api\\Application";
     if (class_exists($class)) {
         $instance = new $class();
         if (!empty($instance)) {
             $instance->addon = $addon;
             if (method_exists($instance, 'install')) {
                 $instance->uninstall();
             }
         }
     }
     $condition = '`name`=:name';
     $pars = array();
     $pars[':name'] = $a;
     $m = new Model();
     $m->table('__EX_ADDONS__')->where($condition)->bind($pars)->delete();
     $m->table('__EX_ADDON_ENTRIES__')->where('`addon`=:name')->bind($pars)->delete();
     $m->table('__RP_PROCESSORS__')->where('`from`=:name')->bind($pars)->delete();
     $m->table('__RP_REPLIES__')->where('`from`=:name')->bind($pars)->delete();
     $this->success('扩展卸载成功');
 }