Bug fixes, plugins databases - Improves, Disqus plugin

This commit is contained in:
dignajar 2016-02-06 17:35:12 -03:00
parent 0729239517
commit e26b86fddd
4 changed files with 52 additions and 40 deletions

View File

@ -103,13 +103,27 @@ class Plugin {
return ''; return '';
} }
public function setDb($array) public function setDb($args)
{ {
$tmp = array(); $tmp = array();
// All fields will be sanitize before save. foreach($this->dbFields as $key=>$value)
foreach($array as $key=>$value) { {
$tmp[$key] = Sanitize::html($value); if(isset($args[$key]))
{
// Sanitize value
$tmpValue = Sanitize::html( $args[$key] );
// Set type
settype($tmpValue, gettype($value));
// Set value
$tmp[$key] = $tmpValue;
}
else
{
$tmp[$key] = false;
}
} }
$this->db = $tmp; $this->db = $tmp;

View File

@ -56,6 +56,9 @@ if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128); define('JSON_PRETTY_PRINT', 128);
} }
// Alert status ok
define('CHECK_SYMBOLIC_LINKS', FALSE);
// Alert status ok // Alert status ok
define('ALERT_STATUS_OK', 0); define('ALERT_STATUS_OK', 0);

View File

@ -40,7 +40,12 @@ class Sanitize {
// Fix for Windows on paths. eg: $path = c:\diego/page/subpage convert to c:\diego\page\subpages // Fix for Windows on paths. eg: $path = c:\diego/page/subpage convert to c:\diego\page\subpages
$fullPath = str_replace('/', DS, $fullPath); $fullPath = str_replace('/', DS, $fullPath);
if(CHECK_SYMBOLIC_LINKS) {
$real = realpath($fullPath); $real = realpath($fullPath);
}
else {
$real = file_exists($fullPath)?$fullPath:false;
}
// If $real is FALSE the file does not exist. // If $real is FALSE the file does not exist.
if($real===false) { if($real===false) {

View File

@ -2,14 +2,14 @@
class pluginDisqus extends Plugin { class pluginDisqus extends Plugin {
private $disable; private $enable;
public function init() public function init()
{ {
$this->dbFields = array( $this->dbFields = array(
'shortname'=>'', 'shortname'=>'',
'enablePages'=>false, 'enablePages'=>false,
'enablePosts'=>true, 'enablePosts'=>false,
'enableDefaultHomePage'=>false 'enableDefaultHomePage'=>false
); );
} }
@ -20,25 +20,17 @@ class pluginDisqus extends Plugin {
global $Url; global $Url;
// Disable the plugin IF ... $this->enable = false;
$this->disable = false;
if( (!$this->getDbField('enablePosts')) && ($Url->whereAmI()=='post') ) { if( $this->getDbField('enablePosts') && ($Url->whereAmI()=='post') ) {
$this->disable = true; $this->enable = true;
} }
elseif( (!$this->getDbField('enablePages')) && ($Url->whereAmI()=='page') ) { elseif( $this->getDbField('enablePages') && ($Url->whereAmI()=='page') ) {
$this->disable = true; $this->enable = true;
} }
elseif( !$this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='page') ) elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') )
{ {
global $Site; $this->enable = true;
if( Text::isNotEmpty($Site->homePage()) ) {
$this->disable = true;
}
}
elseif( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
$this->disable = true;
} }
} }
@ -71,39 +63,34 @@ class pluginDisqus extends Plugin {
public function postEnd() public function postEnd()
{ {
if( $this->disable ) { if( $this->enable ) {
return false; return '<div id="disqus_thread"></div>';
} }
$html = '<div id="disqus_thread"></div>'; return false;
return $html;
} }
public function pageEnd() public function pageEnd()
{ {
if( $this->disable ) { if( $this->enable ) {
return false; return '<div id="disqus_thread"></div>';
} }
$html = '<div id="disqus_thread"></div>'; return false;
return $html;
} }
public function siteHead() public function siteHead()
{ {
if( $this->disable ) { if( $this->enable ) {
return false; return '<style>#disqus_thread { margin: 20px 0 }</style>';
} }
$html = '<style>#disqus_thread { margin: 20px 0 }</style>'; return false;
return $html;
} }
public function siteBodyEnd() public function siteBodyEnd()
{ {
if( $this->disable ) { if( $this->enable ) {
return false;
}
$html = ' $html = '
<script type="text/javascript"> <script type="text/javascript">
@ -121,4 +108,7 @@ class pluginDisqus extends Plugin {
return $html; return $html;
} }
return false;
}
} }