0 Пользователей и 1 Гость просматривают эту тему.
  • 0 Ответов
  • 1815 Просмотров
*

Chigolberi

  • Захожу иногда
  • 464
  • 12 / 0
ExtraVote Plugin - вставка javascript
« : 05.05.2015, 11:46:36 »
Добрый день!

Нужна помощь, кто разбирается в php, нужно вставить код javascript в файл плагина ExtraVote - extravote.php

Файл extravote.php:
Код
<?php

// No direct access
defined('_JEXEC') or die;

jimport('joomla.plugin.plugin');


class plgContentExtraVote extends JPlugin
{
protected $article_id;

public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();

$this->view = JRequest::getCmd('view');
}

public function onContentBeforeDisplay($context, &$article, &$params, $limitstart = 1)
{
if (strpos($context, 'com_content')!== false) {

$this->article_id = $article->id;

$this->ExtraVotePrepare($article, $params);

if ( $this->params->get('display') == 0  )
{
$hide  = $this->params->get('hide', 1);

if ( $hide != 1 || $this->view == 'article' ) {
$article->xid = 0;
return $this->ContentExtraVote($article, $params);
}
}
}

  }

protected function ContentExtraVote(&$article, &$params)
{
$table =($this->params->get('table',1)==1?'#__content_extravote':'#__content_rating');
$rating_count=$rating_sum=0;
$html=$ip='';

if ($params->get('show_vote'))
{
$db = JFactory::getDBO();
$query='SELECT * FROM ' . $table . ' WHERE content_id='.$this->article_id . ($table == '#__content_extravote' ? ' AND extra_id = 0' : '');
$db->setQuery($query);
$vote=$db->loadObject();

if($vote) {
$rating_sum = $vote->rating_sum;
$rating_count = intval($vote->rating_count);
$ip = $vote->lastip;
}

$html .= $this->plgContentExtraVoteStars( $this->article_id, $rating_sum, $rating_count, $article->xid, $ip );
}
return $html;
  }

 
  protected function plgContentExtraVoteStars( $id, $rating_sum, $rating_count, $xid, $ip )
{
$document = JFactory::getDocument();

if ( $this->params->get('css', 1) ) :
$document->addStyleSheet(JURI::root(true).'/plugins/content/extravote/assets/extravote.css');
endif;

$document->addScript(JURI::root(true).'/plugins/content/extravote/assets/extravote.js');

      global $plgContentExtraVoteAddScript;

$show_counter = $this->params->get('show_counter',1);
$show_rating  = $this->params->get('show_rating',1);
$rating_mode  = $this->params->get('rating_mode', 1);
$show_unrated = $this->params->get('show_unrated',1);
$initial_hide = $this->params->get('initial_hide',0);
$add_snippets = $this->params->get('snippets',0);
$currip = $_SERVER['REMOTE_ADDR'];
$rating  = 0;

if(!$plgContentExtraVoteAddScript){
          $document->addScriptDeclaration("
var ev_basefolder = '".JURI::base(true)."';
var extravote_text=Array('".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_MESSAGE_NO_AJAX')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_MESSAGE_LOADING')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_MESSAGE_THANKS')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_MESSAGE_LOGIN')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_MESSAGE_RATED')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_LABEL_VOTES')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_LABEL_VOTE')."','".
JTEXT::_('PLG_CONTENT_EXTRAVOTE_LABEL_RATING').
"');
");
      $plgContentExtraVoteAddScript = 1;
}

if( $rating_count!=0 ) {
$rating  = ($rating_sum / intval( $rating_count ));
} elseif( $show_unrated == 0 ) {
$show_counter = -1;
$show_rating  = -1;
}

$container = 'div';
$class     = 'size-'.$this->params->get('size', 1);

if( (int)$xid ) {
if ( $show_counter == 2 ) $show_counter = 0;
if ( $show_rating == 2 ) $show_rating = 0;
$container = 'span';
$class    .= ' extravote-small'; 
$add_snippets = 0;
} else {
if ( $show_counter == 3 ) $show_counter = 0;
if ( $show_rating == 3 ) $show_rating = 0;
$class    .= ' extravote'; 
}

$stars = (($this->params->get('table',1)!=1 && !(int)$xid)?5:$this->params->get('stars',10));
$spans = '';

for ($i=0,$j=5/$stars; $i<$stars; $i++,$j+=5/$stars) :
$spans .= "
      <span class=\"extravote-star\"><a href=\"javascript:void(null)\" onclick=\"javascript:JVXVote(".$id.",".$j.",".$rating_sum.",".$rating_count.",'".$xid."',".$show_counter.",".$show_rating.",".$rating_mode.");\" title=\"".JTEXT::_('PLG_CONTENT_EXTRAVOTE_RATING_'.($j*10).'_OUT_OF_5')."\" class=\"ev-".($j*10)."-stars\">1</a></span>";
endfor;

