public function filter_adminhandler_post_loadplugins_main_menu($menu) { $active_plugins = Plugins::get_active(); $submenu_count = 0; foreach ($active_plugins as $pluginobj) { $plugin_actions = array(); $plugin_actions = Plugins::filter_id('plugin_config', $pluginobj->plugin_id(), $plugin_actions, $pluginobj->plugin_id()); foreach ($plugin_actions as $plugin_action => $plugin_action_caption) { if (is_numeric($plugin_action)) { $plugin_action = $plugin_action_caption; } $urlparams = array('page' => 'plugins', 'configure' => $pluginobj->plugin_id(), 'configaction' => $plugin_action); $url = URL::get('admin', $urlparams); switch ($plugin_action_caption) { case _t('?'): break; default: $menu['plugins']['submenu']['plugin_' . ++$submenu_count] = array('url' => $url, 'title' => _t('%1$s: %2$s', array($pluginobj->info->name, $plugin_action_caption)), 'text' => _t('%1$s: %2$s', array($pluginobj->info->name, $plugin_action_caption)), 'access' => true, 'hotkey' => $submenu_count); break; } } } return $menu; }
/** * Gets the deactived plugins and themes * * @todo This makes guesses and is not yet used. * * @return array An array of deactivated plugins, with an empty array() on failure */ public function get_deactives() { $active_plugins = Plugins::get_active(); $deactive_plugins = array(); foreach (Plugins::list_all() as $fname => $fpath) { $id = Plugins::id_from_file($fpath); $info = Plugins::load_info($fpath); if (is_null($info) || is_null($id)) { continue; } //@todo $info differs from get_option_from_name() output, but would be inefficient to use for 300+ plugins if (empty($active_plugins[$id])) { $deactive_plugins[$id] = $info; } } return $deactive_plugins; }
/** * Handles get requests for the system information page. */ public function get_sysinfo() { $sysinfo = array(); $siteinfo = array(); // Assemble Site Info $siteinfo[_t('Habari Version')] = Version::get_habariversion(); if (Version::is_devel()) { $siteinfo[_t('Habari Version')] .= " r" . Version::get_svn_revision(); } $siteinfo[_t('Habari API Version')] = Version::get_apiversion(); $siteinfo[_t('Habari DB Version')] = Version::get_dbversion(); $siteinfo[_t('Active Theme')] = Options::get('theme_name'); $siteinfo[_t('Site Language')] = strlen(Options::get('system_locale')) ? Options::get('system_locale') : 'en-us'; $this->theme->siteinfo = $siteinfo; // Assemble System Info $sysinfo[_t('PHP Version')] = phpversion(); $sysinfo[_t('Server Software')] = $_SERVER['SERVER_SOFTWARE']; $sysinfo[_t('Database')] = DB::get_driver_name() . ' - ' . DB::get_driver_version(); $sysinfo[_t('PHP Extensions')] = implode(', ', get_loaded_extensions()); if (defined('PCRE_VERSION')) { $sysinfo[_t('PCRE Version')] = PCRE_VERSION; } else { // probably PHP < 5.2.4 ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean(); preg_match('/PCRE Library Version.*class="v">(.*)$/mi', $phpinfo, $matches); $sysinfo[_t('PCRE Version')] = $matches[1]; } $sysinfo[_t('Browser')] = $_SERVER['HTTP_USER_AGENT']; $this->theme->sysinfo = $sysinfo; // Assemble Class Info $classinfo = Utils::glob(HABARI_PATH . "/user/classes/*.php"); if (count($classinfo)) { $classinfo = array_map('realpath', $classinfo); } $this->theme->classinfo = $classinfo; // Assemble Plugin Info $raw_plugins = Plugins::get_active(); $plugins = array('system' => array(), 'user' => array(), '3rdparty' => array(), 'other' => array()); foreach ($raw_plugins as $plugin) { $file = $plugin->get_file(); if (preg_match('%[\\\\/](system|3rdparty|user)[\\\\/]plugins[\\\\/]%i', $file, $matches)) { // A plugin's info is XML, cast the element to a string. See #1026. $plugins[strtolower($matches[1])][(string) $plugin->info->name] = $file; } else { $plugins['other'][$plugin->info->name] = $file; } } $this->theme->plugins = $plugins; $this->display('sysinfo'); }
/** * Fill the block. */ public function action_block_content_creditdue($block) { $block->theme_credits = Themes::get_active(); $block->plugin_credits = Plugins::get_active(); }
/** * Handles plugin activation or deactivation. */ public function get_plugin_toggle() { $extract = $this->handler_vars->filter_keys('plugin_id', 'action'); foreach ($extract as $key => $value) { ${$key} = $value; } $plugins = Plugins::list_all(); foreach ($plugins as $file) { if (Plugins::id_from_file($file) == $plugin_id) { switch (strtolower($action)) { case 'activate': if (Plugins::activate_plugin($file)) { $plugins = Plugins::get_active(); Session::notice(_t("Activated plugin '%s'", array($plugins[Plugins::id_from_file($file)]->info->name)), $plugins[Plugins::id_from_file($file)]->plugin_id); } break; case 'deactivate': if (Plugins::deactivate_plugin($file)) { $plugins = Plugins::get_active(); Session::notice(_t("Deactivated plugin '%s'", array($plugins[Plugins::id_from_file($file)]->info->name)), $plugins[Plugins::id_from_file($file)]->plugin_id); } break; default: Plugins::act('adminhandler_get_plugin_toggle_action', $action, $file, $plugin_id, $plugins); break; } } } Utils::redirect(URL::get('admin', 'page=plugins')); }
/** * Handles get requests for the system information page. */ public function get_sysinfo() { $sysinfo = array(); $siteinfo = array(); // Assemble Site Info $siteinfo[_t('Habari Version')] = Version::get_habariversion(); if (Version::is_devel()) { $siteinfo[_t('Habari Version')] .= " " . Version::get_git_short_hash(); } $siteinfo[_t('Habari API Version')] = Version::get_apiversion(); $siteinfo[_t('Habari DB Version')] = Version::get_dbversion(); $siteinfo[_t('Active Theme')] = Options::get('theme_name'); $siteinfo[_t('System Locale')] = HabariLocale::get(); $siteinfo[_t('Cache Class')] = Cache::get_class(); $this->theme->siteinfo = $siteinfo; // Assemble System Info $sysinfo[_t('PHP Version')] = phpversion(); $sysinfo[_t('Server Software')] = $_SERVER['SERVER_SOFTWARE']; $sysinfo[_t('Database')] = DB::get_driver_name() . ' - ' . DB::get_driver_version(); $sysinfo[_t('PHP Extensions')] = implode(', ', get_loaded_extensions()); $sysinfo[_t('PHP Configuration Settings')] = implode("<br>", Utils::get_ini_settings()); if (defined('PCRE_VERSION')) { $sysinfo[_t('PCRE Version')] = PCRE_VERSION; } else { // probably PHP < 5.2.4 ob_start(); phpinfo(8); $phpinfo = ob_get_contents(); ob_end_clean(); preg_match('/PCRE Library Version.*class="v">(.*)$/mi', $phpinfo, $matches); $sysinfo[_t('PCRE Version')] = $matches[1]; } $sysinfo[_t('Browser')] = $_SERVER['HTTP_USER_AGENT']; $this->theme->sysinfo = $sysinfo; // Assemble Class Info $classinfo = Utils::glob(HABARI_PATH . "/user/classes/*.php"); if (count($classinfo)) { $classinfo = array_map('realpath', $classinfo); } $this->theme->classinfo = $classinfo; // Assemble Plugin Info $raw_plugins = Plugins::get_active(); $plugins = array('system' => array(), 'user' => array(), '3rdparty' => array(), 'other' => array()); foreach ($raw_plugins as $plugin) { $file = $plugin->get_file(); // Catch plugins that are symlinked from other locations as ReflectionClass->getFileName() only returns the ultimate file path, not the symlink path, and we really want the symlink path $all_plugins = Plugins::list_all(); $filename = basename($file); if (array_key_exists($filename, $all_plugins) && $all_plugins[$filename] != $file) { $file = $all_plugins[$filename]; } if (preg_match('%[\\\\/](system|3rdparty|user)[\\\\/]plugins[\\\\/]%i', $file, $matches)) { // A plugin's info is XML, cast the element to a string. See #1026. $plugins[strtolower($matches[1])][(string) $plugin->info->name] = $file; } else { // A plugin's info is XML, cast the element to a string. $plugins['other'][(string) $plugin->info->name] = $file; } } $this->theme->plugins = $plugins; $this->theme->admin_page = _t('System Information'); $this->display('sysinfo'); }
/** * Loop through all the active plugins and add their information to the list of plugins to check for updates. */ private static function add_plugins() { $plugins = Plugins::get_active(); foreach ($plugins as $plugin) { // name and version are required in the XML file, make sure GUID is set if (!isset($plugin->info->guid)) { continue; } Update::add($plugin->info->name, $plugin->info->guid, $plugin->info->version); } }
public static function provided($exclude = null) { $active_plugins = Plugins::get_active(); $provided = array(); foreach ($active_plugins as $plugin_id => $plugin) { if ($plugin->info->name == $exclude || $plugin_id == $exclude) { continue; } if (isset($plugin->info->provides)) { foreach ($plugin->info->provides->feature as $provide) { $provided[(string) $provide][] = (string) $plugin->info->name; } } } return Plugins::filter('provided', $provided); }
/** * Get a list of features and the active plugins that provide that feature * @param null|string $exclude A plugin id to exclude from the results * @param bool $include_inactive Default false. If true, include inactive plugins in the list. * @param bool $use_file If true, return a filename as the depenedency. If false (default), return the name of the plugin. * @return array An array with keys of the feature name, values are an array of plugin names providing that feature */ public static function provided($exclude = null, $include_inactive = false, $use_file = false) { if ($include_inactive) { $all_plugins = Plugins::list_all(); $plugin_list = array(); foreach ($all_plugins as $plugin => $plugin_file) { $pdata = new \stdClass(); $pdata->info = self::load_info($plugin_file); $pdata->filename = $plugin_file; $plugin_list[self::id_from_file($plugin_file)] = $pdata; } } else { $plugin_list = Plugins::get_active(); } $provided = array(); foreach ($plugin_list as $plugin_id => $plugin) { if ($plugin->info->name == $exclude || $plugin_id == $exclude) { continue; } if (isset($plugin->info->provides)) { foreach ($plugin->info->provides->feature as $provide) { if ($use_file) { $provided[(string) $provide][] = isset(self::$plugin_files[get_class($plugin)]) ? self::$plugin_files[get_class($plugin)] : $plugin->filename; } else { $provided[(string) $provide][] = (string) $plugin->info->name; } } } } return Plugins::filter('provided', $provided); }