Disqus plugin

This commit is contained in:
dignajar 2015-08-17 12:07:18 -03:00
parent b97b26a977
commit f93205adf2
1 changed files with 44 additions and 10 deletions

View File

@ -2,6 +2,8 @@
class pluginDisqus extends Plugin { class pluginDisqus extends Plugin {
private $disable;
public function init() public function init()
{ {
$this->dbFields = array( $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() public function form()
{ {
global $Language; global $Language;
@ -41,34 +71,38 @@ class pluginDisqus extends Plugin {
public function postEnd() public function postEnd()
{ {
$html = ''; if( $this->disable ) {
if( $this->getDbField('enablePosts') ) { return false;
$html = '<div id="disqus_thread"></div>';
} }
$html = '<div id="disqus_thread"></div>';
return $html; return $html;
} }
public function pageEnd() public function pageEnd()
{ {
$html = ''; if( $this->disable ) {
if( $this->getDbField('enablePages') ) { return false;
$html = '<div id="disqus_thread"></div>';
} }
$html = '<div id="disqus_thread"></div>';
return $html; return $html;
} }
public function siteHead() public function siteHead()
{ {
if( $this->disable ) {
return false;
}
$html = '<style>#disqus_thread { margin: 20px 0 }</style>'; $html = '<style>#disqus_thread { margin: 20px 0 }</style>';
return $html; return $html;
} }
public function siteBodyEnd() public function siteBodyEnd()
{ {
global $Url; if( $this->disable ) {
return false;
if( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
return '';
} }
$html = ' $html = '