1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 21:21:54 +02:00

Rating system re-work and cleanup.

This commit is contained in:
CaMer0n 2012-05-27 10:42:16 +00:00
parent 189359df33
commit ed28dc0808
21 changed files with 1744 additions and 107 deletions

@ -731,8 +731,8 @@ class page_admin_ui extends e_admin_ui
}
}*/
admin_update($update, 'update', LAN_UPDATED, false, false); // Display result of update
$mes = e107::getMessage();
$mes->autoMessage($update, 'update', LAN_UPDATED, false, false); // Display result of update
}
else
{ // New page/menu
@ -755,7 +755,7 @@ class page_admin_ui extends e_admin_ui
'page_theme' => $menuname,
'page_template' => varset($_POST['page_template'],'')
);
$pid = admin_update($sql->db_Insert('page', $info), 'insert', $addMsg, LAN_CREATED_FAILED, false);
$pid = e107::getMessage()->autoMessage($sql->db_Insert('page', $info), 'insert', $addMsg, LAN_CREATED_FAILED, false);
$admin_log->log_event('CPAGE_01',$menuname.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,'');
if($type)
@ -768,7 +768,7 @@ class page_admin_ui extends e_admin_ui
'menu_pages' => '',
'menu_path' => $pid,
);
admin_update($sql->db_Insert('menus', $info), 'insert', CUSLAN_52, LAN_CREATED_FAILED, false);
e107::getMessage()->autoMessage($sql->db_Insert('menus', $info), 'insert', CUSLAN_52, LAN_CREATED_FAILED, false);
}
/*if(vartrue($_POST['page_link']))

@ -25,6 +25,33 @@ define("USER_AREA", FALSE);
e107::getDb()->db_Mark_Time('(Header Top)');
e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2);
e107::css('core', 'colorbox/colorbox.css', 'jquery');
e107::js('core', 'jquery.elastic.js', 'jquery', 2);
e107::js('core', 'jquery-ui-timepicker-addon.js', 'jquery', 2);
e107::js('core', 'plupload/plupload.full.js', 'jquery', 2);
e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery');
e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2);
e107::css('core', 'chosen/chosen.css', 'jquery');
e107::js('core', 'chosen/chosen.jquery.min.js', 'jquery', 2);
e107::css('core', 'password/style.css', 'jquery');
e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2);
//
e107::js("core", "plupload/customUpload.js","jquery",3);
e107::js("core", "core/mediaManager.js","jquery",3);
e107::css('core', 'core/admin.jquery.css', 'jquery');
e107::css('core', 'core/all.jquery.css', 'jquery');
e107::js("core", "core/admin.jquery.js","jquery",4); // Load all default functions.
e107::js("core", "core/all.jquery.js","jquery",4); // Load all default functions.
//
// *** Code sequence for headers ***
// IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE
@ -755,7 +782,7 @@ if ($e107_popup != 1)
}
/**
* Automate DB system messages
* Automate DB system messages DEPRECATED
* NOTE: default value of $output parameter will be changed to false (no output by default) in the future
*
* @param integer|bool $update return result of db::db_Query
@ -766,6 +793,8 @@ if ($e107_popup != 1)
* @return integer|bool db::db_Query result
*/
// TODO - This function often needs to be available BEFORE header.php is loaded.
// It has been copied to message_handler.php as autoMessage();
function admin_update($update, $type = 'update', $success = false, $failed = false, $output = true)
@ -810,6 +839,8 @@ if ($e107_popup != 1)
$text = ($failed ? $failed : $msg." - ".LAN_TRY_AGAIN)."<br />".LAN_ERROR." ".mysql_errno().": ".mysql_error();
$emessage->add($text, E_MESSAGE_ERROR);
}
$emessage->addInfo("Using deprecated admin_update() which has been replaced by \$mes->autoMessage();");
if ($output) echo $emessage->render();
return $update;

