add the possibility to use independend classes in plugins
This commit is contained in:
parent
f6a6660f48
commit
336cffe777
4 changed files with 91 additions and 1 deletions
79
bl-kernel/abstract/PluginInterface.php
Normal file
79
bl-kernel/abstract/PluginInterface.php
Normal file
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
interface PluginInterface
|
||||
{
|
||||
public function save();
|
||||
|
||||
public function includeCSS($filename);
|
||||
|
||||
public function includeJS($filename);
|
||||
|
||||
public function domainPath();
|
||||
|
||||
public function htmlPath();
|
||||
|
||||
public function phpPath();
|
||||
|
||||
public function phpPathDB();
|
||||
|
||||
public function getMetadata($key);
|
||||
|
||||
public function setMetadata($key, $value);
|
||||
|
||||
public function getValue($field, $html = true);
|
||||
|
||||
public function label();
|
||||
|
||||
public function name();
|
||||
|
||||
public function description();
|
||||
|
||||
public function author();
|
||||
|
||||
public function email();
|
||||
|
||||
public function type();
|
||||
|
||||
public function website();
|
||||
|
||||
public function position();
|
||||
|
||||
public function version();
|
||||
|
||||
public function releaseDate();
|
||||
|
||||
public function className();
|
||||
|
||||
public function formButtons();
|
||||
|
||||
public function isCompatible();
|
||||
|
||||
public function directoryName();
|
||||
|
||||
public function install($position = 1);
|
||||
|
||||
public function uninstall();
|
||||
|
||||
/**
|
||||
* Returns True if the plugin is installed
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function installed(): bool;
|
||||
|
||||
public function workspace();
|
||||
|
||||
public function init();
|
||||
|
||||
public function prepare();
|
||||
|
||||
public function post();
|
||||
|
||||
public function configure($args);
|
||||
|
||||
public function setField($field, $value);
|
||||
|
||||
public function setPosition($position);
|
||||
|
||||
public function webhook($URI = false, $returnsAfterURI = false, $fixed = true);
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
class Plugin {
|
||||
class Plugin implements PluginInterface
|
||||
{
|
||||
|
||||
// (string) directory name, just the name
|
||||
// Ex: sitemap
|
||||
|
|
|
@ -70,11 +70,15 @@ mb_internal_encoding(CHARSET);
|
|||
// Set HTTP output character encoding
|
||||
mb_http_output(CHARSET);
|
||||
|
||||
// Include interfaces
|
||||
include(PATH_ABSTRACT.'PluginInterface.php');
|
||||
|
||||
// Inclde Abstract Classes
|
||||
include(PATH_ABSTRACT.'dbjson.class.php');
|
||||
include(PATH_ABSTRACT.'dblist.class.php');
|
||||
include(PATH_ABSTRACT.'plugin.class.php');
|
||||
|
||||
|
||||
// Inclde Classes
|
||||
include(PATH_KERNEL.'pages.class.php');
|
||||
include(PATH_KERNEL.'users.class.php');
|
||||
|
|
|
@ -78,6 +78,12 @@ function buildPlugins()
|
|||
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
||||
|
||||
foreach ($pluginsDeclaredClasess as $pluginClass) {
|
||||
|
||||
$reflect = new ReflectionClass($pluginClass);
|
||||
if(!$reflect->implementsInterface('PluginInterface')){
|
||||
continue;
|
||||
}
|
||||
|
||||
$Plugin = new $pluginClass;
|
||||
|
||||
// Check if the plugin is translated
|
||||
|
|
Loading…
Reference in a new issue