Plugins init
This commit is contained in:
parent
5c4262e2ec
commit
1e327e31b5
|
@ -0,0 +1,27 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
setSettings($_POST);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
|
@ -1,2 +1,9 @@
|
|||
<h2 class="title"><i class="fa fa-rocket"></i> Plugins</h2>
|
||||
<p>Not implemented...</p>
|
||||
|
||||
<?php
|
||||
foreach($plugins['all'] as $Plugin)
|
||||
{
|
||||
echo '<p>'.$Plugin->title().'</p>';
|
||||
}
|
||||
?>
|
|
@ -26,8 +26,11 @@ class Plugin {
|
|||
// Class Name
|
||||
$this->className = $reflector->getName();
|
||||
|
||||
// Initialize dbFields from the children.
|
||||
$this->init();
|
||||
|
||||
// Init empty database
|
||||
$this->db = array();
|
||||
$this->db = $this->dbFields;
|
||||
|
||||
$this->fileDb = PATH_PLUGINS_DATABASES.$this->directoryName.'/db.php';
|
||||
|
||||
|
@ -39,15 +42,21 @@ class Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
public function title()
|
||||
{
|
||||
//var_dump($this->db);
|
||||
return $this->db['title'];
|
||||
}
|
||||
|
||||
// Return TRUE if the installation success, otherwise FALSE.
|
||||
public function install()
|
||||
{
|
||||
if($this->installed())
|
||||
if($this->installed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create plugin directory for databases and others files.
|
||||
if( !mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, 0755, true) )
|
||||
return false;
|
||||
mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, 0755, true);
|
||||
|
||||
if( !empty($this->dbFields) )
|
||||
{
|
||||
|
@ -60,7 +69,8 @@ class Plugin {
|
|||
|
||||
public function uninstall()
|
||||
{
|
||||
|
||||
unlink($this->fileDb);
|
||||
rmdir(PATH_PLUGINS_DATABASES.$this->directoryName);
|
||||
}
|
||||
|
||||
public function installed()
|
||||
|
@ -70,7 +80,8 @@ class Plugin {
|
|||
|
||||
public function init()
|
||||
{
|
||||
|
||||
// This method is used on childre classes.
|
||||
// The user can define your own dbFields.
|
||||
}
|
||||
|
||||
// DEBUG: Ver si se usa
|
||||
|
|
|
@ -5,7 +5,8 @@ $plugins = array(
|
|||
'onSiteBody'=>array(),
|
||||
'onSidebar'=>array(),
|
||||
'onAdminHead'=>array(),
|
||||
'onAdminBody'=>array()
|
||||
'onAdminBody'=>array(),
|
||||
'all'=>array()
|
||||
);
|
||||
|
||||
function build_plugins()
|
||||
|
@ -30,6 +31,12 @@ function build_plugins()
|
|||
{
|
||||
$Plugin = new $pluginClass;
|
||||
|
||||
// All plugins installed and not installed.
|
||||
array_push($plugins['all'], $Plugin);
|
||||
|
||||
// If the plugin installed, then add the plugin on the arrays.
|
||||
if($Plugin->installed())
|
||||
{
|
||||
if($Plugin->onSiteHead()!==false)
|
||||
array_push($plugins['onSiteHead'], $Plugin);
|
||||
|
||||
|
@ -45,6 +52,7 @@ function build_plugins()
|
|||
if($Plugin->onAdminBody()!==false)
|
||||
array_push($plugins['onAdminBody'], $Plugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build_plugins();
|
||||
|
|
Loading…
Reference in New Issue