bludit/kernel/abstract/plugin.class.php

123 lines
1.9 KiB
PHP
Raw Normal View History

2015-05-05 03:00:01 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
2015-03-08 18:02:59 +01:00
class Plugin {
// (string) Plugin's directory
public $directoryName;
2015-05-05 03:00:01 +02:00
2015-03-08 18:02:59 +01:00
// (string) Database path and filename
public $fileDb;
2015-05-05 03:00:01 +02:00
2015-03-08 18:02:59 +01:00
// (array) Database
public $db;
// (array) Database fields, only for initialize.
public $dbFields;
public $className;
function __construct()
{
$reflector = new ReflectionClass(get_class($this));
// Directory name
$this->directoryName = basename(dirname($reflector->getFileName()));
// Class Name
$this->className = $reflector->getName();
// Init empty database
$this->db = array();
$this->fileDb = PATH_PLUGINS_DATABASES.$this->directoryName.'/db.php';
// If the plugin installed then get the database.
if($this->installed())
{
2015-05-05 03:00:01 +02:00
$Tmp = new dbJSON($this->fileDb);
$this->db = $Tmp->db;
2015-03-08 18:02:59 +01:00
}
}
// Return TRUE if the installation success, otherwise FALSE.
public function install()
{
if($this->installed())
return false;
// Create plugin directory for databases and others files.
if( !mkdir(PATH_PLUGINS_DATABASES.$this->directoryName, 0755, true) )
return false;
if( !empty($this->dbFields) )
{
2015-05-05 03:00:01 +02:00
$Tmp = new dbJSON($this->fileDb);
2015-03-08 18:02:59 +01:00
$Tmp->setDb($this->dbFields);
}
return true;
}
public function uninstall()
{
}
public function installed()
{
return file_exists($this->fileDb);
}
public function init()
{
2015-05-05 03:00:01 +02:00
}
2015-03-08 18:02:59 +01:00
// DEBUG: Ver si se usa
public function showdb()
{
print_r( $this->db );
}
// EVENTS
// Before the posts load.
public function beforePostsLoad()
{
return false;
}
// After the posts load.
public function afterPostsLoad()
{
return false;
}
// Before the pages load.
public function beforePagesLoad()
{
return false;
}
// After the pages load.
public function afterPagesLoad()
{
return false;
}
public function onSiteHead()
{
return false;
}
public function onSiteBody()
{
2015-05-05 03:00:01 +02:00
return false;
2015-03-08 18:02:59 +01:00
}
public function onSidebar()
{
2015-05-05 03:00:01 +02:00
return false;
2015-03-08 18:02:59 +01:00
}
2015-05-05 03:00:01 +02:00
}