Merge pull request #1376 from gaincoder/v4.0
add the possibility to use independend classes in plugins
This commit is contained in:
commit
6cebc2850b
4 changed files with 91 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
|
|
||||||
class Plugin {
|
class Plugin implements PluginInterface
|
||||||
|
{
|
||||||
|
|
||||||
// (string) directory name, just the name
|
// (string) directory name, just the name
|
||||||
// Ex: sitemap
|
// Ex: sitemap
|
||||||
|
|
79
bl-kernel/abstract/plugin.interface.php
Normal file
79
bl-kernel/abstract/plugin.interface.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);
|
||||||
|
}
|
|
@ -70,11 +70,15 @@ mb_internal_encoding(CHARSET);
|
||||||
// Set HTTP output character encoding
|
// Set HTTP output character encoding
|
||||||
mb_http_output(CHARSET);
|
mb_http_output(CHARSET);
|
||||||
|
|
||||||
|
// Include interfaces
|
||||||
|
include(PATH_ABSTRACT . 'plugin.interface.php');
|
||||||
|
|
||||||
// Inclde Abstract Classes
|
// Inclde Abstract Classes
|
||||||
include(PATH_ABSTRACT.'dbjson.class.php');
|
include(PATH_ABSTRACT.'dbjson.class.php');
|
||||||
include(PATH_ABSTRACT.'dblist.class.php');
|
include(PATH_ABSTRACT.'dblist.class.php');
|
||||||
include(PATH_ABSTRACT.'plugin.class.php');
|
include(PATH_ABSTRACT.'plugin.class.php');
|
||||||
|
|
||||||
|
|
||||||
// Inclde Classes
|
// Inclde Classes
|
||||||
include(PATH_KERNEL.'pages.class.php');
|
include(PATH_KERNEL.'pages.class.php');
|
||||||
include(PATH_KERNEL.'users.class.php');
|
include(PATH_KERNEL.'users.class.php');
|
||||||
|
|
|
@ -78,6 +78,12 @@ function buildPlugins()
|
||||||
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
$pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess);
|
||||||
|
|
||||||
foreach ($pluginsDeclaredClasess as $pluginClass) {
|
foreach ($pluginsDeclaredClasess as $pluginClass) {
|
||||||
|
|
||||||
|
$reflect = new ReflectionClass($pluginClass);
|
||||||
|
if(!$reflect->implementsInterface('PluginInterface')){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$Plugin = new $pluginClass;
|
$Plugin = new $pluginClass;
|
||||||
|
|
||||||
// Check if the plugin is translated
|
// Check if the plugin is translated
|
||||||
|
|
Loading…
Add table
Reference in a new issue