2015-08-14 03:22:26 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class pluginDisqus extends Plugin {
|
|
|
|
|
|
|
|
public function init()
|
|
|
|
{
|
|
|
|
$this->dbFields = array(
|
2017-05-30 19:18:18 +02:00
|
|
|
'shortname'=>''
|
2015-08-14 03:22:26 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function form()
|
|
|
|
{
|
|
|
|
global $Language;
|
|
|
|
|
|
|
|
$html = '<div>';
|
2015-08-17 04:33:49 +02:00
|
|
|
$html .= '<label>'.$Language->get('Disqus shortname').'</label>';
|
2017-05-30 19:18:18 +02:00
|
|
|
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
|
2015-08-17 04:33:49 +02:00
|
|
|
$html .= '</div>';
|
|
|
|
|
2015-08-14 03:22:26 +02:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pageEnd()
|
|
|
|
{
|
2017-05-30 19:18:18 +02:00
|
|
|
global $page;
|
|
|
|
|
|
|
|
if( ($page->key()!='error') && ($page->allowComments()) ) {
|
|
|
|
$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().';
|
|
|
|
};
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
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>
|
|
|
|
';
|
2015-08-17 04:33:49 +02:00
|
|
|
}
|
2015-08-17 17:07:18 +02:00
|
|
|
|
2016-02-06 21:35:12 +01:00
|
|
|
return false;
|
2015-08-14 03:22:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function siteHead()
|
|
|
|
{
|
2017-05-30 19:18:18 +02:00
|
|
|
return '<style>#disqus_thread { margin: 20px 0 }</style>';
|
2015-08-14 03:22:26 +02:00
|
|
|
}
|
|
|
|
|
2016-02-06 21:35:12 +01:00
|
|
|
}
|