$html = "
<".$container." class=\"".$class."\">
  <span class=\"extravote-stars\"".($add_snippets?" itemprop=\"aggregateRating\" itemscope itemtype=\"http://schema.org/AggregateRating\"":"").">".($add_snippets?"
  <meta itemprop=\"ratingCount\" content=\"".$rating_count."\" />
":"
")."<span id=\"rating_".$id."_".$xid."\" class=\"current-rating\"".((!$initial_hide||$currip==$ip)?" style=\"width:".round($rating*20)."%;\"":"")."".($add_snippets?" itemprop=\"ratingValue\"":"").">".($add_snippets?$rating:"")."</span>"
.$spans."
  </span>
  <span class=\"extravote-info".(($initial_hide&&$currip!=$ip)?" ihide\"":"")."\" id=\"extravote_".$id."_".$xid."\">";
 
  if ( $show_rating > 0 ) {
if ( $rating_mode == 0 ) {
$rating = round($rating*20). '%';
} else {
$rating = number_format($rating,2);
}
$html .= JTEXT::sprintf('PLG_CONTENT_EXTRAVOTE_LABEL_RATING', $rating);
}

  if ( $show_counter > 0 ) {
if($rating_count!=1) {
$html .= JTEXT::sprintf('PLG_CONTENT_EXTRAVOTE_LABEL_VOTES', $rating_count);
} else {
$html .= JTEXT::sprintf('PLG_CONTENT_EXTRAVOTE_LABEL_VOTE', $rating_count);
}
}

  $html .="</span>";
  $html .="
</".$container.">";

return $html;
  }

  protected function ExtraVotePrepare( $article, &$params )
{
    if (isset($this->article_id)) {

        $extra = $this->params->get('extra', 1);
$main  = $this->params->get('main', 1);

      if ( $extra != 0 ) {

        $regex = "#{extravote\s*([0-9]+)}#s";

if ( $this->view != 'article' ) {
if ( $extra == 2 ) {
$article->introtext = preg_replace( $regex, '', $article->introtext );
} else {
$article->introtext = preg_replace_callback( $regex, array($this,'plgContentExtraVoteReplacer'), $article->introtext );
}
} else {
//     $this->article_id = $article->id;
        $article->text = preg_replace_callback( $regex, array($this,'plgContentExtraVoteReplacer'), $article->text );
    }
    }

      if ( $main != 0 ) {

if ( $main == 2 && $this->view != 'article')
    {
        $article->introtext = preg_replace( '#{mainvote}#', '', $article->introtext );
    } else {
    $this->article_id = $article->id;
if ( $this->view == 'article' ) {
        $article->text = preg_replace_callback( '#{mainvote}#', array($this,'plgContentExtraVoteReplacer'), $article->text );
} else {
        $article->introtext = preg_replace_callback( '#{mainvote}#', array($this,'plgContentExtraVoteReplacer'), $article->introtext );
}
    }
    }

    if ( $this->params->get('display') == 1 )  {

        $article->xid = 0;
if ( $this->view == 'article' ) {
        $article->text .= $this->ContentExtraVote($article, $params);
} elseif ( $this->params->get('hide') == 0 ) {
        $article->introtext .= $this->ContentExtraVote($article, $params);
}
    }
      }
  }
 
protected function plgContentExtraVoteReplacer(&$matches )
{
  $db = JFactory::getDBO();
$xid = 0;
if (isset($matches[1])) {
$xid = (int)$matches[1];
}
  $cid = 0;
if ( $this->params->get('article_id') || $xid == 0 ) {
$cid = $this->article_id;
}
  $rating_sum = 0;
  $rating_count = 0;

if ( $xid == 0 ) :
global $extravote_mainvote;
$extravote_mainvote .= 'x';
$xid = $extravote_mainvote;
$table =($this->params->get('table',1)==1?'#__content_extravote':'#__content_rating');
$db->setQuery('SELECT * FROM ' . $table . ' WHERE content_id='.(int)$cid);
else : 
$db->setQuery('SELECT * FROM #__content_extravote WHERE content_id='.(int)$cid.' AND extra_id='.(int)$xid);
endif; 
  $vote = $db->loadObject();
  if($vote) {
if($vote->rating_count!=0)
$rating_sum = $vote->rating_sum;
$rating_count = intval($vote->rating_count);
}
return $this->plgContentExtraVoteStars( $cid, $rating_sum, $rating_count, $xid, ($vote?$vote->lastip:'') );
}

}

Нужно вставить код социальных кнопок после строки $html .="</span>";:
Код
<script type="text/javascript" src="//yandex.st/share/share.js"
charset="utf-8"></script>
<div class="yashare-auto-init" data-yashareL10n="ru"
 data-yashareQuickServices="vkontakte,facebook,twitter,odnoklassniki,moimir,gplus" data-yashareTheme="counter" data-yasharetype="small"></div>

Ни как ни получается вставить код, получаю синтаксическую ошибку.

Кто разбирается в php, подскажите как правильно вставить код социальных кнопок?
Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

Content - Extranews plugin

Автор videoruslan

Ответов: 0
Просмотров: 1094
Последний ответ 16.01.2019, 12:16:06
от videoruslan
Allvideos Plugin mp3 плеер внешний вид жесть

Автор liberator

Ответов: 0
Просмотров: 760
Последний ответ 27.11.2018, 15:31:05
от liberator
ExtraVote не сохраняет рейтинг

Автор koskanalya

Ответов: 3
Просмотров: 870
Последний ответ 07.08.2018, 13:25:43
от kern.USR
Сравнивать хотя бы с 20 последними проголосовавшими IP при голосовании в extravote

Автор gomesgomes

Ответов: 3
Просмотров: 1527
Последний ответ 05.01.2018, 13:48:53
от Lepricon
JoomlaWorks 'AllVideos' Plugin v4.7.0

Автор BVV

Ответов: 9
Просмотров: 1120
Последний ответ 02.11.2016, 09:59:45
от BVV