function _import(&$plugin, $autocreate = true, $dispatcher = null) { static $paths; if (!$paths) { $paths = array(); } $result = false; $plugin->type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $plugin->type); $plugin->name = preg_replace('/[^A-Z0-9_\\.-]/i', '', $plugin->name); $base_path = dirname(__FILE__); $path = $base_path . DS . $plugin->type . DS . $plugin->name . '.php'; if (!isset($paths[$path])) { if (file_exists($path)) { //needed for backwards compatibility jimport('joomla.plugin.plugin'); require_once $path; $paths[$path] = true; if ($autocreate) { // Makes sure we have an event dispatcher if (!is_object($dispatcher)) { $dispatcher =& JDispatcher::getInstance(); } $className = 'plg' . $plugin->type . $plugin->name; if (class_exists($className)) { // load plugin parameters $plugin =& JCKPluginsHelper::getPlugin($plugin->type, $plugin->name); // create the plugin $instance = new $className($dispatcher, (array) $plugin); } } } else { $paths[$path] = false; } } }