Browse Source

first working version

master
Gogs 5 years ago
parent
commit
8cb8d16692
  1. 132
      plugin.php

132
plugin.php

@ -2,7 +2,7 @@
class pluginIsso extends Plugin {
private $enable, $customCss;
private $enable;
public function init()
{
@ -14,15 +14,16 @@ class pluginIsso extends Plugin {
'pathSrc'=>'',
'pathCss'=>'',
'dataLang'=>'',
'dataReplySelf'=>0,
'dataRequireEmail'=>'',
'dataCommentsTop'=>'',
'dataCommentsNested'=>'',
'dataRevealClick'=>'',
'dataAvatar'=>'',
'dataReplySelf'=>'false',
'dataRequireAuthor'=>'true',
'dataRequireEmail'=>'false',
'dataCommentsTop'=>'10',
'dataCommentsNested'=>'5',
'dataRevealClick'=>'5',
'dataAvatar'=>'true',
'dataAvatarBg'=>'',
'dataAvatarFg'=>'',
'dataVote'=>''
'dataVote'=>'true'
);
}
@ -43,12 +44,6 @@ class pluginIsso extends Plugin {
elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') ) {
$this->enable = true;
}
if( Text::isEmpty($this->getDbField('pathCss')) ) {
$this->customCss = false;
} else {
$this->customCss = true;
}
}
public function form()
@ -82,62 +77,82 @@ class pluginIsso extends Plugin {
$html .= '<input name="pathSrc" id="jssource" type="text" value="'.$this->getDbField('pathSrc').'">';
$html .= '</div>';
$html .= '<p><h3>'.$Language->get('Optional settings').':</h3></p>';
$html .= '<form>';
$html .= '<label>data-isso-reply-to-self: [true/false]</label>';
$html .= '<input name="datareplyself" id="jsdatareplyself" type="radio" value="1" '.(($this->getDbField('dataReplySelf'))?'checked':'').'> true</br>';
$html .= '<input name="datareplyself" id="jsdatareplyself2" type="radio" value="0" '.((!$this->getDbField('dataReplySelf'))?'checked':'').'> false';
$html .= '</form>';
$html .= '<div>';
$html .= '<label>data-isso-require-email: [true/false]</label>';
$html .= '<input name="datarequireemail" id="jsdatarequireemail" type="text" value="'.$this->getDbField('dataRequireEmail').'">';
$html .= '<label>data-isso-reply-to-self: ['.$Language->get('true').'/'.$Language->get('false').']</label>';
$html .= '<input name="dataReplySelf" id="jsdatareplyself_1" type="radio" value="true" ';
$html .= (($this->getDbField('dataReplySelf') == 'true')?'checked':'').'> '.$Language->get('true').'</br>';
$html .= '<input name="dataReplySelf" id="jsdatareplyself_2" type="radio" value="false" ';
$html .= (($this->getDbField('dataReplySelf') == 'false')?'checked':'').'> '.$Language->get('false').'</br>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-vote: [true/false]</label>';
$html .= '<input name="datavote" id="jsdatavote" type="text" value="'.$this->getDbField('dataVote').'">';
$html .= '<label>data-isso-require-author: ['.$Language->get('true').'/'.$Language->get('false').']</label>';
$html .= '<input name="dataRequireAuthor" id="jsdatarequireauthor_1" type="radio" value="true" ';
$html .= (($this->getDbField('dataRequireAuthor') == 'true')?'checked':'').'> '.$Language->get('true').'</br>';
$html .= '<input name="dataRequireAuthor" id="jsdatarequireauthor_2" type="radio" value="false" ';
$html .= (($this->getDbField('dataRequireAuthor') == 'false')?'checked':'').'> '.$Language->get('false').'</br>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-avatar: [true/false]</label>';
$html .= '<input name="dataavatar" id="jsdataavatar" type="text" value="'.$this->getDbField('dataAvatar').'">';
$html .= '<label>data-isso-require-email: ['.$Language->get('true').'/'.$Language->get('false').']</label>';
$html .= '<input name="dataRequireEmail" id="jsdatarequireemail_1" type="radio" value="true" ';
$html .= (($this->getDbField('dataRequireEmail') == 'true')?'checked':'').'> '.$Language->get('true').'</br>';
$html .= '<input name="dataRequireEmail" id="jsdatarequireemail_2" type="radio" value="false" ';
$html .= (($this->getDbField('dataRequireEmail') == 'false')?'checked':'').'> '.$Language->get('false').'</br>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-vote: ['.$Language->get('true').'/'.$Language->get('false').']</label>';
$html .= '<input name="dataVote" id="jsdatavote_1" type="radio" value="true" ';
$html .= (($this->getDbField('dataVote') == 'true')?'checked':'').'> '.$Language->get('true').'</br>';
$html .= '<input name="dataVote" id="jsdatavote_2" type="radio" value="false" ';
$html .= (($this->getDbField('dataVote') == 'false')?'checked':'').'> '.$Language->get('false').'</br>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-avatar: ['.$Language->get('true').'/'.$Language->get('false').']</label>';
$html .= '<input name="dataAvatar" id="jsdataavatar_1" type="radio" value="true" ';
$html .= (($this->getDbField('dataAvatar') == 'true')?'checked':'').'> '.$Language->get('true').'</br>';
$html .= '<input name="dataAvatar" id="jsdataavatar_2" type="radio" value="false" ';
$html .= (($this->getDbField('dataAvatar') == 'false')?'checked':'').'> '.$Language->get('false').'</br>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-avatar-fg: ['.$Language->get('#colorcode').']</label>';
$html .= '<input name="dataavatarfg" id="jsdataavatarfg" type="text" value="'.$this->getDbField('dataAvatarFg').'">';
$html .= '<input name="dataAvatarFg" id="jsdataavatarfg" type="text" value="'.$this->getDbField('dataAvatarFg').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-avatar-bg: ['.$Language->get('#colorcode').']</label>';
$html .= '<input name="dataavatarbg" id="jsdataavatarbg" type="text" value="'.$this->getDbField('dataAvatarBg').'">';
$html .= '<input name="dataAvatarBg" id="jsdataavatarbg" type="text" value="'.$this->getDbField('dataAvatarBg').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-lang: ['.$Language->get('(two letter) language code').']</label>';
$html .= '<input name="datalang" id="jsdatalang" type="text" value="'.$this->getDbField('dataLang').'">';
$html .= '<input name="dataLang" id="jsdatalang" type="text" value="'.$this->getDbField('dataLang').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-max-comments-top: ['.$Language->get('number').']</label>';
$html .= '<input name="datacommentstop" id="jsdatacommentstop" type="text" value="'.$this->getDbField('dataCommentsTop').'">';
$html .= '<input name="dataCommentsTop" id="jsdatacommentstop" type="number" min="0" value="'.$this->getDbField('dataCommentsTop').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-max-comments-nested: ['.$Language->get('number').']</label>';
$html .= '<input name="datacommentsnested" id="jsdatacommentsnested" type="text" value="'.$this->getDbField('dataCommentsNested').'">';
$html .= '<input name="dataCommentsNested" id="jsdatacommentsnested" type="number" min="0" value="'.$this->getDbField('dataCommentsNested').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>data-isso-reveal-on-click: ['.$Language->get('number').']</label>';
$html .= '<input name="datarevealclick" id="jsdatarevealclick" type="text" value="'.$this->getDbField('dataRevealClick').'">';
$html .= '<input name="dataRevealClick" id="jsdatarevealclick" type="number" min="0" value="'.$this->getDbField('dataRevealClick').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Path to custom CSS').'</label>';
$html .= '<input name="datacss" id="jsdatacss" type="text" value="'.$this->getDbField('pathCss').'">';
$html .= '<input name="pathCss" id="jsdatacss" type="text" value="'.$this->getDbField('pathCss').'">';
$html .= '</div>';
return $html;
@ -145,8 +160,13 @@ class pluginIsso extends Plugin {
public function postEnd()
{
global $Language;
if( $this->enable ) {
return '<section id="isso-thread"></section>';
$html = '<section id="isso-thread"></section>';
$html .= '<noscript>'.$Language->get('The comment section powered by isso can not be shown without javascript!');
$html .= '</noscript>';
return $html;
}
return false;
@ -155,12 +175,16 @@ class pluginIsso extends Plugin {
public function pageEnd()
{
global $Url;
global $Language;
// Bludit check not-found page after the plugin method construct.
// It's necesary check here the page not-found.
if( $this->enable && !$Url->notFound()) {
return '<section id="isso-thread"></section>';
$html = '<section id="isso-thread"></section>';
$html .= '<noscript>'.$Language->get('The comment section powered by isso can not be shown without javascript!');
$html .= '</noscript>';
return $html;
}
return false;
@ -171,55 +195,55 @@ class pluginIsso extends Plugin {
if( $this->enable ) {
$html = '<style>#isso-thread { margin: 20px 0 !important }</style>';
if( $this->customCss ) {
$html .= '<link rel="stylesheet" href="'.$this->getDbField('pathCss').'">';
if( !Text::isEmpty($this->getDbField('pathCss')) ) {
$html .= '<link rel="stylesheet" href="'.trim($this->getDbField('pathCss')).'">';
}
$html .= '<script ';
$html .= 'data-isso="'.$this->getDbField('pathData').'" ';
$html .= 'src="'.$this->getDbField('pathSrc').'" ';
if( $this->getDbField('dataReplySelf') === 'true' || $this->getDbField('dataReplySelf') === 'false' ) {
if( $this->getDbField('dataReplySelf') == 'true' || $this->getDbField('dataReplySelf') == 'false' ) {
$html .= 'data-isso-reply-to-self="'.$this->getDbField('dataReplySelf').'" ';
}
if( $this->getDbField('dataRequireEmail') === 'true' || $this->getDbField('dataRequireEmail') === 'false' ) {
if( $this->getDbField('dataRequireEmail') == 'true' || $this->getDbField('dataRequireEmail') == 'false' ) {
$html .= 'data-isso-require-email="'.$this->getDbField('dataRequireEmail').'" ';
}
if( $this->getDbField('dataVote') === 'true' || $this->getDbField('dataVote') === 'false' ) {
if( $this->getDbField('dataVote') == 'true' || $this->getDbField('dataVote') == 'false' ) {
$html .= 'data-isso-vote="'.$this->getDbField('dataVote').'" ';
}
if( $this->getDbField('dataAvatar') === 'true' || $this->getDbField('dataAvatar') === 'false' ) {
if( $this->getDbField('dataAvatar') == 'true' || $this->getDbField('dataAvatar') == 'false' ) {
$html .= 'data-isso-avatar="'.$this->getDbField('dataAvatar').'" ';
}
if( !empty($this->getDbField('dataAvatarFg')) ) {
$html .= 'data-isso-avatar-fg="'.$this->getDbField('dataAvatarFg').'" ';
if( !Text::isEmpty($this->getDbField('dataAvatarFg')) ) {
$html .= 'data-isso-avatar-fg="'.trim($this->getDbField('dataAvatarFg')).'" ';
}
if( !empty($this->getDbField('dataAvatarBg')) ) {
$html .= 'data-isso-avatar-bg="'.$this->getDbField('dataAvatarBg').'" ';
if( !Text::isEmpty($this->getDbField('dataAvatarBg')) ) {
$html .= 'data-isso-avatar-bg="'.trim($this->getDbField('dataAvatarBg')).'" ';
}
if( !empty($this->getDbField('dataLang')) ) {
$html .= 'data-isso-lang="'.$this->getDbField('dataLang').'" ';
if( !Text::isEmpty($this->getDbField('dataLang')) ) {
$html .= 'data-isso-lang="'.trim($this->getDbField('dataLang')).'" ';
}
if( is_numeric( $this->getDbField('dataCommentsTop') ) ) {
if( Valid::int( $this->getDbField('dataCommentsTop') ) ) {
$html .= 'data-isso-max-comments-top="'.$this->getDbField('dataCommentsTop').'" ';
}
if( is_numeric( $this->getDbField('dataCommentsNested') ) ) {
if( Valid::int( $this->getDbField('dataCommentsNested') ) ) {
$html .= 'data-isso-max-comments-nested="'.$this->getDbField('dataCommentsNested').'" ';
}
if( is_numeric( $this->getDbField('dataRevealClick') ) ) {
if( Valid::int( $this->getDbField('dataRevealClick') ) ) {
$html .= 'data-isso-reveal-on-click="'.$this->getDbField('dataRevealClick').'" ';
}
if( $this->customCss ) {
if( !Text::isEmpty($this->getDbField('pathCss')) ) {
$html .= 'data-isso-css="false" ';
} else {
$html .= 'data-isso-css="true" ';

Loading…
Cancel
Save