Disqus plugin

This commit is contained in:
dignajar 2015-08-17 12:07:18 -03:00
parent b97b26a977
commit f93205adf2

View File

@ -2,6 +2,8 @@
class pluginDisqus extends Plugin {
private $disable;
public function init()
{
$this->dbFields = array(
@ -12,6 +14,34 @@ class pluginDisqus extends Plugin {
);
}
function __construct()
{
parent::__construct();
// Disable the plugin IF ...
global $Url;
$this->disable = false;
if( (!$this->getDbField('enablePosts')) && ($Url->whereAmI()=='post') ) {
$this->disable = true;
}
elseif( (!$this->getDbField('enablePages')) && ($Url->whereAmI()=='page') ) {
$this->disable = true;
}
elseif( !$this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='page') )
{
global $Page;
global $Site;
if( $Site->homePage()==$Page->key() ) {
$this->disable = true;
}
}
elseif( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
$this->disable = true;
}
}
public function form()
{
global $Language;
@ -41,34 +71,38 @@ class pluginDisqus extends Plugin {
public function postEnd()
{
$html = '';
if( $this->getDbField('enablePosts') ) {
$html = '<div id="disqus_thread"></div>';
if( $this->disable ) {
return false;
}
$html = '<div id="disqus_thread"></div>';
return $html;
}
public function pageEnd()
{
$html = '';
if( $this->getDbField('enablePages') ) {
$html = '<div id="disqus_thread"></div>';
if( $this->disable ) {
return false;
}
$html = '<div id="disqus_thread"></div>';
return $html;
}
public function siteHead()
{
if( $this->disable ) {
return false;
}
$html = '<style>#disqus_thread { margin: 20px 0 }</style>';
return $html;
}
public function siteBodyEnd()
{
global $Url;
if( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
return '';
if( $this->disable ) {
return false;
}
$html = '