@ -1,5 +1,5 @@
$(document).ready(function()
{
{
$(".e-hideme").hide();
$(".e-expandit").show();

Binary file not shown.

After

(image error) Size: 699 B

Binary file not shown.

After

(image error) Size: 715 B

Binary file not shown.

After

(image error) Size: 667 B

Binary file not shown.

After

(image error) Size: 685 B

Binary file not shown.

After

(image error) Size: 631 B

@ -0,0 +1,916 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta name="keywords" content="jquery,rating,raty,voto,star,staring,classificacao,classificar,votar,plugin" />
<meta name="description" content="jQuery Raty - A Star Rating Plugin" />
<title>jQuery Raty - A Star Rating Plugin</title>
<!-- This CSS does not belong to the plugin. -->
<link type="text/css" rel="stylesheet" href="doc/css/stylesheet.css"/>
<script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="js/jquery.raty.min.js"></script>
<script type="text/javascript">
// This code does NOT belong the plugin. See the example code at the bottom of this page.
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-194992347-3']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="header">
<div id="title">
<a href="http://wbotelhos.com/raty">jQuery Raty - A Star Rating Plugin</a>
<span id="version">(current version: 2.4.5)</span>
</div>
<div id="menu">
<a href="http://github.com/downloads/wbotelhos/raty/jquery.raty-2.4.5.zip" target="_blank">Download</a> |
<a href="http://github.com/wbotelhos/raty" target="_blank">Github</a> |
<a href="http://www.wbotelhos.com/raty/changelog.md" target="_blank">Change Log</a> |
<a href="http://www.wbotelhos.com/raty/README.md" target="_blank">Readme</a> |
<a href="http://www.wbotelhos.com/2010/07/14/jquery-raty-a-star-rating-plugin" target="_blank">Article</a> |
<a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">License</a> |
<a href="http://www.wbotelhos.com/2010/07/14/jquery-raty-a-star-rating-plugin#comments" target="_blank" style="color: #2C8CBD;">Doubt</a> |
<a href="http://www.wbotelhos.com/lab" target="_blank" style="color: #000;">yLab</a>
</div>
<a id="coffee" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=X8HEP2878NDEG&amp;item_name=jQuery%20Raty" target="_blank">buy me a coffee</a>
<div class="description">jQuery <strong>Raty</strong> is a plugin that generates a customizable star rating.</div>
</div>
<div id="content">
<div id="default-demo" class="session-first">Default options:</div>
<div id="default"></div>
<div class="source">
$('#star').raty();<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div>
<div id="fixed-demo" class="session">Started with a score and read only value:</div>
<div id="fixed"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;readOnly : true,<br/>
&#160;&#160;score&#160;&#160;&#160; : 2<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div>
<div id="score-demo" class="session">Starting with a callback:</div>
<div id="score" data-rating="3"></div>
<div class="source">
$('#score').raty({<br/>
&#160;&#160;score: function() {<br/>
&#160;&#160;&#160;&#160;return $(this).attr('data-rating');<br/>
&#160;&#160;}<br/>
});<br/><br/>
&lt;div id="star" data-rating="3"&gt;&lt;/div&gt;
</div>
<div id="anyone-demo" class="session">A hint for no rated elements when it's read-only:</div>
<div id="anyone"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;readOnly&#160;&#160; : true,<br/>
&#160;&#160;noRatedMsg : 'anyone rated this product yet!'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div>
<div id="number-demo" class="session">Custom score name and a number of stars:</div>
<div id="number"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;scoreName : 'entity.score',<br/>
&#160;&#160;number&#160;&#160;&#160; : 10<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div>
<div id="click-demo" class="session">Using click function:</div>
<div id="click"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;click: function(score, evt) {<br/>
&#160;&#160;&#160;&#160;alert('ID: ' + $(this).attr('id') + '\nscore: ' + score + '\nevent: ' + evt);<br/>
&#160;&#160;}<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- The argument score is the selected value;<br/>
- The argument evt is the click event;<br/>
- You can mension the star element (DOM) itself using 'this'.<br/>
</span>
<div id="cancel-demo" class="session">Default cancel button:</div>
<div id="cancel"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;cancel: true<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- The score value for the click on cancel button is null.<br/>
</span>
<div id="cancel-custom-demo" class="session">Custom cancel button:</div>
<div id="cancel-custom"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;cancelHint&#160; : 'remove my rating!',<br/>
&#160;&#160;cancelPlace : 'right',<br/>
&#160;&#160;click&#160;&#160;&#160;&#160;&#160;&#160; : function(score, evt) {<br/>
&#160;&#160;&#160;&#160;alert('score: ' + score);<br/>
&#160;&#160;}<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div>
<div id="half-demo" class="session">Half star voting:</div>
<div id="half"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;half&#160; : true,<br/>
&#160;&#160;score : 3.3<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- You can disable the 'halfShow' option to just vote with half star but not show it.<br/>
- If 'halfShow' is disabled, then score &gt;= x.6 will be rounded up visually.<br/>
- The interval can be:<br/>
-- Rounded down: [x.00 .. x.25]<br/>
-- Half star:&#160;&#160;&#160; [x.26 .. x.75]<br/>
-- Rounded up:&#160;&#160; [x.76 .. x.99]
</span>
<div id="round-demo" class="session">Custom round option:</div>
<div id="round"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;score : 1.26,<br/>
&#160;&#160;round : { down: .25, full: .6, up: .76 }<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- This example use the default round values;<br/>
- down: with halfShow enabled, score &lt;= x.25 will be rounded down; (inclusive)<br/>
- up: with halfShow enabled, score &gt;= x.76 will be rounded up; (inclusive)<br/>
- down-up: with halfShow enabled, score &gt; x.25 and score &lt; .76 will be half star; (inclusive)<br/>
- full: with halfShow disabled, score &gt;= x.6 will be rounded up; (inclusive)<br/>
</span>
<div id="icon-demo" class="session">Custom hint and icons:</div>
<div id="icon"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;hints&#160;&#160; : ['a', '', null, 'd', '5'],<br/>
&#160;&#160;starOn&#160; : 'medal-on.png',<br/>
&#160;&#160;starOff : 'medal-off.png'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- To display the number of the star, set null.
</span>
<div id="range-demo" class="session">Range of custom icons:</div>
<div id="range"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;iconRange: [<br/>
&#160;&#160;&#160;&#160;{ range: 2, on: 'face-a.png', off: 'face-a-off.png' },<br/>
&#160;&#160;&#160;&#160;{ range: 3, on: 'face-b.png', off: 'face-b-off.png' },<br/>
&#160;&#160;&#160;&#160;{ range: 4, on: 'face-c.png', off: 'face-c-off.png' },<br/>
&#160;&#160;&#160;&#160;{ range: 5, on: 'face-d.png', off: 'face-d-off.png' }<br/>
&#160;&#160;]<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- It's a array of objects where each one represents a custom icon;<br/>
- The value range is until wich position the icon will be displayed;<br/>
- The value on is the active icon;<br/>
- The value off is the inactive icon;<br/>
- The sequence of the range interval should be in a ascending order;<br/>
- If the value on or off is omitted then the attribute starOn or starOff will be used.
</span>
<div id="big-demo" class="session">Bigger icon:</div>
<div id="big"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160; : true,<br/>
&#160;&#160;cancelOff : 'cancel-off-big.png',<br/>
&#160;&#160;cancelOn&#160; : 'cancel-on-big.png',<br/>
&#160;&#160;half&#160;&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;size&#160;&#160;&#160;&#160;&#160; : 24,<br/>
&#160;&#160;starHalf&#160; : 'star-half-big.png',<br/>
&#160;&#160;starOff&#160;&#160; : 'star-off-big.png',<br/>
&#160;&#160;starOn&#160;&#160;&#160; : 'star-on-big.png'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- You can specify your own width as following: width: 120.
</span>
<div id="group-demo" class="session">Group of elements:</div>
<div class="group"></div>
<div class="group"></div>
<div class="group"></div>
<div class="source">
$('.star').raty();<br/><br/>
&lt;div class="star"&gt;&lt;/div&gt;<br/>
&lt;div class="star"&gt;&lt;/div&gt;<br/>
&lt;div class="star"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- The ID is optional and must be unique;<br/>
- If you don't pass a ID for the element, then it will be created.
</span>
<div id="target-demo" class="session">Displaying hint in a target element:</div>
<div id="target"></div>
<div id="hint"></div><br/>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;cancelHint : 'none',<br/>
&#160;&#160;target&#160;&#160;&#160;&#160; : '#hint'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
&lt;div id="target"&gt;&lt;/div&gt;
</div>
<div id="target-number-demo" class="session">Displaying and keeping the score in a target element:</div>
<div id="target-number"></div>
<select id="score-target">
<option value="">--</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
<div class="source left">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;target&#160;&#160;&#160;&#160; : '#score',<br/>
&#160;&#160;targetKeep : true,<br/>
&#160;&#160;targetType : 'number'<br/>
});<br/><br/>
&lt;select id="target"&gt;<br/>
&#160;&#160;&lt;option value=""&gt;0&lt;/option&gt;<br/>
&#160;&#160;&lt;option value="1"&gt;1&lt;/option&gt;<br/>
&#160;&#160;&lt;option value="2"&gt;2&lt;/option&gt;<br/>
&#160;&#160;&lt;option value="3"&gt;3&lt;/option&gt;<br/>
&#160;&#160;&lt;option value="4"&gt;4&lt;/option&gt;<br/>
&#160;&#160;&lt;option value="5"&gt;5&lt;/option&gt;<br/>
&lt;/select&gt;<br/>
</div><br/>
<span class="comment">
- You can to choose the target types 'hint' or 'number'.
</span>
<div id="target-out-demo" class="session">Setting default value to the target on mouseout:</div>
<div id="target-out"></div>
<div id="hint-out"></div><br/>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;target&#160;&#160;&#160;&#160; : '#hint',<br/>
&#160;&#160;targetText : '--'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
&lt;div id="target"&gt;&lt;/div&gt;
</div>
<div id="format-demo" class="session">Displaying hint with format template:</div>
<div id="format"></div>
<div id="hint-format"></div><br/>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;cancelHint&#160;&#160; : 'Sure?',<br/>
&#160;&#160;target&#160;&#160;&#160;&#160;&#160;&#160; : '#hint',<br/>
&#160;&#160;targetFormat : 'your score: {score}',<br/>
&#160;&#160;targetText&#160;&#160; : 'none',<br/>
&#160;&#160;targetKeep&#160;&#160; : true<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
&lt;div id="target"&gt;&lt;/div&gt;
</div>
<div id="mouseover-demo" class="session">Using mouseover callback:</div>
<div id="mouseover"></div>
<div id="mouseover-target"></div><br/>
<div class="source" style="margin-top: 15px;">
$('#star').raty({<br/>
&#160;&#160;cancel&#160;&#160;&#160; : true,<br />
&#160;&#160;mouseover : function(score, evt) {<br />
&#160;&#160;&#160;&#160;var target = $('#mouseover-target');<br /><br />
&#160;&#160;&#160;&#160;if (score === null) {<br />
&#160;&#160;&#160;&#160;&#160;&#160;target.html('Boring!');<br />
&#160;&#160;&#160;&#160;} else if (score === undefined) {<br />
&#160;&#160;&#160;&#160;&#160;&#160;target.empty();<br />
&#160;&#160;&#160;&#160;} else {<br />
&#160;&#160;&#160;&#160;&#160;&#160;target.html('score: ' + score);<br />
&#160;&#160;&#160;&#160;}<br />
&#160;&#160;}<br />
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
&lt;div id="target"&gt;&lt;/div&gt;
</div>
<span class="comment">
- The options target, targetFormat, targetKeep, targetText and targetType are abstractions of this callback.
</span>
<div id="precision-demo" class="session">Half star voting precision:</div>
<div id="precision"></div>
<div id="precision-target"></div><br/>
<div class="source" style="margin-top: 15px;">
$('#star').raty({<br/>
&#160;&#160;half&#160;&#160;&#160;&#160;&#160;&#160; : true,<br/>
&#160;&#160;precision&#160; : true,<br/>
&#160;&#160;size&#160;&#160;&#160;&#160;&#160;&#160; : 24,<br/>
&#160;&#160;starHalf&#160;&#160; : 'star-half-big.png',<br/>
&#160;&#160;starOff&#160;&#160;&#160; : 'star-off-big.png',<br/>
&#160;&#160;starOn&#160;&#160;&#160;&#160; : 'star-on-big.png'<br/>
&#160;&#160;target&#160;&#160;&#160;&#160; : '#precision-target'<br/>
&#160;&#160;targetType : 'number'<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
&lt;div id="target"&gt;&lt;/div&gt;
</div>
<div id="space-demo" class="session">Without space between stars:</div>
<div id="space"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;space: false<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
</div>
<div id="single-demo" class="session">Single icon:</div>
<div id="single"></div>
<div class="source">
$('#star').raty({<br/>
&#160;&#160;single: true<br/>
});<br/><br/>
&lt;div id="star"&gt;&lt;/div&gt;<br/>
</div>
<div id="action-demo" class="session">Directed actions with public functions:</div>
love:
<div class="action"></div>
happy:
<div class="action"></div><br/>
your last rate:
<div id="result"></div>
<div class="source">
$('.star').raty({<br/>
&#160;&#160;half&#160; : true,<br/>
&#160;&#160;click : function(score, evt) {<br/>
&#160;&#160;&#160;&#160;$(this).raty('cancel');<br/>
&#160;&#160;&#160;&#160;$('#result').raty('score', score);<br/>
&#160;&#160;}<br/>
});<br/><br/>
&lt;div class="star"&gt;&lt;/div&gt;<br/>
&lt;div class="star"&gt;&lt;/div&gt;<br/><br/>
&lt;div id="result"&gt;&lt;/div&gt;
</div><br/>
<span class="comment">
- All functions have a optional second parameter to specify which container will be executed;<br/>
- You can pass a ID or a class to be the target of the action;<br/>
- If the ID or class are not specified, then the last element Raty will be takes.
</span>
<div id="function-demo" class="session">Functions Demo:</div>
<div id="function"></div>
<div id="hint-function"></div><br/>
<div style="color: #CCC; margin-top: 15px;">
<a href="javascript:void(0);" title="1" class="score">Score 1</a> |
<a href="javascript:void(0);" title="2" class="score">Score 2</a> |
<a href="javascript:void(0);" title="3" class="score">Score 3</a> |
<a href="javascript:void(0);" title="4" class="score">Score 4</a> |
<a href="javascript:void(0);" title="5" class="score">Score 5</a>
</div>
<div style="color: #CCC; margin-top: 15px;">
<a href="javascript:void(0);" title="1" class="click">Click 1</a> |
<a href="javascript:void(0);" title="2" class="click">Click 2</a> |
<a href="javascript:void(0);" title="3" class="click">Click 3</a> |
<a href="javascript:void(0);" title="4" class="click">Click 4</a> |
<a href="javascript:void(0);" title="5" class="click">Click 5</a>
</div>
<div style="color: #CCC; margin-top: 15px;">
<a href="javascript:void(0);" title="true" class="readOnly">ReadOnly (true)</a> |
<a href="javascript:void(0);" title="false" class="readOnly">ReadOnly (false)</a>
</div>
<div style="color: #CCC; margin-top: 15px;">
<a href="javascript:void(0);" title="false" class="cancel">Cancel</a> |
<a href="javascript:void(0);" title="true" class="cancel">Cancel (trigger)</a>
</div>
<div style="color: #CCC; margin-top: 15px;">
<a id="reload" href="javascript:void(0);" title="reload">Reload</a> |
<a id="get-score" href="javascript:void(0);" title="score">Score</a>
</div>
<div class="action-wrapper">
settings: <input id="set-id" type="text" value="{ number: 3 }" class="action-field" />
<a id="set-action" href="javascript:void(0);" title="set" class="action-link">set</a>
</div>
<div id="global-demo" class="session">Changing the settings globally:</div>
<div class="source">
$.fn.raty.defaults.starOn = 'star-on.gif';<br/>
$.fn.raty.defaults.starOff = 'star-off.gif';
</div>
<span class="comment">
- You can change any option mention the scope <b>$.fn.raty.defaults.</b> + <i>option_name</i>;<br/>
- This setup must be called before you bind the Raty, of course.
</span>
<div class="session">Default options:</div>
<div class="session-option">cancel: <span>false</span></div>
<div class="comment">If will be showed a button to cancel the rating.</div>
<hr />
<div class="session-option">cancelHint: <span>'cancel this rating!'</span></div>
<div class="comment">The hint information.</div>
<hr />
<div class="session-option">cancelHint: 'cancel this rating!'<br/>
<div class="comment">The hint information.</div>
<hr />
<div class="session-option">cancelOff: <span>'cancel-off.png'</span></div>
<div class="comment">Name of the cancel image off.</div>
<hr />
<div class="session-option">cancelOn: <span>'cancel-on.png'</span></div>
<div class="comment">Name of the cancel image on.</div>
<hr />
<div class="session-option">cancelPlace: <span>'left'</span></div>
<div class="comment">Position of the cancel button.</div>
<hr />
<div class="session-option">click: <span>undefined</span></div>
<div class="comment">Function that returns the selected value.</div>
<hr />
<div class="session-option">half: <span>false</span></div>
<div class="comment">Enables half star selection.</div>
<hr />
<div class="session-option">halfShow: <span>true</span></div>
<div class="comment">Enables half star display.</div>
<hr />
<div class="session-option">hints: <span>['bad', 'poor', 'regular', 'good', 'gorgeous']</span></div>
<div class="comment">List of names that will be used as a hint on each star.</div>
<hr />
<div class="session-option">iconRange: <span>undefined</span></div>
<div class="comment">List of object that represent each icon with position and names.</div>
<hr />
<div class="session-option">noRatedMsg: <span>'not rated yet'</span></div>
<div class="comment">A hint for no rated elements when it's read-only.</div>
<hr />
<div class="session-option">number: <span>5</span></div>
<div class="comment">Number of stars that will be presented.</div>
<hr />
<div class="session-option">path: <span>'img/'</span></div>
<div class="comment">A range of custom icons that you can set.</div>
<hr />
<div class="session-option">precision: <span>false</span></div>
<div class="comment">Enables the selection of a precision score.</div>
<hr />
<div class="session-option">readOnly: <span>false</span></div>
<div class="comment">If the stars will be read-only.</div>
<hr />
<div class="session-option">round: <span>{ down: <span>.25, full: <span>.6, up: <span>.76 }</span></div>
<div class="comment">Configuration to set the round rules.</div>
<hr />
<div class="session-option">score: <span>undefined</span></div>
<div class="comment">Number of stars to be selected.</div>
<hr />
<div class="session-option">scoreName: <span>'score'</span></div>
<div class="comment">Name of the hidden field that holds the score value.</div>
<hr />
<div class="session-option">single: <span>false</span></div>
<div class="comment">Enables the single star selection.</div>
<hr />
<div class="session-option">space: <span>true</span></div>
<div class="comment">Puts space between the stars.</div>
<hr />
<div class="session-option">size: <span>16</span></div>
<div class="comment">The icons size.</div>
<hr />
<div class="session-option">starHalf: <span>'star-half.png'</span></div>
<div class="comment">The name of the half star image.</div>
<hr />
<div class="session-option">starOff: <span>'star-off.png'</span></div>
<div class="comment">Name of the star image off.</div>
<hr />
<div class="session-option">starOn: <span>'star-on.png'</span></div>
<div class="comment">Name of the star image on.</div>
<hr />
<div class="session-option">target: <span>undefined</span></div>
<div class="comment">Element selector where the rating will be displayed.</div>
<hr />
<div class="session-option">targetFormat: <span>'{score}'</span></div>
<div class="comment">Template to interpolate the score with some thing.</div>
<hr />
<div class="session-option">targetKeep: <span>false</span></div>
<div class="comment">If the last choose value will be keeped on mouseout.</div>
<hr />
<div class="session-option">targetText: <span>''</span></div>
<div class="comment">Default value when there is no score or targetKeep is off.</div>
<hr />
<div class="session-option">targetType: <span>'hint'</span></div>
<div class="comment">What display on target element hint or number.</div>
<hr />
<div class="session-option">width&#160;: <span>undefined</span></div>
<div class="comment">The container width of the stars.</div>
<div class="session">Functions:</div>
<div class="source">$('#star').raty('score');</div>
<div class="comment">Recovers the current score or undefined for no rated. Class returns an array of score</div>
<div class="source">$('#star').raty('score', 3);</div>
<div class="comment">Set the score with 3 stars.</div>
<div class="source">$('#star').raty('click', 2);</div>
<div class="comment">Click on the second star of the Raty with ID called 'raty'.</div>
<div class="source">$('.star').raty('readOnly', true);</div>
<div class="comment">Adjusts all Raty with class called 'raty' for read-only.</div>
<div class="source">$('#star').raty('cancel', true);</div>
<div class="comment">Cancel the rating. The second optional parameter enable thes click callback.</div>
<div class="source">$('#star').raty('reload');</div>
<div class="comment">Reload the rating with the current configuration.</div>
<div class="source">$('#star').raty('set', { number: 10 });</div>
<div class="comment">Reload the rating applying new configurations.</div>
</div>
<div id="footer">
<div id="copy">&copy; 2010 <a href="http://www.wbotelhos.com/" target="_blank">wbotelhos.com</a></div>
</div>
<script type="text/javascript">
$(function() {
$('#default').raty();
$('#fixed').raty({
readOnly : true,
score : 2
});
$('#score').raty({
score: function() {
return $(this).attr('data-rating');
}
});
$('#anyone').raty({
readOnly : true,
noRatedMsg : 'anyone rated this product yet!'
});
$('#number').raty({
scoreName : 'entity.score',
number : 10
});
$('#click').raty({
click: function(score, evt) {
alert('ID: ' + $(this).attr('id') + '\nscore: ' + score + '\nevent: ' + evt);
}
});
$('#cancel').raty({
cancel: true
});
$('#cancel-custom').raty({
cancel : true,
cancelHint : 'remove my rating!',
cancelPlace : 'right',
click : function(score, evt) {
alert('score: ' + score);
}
});
$('#half').raty({
half : true,
score : 3.3
});
$('#round').raty({
score : 1.26,
round : { down: .25, full: .6, up: .76 }
});
$('#icon').raty({
hints : ['a', '', null, 'd', '5'],
path : 'doc/img/',
starOn : 'medal-on.png',
starOff : 'medal-off.png'
});
$('#range').raty({
iconRange : [
{ range: 2, on: 'face-a.png', off: 'face-a-off.png' },
{ range: 3, on: 'face-b.png', off: 'face-b-off.png' },
{ range: 4, on: 'face-c.png', off: 'face-c-off.png' },
{ range: 5, on: 'face-d.png', off: 'face-d-off.png' }
],
path : 'doc/img/'
});
$('#big').raty({
cancel : true,
cancelOff : 'cancel-off-big.png',
cancelOn : 'cancel-on-big.png',
half : true,
path : 'doc/img/',
size : 24,
starOff : 'star-off-big.png',
starOn : 'star-on-big.png',
starHalf : 'star-half-big.png'
});
$('.group').raty();
$('#target').raty({
cancel : true,
cancelHint : 'none',
target : '#hint'
});
$('#format').raty({
cancel : true,
cancelHint : 'Sure?',
target : '#hint-format',
targetFormat : 'your score: {score}',
targetKeep : true,
targetText : 'none'
});
$('#target-number').raty({
cancel : true,
target : '#score-target',
targetKeep : true,
targetType : 'number'
});
$('#target-out').raty({
target : '#hint-out',
targetText : '--'
});
$('#mouseover').raty({
cancel : true,
mouseover : function(score, evt) {
var target = $('#mouseover-target');
if (score === null) {
target.html('Boring!');
} else if (score === undefined) {
target.empty();
} else {
target.html('score: ' + score);
}
}
});
$('#precision').raty({
half : true,
path : 'doc/img/',
precision : true,
size : 24,
starOff : 'star-off-big.png',
starOn : 'star-on-big.png',
starHalf : 'star-half-big.png',
target : '#precision-target',
targetType : 'number'
});
$('#space').raty({
space: false
});
$('#single').raty({
single: true
});
var $result = $('#result').raty();
$('.action').raty({
click: function(score, evt) {
$(this).raty('cancel');
$result.raty('score', score);
}
});
$('#function').raty({
cancel : true,
cancelHint : 'Boring!',
click : function(score, evt) {
$(this).fadeOut(function() { $(this).fadeIn(); });
},
targetKeep : true,
score : 2,
target : '#hint-function',
targetText : '--'
});
$('.score').click(function() {
$('#function').raty('score', this.title);
});
$('.click').click(function() {
$('#function').raty('click', this.title);
});
$('.readOnly').click(function() {
$('#function').raty('readOnly', (this.title == 'true') ? true : false);
});
$('.cancel').click(function() {
$('#function').raty('cancel', (this.title == 'true') ? true : false);
});
$('#reload').click(function() {
$('#function').raty('reload');
});
$('#get-score').click(function() {
alert($('#function').raty('score'));
});
$('#set-action').on('click', function() {
var options = $('#set-id').val();
eval("$('#function').raty('set', " + options + ");");
});
});
</script>
</body>
</html>

@ -0,0 +1,462 @@
/*!
* jQuery Raty - A Star Rating Plugin - http://wbotelhos.com/raty
* -------------------------------------------------------------------
*
* jQuery Raty is a plugin that generates a customizable star rating.
*
* Licensed under The MIT License
*
* @version 2.4.5
* @since 2010.06.11
* @author Washington Botelho
* @documentation wbotelhos.com/raty
* @twitter twitter.com/wbotelhos
*
* Usage:
* -------------------------------------------------------------------
* $('#star').raty();
*
* <div id="star"></div>
*
*/
;(function($) {
var methods = {
init: function(settings) {
return this.each(function() {
var self = this,
$this = $(self).empty();
self.opt = $.extend(true, {}, $.fn.raty.defaults, settings);
$this.data('settings', self.opt);
self.opt.number = methods.between(self.opt.number, 0, 20);
if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') {
self.opt.path += '/';
}
if (typeof self.opt.score == 'function') {
self.opt.score = self.opt.score.call(self);
}
if (self.opt.score) {
self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
}
for (var i = 1; i <= self.opt.number; i++) {
$('<img />', {
src : self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff : self.opt.starOn),
alt : i,
class : self.opt.css,
title : (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i
}).appendTo(self);
if (self.opt.space) {
$this.append((i < self.opt.number) ? '&#160;' : '');
}
}
self.stars = $this.children('img:not(".raty-cancel")');
self.score = $('<input />', { type: 'hidden', name: self.opt.scoreName }).appendTo(self);
if (self.opt.score && self.opt.score > 0) {
self.score.val(self.opt.score);
methods.roundStar.call(self, self.opt.score);
}
if (self.opt.iconRange) {
methods.fill.call(self, self.opt.score);
}
methods.setTarget.call(self, self.opt.score, self.opt.targetKeep);
var space = self.opt.space ? 4 : 0,
width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space);
if (self.opt.cancel) {
self.cancel = $('<img />', { src: self.opt.path + self.opt.cancelOff, alt: 'x', title: self.opt.cancelHint, 'class': 'raty-cancel' });
if (self.opt.cancelPlace == 'left') {
$this.prepend('&#160;').prepend(self.cancel);
} else {
$this.append('&#160;').append(self.cancel);
}
width += (self.opt.size + space);
}
if (self.opt.readOnly) {
methods.fixHint.call(self);
if (self.cancel) {
self.cancel.hide();
}
} else {
$this.css('cursor', 'pointer');
methods.bindAction.call(self);
}
// $this.css('width', width);
});
}, between: function(value, min, max) {
return Math.min(Math.max(parseFloat(value), min), max);
}, bindAction: function() {
var self = this,
$this = $(self);
$this.mouseleave(function() {
var score = self.score.val() || undefined;
methods.initialize.call(self, score);
methods.setTarget.call(self, score, self.opt.targetKeep);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, score);
}
});
var action = self.opt.half ? 'mousemove' : 'mouseover';
if (self.opt.cancel) {
self.cancel.mouseenter(function() {
$(this).attr('src', self.opt.path + self.opt.cancelOn);
self.stars.attr('src', self.opt.path + self.opt.starOff);
methods.setTarget.call(self, null, true);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, null);
}
}).mouseleave(function() {
$(this).attr('src', self.opt.path + self.opt.cancelOff);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, self.score.val() || null);
}
}).click(function(evt) {
self.score.removeAttr('value');
if (self.opt.click) {
self.opt.click.call(self, null, evt);
}
});
}
self.stars.bind(action, function(evt) {
var value = parseInt(this.alt, 10);
if (self.opt.half) {
var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size),
diff = (position > .5) ? 1 : .5;
value = parseFloat(this.alt) - 1 + diff;
methods.fill.call(self, value);
if (self.opt.precision) {
value = value - diff + position;
}
methods.showHalf.call(self, value);
} else {
methods.fill.call(self, value);
}
$this.data('score', value);
methods.setTarget.call(self, value, true);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, value, evt);
}
}).click(function(evt) {
self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt);
if (self.opt.click) {
self.opt.click.call(self, self.score.val(), evt);
}
});
}, cancel: function(isClick) {
return $(this).each(function() {
var self = this,
$this = $(self);
if ($this.data('readonly') === true) {
return this;
}
if (isClick) {
methods.click.call(self, null);
} else {
methods.score.call(self, null);
}
self.score.removeAttr('value');
});
}, click: function(score) {
return $(this).each(function() {
if ($(this).data('readonly') === true) {
return this;
}
methods.initialize.call(this, score);
if (this.opt.click) {
this.opt.click.call(this, score);
} else {
methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.');
}
methods.setTarget.call(this, score, true);
});
}, error: function(message) {
$(this).html(message);
$.error(message);
}, fill: function(score) {
var self = this,
number = self.stars.length,
count = 0,
$star ,
star ,
icon ;
for (var i = 1; i <= number; i++) {
$star = self.stars.eq(i - 1);
if (self.opt.iconRange && self.opt.iconRange.length > count) {
star = self.opt.iconRange[count];
if (self.opt.single) {
icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
} else {
icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
}
if (i <= star.range) {
$star.attr('src', self.opt.path + icon);
}
if (i == star.range) {
count++;
}
} else {
if (self.opt.single) {
icon = (i == score) ? self.opt.starOn : self.opt.starOff;
} else {
icon = (i <= score) ? self.opt.starOn : self.opt.starOff;
}
$star.attr('src', self.opt.path + icon);
}
}
}, fixHint: function() {
var $this = $(this),
score = parseInt(this.score.val(), 10),
hint = this.opt.noRatedMsg;
if (!isNaN(score) && score > 0) {
hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score;
}
$this.data('readonly', true).css('cursor', 'default').attr('title', hint);
this.score.attr('readonly', 'readonly');
this.stars.attr('title', hint);
}, getScore: function() {
var score = [],
value ;
$(this).each(function() {
value = this.score.val();
score.push(value ? parseFloat(value) : undefined);
});
return (score.length > 1) ? score : score[0];
}, readOnly: function(isReadOnly) {
return this.each(function() {
var $this = $(this);
if ($this.data('readonly') === isReadOnly) {
return this;
}
if (this.cancel) {
if (isReadOnly) {
this.cancel.hide();
} else {
this.cancel.show();
}
}
if (isReadOnly) {
$this.unbind();
$this.children('img').unbind();
methods.fixHint.call(this);
} else {
methods.bindAction.call(this);
methods.unfixHint.call(this);
}
$this.data('readonly', isReadOnly);
});
}, reload: function() {
return methods.set.call(this, {});
}, roundStar: function(score) {
var diff = (score - Math.floor(score)).toFixed(2);
if (diff > this.opt.round.down) {
var icon = this.opt.starOn; // Full up: [x.76 .. x.99]
if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75]
icon = this.opt.starHalf;
} else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5]
icon = this.opt.starOff;
}
this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon);
} // Full down: [x.00 .. x.25]
}, score: function() {
return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this);
}, set: function(settings) {
this.each(function() {
var $this = $(this),
actual = $this.data('settings'),
clone = $this.clone().removeAttr('style').insertBefore($this);
$this.remove();
clone.raty($.extend(actual, settings));
});
return $(this.selector);
}, setScore: function(score) {
return $(this).each(function() {
if ($(this).data('readonly') === true) {
return this;
}
methods.initialize.call(this, score);
methods.setTarget.call(this, score, true);
});
}, setTarget: function(value, isKeep) {
if (this.opt.target) {
var $target = $(this.opt.target);
if ($target.length == 0) {
methods.error.call(this, 'target selector invalid or missing!');
}
var score = value;
if (!isKeep || score === undefined) {
score = this.opt.targetText;
} else {
if (this.opt.targetType == 'hint') {
score = (score === null && this.opt.cancel)
? this.opt.cancelHint
: this.opt.hints[Math.ceil(score - 1)];
} else {
score = this.opt.precision
? parseFloat(score).toFixed(1)
: parseInt(score, 10);
}
}
if (this.opt.targetFormat.indexOf('{score}') < 0) {
methods.error.call(this, 'template "{score}" missing!');
}
if (value !== null) {
score = this.opt.targetFormat.toString().replace('{score}', score);
}
if ($target.is(':input')) {
$target.val(score);
} else {
$target.html(score);
}
}
}, showHalf: function(score) {
var diff = (score - Math.floor(score)).toFixed(1);
if (diff > 0 && diff < .6) {
this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf);
}
}, initialize: function(score) {
score = !score ? 0 : methods.between(score, 0, this.opt.number);
methods.fill.call(this, score);
if (score > 0) {
if (this.opt.halfShow) {
methods.roundStar.call(this, score);
}
this.score.val(score);
}
}, unfixHint: function() {
for (var i = 0; i < this.opt.number; i++) {
this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i);
}
$(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title');
this.score.attr('readonly', 'readonly');
}
};
$.fn.raty = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('Method ' + method + ' does not exist!');
}
};
$.fn.raty.defaults = {
cancel : false,
cancelHint : 'cancel this rating!',
cancelOff : 'cancel-off.png',
cancelOn : 'cancel-on.png',
cancelPlace : 'left',
click : undefined,
half : false,
halfShow : true,
hints : ['bad', 'poor', 'regular', 'good', 'gorgeous'],
iconRange : undefined,
mouseover : undefined,
noRatedMsg : 'not rated yet',
number : 5,
path : 'img/',
precision : false,
round : { down: .25, full: .6, up: .76 },
readOnly : false,
score : undefined,
scoreName : 'score',
single : false,
size : 16,
space : true,
starHalf : 'star-half.png',
starOff : 'star-off.png',
starOn : 'star-on.png',
target : undefined,
targetFormat : '{score}',
targetKeep : false,
targetText : '',
targetType : 'hint',
width : undefined,
css : 'raty'
};
})(jQuery);

