Source for file plugins.php
Documentation is available at plugins.php
* MvBlog -- An open source no-nosense blogtool
* Copyright (C) 2005-2006, Michiel van Baak
* Michiel van Baak <mvanbaak@users.sourceforge.net>
* See http://dev.mvblog.org for more information on MvBlog.
* That page also provides Bugtrackers, Filereleases etc.
* This program is free software, distributed under the terms of
* the GNU General Public License Version 2. See the LICENSE file
* at the top of the source tree.
* @author Michiel van Baak
* @copyright 2005-2006 Michiel van Baak
* Class that holds methods to manage plugins etc.
* @var array $plugins Contains all loaded plugin objects
* @var string $plugindir The directory that holds all the plugins
* Load all plugins into plugins array
* @param string $plugindir The dir to load
/* make sure the dir is set and that it contains sane data */
if (!strlen($plugindir)) die("Plugindir not given");
$plugindir =
str_replace("../../", "", $plugindir); // get rid of ../
$plugindir =
preg_replace("/^\//si", "", $plugindir); // get rid of .
/* check if it is there, if not look 1 level up, not more */
$plugindir =
"../".
$plugindir;
/* read all files and init the objects */
while (false !==
($file =
readdir($handle))) {
if (strpos($file, ".") ===
0) continue; // dont process . .. or hidden files/dirs
/* all files should be: pluginname.php */
$this->plugins[$filename] =
new $filename($mvblog);
// FB: 20070304: Eval isn't needed here. Commented out and replaced
// by the line above. This fixed 'undefined constant' errors.
//eval("\$this->plugins[".$filename."] = new ".$filename."(\$mvblog);");
/* activate_plugin {{{ */
* If the plugin is not loaded, do nothing
* @param string $plugin The plugin name to activate
* @return bool true on success, false on failure
$this->plugins[$plugin]->active =
true;
$this->plugins[$plugin]->activate();
/* deactivate_plugin {{{ */
* deActivate givin plugin
* If the plugin is not loaded, do nothing
* @param string $plugin The plugin name to deactivate
* @return bool true on success, false on failure
$this->plugins[$plugin]->active =
false;
$this->plugins[$plugin]->deactivate();
/* set_active_plugins {{{ */
* Activate plugins using an external array.
* This can be usefull if you store your activate plugins in a database
* @param array $active_plugins Array with plugin names to activate
foreach ($active_plugins as $activate) {
/* get_active_plugins {{{ */
* Return array of active plugins
foreach ($this->plugins as $name=>
$plugin) {
* Loop through all the plugins and run functions registered to given hooktype
foreach ($this->plugins as $plugin) {
/* only run when the plugin is active */
foreach ($plugin->hooks as $hook=>
$function) {
$data = eval
("return \$plugin->$function(\$data);");
* Default Plugin class with predefined variables and addHook function.
* All plugins should extend on this one
public $hooks =
array(); // de array van alle hooks en functies daaraan gebonden
public $active =
false; // standaard is de plugin uitgeschakeld
public function addHook($hook_name, $function_name){
$this->hooks[$hook_name] =
$function_name;
* A plugin should implement this to assure at least the basics are correct
public function addHook($hook_name, $function_name);
Documentation generated on Fri, 28 Dec 2007 13:17:42 +0100 by phpDocumentor 1.4.1