- Сообщений: 5
- Спасибо получено: 0
<?php
/**
* JLcomments
*
* @version 2.6
* @author Kunitsyn Vadim (vadim@joomline.ru), Artem Jukov (artem@joomline.ru)
* @copyright (C) 2011 by Kunitsyn Vadim(http://www.joomline.ru)
* @license GNU/GPL: http://www.gnu.org/copyleft/gpl.html
**/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
class plgContentJlcomments extends JPlugin
{
public function onContentPrepare($context, &$article, &$params, $page = 0){
if($context == 'com_content.article'){
if (strpos($article->text, '{jlcomments-off}') !== false) {
$article->text = str_replace("{jlcomments-off}","",$article->text);
return true;
}
if (strpos($article->text, '{jlcomments}') === false && !$this->params->def('autoAdd')) {
return true;
}
$exceptcat = is_array($this->params->def('categories')) ? $this->params->def('categories') : array($this->params->def('categories'));
if (!in_array($article->catid,$exceptcat)) {
$view = JRequest::getCmd('view');
if ($view == 'article') {
$doc = JFactory::getDocument();
$uri = JURI::getInstance();
$base = $uri->toString(array('scheme', 'host', 'port'));
$article_url = $base.JRoute::_(ContentHelperRoute::getArticleRoute($article->slug, $article->catid, $article->catslug));
$apiId = $this->params->def('apiId');
$widthvk = $this->params->def('widthvk');
$widthfb = $this->params->def('widthfb');
$widthgoogle = $this->params->def('widthgoogle');
$comLimit = $this->params->def('comLimit');
$attach = $this->params->def('attach');
$autoPublish = $this->params->def('autoPublish');
$norealtime = $this->params->def('norealtime');
$fbId = $this->params->def('fbId');
$fbadmin = $this->params->def('fbadmin');
$fb_lang = $this->params->def('fb_lang');
$typeviewerjq = $this->params->def('typeviewerjq');
$typeviewerbs = $this->params->def('typeviewerbs');
$typeviewernojq = $this->params->def('typeviewernojq');
$typeviewercss = $this->params->def('typeviewercss');
$link = $this->params->def('link');
$colorscheme = $this->params->def('colorscheme');
$order_by_fb = $this->params->def('orderbyfb');
$linknone = '';
$lang = JFactory::getLanguage();
$lang->load('plg_content_jlcomments', JPATH_ADMINISTRATOR);
$jlcomments_comments = JText::_('PLG_JLCOMMENTS_COMMENTS');
$jlcomments_vk = JText::_('PLG_JLCOMMENTS_VK');
$jlcomments_fb = JText::_('PLG_JLCOMMENTS_FB');
$jlcomments_google = JText::_('PLG_JLCOMMENTS_GOOGLE');
$script = "VK.init({apiId: $apiId, onlyWidgets: true});";
$doc->addCustomTag('<meta property="fb:admins" content="'.$fbadmin.'"/>');
$doc->addCustomTag('<meta property="fb:app_id" content="'.$fbId.'"/>');
$doc->addScript("//vk.com/js/api/openapi.js?95");
$doc->addCustomTag('<script src="https://apis.google.com/js/plusone.js" type="text/javascript">/* {lang: "'.$fb_lang.'"} */</script>');
$doc->addScriptDeclaration($script);
$pagehash = $article->id;
$orders = explode(",",$this->params->def('orders'));
if (($this->params->def('googleid')!='')&&($this->params->def('googleplus'))){
$doc->addCustomTag('<link rel="author" href="https://plus.google.com/'. $this->params->def('googleid') .'/">');
}
else {}
if ($link==0){
$linknone = 'display:none;';
}
else {}
If ($typeviewerjq==1) {
$doc->addCustomTag('<script src="http://yandex.st/jquery/1.9.1/jquery.min.js"></script>');
}
If ($typeviewercss==1) {
$doc->addStyleSheet("/plugins/content/jlcomments/css/jlcomtabs.css");
}
If ($typeviewerbs==1) {
$doc->addCustomTag('<script src="http://yandex.st/bootstrap/2.3.0/js/bootstrap.min.js"></script>');
}
If ($typeviewernojq==1) {
$doc->addCustomTag ('<script type="text/javascript">var jqjlcomm = jQuery.noConflict();</script>');
}
else {}
$comments = JPATH_SITE . '/components/com_jcomments/jcomments.php';
if (file_exists($comments)) {
require_once($comments);
$options['object_id'] = $pagehash;
$options['object_group'] = 'com_content';
$options['published'] = 1;
$count = JCommentsModel::getCommentsCount($options);
}
$scriptPage = <<<HTML
<div style="clear:both"> </div><div id="jlcomments_container"><ul class="nav nav-tabs" id="plgjlcomments1">
HTML;
foreach ($orders as $order) {
switch($order) {
case 1: if ($this->params->def('showjcomments')) { $scriptPage .= <<<HTML
<li style="list-style-type: none;" class="active"><a href="#jcommentscomm" data-toggle="tab"><i class="jlico-comments"></i> $jlcomments_comments ($count)</a></li>
HTML;
} else {$scriptPage .='';$showjcomments='-1';} break;
case 2: if ($this->params->def('showvkontakte')) { $scriptPage .= <<<HTML
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.ajax({
url: "https://api.vk.com/method/widgets.getComments.json?widget_api_id=$apiId&page_id=$pagehash",
dataType: 'jsonp',
success: function(data){
jQuery('#vk_count').text(data.response.count);
},
error: function(data){
console.log(data);
}
});
});
/* ]]> */
</script>
<li style="list-style-type: none;"><a href="#vkcomm" data-toggle="tab"><i class="jlico-vk"></i> $jlcomments_vk (<span id="vk_count"></span>)</a></li>
HTML;
} else {$scriptPage .='';} break;
case 3: if ($this->params->def('googleplus')) {
$width_ = $widthgoogle.'px';
$doc = JFactory::getDocument();
$style1 = '#googlecomm * {width:$width_ !important;min-height:600px !important;}';
$doc->addStyleDeclaration( $style1 );
$scriptPage .= <<<HTML
<li style="list-style-type: none;"><a href="#googlecomm" data-toggle="tab"><i class="jlico-google"></i> $jlcomments_google</a></li>
HTML;
} else {$scriptPage .='';} break;
case 4: if ($this->params->def('showfacebook')) {$doc = JFactory::getDocument();
$style2 = '.fb-comments,.fb-comments span,.fb-comments iframe {min-height: 300px!important; width:100%!important;} .fb_hide_iframes iframe {left:0px !important;}';
$doc->addStyleDeclaration( $style2 );
$scriptPage .= <<<HTML
<li style="list-style-type: none;"><a href="#fbcomm" data-toggle="tab"><div><i class="jlico-facebook"></i> $jlcomments_fb (<span class="fb-comments-count" data-href="$article_url"></span>)</div></a></li>
HTML;
} else {$scriptPage .='';} break;
}
}
$scriptPage .= <<<HTML
</ul>
<div class="tab-content">
HTML;
foreach ($orders as $order) {
switch($order) {
case 1: if ($this->params->def('showjcomments')) { $scriptPage .= <<<HTML
<div class="tab-pane active" id="jcommentscomm">
{jcomments}
</div>
HTML;
} else {$scriptPage .='';$showjcomments='-1';} break;
case 2: if ($this->params->def('showvkontakte')) { $scriptPage .= <<<HTML
<div class="tab-pane" id="vkcomm">
<div id='jlcomments'></div>
<script type='text/javascript'>
/* <![CDATA[ */
VK.Widgets.Comments('jlcomments', {limit: $comLimit, width: '$widthvk', attach: '$attach', autoPublish: $autoPublish, norealtime: $norealtime},$pagehash);
/* ]]> */
</script>
</div>
HTML;
} else {$scriptPage .='';} break;
case 3: if ($this->params->def('googleplus')) {
$scriptPage .= <<<HTML
<div class="tab-pane" id="googlecomm">
<div class="g-comments"
data-href="$article_url"
data-width="$widthgoogle"
data-first_party_property="BLOGGER"
data-view_type="FILTERED_POSTMOD">
</div>
</div>
HTML;
} else {$scriptPage .='';} break;
case 4: if ($this->params->def('showfacebook')) { $scriptPage .= <<<HTML
<div class="tab-pane" id="fbcomm">
<script type="text/javascript">/* <![CDATA[ */(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/$fb_lang/all.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));/* ]]> */</script>
<div class="fb-comments" data-href="$article_url" data-num-posts="$comLimit" data-width="$widthfb" data-colorscheme="$colorscheme" data-order-by="$order_by_fb"></div>
</div>
HTML;
} else {$scriptPage .='';} break;
}
}
$scriptPage .= <<<HTML
</div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery('#plgjlcomments1 a:first').tab('show');
});
/* ]]> */
</script>
<div style="text-align: right; $linknone;">
<a style="text-decoration:none; color: #c0c0c0; font-family: arial,helvetica,sans-serif; font-size: 5pt; " target="_blank" href="http://www.38i.ru">www.38i.ru</a>
</div>
HTML;
if ($this->params->def('autoAdd') == 1) {
$article->text .= $scriptPage;
} else {
$article->text = str_replace("{jlcomments}",$scriptPage,$article->text);
}
}
} else {
$article->text = str_replace("{jlcomments}","",$article->text);
}
}
}
}
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
GitHub — крупнейший веб-сервис для хостинга IT-проектов и их совместной разработки. Основан на системе контроля версий Git и разработан на Ruby on Rails и Erlang компанией GitHub, Inc (ранее Logical Awesome).
$doc->addCustomTag('<script src="https://apis.google.com/js/plusone.js" type="text/javascript">/* {lang: "'.$fb_lang.'"} */</script>');
$scriptPage = <<<HTML
<div style="clear:both"> </div><div id="jlcomments_container"><ul class="nav nav-tabs" id="plgjlcomments1">
HTML;
<li style="list-style-type: none;"><a href="#fbcomm" data-toggle="tab"><div><i class="jlico-facebook"></i> $jlcomments_fb (<span class="fb-comments-count" data-href="$article_url"></span>)</div></a></li>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.ajax({
url: "https://api.vk.com/method/widgets.getComments.json?widget_api_id=$apiId&page_id=$pagehash",
dataType: 'jsonp',
success: function(data){
jQuery('#vk_count').text(data.response.count);
},
error: function(data){
console.log(data);
}
});
});
/* ]]> */
</script>
<script type='text/javascript'>
/* <![CDATA[ */
VK.Widgets.Comments('jlcomments', {limit: $comLimit, width: '$widthvk', attach: '$attach', autoPublish: $autoPublish, norealtime: $norealtime},$pagehash);
/* ]]> */
</script>
<div class="tab-pane" id="fbcomm">
<script type="text/javascript">/* <![CDATA[ */(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/$fb_lang/all.js#xfbml=1&version=v2.0";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));/* ]]> */</script>
<div class="fb-comments" data-href="$article_url" data-num-posts="$comLimit" data-width="$widthfb" data-colorscheme="$colorscheme" data-order-by="$order_by_fb"></div>
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery('#plgjlcomments1 a:first').tab('show');
});
/* ]]> */
</script>
} else {$scriptPage .='';} break;
case 3: if ($this->params->def('googleplus')) {
$width_ = $widthgoogle.'px';
$doc = JFactory::getDocument();
$style1 = '#googlecomm * {width:$width_ !important;min-height:600px !important;}';
$doc->addStyleDeclaration( $style1 );
$scriptPage .= <<<HTML
<li style="list-style-type: none;"><a href="#googlecomm" data-toggle="tab"><i class="jlico-google"></i> $jlcomments_google</a></li>
HTML;
case 4: if ($this->params->def('showfacebook')) {$doc = JFactory::getDocument();
$style2 = '.fb-comments,.fb-comments span,.fb-comments iframe {min-height: 300px!important; width:100%!important;} .fb_hide_iframes iframe {left:0px !important;}';
$doc->addStyleDeclaration( $style2 );
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
$doc->addCustomTag('<script src="https://apis.google.com/js/plusone.js" type="text/javascript" async="async">/* {lang: "'.$fb_lang.'"} */</script>');
$doc->addCustomTag('<script src="//yandex.st/bootstrap/2.3.0/js/bootstrap.min.js" async="async"></script>');
$doc->addScript("//vk.com/js/api/openapi.js?95");
$doc->addCustomTag('<script src="//vk.com/js/api/openapi.js?95" async="async"></script>');
<!-- Put this script tag to the <head> of your page -->
<script type="text/javascript" src="//vk.com/js/api/openapi.js?127"></script>
$doc->addScript("//vk.com/js/api/openapi.js?127");
Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.
Контакты:
тел.: +7 950 676-22-39
email: Адрес электронной почты защищен от спам-ботов. Для просмотра адреса в вашем браузере должен быть включен Javascript.