Bonjour tout le monde! J'espère que quelqu'un pourra m'aider sur ce forum.
Voila je débute dans la creation de site et je me prends la tete depuis quelques jours sur mon blog.
J'ai un système de vote,"5 star-rating sytem" qui marche très bien mais que j'aimerai paramétrer à ma façon pour qu'il n'y ait que 2 étoiles. Si vous pouviez jeter un coup d'oeil pour voir ce que je peux changer ce serait cool!!
<?php
// Set flag that this is a parent file
define('_JEXEC', 1);
// no direct access
defined('_JEXEC') or die('Restricted access');
define( 'DS', DIRECTORY_SEPARATOR );
define('JPATH_BASE', dirname(__FILE__).DS.'..'.DS.'..'.DS.'..' );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
jimport('joomla.database.database');
jimport('joomla.database.table');
$mainframe = &JFactory::getApplication('site');
$mainframe->initialise();
$user = &JFactory::getUser();
$plugin = &JPluginHelper::getPlugin('content', 'extravote');
$params = new JParameter($plugin->params);
if ( $params->get('access') == 1 && !$user->get('id') ) {
echo 'login';
} else {
$user_rating = JRequest::getInt('user_rating');
$cid = JRequest::getInt('cid');
$xid = JRequest::getVar('xid');
$db = &JFactory::getDBO();
if (($user_rating >= 1) and ($user_rating <= 2)) {
$currip = ( phpversion() <= '4.2.1' ? @getenv( 'REMOTE_ADDR' ) : $_SERVER['REMOTE_ADDR'] );
if ( !(int)$xid ){
$query = "SELECT * FROM #__content_rating WHERE content_id = " . $cid;
$db->setQuery( $query );
$votesdb = $db->loadObject();
if ( !$votesdb ) {
$query = "INSERT INTO #__content_rating ( content_id, lastip, rating_sum, rating_count )"
. "\n VALUES ( " . $cid . ", " . $db->Quote( $currip ) . ", " . $user_rating . ", 1 )";
$db->setQuery( $query );
$db->query() or die( $db->stderr() );;
} else {
if ($currip != ($votesdb->lastip)) {
$query = "UPDATE #__content_rating"
. "\n SET rating_count = rating_count + 1, rating_sum = rating_sum + " . $user_rating . ", lastip = " . $db->Quote( $currip )
. "\n WHERE content_id = " . $cid;
$db->setQuery( $query );
$db->query() or die( $db->stderr() );
} else {
echo 'voted';
exit();
}
}
} else {
$query = "SELECT * FROM #__content_extravote WHERE content_id=".$cid." AND extra_id=".$xid;
$db->setQuery( $query );
$votesdb = $db->loadObject();
if ( !$votesdb ) {
$query = "INSERT INTO #__content_extravote (content_id,extra_id,lastip,rating_sum,rating_count)"
. "\n VALUES (".$cid.",".$xid.",".$db->Quote($currip).",".$user_rating.",1)";
$db->setQuery( $query );
$db->query() or die( $db->stderr() );;
} else {
if ($currip != ($votesdb->lastip)) {
$query = "UPDATE #__content_extravote"
. "\n SET rating_count = rating_count + 1, rating_sum = rating_sum + " . $user_rating . ", lastip = " . $db->Quote( $currip )
. "\n WHERE content_id=".$cid." AND extra_id=".$xid;
$db->setQuery( $query );
$db->query() or die( $db->stderr() );
} else {
echo 'voted';
exit();
}
}
}
echo 'thanks';
}
}
vote.js
function JVXVote(id,i,total,total_count,xid,counter){
var currentURL = window.location;
var live_site = currentURL.protocol+'//'+currentURL.host+sfolder;
var lsXmlHttp;
var div = document.getElementById('extravote_'+id+'_'+xid);
div.innerHTML='<img src="'+live_site+'/plugins/content/extravote/loading.gif" border="0" align="absmiddle" /> '+'<small>'+extravote_text[1]+'</small>';
try {
lsXmlHttp=new XMLHttpRequest();
} catch (e) {
try { lsXmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try { lsXmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert(extravote_text[0]);
return false;
}
}
}
lsXmlHttp.onreadystatechange=function() {
var response;
if(lsXmlHttp.readyState==4){
setTimeout(function(){
response = lsXmlHttp.responseText;
if(response=='thanks') div.innerHTML='<small>'+extravote_text[2]+'</small>';
if(response=='login') div.innerHTML='<small>'+extravote_text[3]+'</small>';
if(response=='voted') div.innerHTML='<small>'+extravote_text[4]+'</small>';
},500);
setTimeout(function(){
if(response=='thanks'){
var newtotal = total_count+1;
var percentage = ((total + i)/(newtotal));
document.getElementById('rating_'+id+'_'+xid).style.width=parseInt(percentage*20)+'%';
}
if(counter!=0){
if(response=='thanks'){
if(newtotal!=1)
var newvotes=newtotal+' '+extravote_text[5];
else
var newvotes=newtotal+' '+extravote_text[6];
div.innerHTML='<small>( '+newvotes+' )</small>';
} else {
if(total_count!=0 || counter!=-1) {
if(total_count!=1)
var votes=total_count+' '+extravote_text[5];
else
var votes=total_count+' '+extravote_text[6];
div.innerHTML='<small>( '+votes+' )</small>';
} else {
div.innerHTML='';
}
}
} else {
div.innerHTML='';
}
},2000);
}
}
lsXmlHttp.open("GET",live_site+"/plugins/content/extravote/ajax.php?task=vote&user_rating="+i+"&cid="+id+"&xid="+xid,true);
lsXmlHttp.send(null);
}
vote.css
div.extravote-container{display:inline-block;line-height:25px;vertical-align:middle;}
div.extravote-container-small{display:inline-block;line-height:22px;vertical-align:middle}
div.extravote-container ul.extravote-stars{height:25px;width:125px;padding:0!important;margin:0!important;}
div.extravote-container-small ul.extravote-stars-small{height:22px;width:110px;padding:0!important;margin:0!important;}
div.extravote-container ul.extravote-stars, div.extravote-container ul.extravote-stars li a:hover, div.extravote-container ul.extravote-stars li.current-rating {background-image:url(star.gif);background-color:transparent;background-repeat:repeat-x;background-position:left -1000px;padding:0!important;margin:0!important;}
div.extravote-container-small ul.extravote-stars-small, div.extravote-container-small ul.extravote-stars-small li a:hover, div.extravote-container-small ul.extravote-stars-small li.current-rating {background-image:url(star_small.gif);background-color:transparent;background-repeat:repeat-x;background-position:left -1000px;padding:0!important;margin:0!important;}
div.extravote-container ul.extravote-stars,div.extravote-container-small ul.extravote-stars-small {background-position:left top;list-style-image:none;list-style-position:outside;list-style-type:none;margin:0pt;overflow:hidden;padding:0pt;position:relative;}
div.extravote-container ul.extravote-stars li, div.extravote-container-small ul.extravote-stars-small li {background-image:none;display:inline;padding:0pt;}
div.extravote-container ul.extravote-stars li a, div.extravote-container ul.extravote-stars li.current-rating,div.extravote-container-small ul.extravote-stars-small li a, div.extravote-container-small ul.extravote-stars-small li.current-rating {border:medium none;cursor:pointer;left:0pt;outline-color:-moz-use-text-color;outline-style:none;outline-width:medium;overflow:hidden;position:absolute;text-indent:-1000em;top:0pt;}
div.extravote-container ul.extravote-stars li a, div.extravote-container ul.extravote-stars li.current-rating {height:25px;line-height:25px;}
div.extravote-container-small ul.extravote-stars-small li a, div.extravote-container-small ul.extravote-stars-small li.current-rating {height:22px;line-height:22px;}
div.extravote-container ul.extravote-stars li a:hover,div.extravote-container-small ul.extravote-stars-small li a:hover {background-position:left bottom;}
div.extravote-container ul.extravote-stars li.current-rating,div.extravote-container-small ul.extravote-stars-small li.current-rating {background-position:left center;z-index:1;}
div.extravote-container ul.extravote-stars li a.one-star, div.extravote-container-small ul.extravote-stars-small li a.one-star {width:20%;padding:0;margin:0;z-index:6;}
div.extravote-container ul.extravote-stars li a.two-stars, div.extravote-container-small ul.extravote-stars-small li a.two-stars {width:40%;padding:0;margin:0;z-index:5;}
div.extravote-container ul.extravote-stars li a.three-stars, div.extravote-container-small ul.extravote-stars-small li a.three-stars {width:60%;padding:0;margin:0;z-index:4;}
div.extravote-container ul.extravote-stars li a.four-stars, div.extravote-container-small ul.extravote-stars-small li a.four-stars {width:80%;padding:0;margin:0;z-index:3;}
div.extravote-container ul.extravote-stars li a.five-stars, div.extravote-container-small ul.extravote-stars-small li a.five-stars {width:100%;padding:0;margin:0;z-index:2;}
.extravote-count {vertical-align:middle;}
Il y a quatre fichiers en tout.Merci d'avance!
5 star rating systeme
× Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
× Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.