From a90ff3e6352fcbd1b77c3a94fe1783c01ea435b9 Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Tue, 30 May 2017 19:18:18 +0200 Subject: [PATCH] Division by zero fixed and installer updated --- bl-kernel/abstract/plugin.class.php | 12 +++- bl-kernel/boot/rules/99.themes.php | 11 +-- bl-plugins/disqus/metadata.json | 8 +-- bl-plugins/disqus/plugin.php | 108 ++++++---------------------- bl-plugins/tags/plugin.php | 55 +++----------- bl-themes/editorial/php/home.php | 2 +- bl-themes/editorial/php/page.php | 6 ++ install.php | 4 +- 8 files changed, 61 insertions(+), 145 deletions(-) diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 9c383e70..2c203aa5 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -181,9 +181,15 @@ class Plugin { public function isCompatible() { - $explode = explode(',', $this->getMetadata('compatible')); - - return in_array(BLUDIT_VERSION, $explode); + $bluditRoot = explode('.', BLUDIT_VERSION); + $compatible = explode(',', $this->getMetadata('compatible')); + foreach( $compatible as $version ) { + $root = explode('.', $version); + if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) { + return true; + } + } + return false; } public function directoryName() diff --git a/bl-kernel/boot/rules/99.themes.php b/bl-kernel/boot/rules/99.themes.php index 8798943d..3751f04a 100644 --- a/bl-kernel/boot/rules/99.themes.php +++ b/bl-kernel/boot/rules/99.themes.php @@ -45,11 +45,14 @@ function buildThemes() $metadata = json_decode($metadataString, true); $database['compatible'] = false; - if( !empty($metadata['compatible']) ) { - $explode = explode(',', $metadata['compatible']); - if(in_array(BLUDIT_VERSION, $explode)) { - $database['compatible'] = true; + $bluditRoot = explode('.', BLUDIT_VERSION); + $compatible = explode(',', $metadata['compatible']); + foreach( $compatible as $version ) { + $root = explode('.', $version); + if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) { + $database['compatible'] = true; + } } } diff --git a/bl-plugins/disqus/metadata.json b/bl-plugins/disqus/metadata.json index 8801aa07..a5c64fc0 100644 --- a/bl-plugins/disqus/metadata.json +++ b/bl-plugins/disqus/metadata.json @@ -2,9 +2,9 @@ "author": "Bludit", "email": "", "website": "https://plugins.bludit.com", - "version": "1.5.2", - "releaseDate": "2016-05-28", + "version": "2.0", + "releaseDate": "2017-05-26", "license": "MIT", - "compatible": "1.5.2", + "compatible": "2.0", "notes": "" -} +} \ No newline at end of file diff --git a/bl-plugins/disqus/plugin.php b/bl-plugins/disqus/plugin.php index d5861887..9caa9009 100644 --- a/bl-plugins/disqus/plugin.php +++ b/bl-plugins/disqus/plugin.php @@ -2,86 +2,47 @@ class pluginDisqus extends Plugin { - private $enable; - public function init() { $this->dbFields = array( - 'shortname'=>'', - 'enablePages'=>0, - 'enablePosts'=>0, - 'enableDefaultHomePage'=>1 + 'shortname'=>'' ); } - function __construct() - { - parent::__construct(); - - global $Url; - - $this->enable = false; - - if( $this->getDbField('enablePosts') && ($Url->whereAmI()=='post') ) { - $this->enable = true; - } - elseif( $this->getDbField('enablePages') && ($Url->whereAmI()=='page') ) { - $this->enable = true; - } - elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') ) - { - $this->enable = true; - } - } - public function form() { global $Language; $html = '
'; $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= 'getDbField('enablePages')?'checked':'').'>'; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= 'getDbField('enablePosts')?'checked':'').'>'; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= ''; - $html .= 'getDbField('enableDefaultHomePage')?'checked':'').'>'; - $html .= ''; + $html .= ''; $html .= '
'; return $html; } - public function postEnd() - { - if( $this->enable ) { - return '
'; - } - - return false; - } - public function pageEnd() { - global $Url; + global $page; - // Bludit check not-found page after the plugin method construct. - // It's necesary check here the page not-found. + if( ($page->key()!='error') && ($page->allowComments()) ) { + $html = '
'; + $html .= ' + + + '; } return false; @@ -89,34 +50,7 @@ class pluginDisqus extends Plugin { public function siteHead() { - if( $this->enable ) { - return ''; - } - - return false; + return ''; } - public function siteBodyEnd() - { - if( $this->enable ) { - - $html = ' - -'; - - return $html; - } - - return false; - } } \ No newline at end of file diff --git a/bl-plugins/tags/plugin.php b/bl-plugins/tags/plugin.php index 978fbd64..86d6543a 100644 --- a/bl-plugins/tags/plugin.php +++ b/bl-plugins/tags/plugin.php @@ -5,8 +5,7 @@ class pluginTags extends Plugin { public function init() { $this->dbFields = array( - 'label'=>'Tags', - 'sort'=>'date' + 'label'=>'Tags' ); } @@ -15,23 +14,8 @@ class pluginTags extends Plugin { global $Language; $html = '
'; - $html .= ''; - $html .= ''; - $html .= '
'; - - $html .= '
'; - $html .= $Language->get('Sort the tag list by').': '; + $html .= ''; + $html .= ''; $html .= '
'; return $html; @@ -43,7 +27,6 @@ class pluginTags extends Plugin { global $dbTags; global $Url; - $db = $dbTags->db['postsIndex']; $filter = $Url->filters('tag'); $html = '
'; @@ -51,32 +34,16 @@ class pluginTags extends Plugin { $html .= '
'; $html .= '
    '; - $tagArray = array(); - - foreach($db as $tagKey=>$fields) - { - $tagArray[] = array('tagKey'=>$tagKey, 'count'=>$dbTags->countPostsByTag($tagKey), 'name'=>$fields['name']); + // By default the database of tags are alphanumeric sorted + foreach( $dbTags->db as $key=>$fields ) { + $html .= '
  • '; + $html .= ''; + $html .= $fields['name']; + $html .= ' ('.count($fields['list']).')'; + $html .= ''; + $html .= '
  • '; } - // Sort the array based on options - if ($this->getDbField('sort') == "count") - { - usort($tagArray, function($a, $b) { - return $b['count'] - $a['count']; - }); - } - elseif ($this->getDbField('sort') == "alpha") - { - usort($tagArray, function($a, $b) { - return strcmp($a['tagKey'], $b['tagKey']); - }); - } - - foreach($tagArray as $tagKey=>$fields) - { - // Print the parent - $html .= '
  • '.$fields['name'].' ('.$fields['count'].')
  • '; - } $html .= '
'; $html .= '
'; $html .= '
'; diff --git a/bl-themes/editorial/php/home.php b/bl-themes/editorial/php/home.php index 4144c812..16663be9 100644 --- a/bl-themes/editorial/php/home.php +++ b/bl-themes/editorial/php/home.php @@ -19,7 +19,7 @@
-

Ipsum sed dolor

+

Pages

diff --git a/bl-themes/editorial/php/page.php b/bl-themes/editorial/php/page.php index f35d3ee8..9af8a2f0 100644 --- a/bl-themes/editorial/php/page.php +++ b/bl-themes/editorial/php/page.php @@ -1,9 +1,15 @@
+

title() ?>

+ + content() ?> + + +
\ No newline at end of file diff --git a/install.php b/install.php index d84939e3..b44df719 100644 --- a/install.php +++ b/install.php @@ -358,10 +358,10 @@ function install($adminPassword, $email, $timezone) 'language'=>$Language->getCurrentLocale(), 'locale'=>$Language->getCurrentLocale(), 'timezone'=>$timezone, - 'theme'=>'log', + 'theme'=>'editorial', 'adminTheme'=>'default', 'homepage'=>'', - 'postsperpage'=>'6', + 'itemsPerPage'=>'6', 'uriPage'=>'/', 'uriTag'=>'/tag/', 'uriCategory'=>'/category/',