Здравствуйте!
Я захотел модифицировать стандартный плагин голосования за материал - сделал его более интерактивным, подобно подобно другим сторонним рейтингам, и также увеличил количество "звезд" до 10 штук. Но при голосовании Joomla 2.5 почему-то не хочет принимать голоса больше стандартных пяти, выходит предупреждение - "
Рейтинг статьи: Неверный рейтинг: 8".
Подскажите, кто знает, как увеличить максимально возможный голос? Плагин состоит всего из одного PHP файла, и других упоминаний о нем я не нашел.
Вот мой модифицированный код файла
plugins\content\vote\vote.php:
<?php
// No direct access.
defined('_JEXEC') or die;
/**
* Vote plugin.
*
* @package Joomla.Plugin
* @subpackage Content.vote
*/
class plgContentVote extends JPlugin
{
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.5
*/
public function __construct(& $subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
/**
* @since 1.6
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
{
$html = '';
if ($params->get('show_vote'))
{
$rating = intval(@$row->rating);
$rating_count = intval(@$row->rating_count);
$view = JRequest::getString('view', '');
$img = '';
// look for images in template if available
$starImageOn = JHtml::_('image', 'system/rating_star.png', NULL, NULL, true);
$starImageOff = JHtml::_('image', 'system/rating_star_blank.png', NULL, NULL, true);
for ($i=0; $i < $rating; $i++) {
$img .= $starImageOn;
}
for ($i=$rating; $i < 10; $i++) {
$img .= $starImageOff;
}
$html .= '<span class="content_rating">';
$html .= JText::sprintf( 'PLG_VOTE_USER_RATING', $img, $rating_count );
$html .= "</span>\n<br />\n";
if ( $view == 'article' && $row->state == 1)
{
$uri = JFactory::getURI();
$uri->setQuery($uri->getQuery().'&hitcount=0');
$html .= '<form method="post" action="' . $uri->toString(). '">';
$html .= JText::_( 'PLG_VOTE_POOR' );
$html .= '<ul class="content_vote">';
$html .= '<li class="current_rating" style="width:'. $rating *10 .'%;" ></li>';
$html .= '<li tabindex="1"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '1').'" name="user_rating" value="1" /></li>';
$html .= '<li tabindex="2"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '2').'" name="user_rating" value="2" /></li>';
$html .= '<li tabindex="3"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '3').'" name="user_rating" value="3" /></li>';
$html .= '<li tabindex="4"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '4').'" name="user_rating" value="4" /></li>';
$html .= '<li tabindex="5"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '5').'" name="user_rating" value="5" /></li>';
$html .= '<li tabindex="6"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '6').'" name="user_rating" value="6" /></li>';
$html .= '<li tabindex="7"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '7').'" name="user_rating" value="7" /></li>';
$html .= '<li tabindex="8"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '8').'" name="user_rating" value="8" /></li>';
$html .= '<li tabindex="9"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '9').'" name="user_rating" value="9" /></li>';
$html .= '<li tabindex="10"><input type="radio" title="'.JText::sprintf('PLG_VOTE_VOTE', '10').'" name="user_rating" value="10" checked="checked" /></li>';
$html .= '</ul>';
$html .= JText::_( 'PLG_VOTE_BEST' );
$html .= ' <input class="button" type="submit" name="submit_vote" value="'. JText::_( 'PLG_VOTE_RATE' ).'" />';
$html .= '<input type="hidden" name="task" value="article.vote" />';
$html .= '<input type="hidden" name="hitcount" value="0" />';
$html .= '<input type="hidden" name="url" value="'. $uri->toString().'" />';
$html .= JHtml::_('form.token');
$html .= '</form>';
}
}
return $html;
}
}
И, CSS к этому плагину:
ul.content_vote {
background-position: left top;
float: none;
height: 32px;
list-style: none outside none;
margin: 0;
overflow: hidden;
padding: 0;
position: relative;
width: 320px;
display: inline-block;
}
ul.content_vote li {
display: inline-block;
/*float: left;*/
width: 32px;
position: absolute;
background: none;
padding: 0;
}
ul.content_vote li:nth-child(2) {width: 32px; z-index: 11;}
ul.content_vote li:nth-child(3) {width: 64px; z-index: 10;}
ul.content_vote li:nth-child(4) {width: 96px; z-index: 9;}
ul.content_vote li:nth-child(5) {width: 128px; z-index: 8;}
ul.content_vote li:nth-child(6) {width: 160px; z-index: 7;}
ul.content_vote li:nth-child(7) {width: 192px; z-index: 6;}
ul.content_vote li:nth-child(8) {width: 224px; z-index: 5;}
ul.content_vote li:nth-child(9) {width: 256px; z-index: 4;}
ul.content_vote li:nth-child(10) {width: 288px; z-index: 3;}
ul.content_vote li:nth-child(11) {width: 320px; z-index: 2;}
ul.content_vote li:nth-child(3) input {margin-left: 40px; z-index: 9;}
ul.content_vote li:nth-child(4) input {margin-left: 74px; z-index: 8;}
ul.content_vote li:nth-child(5) input {margin-left: 106px; z-index: 7;}
ul.content_vote li:nth-child(6) input {margin-left: 138px; z-index: 6;}
ul.content_vote li:nth-child(7) input {margin-left: 170px; z-index: 5;}
ul.content_vote li:nth-child(8) input {margin-left: 202px; z-index: 4;}
ul.content_vote li:nth-child(9) input {margin-left: 234px; z-index: 3;}
ul.content_vote li:nth-child(10) input {margin-left: 266px; z-index: 2;}
ul.content_vote li:nth-child(11) input {margin-left: 298px; z-index: 1;}
.content_vote input {
height: 68px;
width: 20px;
}
ul.content_vote{
background: url("/media/system/images/rating_star_blank.png") repeat-x transparent;
}
ul.content_vote li:hover, ul.content_vote li:active, ul.content_vote li:focus {
background: url("/media/system/images/rating_star_vote.png") repeat-x transparent;
}
ul.content_vote .current_rating {
background: url("/media/system/images/rating_star.png") repeat-x transparent;
position: absolute;
height: 32px;
z-index: 1;
}
Также, помогите сделать "закрепление" голоса перед нажатием на кнопку "проголосовать", то есть чтобы фоновый рисунок не сбивался при отведении курсора от шкалы.