diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php
old mode 100644
new mode 100755
index 13acf26c..eacaeaf7
--- a/bl-kernel/abstract/plugin.class.php
+++ b/bl-kernel/abstract/plugin.class.php
@@ -21,9 +21,14 @@ class Plugin {
// (array) Plugin's information.
public $metadata;
+
+ // (dbLanguage) Plugin's localisation.
+ public $language;
function __construct()
{
+ global $Site;
+
$this->dbFields = array();
$reflector = new ReflectionClass(get_class($this));
@@ -47,6 +52,16 @@ class Plugin {
$metadataString = file_get_contents($this->filenameMetadata);
$this->metadata = json_decode($metadataString, true);
+ // Load localisation
+ $tmp = new dbLanguage($Site->locale(), PATH_PLUGINS.$this->directoryName.DS.'languages'.DS);
+ // Set name and description from the language file.
+ $this->setMetadata('name',$tmp->db['plugin-data']['name']);
+ $this->setMetadata('description',$tmp->db['plugin-data']['description']);
+
+ // Remove name and description
+ unset($tmp->db['plugin-data']);
+ $this->language = $tmp;
+
// If the plugin is installed then get the database.
if($this->installed())
{
@@ -218,8 +233,12 @@ class Plugin {
public function init()
{
- // This method is used on childre classes.
- // The user can define your own dbFields.
+ // This method is used on child classes.
+ // The user can define their own dbFields.
}
+ public function L($key)
+ {
+ return $this->language->get($key);
+ }
}
\ No newline at end of file
diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php
old mode 100644
new mode 100755
index e54d7699..77611470
--- a/bl-kernel/boot/rules/60.plugins.php
+++ b/bl-kernel/boot/rules/60.plugins.php
@@ -75,26 +75,27 @@ function buildPlugins()
foreach($pluginsDeclaredClasess as $pluginClass)
{
- $Plugin = new $pluginClass;
+ $Plugin = new $pluginClass();
- // Check if the plugin is translated.
- $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
- if( !Sanitize::pathFile($languageFilename) ) {
- $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
- }
+ // Deprecated
+ // // Check if the plugin is translated.
+ // $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.$Site->locale().'.json';
+ // if( !Sanitize::pathFile($languageFilename) ) {
+ // $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.'en_US.json';
+ // }
- $database = file_get_contents($languageFilename);
- $database = json_decode($database, true);
+ // $database = file_get_contents($languageFilename);
+ // $database = json_decode($database, true);
- // Set name and description from the language file.
- $Plugin->setMetadata('name',$database['plugin-data']['name']);
- $Plugin->setMetadata('description',$database['plugin-data']['description']);
+ // // Set name and description from the language file.
+ // $Plugin->setMetadata('name',$database['plugin-data']['name']);
+ // $Plugin->setMetadata('description',$database['plugin-data']['description']);
- // Remove name and description, and add new words if there are.
- unset($database['plugin-data']);
- if(!empty($database)) {
- $Language->add($database);
- }
+ // // Remove name and description, and add new words if there are.
+ // unset($database['plugin-data']);
+ // if(!empty($database)) {
+ // $Language->add($database);
+ // }
// Push Plugin to array all plugins installed and not installed.
$plugins['all'][$pluginClass] = $Plugin;
diff --git a/bl-kernel/dblanguage.class.php b/bl-kernel/dblanguage.class.php
old mode 100644
new mode 100755
index 260de063..9159502d
--- a/bl-kernel/dblanguage.class.php
+++ b/bl-kernel/dblanguage.class.php
@@ -6,22 +6,24 @@ class dbLanguage extends dbJSON
public $db;
public $currentLocale;
- function __construct($locale)
+ function __construct( $locale, $path = null )
{
+ $path = $path ? $path : PATH_LANGUAGES;
+
$this->data = array();
$this->db = array();
$this->currentLocale = 'en_US';
// Default language en_US
- $filename = PATH_LANGUAGES.'en_US.json';
+ $filename = $path.'en_US.json';
if( Sanitize::pathFile($filename) )
{
$Tmp = new dbJSON($filename, false);
- $this->db = array_merge($this->db, $Tmp->db);
+ $this->db = $Tmp->db;
}
// User language
- $filename = PATH_LANGUAGES.$locale.'.json';
+ $filename = $path.$locale.'.json';
if( Sanitize::pathFile($filename) && ($locale!=="en_US") )
{
$this->currentLocale = $locale;
@@ -29,8 +31,11 @@ class dbLanguage extends dbJSON
$this->db = array_merge($this->db, $Tmp->db);
}
- $this->data = $this->db['language-data'];
- unset($this->db['language-data']);
+ if ( $this->data )
+ {
+ $this->data = $this->db['language-data'];
+ unset($this->db['language-data']);
+ }
}
public function getCurrentLocale()
diff --git a/bl-plugins/about/plugin.php b/bl-plugins/about/plugin.php
old mode 100644
new mode 100755
index bb3eccb1..3ef91ad4
--- a/bl-plugins/about/plugin.php
+++ b/bl-plugins/about/plugin.php
@@ -12,14 +12,12 @@ class pluginAbout extends Plugin {
public function form()
{
- global $Language;
-
$html = '
';
@@ -37,7 +35,6 @@ class pluginPages extends Plugin {
public function siteSidebar()
{
- global $Language;
global $pagesParents;
global $Site, $Url;
@@ -55,7 +52,7 @@ class pluginPages extends Plugin {
// Show home link ?
if($this->getDbField('homeLink')) {
$html .= '
';
@@ -85,8 +83,6 @@ class pluginsimpleMDE extends Plugin {
public function adminBodyEnd()
{
global $layout;
- global $Language;
-
$html = '';
// Load CSS and JS only on Controllers in array.
@@ -119,7 +115,7 @@ class pluginsimpleMDE extends Plugin {
// This function is necesary on each Editor, it is used by Bludit Images v8.
$html .= 'function editorAddImage(filename) {
- addContentSimpleMDE("");
+ addContentSimpleMDE("");
}'.PHP_EOL;
$html .= '$(document).ready(function() { '.PHP_EOL;
diff --git a/bl-plugins/tags/plugin.php b/bl-plugins/tags/plugin.php
old mode 100644
new mode 100755
index 978fbd64..3f7f4664
--- a/bl-plugins/tags/plugin.php
+++ b/bl-plugins/tags/plugin.php
@@ -12,23 +12,21 @@ class pluginTags extends Plugin {
public function form()
{
- global $Language;
-
$html = '