2015-03-08 18:02:59 +01:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
|
|
|
|
$plugins = array(
|
|
|
|
'onSiteHead'=>array(),
|
|
|
|
'onSiteBody'=>array(),
|
2015-06-03 03:17:09 +02:00
|
|
|
'onSidebar'=>array(),
|
|
|
|
'onAdminHead'=>array(),
|
2015-06-11 04:27:04 +02:00
|
|
|
'onAdminBody'=>array(),
|
|
|
|
'all'=>array()
|
2015-03-08 18:02:59 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
function build_plugins()
|
|
|
|
{
|
|
|
|
global $plugins;
|
|
|
|
|
|
|
|
// List plugins directories
|
2015-05-31 03:06:55 +02:00
|
|
|
$list = Filesystem::listDirectories(PATH_PLUGINS);
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-06-03 03:17:09 +02:00
|
|
|
// Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess.
|
2015-03-08 18:02:59 +01:00
|
|
|
$currentDeclaredClasess = get_declared_classes();
|
|
|
|
|
2015-06-03 03:17:09 +02:00
|
|
|
// Load each plugin clasess
|
|
|
|
foreach($list as $pluginPath) {
|
2015-03-08 18:02:59 +01:00
|
|
|
include($pluginPath.'/plugin.php');
|
2015-06-03 03:17:09 +02:00
|
|
|
}
|
2015-03-08 18:02:59 +01:00
|
|
|
|
|
|
|
// Get plugins clasess loaded
|
|
|
|
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
|
|
|
|
|
|
|
foreach($pluginsDeclaredClasess as $pluginClass)
|
|
|
|
{
|
|
|
|
$Plugin = new $pluginClass;
|
|
|
|
|
2015-06-11 04:27:04 +02:00
|
|
|
// All plugins installed and not installed.
|
|
|
|
array_push($plugins['all'], $Plugin);
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-06-11 04:27:04 +02:00
|
|
|
// If the plugin installed, then add the plugin on the arrays.
|
|
|
|
if($Plugin->installed())
|
|
|
|
{
|
|
|
|
if($Plugin->onSiteHead()!==false)
|
|
|
|
array_push($plugins['onSiteHead'], $Plugin);
|
2015-03-08 18:02:59 +01:00
|
|
|
|
2015-06-11 04:27:04 +02:00
|
|
|
if($Plugin->onSiteBody()!==false)
|
|
|
|
array_push($plugins['onSiteBody'], $Plugin);
|
2015-06-03 03:17:09 +02:00
|
|
|
|
2015-06-11 04:27:04 +02:00
|
|
|
if($Plugin->onSidebar()!==false)
|
|
|
|
array_push($plugins['onSidebar'], $Plugin);
|
2015-06-03 03:17:09 +02:00
|
|
|
|
2015-06-11 04:27:04 +02:00
|
|
|
if($Plugin->onAdminHead()!==false)
|
|
|
|
array_push($plugins['onAdminHead'], $Plugin);
|
|
|
|
|
|
|
|
if($Plugin->onAdminBody()!==false)
|
|
|
|
array_push($plugins['onAdminBody'], $Plugin);
|
|
|
|
}
|
2015-03-08 18:02:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
build_plugins();
|