From fddf1210323b441e83daabd48928d6a75d613cc5 Mon Sep 17 00:00:00 2001 From: torkel104 Date: Mon, 7 Nov 2016 20:58:26 +0100 Subject: [PATCH] Fixes for new l10n --- bl-kernel/abstract/plugin.class.php | 21 +++++++++++---------- bl-kernel/boot/rules/60.plugins.php | 2 +- bl-kernel/dblanguage.class.php | 17 +++++++++++------ 3 files changed, 23 insertions(+), 17 deletions(-) mode change 100644 => 100755 bl-kernel/dblanguage.class.php diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 3b42cf7d..eacaeaf7 100755 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -25,8 +25,10 @@ class Plugin { // (dbLanguage) Plugin's localisation. public $language; - function __construct($locale) + function __construct() { + global $Site; + $this->dbFields = array(); $reflector = new ReflectionClass(get_class($this)); @@ -43,9 +45,15 @@ class Plugin { // Init empty database $this->db = $this->dbFields; - // Load localisation - $tmp = new dbLanguage($locale, PATH_PLUGINS.$this->directoryName.DS.'languages'.DS); + $this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php'; + // --- Metadata --- + $this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json'; + $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']); @@ -54,13 +62,6 @@ class Plugin { unset($tmp->db['plugin-data']); $this->language = $tmp; - $this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php'; - - // --- Metadata --- - $this->filenameMetadata = PATH_PLUGINS.$this->directoryName().DS.'metadata.json'; - $metadataString = file_get_contents($this->filenameMetadata); - $this->metadata = json_decode($metadataString, true); - // If the plugin is installed then get the database. if($this->installed()) { diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index fc0482ea..77611470 100755 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -75,7 +75,7 @@ function buildPlugins() foreach($pluginsDeclaredClasess as $pluginClass) { - $Plugin = new $pluginClass($Site->locale()); + $Plugin = new $pluginClass(); // Deprecated // // Check if the plugin is translated. diff --git a/bl-kernel/dblanguage.class.php b/bl-kernel/dblanguage.class.php old mode 100644 new mode 100755 index 2801391b..2e80a44e --- 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()