当前位置: 首页>>代码示例>>PHP>>正文


PHP PluginRegistry::activate_plugin_from_dirname方法代码示例

本文整理汇总了PHP中PluginRegistry::activate_plugin_from_dirname方法的典型用法代码示例。如果您正苦于以下问题:PHP PluginRegistry::activate_plugin_from_dirname方法的具体用法?PHP PluginRegistry::activate_plugin_from_dirname怎么用?PHP PluginRegistry::activate_plugin_from_dirname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PluginRegistry的用法示例。


在下文中一共展示了PluginRegistry::activate_plugin_from_dirname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: init

 function init()
 {
     trace('Enter');
     // Select a supported language.
     if ($_SERVER['HTTP_ACCEPT_LANGUAGE']) {
         $langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
         foreach ($langs as $current) {
             if (strstr($current, '-')) {
                 $both = explode('-', $current);
                 $current = $both[0] . '_' . strtoupper($both[1]);
             }
             $best = $this->_get_language($current);
             if ($best) {
                 $lang = $best;
                 break;
             }
         }
     }
     // Fallback to the default language.
     if (!$lang || !preg_match('/^[a-z_]*$/i', $lang)) {
         $lang = cfg('default_language');
     }
     // Init gettext.
     if (!function_exists('gettext')) {
         die('This webserver does not have gettext installed.<br/>' . 'Please contact your webspace provider.');
     }
     $locale_dir = './language/';
     $domain = 'freech';
     putenv("LANG={$lang}.UTF-8");
     @setlocale(LC_ALL, '');
     bindtextdomain($domain, $locale_dir);
     textdomain($domain);
     bind_textdomain_codeset($domain, 'UTF-8');
     trace('Gettext initialized');
     // Start the PHP session.
     session_set_cookie_params(time() + cfg('login_time'));
     if ($_COOKIE['permanent_session']) {
         session_id($_COOKIE['permanent_session']);
         session_start();
     } else {
         session_start();
         if (strtoupper($_POST['permanent']) === 'ON') {
             setcookie('permanent_session', session_id(), time() + cfg('login_time'));
         }
     }
     trace('Session started');
     // Only now start the timer, as cookie handling may scew the result.
     $this->start_time = microtime(TRUE);
     // (Ab)use a Trackable as an eventbus.
     $this->eventbus = new Trackable();
     $this->actions = array();
     $this->views = array();
     $this->current_user = NULL;
     $this->current_forum = NULL;
     $this->links = array('forum' => new Menu(), 'page' => new Menu(), 'search' => new Menu(), 'view' => new Menu(), 'footer' => new Menu(), 'account' => new Menu(), 'breadcrumbs' => new Menu());
     trace('Eventbus created');
     // Connect to the DB.
     $dbn = cfg('db_dbn');
     if (cfg('persistent_db_connection')) {
         $dbn .= '?persist';
     }
     $this->db = ADONewConnection($dbn) or die('FreechForum::FreechForum(): Error: Can\'t connect.' . ' Please check username, password and hostname.');
     if (cfg('db_debug', FALSE)) {
         // enable AdoDB debug mode
         $this->db->debug = true;
     }
     global $ADODB_FETCH_MODE;
     $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
     trace('DB connection opened');
     $this->forumdb = new ForumDB($this->api);
     trace('ForumDB set up');
     $registry = new PluginRegistry();
     trace('Plugin registry initialized');
     foreach (cfg('plugins') as $plugin => $active) {
         if ($active) {
             $registry->activate_plugin_from_dirname('plugins/' . $plugin, $this->api);
         }
     }
     trace('Plugins activated');
     $this->_handle_cookies();
     trace('Cookies initialized');
     // Initialize the visitordb after cookie handling to prevent useless
     // updates.
     if (!cfg('disable_visitor_counter')) {
         require 'services/visitordb.class.php';
         $this->visitordb = new VisitorDB($this->db);
         trace('VisitorDB initialized');
         $this->visitordb->count();
     }
     trace('Visitor counted');
     /* Plugin hook: on_construct
      *   Called from within the FreechForum() constructor before any
      *   other output is produced.
      *   The return value of the callback is ignored.
      *   Args: None.
      */
     $this->eventbus->emit('on_construct', $this->api);
     trace('on_construct calls completed.');
     // Attempt to login, if requested.
     $this->login_error = 0;
//.........这里部分代码省略.........
开发者ID:useada,项目名称:freech-1,代码行数:101,代码来源:main_controller.class.php


注:本文中的PluginRegistry::activate_plugin_from_dirname方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。