From 258e7304ab1950dd23a609ef3fb62bc09df542c3 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Sat, 29 Jul 2017 00:08:19 +0200 Subject: [PATCH] bug fixes --- bl-kernel/boot/init.php | 3 +++ bl-kernel/boot/rules/60.plugins.php | 31 +++++++++++++---------------- bl-kernel/dblanguage.class.php | 2 ++ bl-kernel/helpers/theme.class.php | 2 +- bl-plugins/disqus/plugin.php | 12 +++++++---- bl-themes/kernel-panic/index.php | 4 +++- bl-themes/kernel-panic/php/home.php | 2 ++ bl-themes/kernel-panic/php/page.php | 2 ++ bl-themes/log/index.php | 11 +++++----- 9 files changed, 40 insertions(+), 29 deletions(-) diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index a13c9f53..f1cbe32d 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -143,6 +143,9 @@ define('DIR_PERMISSIONS', 0755); // Admin URI filter define('ADMIN_URI_FILTER', '/admin/'); +// Default language file, in this case is English +define('DEFAULT_LANGUAGE_FILE', 'en_US.json'); + // Set internal character encoding mb_internal_encoding(CHARSET); diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 6ebc5e87..2259bdad 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -54,14 +54,13 @@ function buildPlugins() // List plugins directories $list = Filesystem::listDirectories(PATH_PLUGINS); - // Get declared clasess before load plugins clasess, this list doesn't have the plugins clasess. + // Get declared clasess BEFORE load plugins clasess $currentDeclaredClasess = get_declared_classes(); // Load each plugin clasess foreach($list as $pluginPath) { - // Check if the directory has the plugin.php - if(file_exists($pluginPath.DS.'plugin.php')) { + if (file_exists($pluginPath.DS.'plugin.php')) { include($pluginPath.DS.'plugin.php'); } } @@ -69,38 +68,36 @@ function buildPlugins() // Get plugins clasess loaded $pluginsDeclaredClasess = array_diff(get_declared_classes(), $currentDeclaredClasess); - foreach($pluginsDeclaredClasess as $pluginClass) - { + foreach ($pluginsDeclaredClasess as $pluginClass) { $Plugin = new $pluginClass; - // Check if the plugin is translated. + // 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'; + $languageFilename = PATH_PLUGINS.$Plugin->directoryName().DS.'languages'.DS.DEFAULT_LANGUAGE_FILE; } $database = file_get_contents($languageFilename); $database = json_decode($database, true); - // Set name and description from the language file. + // 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. + // Remove name and description from the language file loaded and add new words if there are + // This function overwrite the key=>value unset($database['plugin-data']); - if(!empty($database)) { + if (!empty($database)) { $Language->add($database); } - // Array with plugin all plugins, installed and not installed + // $plugins['all'] Array with all plugins, installed and not installed $plugins['all'][$pluginClass] = $Plugin; - // If the plugin is installed, order by hooks. - if($Plugin->installed()) { - - foreach($pluginsEvents as $event=>$value) { - - if(method_exists($Plugin, $event)) { + // If the plugin is installed insert on the hooks + if ($Plugin->installed()) { + foreach ($pluginsEvents as $event=>$value) { + if (method_exists($Plugin, $event)) { array_push($plugins[$event], $Plugin); } } diff --git a/bl-kernel/dblanguage.class.php b/bl-kernel/dblanguage.class.php index 504bc492..42782905 100644 --- a/bl-kernel/dblanguage.class.php +++ b/bl-kernel/dblanguage.class.php @@ -76,6 +76,8 @@ class dbLanguage extends dbJSON echo $this->get($string); } + // Add more keys=>values to the current dicionary + // Will be overwrite if exist the key with the new value public function add($array) { $this->db = array_merge($array, $this->db); diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index e89e9580..8f75023a 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -131,7 +131,7 @@ class Theme { public static function plugins($type) { global $plugins; - foreach($plugins[$type] as $plugin) { + foreach ($plugins[$type] as $plugin) { echo call_user_func(array($plugin, $type)); } } diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index 047db1f3..d5973604 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -23,9 +23,15 @@ class pluginDisqus extends Plugin { public function pageEnd() { - global $page; + global $pages; + global $Url; - if( ($page->key()!='error') && ($page->allowComments()) ) { + $page = $pages[0]; + if (empty($page)) { + return false; + } + + if ( (!$Url->notFound()) && ($Url->whereAmI()=='page') && ($page->allowComments()) ) { $html = '
'; $html .= ' - - '; return $html; } diff --git a/bl-themes/kernel-panic/index.php b/bl-themes/kernel-panic/index.php index 7a9189b5..caeebc82 100755 --- a/bl-themes/kernel-panic/index.php +++ b/bl-themes/kernel-panic/index.php @@ -7,6 +7,7 @@ +
@@ -32,7 +33,7 @@
+ \ No newline at end of file diff --git a/bl-themes/kernel-panic/php/home.php b/bl-themes/kernel-panic/php/home.php index c40920e3..f0ca152a 100644 --- a/bl-themes/kernel-panic/php/home.php +++ b/bl-themes/kernel-panic/php/home.php @@ -2,6 +2,7 @@
+ \ No newline at end of file diff --git a/bl-themes/kernel-panic/php/page.php b/bl-themes/kernel-panic/php/page.php index 5a4e8490..8f3b78c1 100644 --- a/bl-themes/kernel-panic/php/page.php +++ b/bl-themes/kernel-panic/php/page.php @@ -1,6 +1,7 @@
\ No newline at end of file diff --git a/bl-themes/log/index.php b/bl-themes/log/index.php index 908be90e..17cfa1ad 100644 --- a/bl-themes/log/index.php +++ b/bl-themes/log/index.php @@ -5,6 +5,8 @@ + +
@@ -58,7 +60,7 @@
@@ -84,9 +84,8 @@ echo Theme::js('assets/js/ie/respond.min.js'); echo ''; echo Theme::js('assets/js/main.js'); - - Theme::plugins('siteBodyEnd'); ?> + \ No newline at end of file