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 '';
}
public function setDb($array)
public function setDb($args)
{
$tmp = array();
// All fields will be sanitize before save.
foreach($array as $key=>$value) {
$tmp[$key] = Sanitize::html($value);
foreach($this->dbFields as $key=>$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;

View File

@ -56,6 +56,9 @@ if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
}
// Alert status ok
define('CHECK_SYMBOLIC_LINKS', FALSE);
// Alert status ok
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
$fullPath = str_replace('/', DS, $fullPath);
if(CHECK_SYMBOLIC_LINKS) {
$real = realpath($fullPath);
}
else {
$real = file_exists($fullPath)?$fullPath:false;
}
// If $real is FALSE the file does not exist.
if($real===false) {

View File

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