Division by zero fixed and installer updated
This commit is contained in:
parent
0d783359fa
commit
a90ff3e635
|
@ -181,9 +181,15 @@ class Plugin {
|
||||||
|
|
||||||
public function isCompatible()
|
public function isCompatible()
|
||||||
{
|
{
|
||||||
$explode = explode(',', $this->getMetadata('compatible'));
|
$bluditRoot = explode('.', BLUDIT_VERSION);
|
||||||
|
$compatible = explode(',', $this->getMetadata('compatible'));
|
||||||
return in_array(BLUDIT_VERSION, $explode);
|
foreach( $compatible as $version ) {
|
||||||
|
$root = explode('.', $version);
|
||||||
|
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function directoryName()
|
public function directoryName()
|
||||||
|
|
|
@ -45,13 +45,16 @@ function buildThemes()
|
||||||
$metadata = json_decode($metadataString, true);
|
$metadata = json_decode($metadataString, true);
|
||||||
|
|
||||||
$database['compatible'] = false;
|
$database['compatible'] = false;
|
||||||
|
|
||||||
if( !empty($metadata['compatible']) ) {
|
if( !empty($metadata['compatible']) ) {
|
||||||
$explode = explode(',', $metadata['compatible']);
|
$bluditRoot = explode('.', BLUDIT_VERSION);
|
||||||
if(in_array(BLUDIT_VERSION, $explode)) {
|
$compatible = explode(',', $metadata['compatible']);
|
||||||
|
foreach( $compatible as $version ) {
|
||||||
|
$root = explode('.', $version);
|
||||||
|
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
|
||||||
$database['compatible'] = true;
|
$database['compatible'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$database = $database + $metadata;
|
$database = $database + $metadata;
|
||||||
array_push($themes, $database);
|
array_push($themes, $database);
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
"author": "Bludit",
|
"author": "Bludit",
|
||||||
"email": "",
|
"email": "",
|
||||||
"website": "https://plugins.bludit.com",
|
"website": "https://plugins.bludit.com",
|
||||||
"version": "1.5.2",
|
"version": "2.0",
|
||||||
"releaseDate": "2016-05-28",
|
"releaseDate": "2017-05-26",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"compatible": "1.5.2",
|
"compatible": "2.0",
|
||||||
"notes": ""
|
"notes": ""
|
||||||
}
|
}
|
|
@ -2,86 +2,47 @@
|
||||||
|
|
||||||
class pluginDisqus extends Plugin {
|
class pluginDisqus extends Plugin {
|
||||||
|
|
||||||
private $enable;
|
|
||||||
|
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->dbFields = array(
|
$this->dbFields = array(
|
||||||
'shortname'=>'',
|
'shortname'=>''
|
||||||
'enablePages'=>0,
|
|
||||||
'enablePosts'=>0,
|
|
||||||
'enableDefaultHomePage'=>1
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
public function form()
|
||||||
{
|
{
|
||||||
global $Language;
|
global $Language;
|
||||||
|
|
||||||
$html = '<div>';
|
$html = '<div>';
|
||||||
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
|
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
|
||||||
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
|
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('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 .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postEnd()
|
|
||||||
{
|
|
||||||
if( $this->enable ) {
|
|
||||||
return '<div id="disqus_thread"></div>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function pageEnd()
|
public function pageEnd()
|
||||||
{
|
{
|
||||||
global $Url;
|
global $page;
|
||||||
|
|
||||||
// Bludit check not-found page after the plugin method construct.
|
if( ($page->key()!='error') && ($page->allowComments()) ) {
|
||||||
// It's necesary check here the page not-found.
|
$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()) {
|
(function() {
|
||||||
return '<div id="disqus_thread"></div>';
|
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;
|
return false;
|
||||||
|
@ -89,34 +50,7 @@ class pluginDisqus extends Plugin {
|
||||||
|
|
||||||
public function siteHead()
|
public function siteHead()
|
||||||
{
|
{
|
||||||
if( $this->enable ) {
|
|
||||||
return '<style>#disqus_thread { margin: 20px 0 }</style>';
|
return '<style>#disqus_thread { margin: 20px 0 }</style>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -5,8 +5,7 @@ class pluginTags extends Plugin {
|
||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$this->dbFields = array(
|
$this->dbFields = array(
|
||||||
'label'=>'Tags',
|
'label'=>'Tags'
|
||||||
'sort'=>'date'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,23 +14,8 @@ class pluginTags extends Plugin {
|
||||||
global $Language;
|
global $Language;
|
||||||
|
|
||||||
$html = '<div>';
|
$html = '<div>';
|
||||||
$html .= '<label>'.$Language->get('Plugin label').'</label>';
|
$html .= '<label>'.$Language->get('Label').'</label>';
|
||||||
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">';
|
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('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 .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
||||||
return $html;
|
return $html;
|
||||||
|
@ -43,7 +27,6 @@ class pluginTags extends Plugin {
|
||||||
global $dbTags;
|
global $dbTags;
|
||||||
global $Url;
|
global $Url;
|
||||||
|
|
||||||
$db = $dbTags->db['postsIndex'];
|
|
||||||
$filter = $Url->filters('tag');
|
$filter = $Url->filters('tag');
|
||||||
|
|
||||||
$html = '<div class="plugin plugin-tags">';
|
$html = '<div class="plugin plugin-tags">';
|
||||||
|
@ -51,32 +34,16 @@ class pluginTags extends Plugin {
|
||||||
$html .= '<div class="plugin-content">';
|
$html .= '<div class="plugin-content">';
|
||||||
$html .= '<ul>';
|
$html .= '<ul>';
|
||||||
|
|
||||||
$tagArray = array();
|
// By default the database of tags are alphanumeric sorted
|
||||||
|
foreach( $dbTags->db as $key=>$fields ) {
|
||||||
foreach($db as $tagKey=>$fields)
|
$html .= '<li>';
|
||||||
{
|
$html .= '<a href="'.DOMAIN_BASE.$filter.'/'.$key.'">';
|
||||||
$tagArray[] = array('tagKey'=>$tagKey, 'count'=>$dbTags->countPostsByTag($tagKey), 'name'=>$fields['name']);
|
$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 .= '</ul>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
$html .= '</div>';
|
$html .= '</div>';
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
<!-- Section -->
|
<!-- Section -->
|
||||||
<section>
|
<section>
|
||||||
<header class="major">
|
<header class="major">
|
||||||
<h2>Ipsum sed dolor</h2>
|
<h2>Pages</h2>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="posts">
|
<div class="posts">
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
<section>
|
<section>
|
||||||
<header class="main">
|
<header class="main">
|
||||||
|
<!-- Title of the page -->
|
||||||
<h1><?php echo $page->title() ?></h1>
|
<h1><?php echo $page->title() ?></h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<!-- Cover image of the page -->
|
||||||
<span class="image main"><img src="<?php echo $page->coverImage() ?>" alt="" /></span>
|
<span class="image main"><img src="<?php echo $page->coverImage() ?>" alt="" /></span>
|
||||||
|
|
||||||
|
<!-- Content of the page -->
|
||||||
<?php echo $page->content() ?>
|
<?php echo $page->content() ?>
|
||||||
|
|
||||||
|
<!-- Plugins with the hook pageEnd -->
|
||||||
|
<?php Theme::plugins('pageEnd') ?>
|
||||||
</section>
|
</section>
|
|
@ -358,10 +358,10 @@ function install($adminPassword, $email, $timezone)
|
||||||
'language'=>$Language->getCurrentLocale(),
|
'language'=>$Language->getCurrentLocale(),
|
||||||
'locale'=>$Language->getCurrentLocale(),
|
'locale'=>$Language->getCurrentLocale(),
|
||||||
'timezone'=>$timezone,
|
'timezone'=>$timezone,
|
||||||
'theme'=>'log',
|
'theme'=>'editorial',
|
||||||
'adminTheme'=>'default',
|
'adminTheme'=>'default',
|
||||||
'homepage'=>'',
|
'homepage'=>'',
|
||||||
'postsperpage'=>'6',
|
'itemsPerPage'=>'6',
|
||||||
'uriPage'=>'/',
|
'uriPage'=>'/',
|
||||||
'uriTag'=>'/tag/',
|
'uriTag'=>'/tag/',
|
||||||
'uriCategory'=>'/category/',
|
'uriCategory'=>'/category/',
|
||||||
|
|
Loading…
Reference in New Issue