@ -195,13 +195,15 @@ class e107
'news' => '{e_HANDLER}news_class.php',
'notify' => '{e_HANDLER}notify_class.php',
'override' => '{e_HANDLER}override_class.php',
'rater' => '{e_HANDLER}rate_class.php',
'redirection' => '{e_HANDLER}redirection_class.php',
'sitelinks' => '{e_HANDLER}sitelinks_class.php',
'themeHandler' => '{e_HANDLER}theme_handler.php',
'user_class' => '{e_HANDLER}userclass_class.php',
'userlogin' => '{e_HANDLER}login.php',
'xmlClass' => '{e_HANDLER}xml_class.php',
'eIPHandler' => '{e_HANDLER}iphandler_class.php',
'eIPHandler' => '{e_HANDLER}iphandler_class.php'
);
@ -1023,6 +1025,17 @@ class e107
{
return self::getSingleton('redirection', true);
}
/**
* Retrieve rater singleton object
*
* @return rate
*/
public static function getRate()
{
return self::getSingleton('rater', true);
}
/**
* Retrieve sitelinks singleton object

@ -549,6 +549,24 @@ class e_form
return $ret;
}
/**
* A 'Rating' element
* @var $text
*/
function rate($table,$id,$options=null)
{
$table = preg_replace('/\W/', '', $table);
$id = intval($id);
return e107::getRate()->render($table, $id, $options);
}
function file($name, $options = array())
{
@ -566,7 +584,7 @@ class e_form
{
$options = $this->format_options('text', $name, $options);
//never allow id in format name-value for text fields
return "<input type='password' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />";
return "<input class='e-password' type='password' name='{$name}' value='{$value}' maxlength='{$maxlength}'".$this->get_attributes($options, $name)." />";
}
// autoexpand done

@ -15,11 +15,91 @@ if (!defined('e107_INIT')) { exit; }
include_lan(e_LANGUAGEDIR.e_LANGUAGE."/lan_rate.php");
class rater {
function rateselect($text, $table, $id, $mode=FALSE) {
function render($table,$id,$options=array())
{
list($votes,$score,$uvoted) = $this->getrating($table, $id);
parse_str($options,$options);
//
$label = varset($options['label'],RATELAN_5);
$readonly = $this->checkrated($table, $id) ? '1' : '0';
$hintArray = array(RATELAN_POOR,RATELAN_FAIR,RATELAN_GOOD,RATELAN_VERYGOOD,RATELAN_EXCELLENT);
$datahint = implode(",",$hintArray);
$path = e_FILE_ABS."jslib/rate/img/";
$score = ($score / 2);
// var_dump($readonly);
if(!$votes)
{
$voteDiz = RATELAN_4;
}
else
{
$voteDiz = ($votes == 1) ? RATELAN_0 : RATELAN_1;
}
if($readonly == '1')
{
$label = RATELAN_3;
}
if(!USERID)
{
$label = RATELAN_6; // Please login to vote.
$readonly = '1';
}
$template = vartrue($options['template'], "STATUS|RATE|VOTES");
$TEMPLATE['STATUS'] = "<div class='e-rate-status e-rate-status-{$table}' id='e-rate-{$table}-{$id}'>".$label."</div>";
$TEMPLATE['RATE'] = "<div class='e-rate e-rate-{$table}' id='{$table}-{$id}' data-hint=\"{$datahint}\" data-readonly='{$readonly}' data-score='{$score}' data-url='".e_BASE."rate.php' data-path='{$path}'></div>";
$TEMPLATE['VOTES'] = "<div class='e-rate-votes e-rate-votes-{$table}' id='e-rate-votes-{$table}-{$id}'>".$this->renderVotes($votes,$score)."</div>";
$tmp = explode("|",$template);
$text = "";
foreach($tmp as $k)
{
$text .= $TEMPLATE[$k];
}
return $text;
}
function renderVotes($votes,$score) // TODO use template?
{
if(!$votes)
{
$voteDiz = RATELAN_4;
}
else
{
$voteDiz = ($votes == 1) ? RATELAN_0 : RATELAN_1;
}
return "{$score}/5 : {$votes} ".$voteDiz;
}
// Legacy Rate Selector.
function rateselect($text, $table, $id, $mode=FALSE)
{
//$mode : if mode is set, no urljump will be used (used in combined comments+rating system)
$table = preg_replace('/\W/', '', $table);
$id = intval($id);
// return $this->render($text,$table,$id,$mode);
// $self = $_SERVER['PHP_SELF'];
// if ($_SERVER['QUERY_STRING']) {
@ -71,7 +151,7 @@ class rater {
}
function checkrated($table, $id) {
$table = preg_replace('/\W/', '', $table);
$id = intval($id);
@ -97,6 +177,12 @@ class rater {
$table = preg_replace('/\W/', '', $table);
$id = intval($id);
if($id == 0)
{
return "There is no item ID in the rating";
}
$sep = chr(1);
$sql = new db;
if (!$sql->db_Select("rate", "*", "rate_table = '{$table}' AND rate_itemid = '{$id}' ")) {
@ -107,8 +193,8 @@ class rater {
$rating = "";
$rateusers = explode(".", $rowgr['rate_voters']);
for($i=0;$i<count($rateusers);$i++){
if(strpos($rateusers[$i], chr(1))){
$rateuserinfo[$i] = explode(chr(1), $rateusers[$i]);
if(strpos($rateusers[$i], $sep)){
$rateuserinfo[$i] = explode($sep, $rateusers[$i]);
if($userid == $rateuserinfo[$i][0]){
$rating[0] = 0; //number of votes, not relevant in users rating
$rating[1] = $rateuserinfo[$i][1]; //the rating by this user
@ -137,14 +223,38 @@ class rater {
}
}
function enterrating($rateindex){
global $sql, $tp;
function submitVote($table,$itemid,$rate)
{
$array = $table."^".$itemid."^^".$rate;
return $this->enterrating($array,true);
}
function enterrating($rateindex,$ajax = false)
{
$sql = e107::getDb();
$tp = e107::getParser();
$qs = explode("^", $rateindex);
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1) {
header("location:".e_BASE."index.php");
exit;
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1)
{
if($ajax == false)
{
header("location:".e_BASE."index.php");
exit;
}
else
{
return "Error: ".print_a($qs,true);
}
}
$table = $tp -> toDB($qs[0], true);
@ -153,18 +263,51 @@ class rater {
//rating is now stored as userid-rating (to retain individual users rating)
//$sep = "^";
$sep = chr(1);
$sep = chr(1); // problematic - invisible in phpmyadmin.
$voter = USERID.$sep.intval($qs[3]);
if ($sql->db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}' ")) {
$row = $sql->db_Fetch();
if ($sql->db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}' "))
{
$row = $sql -> db_Fetch();
$rate_voters = $row['rate_voters'].".".$voter.".";
$sql->db_Update("rate", "rate_votes=rate_votes+1, rate_rating=rate_rating+'{$rate}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' ");
} else {
$sql->db_Insert("rate", " 0, '$table', '$itemid', '$rate', '1', '.".$voter.".' ");
$new_votes = $row['rate_votes'] + 1;
$new_rating = $row['rate_rating'] + $rate;
$stat = ($new_rating /$new_votes)/2;
$statR = round($stat,1);
if(strpos($row['rate_voters'], ".".$voter.".") == true || strpos($row['rate_voters'], ".".USERID.".") == true)
{
return "You already voted|".$this->renderVotes($new_votes,$statR); // " newvotes = ".($statR). " =".$new_votes;
}
if($sql->db_Update("rate", "rate_votes= ".$new_votes.", rate_rating='{$new_rating}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' "))
{
return RATELAN_3."|".$this->renderVotes($new_votes,$statR); // Thank you for your vote.
}
else
{
return "Error";
}
}
elseif($sql->db_Insert("rate", " 0, '$table', '$itemid', '$rate', '1', '.".$voter.".' "))
{
$stat = ($rate /1)/2;
$statR = round($stat,1);
return RATELAN_3."|".$this->renderVotes(1,$statR); ; // Thank you for your vote.
}
}
function composerating($table, $id, $enter=TRUE, $userid=FALSE, $nojump=FALSE){
//enter : boolean to show (rateselect box + textual info) or not
//userid : used to calculate a users given rating

@ -10,11 +10,19 @@
+----------------------------------------------------------------------------+
*/
define("RATELAN_0", "vote");
define("RATELAN_1", "votes");
define("RATELAN_2", "how do you rate this item?");
define("RATELAN_3", "thank you for your vote");
define("RATELAN_4", "not rated");
define("RATELAN_5", "Rate");
define("RATELAN_0", "Vote");
define("RATELAN_1", "Votes");
define("RATELAN_2", "How do you rate this item?");
define("RATELAN_3", "Thanks for voting!");
define("RATELAN_4", "Not rated");
define("RATELAN_5", "Rate this:");
define("RATELAN_6", "Please login to rate this.");
define("RATELAN_POOR","Poor");
define("RATELAN_FAIR","Fair");
define("RATELAN_GOOD","Good");
define("RATELAN_VERYGOOD","Very Good");
define("RATELAN_EXCELLENT","Excellent");
?>

@ -189,7 +189,8 @@ class download_shortcodes
}
function sc_download_list_rating()
{
global $dlrow;
global $dlrow,$tp;
return $tp->rate("download", $dlrow['download_id']);
$rater = new rater();
$ratearray = $rater->getrating("download", $dlrow['download_id']);
if (!$ratearray[0]) {
@ -307,7 +308,7 @@ class download_shortcodes
{
global $pref,$dl,$tp;
if ($pref['agree_flag'] == 1) {
return "xxx<a href='".e_BASE."request.php?".$dl['download_id']."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name']."</a>";
return "<a href='".e_BASE."request.php?".$dl['download_id']."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name']."</a>";
} else {
return "<a href='".e_BASE."request.php?".$dl['download_id']."' title='".LAN_dl_46."'>".$dl['download_name']."</a>";
}
@ -399,7 +400,7 @@ class download_shortcodes
}
else
{
return $dnld_link." xxx<img src='".IMAGE_DOWNLOAD."' alt='*' /></a>";
return $dnld_link."<img src='".IMAGE_DOWNLOAD."' alt='*' /></a>";
}
}
function sc_download_view_filesize()
@ -409,9 +410,14 @@ class download_shortcodes
}
function sc_download_view_rating()
{
global $dlrow;
$frm = e107::getForm();
$options = array('label'=>' ','template'=>'RATE|VOTES|STATUS');
return $frm->rate("download", $dlrow['download_id'],$options);
require_once(e_HANDLER."rate_class.php");
$rater = new rater;
global $dlrow;
$text = "
<table style='width:100%'>
<tr>

@ -103,28 +103,10 @@ e107::css('inline',"/******** Tabs JS */
// jQUERY scripts
e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2);
e107::css('core', 'colorbox/colorbox.css', 'jquery');
e107::js('core', 'jquery.elastic.js', 'jquery', 2);
e107::js('core', 'jquery-ui-timepicker-addon.js', 'jquery', 2);
e107::js('core', 'plupload/plupload.full.js', 'jquery', 2);
e107::css('core', 'plupload/jquery.plupload.queue/css/jquery.plupload.queue.css', 'jquery');
e107::js('core', 'plupload/jquery.plupload.queue/jquery.plupload.queue.js', 'jquery', 2);
e107::css('core', 'chosen/chosen.css', 'jquery');
e107::js('core', 'chosen/chosen.jquery.min.js', 'jquery', 2);
e107::css('core', 'password/style.css', 'jquery');
e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2);
//
e107::js("core", "plupload/customUpload.js","jquery",3);
e107::js("core", "core/mediaManager.js","jquery",3);
e107::css('core', 'core/admin.css', 'jquery');
e107::js('core', 'core/admin.jquery.js', 'jquery', 4);
//e107::css('core', 'core/admin.css', 'jquery');
//e107::js('core', 'core/admin.jquery.js', 'jquery', 4);

@ -827,10 +827,4 @@ h1.bbcode, h2.bbcode, h3.bbcode, h4.bbcode, h5.bbcode, h6.bbcode { }/* override
div.bbcode { margin: 15px 0px; clear: both; } /* layout control via bbcodes */
a.media-select-image { margin:5px; border:1px solid silver; width:120px; height:100px; }
a.media-select-image:hover { border:1px solid red; }
a.media-select-icon { text-align:center; vertical-align:middle; margin:1px; border:1px solid white; width:48px; height:48px;}
a.media-select-icon:hover { border:1px solid red; }
.media-select-container { padding:10px; }
.media-select-none { text-decoration:none; }
.media-select-active { border: 2px solid silver; }

@ -23,6 +23,15 @@ define('ADMIN_AREA',FALSE);
$e107 = e107::getInstance();
$e107->sql->db_Mark_Time('(Header Top)');
e107::css('core', 'password/style.css', 'jquery');
e107::js('core', 'password/jquery.pwdMeter.js', 'jquery', 2);
e107::js('core', 'colorbox/jquery.colorbox-min.js', 'jquery', 2);
e107::css('core', 'colorbox/colorbox.css', 'jquery');
e107::js('core', 'rate/js/jquery.raty.js', 'jquery', 2);
e107::css('core', 'core/all.jquery.css', 'jquery');
e107::js("core", "core/all.jquery.js","jquery",5); // Load all default functions.
//
// *** Code sequence for headers ***
// IMPORTANT: These items are in a carefully constructed order. DO NOT REARRANGE
@ -125,6 +134,8 @@ else
define("e_WYSIWYG",FALSE);
}
//
// D: Register CSS
//
@ -508,6 +519,7 @@ if (count($js_body_onload)) $body_onload = " onload=\"".implode(" ",$js_body_onl
* Fire Event e107:loaded
* FIXME - disable core JS
*/
/*
echo "<script type='text/javascript'>\n";
echo "<!--\n";
echo "\$('e-js-css').remove();\n"; // unobtrusive JS - moved here from external e_css.php
@ -516,7 +528,7 @@ echo "e107Event.trigger('loaded', {element: null}, document);\n";
echo "});\n";
echo "// -->\n";
echo "</script>\n";
*/
echo "</head>
<body".$body_onload.">\n";

@ -428,44 +428,53 @@ class pageClass
// FIXME most probably will fail when cache enabled
function pageRating($page_rating_flag)
{
$rate_text = ''; // Notice removal
if($page_rating_flag)
{
require_once(e_HANDLER."rate_class.php");
$rater = new rater;
$rate_text = "<br /><table style='width:100%'><tr><td style='width:50%'>";
if ($ratearray = $rater->getrating("page", $this->pageID))
{
if ($ratearray[2] == "")
{
$ratearray[2] = 0;
}
$rate_text .= "<img src='".e_IMAGE_ABS."rate/box/box".$ratearray[1].".png' alt='' style='vertical-align:middle;' />\n";
$rate_text .= "&nbsp;".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]."&nbsp;";
$rate_text .= ($ratearray[0] == 1 ? "vote" : "votes");
}
else
{
$rating .= LAN_PAGE_dl_13;
}
$rate_text .= "</td><td style='width:50%; text-align:right'>";
if (!$rater->checkrated("page", $this->pageID) && USER)
{
$rate_text .= $rater->rateselect("&nbsp;&nbsp;&nbsp;&nbsp; <b>".LAN_PAGE_4."</b>", "page", $this->pageID);
}
else if(!USER)
{
$rate_text .= "&nbsp;";
}
else
{
$rate_text .= LAN_PAGE_5;
}
$rate_text .= "</td></tr></table>";
return "<br /><div style='text-align:right'>".e107::getRate()->render("page", $this->pageID,array('label'=>LAN_PAGE_4))."</div>";
/*
$rate_text = ''; // Notice removal
require_once(e_HANDLER."rate_class.php");
$rater = new rater;
$rate_text = "<br /><table style='width:100%'><tr><td style='width:50%'>";
if ($ratearray = $rater->getrating("page", $this->pageID))
{
if ($ratearray[2] == "")
{
$ratearray[2] = 0;
}
$rate_text .= "<img src='".e_IMAGE_ABS."rate/box/box".$ratearray[1].".png' alt='' style='vertical-align:middle;' />\n";
$rate_text .= "&nbsp;".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]."&nbsp;";
$rate_text .= ($ratearray[0] == 1 ? "vote" : "votes");
}
else
{
$rating .= LAN_PAGE_dl_13;
}
$rate_text .= "</td><td style='width:50%; text-align:right'>";
if (!$rater->checkrated("page", $this->pageID) && USER)
{
$rate_text .= $rater->rateselect("&nbsp;&nbsp;&nbsp;&nbsp; <b>".LAN_PAGE_4."</b>", "page", $this->pageID);
}
else if(!USER)
{
$rate_text .= "&nbsp;";
}
else
{
$rate_text .= LAN_PAGE_5;
}
$rate_text .= "</td></tr></table>";
*/
}
return $rate_text;
// return $rate_text;
}
function pageComment($page_comment_flag)

@ -22,19 +22,40 @@
require_once("class2.php");
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/lan_'.e_PAGE);
$qs = explode("^", e_QUERY);
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false)
{
header("location:".e_BASE."index.php");
if(!e_AJAX_REQUEST) // Legacy method.
{
$qs = explode("^", e_QUERY);
if (!$qs[0] || USER == FALSE || $qs[3] > 10 || $qs[3] < 1 || strpos($qs[2], '://') !== false)
{
header("location:".e_BASE."index.php");
exit;
}
$table = $tp -> toDB($qs[0]);
$itemid = intval($qs[1]);
$returnurl = $tp -> toDB($qs[2]);
$rate = intval($qs[3]);
e107::getRate()->submitVote($table,$itemid,$rate);
header("location:".$returnurl);
exit;
}
else // Ajax Used.
{
$table = $tp->toDB($_POST['table']);
$itemid = intval($_POST['id']);
$rate = intval($_POST['score']) * 2;
echo e107::getRate()->submitVote($table,$itemid,$rate);
exit;
}
$table = $tp -> toDB($qs[0]);
$itemid = intval($qs[1]);
$returnurl = $tp -> toDB($qs[2]);
$rate = intval($qs[3]);
/*
if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$itemid}'"))
{
$row = $sql -> db_Fetch();
@ -43,19 +64,41 @@ if ($sql -> db_Select("rate", "*", "rate_table='{$table}' AND rate_itemid='{$ite
$rate_voters = $row['rate_voters'].".".USERID.".";
$new_rating = $row['rate_rating']+$rate;
$sql -> db_Update("rate", "rate_votes=rate_votes+1, rate_rating='{$new_rating}', rate_voters='{$rate_voters}' WHERE rate_id='{$row['rate_id']}' ");
if(!$returnurl)
{
$voteStatus = e107::getRate()->renderVotes($rate_voters,($row['rate_votes'] +1));
echo $voteStatus."|".RATELAN_3; // Thank you for your vote.
}
}
else
{
header("location:".e_BASE."index.php");
if($returnurl)
{
header("location:".e_BASE."index.php");
}
else
{
echo "You already voted!";
}
exit;
}
}
else
{
$sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' ");
if($sql->db_Insert("rate", " 0, '{$table}', '{$itemid}', '{$rate}', '1', '.".USERID.".' "))
{
if(!$returnurl)
{
echo RATELAN_3; // Thank you for your vote.
}
}
}
*/
header("location:".$returnurl);
exit;
?>