Division by zero fixed and installer updated

This commit is contained in:
Diego Najar 2017-05-30 19:18:18 +02:00
parent 0d783359fa
commit a90ff3e635
8 changed files with 61 additions and 145 deletions

View File

@ -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()

View File

@ -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;
}
}
}

View File

@ -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": ""
}
}

View File

@ -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 = '<div>';
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enablePages" value="0">';
$html .= '<input name="enablePages" id="jsenablePages" type="checkbox" value="1" '.($this->getDbField('enablePages')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePages">'.$Language->get('Enable Disqus on pages').'</label>';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enablePosts" value="0">';
$html .= '<input name="enablePosts" id="jsenablePosts" type="checkbox" value="1" '.($this->getDbField('enablePosts')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePosts">'.$Language->get('Enable Disqus on posts').'</label>';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enableDefaultHomePage" value="0">';
$html .= '<input name="enableDefaultHomePage" id="jsenableDefaultHomePage" type="checkbox" value="1" '.($this->getDbField('enableDefaultHomePage')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenableDefaultHomePage">'.$Language->get('Enable Disqus on default home page').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
$html .= '</div>';
return $html;
}
public function postEnd()
{
if( $this->enable ) {
return '<div id="disqus_thread"></div>';
}
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 = '<div id="disqus_thread"></div>';
$html .= '<script type="text/javascript">
var disqus_config = function () {
this.page.url = '.$page->permalink().';
this.page.identifier = '.$page->uuid().';
};
if( $this->enable && !$Url->notFound()) {
return '<div id="disqus_thread"></div>';
(function() {
var d = document, s = d.createElement("script");
s.src = "https://'.$this->getValue('shortname').'.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
';
}
return false;
@ -89,34 +50,7 @@ class pluginDisqus extends Plugin {
public function siteHead()
{
if( $this->enable ) {
return '<style>#disqus_thread { margin: 20px 0 }</style>';
}
return false;
return '<style>#disqus_thread { margin: 20px 0 }</style>';
}
public function siteBodyEnd()
{
if( $this->enable ) {
$html = '
<script type="text/javascript">
var disqus_shortname = "'.$this->getDbField('shortname').'";
(function() {
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>';
return $html;
}
return false;
}
}

View File

@ -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 = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
$html .= '</div>';
$html .= '<div>';
$html .= $Language->get('Sort the tag list by').': <select name="sort">';
foreach(array('alpha' => 'Alphabetical order',
'count' => 'Number of times each tag has been used',
'date' => 'Date each tag was first used') as $key=>$value) {
if ($key == $this->getDbField('sort')) {
$html .= '<option value="'.$key.'" selected>'.$Language->get($value).'</option>';
} else {
$html .= '<option value="'.$key.'">'.$Language->get($value).'</option>';
}
}
$html .= '</select>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '</div>';
return $html;
@ -43,7 +27,6 @@ class pluginTags extends Plugin {
global $dbTags;
global $Url;
$db = $dbTags->db['postsIndex'];
$filter = $Url->filters('tag');
$html = '<div class="plugin plugin-tags">';
@ -51,32 +34,16 @@ class pluginTags extends Plugin {
$html .= '<div class="plugin-content">';
$html .= '<ul>';
$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 .= '<li>';
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$key.'">';
$html .= $fields['name'];
$html .= ' ('.count($fields['list']).')';
$html .= '</a>';
$html .= '</li>';
}
// 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 .= '<li><a href="'.HTML_PATH_ROOT.$filter.'/'.$fields['tagKey'].'">'.$fields['name'].' ('.$fields['count'].')</a></li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';

View File

@ -19,7 +19,7 @@
<!-- Section -->
<section>
<header class="major">
<h2>Ipsum sed dolor</h2>
<h2>Pages</h2>
</header>
<div class="posts">

View File

@ -1,9 +1,15 @@
<section>
<header class="main">
<!-- Title of the page -->
<h1><?php echo $page->title() ?></h1>
</header>
<!-- Cover image of the page -->
<span class="image main"><img src="<?php echo $page->coverImage() ?>" alt="" /></span>
<!-- Content of the page -->
<?php echo $page->content() ?>
<!-- Plugins with the hook pageEnd -->
<?php Theme::plugins('pageEnd') ?>
</section>

View File

@ -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/',