/** * Boots the Helper. */ public static function boot() { self::$base = plugin_directory(); self::$base = self::$base . '/' . basename(plugin_dir_url(__DIR__)) . '/'; self::$config = @(require self::$base . '/herbert.config.php'); self::$booted = true; }
function process() { if (!$this->dir_delete(DOKU_PLUGIN . plugin_directory($this->manager->plugin))) { $this->manager->error = sprintf($this->lang['error_delete'], $this->manager->plugin); } else { msg("Plugin {$this->manager->plugin} successfully deleted."); $this->refresh(); } }
private function __construct() { $paths = array(plugin_directory() . '/Entity'); $isDevMode = false; $dbParams = array('driver' => 'pdo_mysql', 'user' => DB_USER, 'password' => DB_PASSWORD, 'dbname' => DB_NAME); $config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode); $this->entityManager = EntityManager::create($dbParams, $config); $tablePrefix = new TablePrefix($GLOBALS['table_prefix']); // set le prefix des tables, identique a la config de WP $this->entityManager->getEventManager()->addEventListener(\Doctrine\ORM\Events::loadClassMetadata, $tablePrefix); }
/** * load default settings for plugins and templates */ function get_plugintpl_default($tpl) { $file = '/conf/default.php'; $default = array(); foreach ($this->get_plugin_list() as $plugin) { $plugin_dir = plugin_directory($plugin); if (@file_exists(DOKU_PLUGIN . $plugin_dir . $file)) { $conf = array(); @(include DOKU_PLUGIN . $plugin_dir . $file); foreach ($conf as $key => $value) { $default['plugin' . CM_KEYMARKER . $plugin . CM_KEYMARKER . $key] = $value; } } } // the same for the active template if (@file_exists(DOKU_TPLINC . $file)) { $conf = array(); @(include DOKU_TPLINC . $file); foreach ($conf as $key => $value) { $default['tpl' . CM_KEYMARKER . $tpl . CM_KEYMARKER . $key] = $value; } } return $default; }
/** * return a list (name & type) of all the component plugins that make up this plugin * * @todo can this move to pluginutils? */ function get_plugin_components($plugin) { global $plugin_types; $components = array(); $path = DOKU_PLUGIN . plugin_directory($plugin) . '/'; foreach ($plugin_types as $type) { if (@file_exists($path . $type . '.php')) { $components[] = array('name' => $plugin, 'type' => $type); continue; } if ($dh = @opendir($path . $type . '/')) { while (false !== ($cp = readdir($dh))) { if ($cp == '.' || $cp == '..' || strtolower(substr($cp, -4)) != '.php') { continue; } $components[] = array('name' => $plugin . '_' . substr($cp, 0, -4), 'type' => $type); } closedir($dh); } } return $components; }
function plugin_readlog($plugin, $field) { static $log = array(); $file = DOKU_PLUGIN . plugin_directory($plugin) . '/manager.dat'; if (!isset($log[$plugin])) { $tmp = @file_get_contents($file); if (!$tmp) { return ''; } $log[$plugin] =& $tmp; } if ($field == 'ALL') { return $log[$plugin]; } $match = array(); if (preg_match_all('/' . $field . '=(.*)$/m', $log[$plugin], $match)) { return implode("\n", $match[1]); } return ''; }
/** * load metadata for page metadata * * @return array metadata of properties */ function get_metatype() { $file = '/conf/metatypes.php'; $class = '/conf/meta.class.php'; $metatype = array(); foreach ($this->get_plugin_list() as $plugin) { $plugin_dir = plugin_directory($plugin); if (file_exists(DOKU_PLUGIN . $plugin_dir . $file)) { $meta = array(); @(include DOKU_PLUGIN . $plugin_dir . $file); @(include DOKU_PLUGIN . $plugin_dir . $class); foreach ($meta as $key => $value) { $metatype[$key] = $value; } } } return $metatype; }
*/ $herbert = Herbert\Framework\Application::getInstance(); /** * Load all herbert.php files in plugin roots. */ $iterator = new DirectoryIterator(plugin_directory()); foreach ($iterator as $directory) { if (!$directory->valid() || $directory->isDot() || !$directory->isDir()) { continue; } $root = $directory->getPath() . '/' . $directory->getFilename(); if (!file_exists($root . '/herbert.config.php')) { continue; } $config = $herbert->getPluginConfig($root); $plugin = substr($root . '/plugin.php', strlen(plugin_directory())); $plugin = ltrim($plugin, '/'); register_activation_hook($plugin, function () use($herbert, $config, $root) { if (!$herbert->pluginMatches($config)) { $herbert->pluginMismatched($root); } $herbert->pluginMatched($root); $herbert->loadPlugin($config); $herbert->activatePlugin($root); }); register_deactivation_hook($plugin, function () use($herbert, $root) { $herbert->deactivatePlugin($root); }); // Ugly hack to make the install hook work correctly // as WP doesn't allow closures to be passed here register_uninstall_hook($plugin, create_function('', 'herbert()->deletePlugin(\'' . $root . '\');'));