Initialer Commit in GIT
7
public/.htaccess
Normal file
@ -0,0 +1,7 @@
|
||||
<IfModule !mod_authz_core.c>
|
||||
Order allow,deny
|
||||
Allow from all
|
||||
</IfModule>
|
||||
<IfModule mod_authz_core.c>
|
||||
Require all granted
|
||||
</IfModule>
|
135
public/css/backend.css
Normal file
@ -0,0 +1,135 @@
|
||||
/**
|
||||
* Contao Open Source CMS
|
||||
* Copyright (C) 2005-2011 Leo Feyer
|
||||
*
|
||||
* Formerly known as TYPOlight Open Source CMS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program. If not, please visit the Free
|
||||
* Software Foundation website at <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* PHP version 5
|
||||
* @copyright cgo IT, 2013
|
||||
* @author Carsten Götzinger (info@cgo-it.de)
|
||||
* @package rateit
|
||||
* @license GNU/LGPL
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
/* General */
|
||||
.mod_rateit .nowrap { white-space:nowrap; }
|
||||
.mod_rateit .middle, .mod_rateit .middle * { vertical-align:middle; }
|
||||
.mod_rateit table.nested { width:100%; margin:0; border:0; }
|
||||
.mod_rateit table td.nopadding { vertical-align:top; padding:0px !important;}
|
||||
|
||||
/* Rating list */
|
||||
/*.rating_container { margin:12px; }*/
|
||||
.mod_rateit table
|
||||
{
|
||||
width:100%;
|
||||
margin:6px 0;
|
||||
border-top:1px solid #ddd;
|
||||
border-bottom:1px solid #ddd;
|
||||
}
|
||||
.mod_rateit table th, .mod_rateit table td
|
||||
{
|
||||
padding:3px 6px;
|
||||
background-color:#f9f9f9;
|
||||
text-align:left;
|
||||
line-height:1;
|
||||
}
|
||||
.mod_rateit table th.selectall {
|
||||
background-color:#fff;
|
||||
}
|
||||
.mod_rateit table.rating-selectall {
|
||||
border:0px;
|
||||
}
|
||||
.mod_rateit table th { background-color:#fbf7f1; }
|
||||
.mod_rateit table tr.title th
|
||||
{
|
||||
padding:6px;
|
||||
background-color:#f0f0f0;
|
||||
border-bottom:1px solid #ddd;
|
||||
}
|
||||
.mod_rateit table tr.title span.leftblock
|
||||
{
|
||||
padding-top:2px;
|
||||
display:block;
|
||||
float:left;
|
||||
}
|
||||
.mod_rateit table tr.title span.leftblock a { color:#8ab858 !important; }
|
||||
.mod_rateit table tr.title span.rightblock { display:block; float:right; }
|
||||
.mod_rateit table tr.info th, .mod_rateit table tr.info td { border-top:1px solid #fff; font-size:10px; }
|
||||
.mod_rateit table .listcol1, .mod_rateit table .listcol3, .mod_rateit table .viewcol1, .mod_rateit table .viewcol3 { width:23%; }
|
||||
.mod_rateit table .listcol2, .mod_rateit table .viewcol2 { width:27%; }
|
||||
|
||||
/* Details view */
|
||||
.mod_rateit_view tr.spacer td
|
||||
{
|
||||
background-color:#fff;
|
||||
border-top:1px solid #ddd;
|
||||
border-bottom:1px solid #ddd;
|
||||
line-height:4px;
|
||||
}
|
||||
|
||||
/* Status colors */
|
||||
.mod_rateit table.rating td.active-0 { background-color:#ffe0e0; }
|
||||
.mod_rateit table.rating td.type-ce { background-color:#e0e0ff; }
|
||||
.mod_rateit table.rating td.type-module { background-color:#ffe0e0; }
|
||||
.mod_rateit table.rating td.type-news { background-color:#aae0e0; }
|
||||
.mod_rateit table.rating td.type-faq { background-color:#ffe0aa; }
|
||||
.mod_rateit table.rating td.type-article { background-color:#ffcce0; }
|
||||
.mod_rateit table.rating td.type-galpic { background-color:#ffe066; }
|
||||
.mod_rateit table.rating td.active-1, .mod_rateit table.rating td.type-page { background-color:#e0ffe0; }
|
||||
.mod_rateit table.rating td.
|
||||
|
||||
/* Rating-Statistics */
|
||||
.mod_rateit table th.statistics { float:left; }
|
||||
|
||||
/* Rating */
|
||||
.mod_rateit div.ratebarframe
|
||||
{
|
||||
width:60px;
|
||||
float:left;
|
||||
background-color:#ffe0e0;
|
||||
border:1px solid #999;
|
||||
font-size:1px;
|
||||
line-height:1px;
|
||||
}
|
||||
.mod_rateit div.ratebar
|
||||
{
|
||||
width:10%;
|
||||
height:12px;
|
||||
background-color:#c0ffc0;
|
||||
font-size:1px;
|
||||
}
|
||||
.mod_rateit div.ratebartext { margin-left:65px; }
|
||||
|
||||
.mod_rateit a.header_export_excel{
|
||||
padding:2px 0 3px 20px;
|
||||
background-image:url("../images/exportEXCEL.gif");
|
||||
background-position:left center;
|
||||
background-repeat:no-repeat;
|
||||
}
|
||||
|
||||
.mod_rateit div.chart {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mod_rateit .w50 {
|
||||
width: 48%;
|
||||
}
|
||||
|
||||
.mod_rateit .h100 {
|
||||
height: 100%;
|
||||
}
|
11
public/css/heart.css
Normal file
@ -0,0 +1,11 @@
|
||||
.rateItRating .wrapper, .mbrateItRating .wrapper {
|
||||
background: url('../images/heart.gif');
|
||||
}
|
||||
|
||||
div.rateItRating div.rateItRating-hover, div.mbrateItRating div.rateItRating-hover {
|
||||
background: url('../images/heart.gif') left;
|
||||
}
|
||||
|
||||
div.rateItRating div.rateItRating-selected, div.mbrateItRating div.rateItRating-selected {
|
||||
background: url('../images/heart.gif') left;
|
||||
}
|
65
public/css/rateit.css
Normal file
@ -0,0 +1,65 @@
|
||||
.rateItRating {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.mbrateItRating {
|
||||
position: relative;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.rateItRating .wrapper, .mbrateItRating .wrapper {
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
diplay: inline-block;
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.rateItRating[rel="not-rateable"] {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.rateItRating[rel="not-rateable"] .wrapper {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
div.mod_rateit_top_ratings ul {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
div.mod_rateit_top_ratings li {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
div.mod_rateit_top_ratings div.rateItTitle {
|
||||
display: inline-block;
|
||||
max-width: 40%;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
div.rateItRating div.rateItRating-hover, div.rateItRating div.rateItRating-selected,
|
||||
div.mbrateItRating div.rateItRating-hover, div.mbrateItRating div.rateItRating-selected {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.rateItRating .ratingText {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.mbrateItRating .mbratingText {
|
||||
display: inline-block;
|
||||
color: #ccc;
|
||||
}
|
||||
|
||||
.ratingText.ratingError {
|
||||
color: #f00;
|
||||
}
|
||||
|
||||
.rateItRating .ratingText.loading, .mbrateItRating .mbratingText.loading {
|
||||
background: url('../images/ajax-loading.gif') no-repeat;
|
||||
/*text-indent: -999em;*/
|
||||
}
|
||||
|
||||
span.rating-microdata {
|
||||
display: none;
|
||||
}
|
11
public/css/star.css
Normal file
@ -0,0 +1,11 @@
|
||||
.rateItRating .wrapper, .mbrateItRating .wrapper {
|
||||
background: url("../images/star.gif");
|
||||
}
|
||||
|
||||
div.rateItRating div.rateItRating-hover, div.mbrateItRating div.rateItRating-hover {
|
||||
background: url("../images/star.gif") left;
|
||||
}
|
||||
|
||||
div.rateItRating div.rateItRating-selected, div.mbrateItRating div.rateItRating-selected {
|
||||
background: url("../images/star.gif") left;
|
||||
}
|
BIN
public/images/ajax-loading.gif
Normal file
After Width: | Height: | Size: 847 B |
BIN
public/images/article.gif
Normal file
After Width: | Height: | Size: 392 B |
BIN
public/images/exportEXCEL.gif
Normal file
After Width: | Height: | Size: 282 B |
BIN
public/images/heart.gif
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
public/images/icon.png
Normal file
After Width: | Height: | Size: 722 B |
BIN
public/images/info.gif
Normal file
After Width: | Height: | Size: 354 B |
BIN
public/images/page.gif
Normal file
After Width: | Height: | Size: 625 B |
BIN
public/images/star.gif
Normal file
After Width: | Height: | Size: 815 B |
22
public/js/RateItBackend.js
Normal file
@ -0,0 +1,22 @@
|
||||
var RateItBackend =
|
||||
{
|
||||
/**
|
||||
* Add the interactive help
|
||||
*/
|
||||
addInteractiveHelp: function() {
|
||||
// Links and input elements
|
||||
['div.statisticsbar[title]'].each(function(el) {
|
||||
new Tips.Contao($$(el).filter(function(i) {
|
||||
return i.title != '';
|
||||
}), {
|
||||
offset: {x:0, y:26}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
//Initialize the back end script
|
||||
window.addEvent('domready', function() {
|
||||
RateItBackend.addInteractiveHelp();
|
||||
});
|
||||
|
114
public/js/helper.js
Normal file
@ -0,0 +1,114 @@
|
||||
if (typeof Object.create !== 'function') {
|
||||
Object.create = function (o) {
|
||||
function F() {}
|
||||
F.prototype = o;
|
||||
return new F();
|
||||
};
|
||||
}
|
||||
|
||||
function $tryCatch() {
|
||||
for (var i = 0, l = arguments.length; i < l; i++){
|
||||
try {
|
||||
return arguments[i]();
|
||||
} catch(e){}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
var Browser = {
|
||||
|
||||
Engine: {name: 'unknown', version: 0},
|
||||
|
||||
Platform: {name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()},
|
||||
|
||||
Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)},
|
||||
|
||||
Plugins: {},
|
||||
|
||||
Engines: {
|
||||
|
||||
presto: function(){
|
||||
return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925));
|
||||
},
|
||||
|
||||
trident: function(){
|
||||
return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4);
|
||||
},
|
||||
|
||||
webkit: function(){
|
||||
return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419);
|
||||
},
|
||||
|
||||
gecko: function(){
|
||||
return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Browser.Platform[Browser.Platform.name] = true;
|
||||
|
||||
Browser.detect = function(){
|
||||
|
||||
for (var engine in this.Engines){
|
||||
var version = this.Engines[engine]();
|
||||
if (version){
|
||||
this.Engine = {name: engine, version: version};
|
||||
this.Engine[engine] = this.Engine[engine + version] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return {name: engine, version: version};
|
||||
|
||||
};
|
||||
|
||||
Browser.detect();
|
||||
|
||||
Browser.Request = function(){
|
||||
return $tryCatch(function(){
|
||||
return new XMLHttpRequest();
|
||||
}, function(){
|
||||
return new ActiveXObject('MSXML2.XMLHTTP');
|
||||
}, function(){
|
||||
return new ActiveXObject('Microsoft.XMLHTTP');
|
||||
});
|
||||
};
|
||||
|
||||
Browser.Features.xhr = !!(Browser.Request());
|
||||
|
||||
Browser.Plugins.Flash = (function(){
|
||||
var version = ($tryCatch(function(){
|
||||
return navigator.plugins['Shockwave Flash'].description;
|
||||
}, function(){
|
||||
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
|
||||
}) || '0 r0').match(/\d+/g);
|
||||
return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0};
|
||||
})();
|
||||
|
||||
function $exec(text){
|
||||
if (!text) return text;
|
||||
if (window.execScript){
|
||||
window.execScript(text);
|
||||
} else {
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('type', 'text/javascript');
|
||||
script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;
|
||||
document.head.appendChild(script);
|
||||
document.head.removeChild(script);
|
||||
}
|
||||
return text;
|
||||
};
|
||||
|
||||
function getPosition(element) {
|
||||
var xPosition = 0;
|
||||
var yPosition = 0;
|
||||
|
||||
while(element) {
|
||||
xPosition += (element.offsetLeft - element.scrollLeft + element.clientLeft);
|
||||
yPosition += (element.offsetTop - element.scrollTop + element.clientTop);
|
||||
element = element.offsetParent;
|
||||
}
|
||||
return { x: xPosition, y: yPosition };
|
||||
}
|
2240
public/js/jquery-ui-effects.custom.js
Normal file
6
public/js/jquery-ui-effects.custom.min.js
vendored
Normal file
1127
public/js/jquery/colorbox/colorbox-rateit.js
vendored
Normal file
7
public/js/jquery/colorbox/colorbox-rateit.min.js
vendored
Normal file
1025
public/js/mootools/mediabox/mediabox-rateit-uncompressed.js
Normal file
1
public/js/mootools/mediabox/mediabox-rateit.js
Normal file
75
public/js/onReadyRateIt-uncompressed.js
Normal file
@ -0,0 +1,75 @@
|
||||
var readyListRateIt = [];
|
||||
|
||||
function onReadyRateIt(handler) {
|
||||
|
||||
function executeHandlers() {
|
||||
for ( var i = 0; i < readyListRateIt.length; i++) {
|
||||
readyListRateIt[i]();
|
||||
}
|
||||
}
|
||||
|
||||
if (!readyListRateIt.length) { // set handler on first run
|
||||
bindReady(executeHandlers);
|
||||
}
|
||||
|
||||
readyListRateIt.push(handler);
|
||||
}
|
||||
|
||||
function bindReady(handler) {
|
||||
|
||||
var called = false;
|
||||
|
||||
function ready() {
|
||||
if (called)
|
||||
return
|
||||
|
||||
called = true;
|
||||
handler();
|
||||
}
|
||||
|
||||
if (document.addEventListener) { // native event
|
||||
document.addEventListener("DOMContentLoaded", ready, false);
|
||||
} else if (document.attachEvent) { // IE
|
||||
|
||||
try {
|
||||
var isFrame = window.frameElement != null;
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
// IE, the document is not inside a frame
|
||||
if (document.documentElement.doScroll && !isFrame) {
|
||||
function tryScroll() {
|
||||
if (called)
|
||||
return;
|
||||
try {
|
||||
document.documentElement.doScroll("left");
|
||||
ready();
|
||||
} catch (e) {
|
||||
setTimeout(tryScroll, 10);
|
||||
}
|
||||
}
|
||||
tryScroll();
|
||||
}
|
||||
|
||||
// IE, the document is inside a frame
|
||||
document.attachEvent("onreadystatechange", function() {
|
||||
if (document.readyState === "complete") {
|
||||
ready();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Old browsers
|
||||
if (window.addEventListener)
|
||||
window.addEventListener('load', ready, false);
|
||||
else if (window.attachEvent)
|
||||
window.attachEvent('onload', ready);
|
||||
else {
|
||||
var fn = window.onload; // very old browser, copy old onload
|
||||
window.onload = function() { // replace by new onload and call the
|
||||
// old one
|
||||
fn && fn();
|
||||
ready();
|
||||
};
|
||||
}
|
||||
}
|
1
public/js/onReadyRateIt.js
Normal file
@ -0,0 +1 @@
|
||||
function onReadyRateIt(e){function t(){for(var e=0;e<readyListRateIt.length;e++){readyListRateIt[e]()}}if(!readyListRateIt.length){bindReady(t)}readyListRateIt.push(e)}function bindReady(e){function n(){if(t)return;t=true;e()}var t=false;if(document.addEventListener){document.addEventListener("DOMContentLoaded",n,false)}else if(document.attachEvent){try{var r=window.frameElement!=null}catch(i){}if(document.documentElement.doScroll&&!r){function s(){if(t)return;try{document.documentElement.doScroll("left");n()}catch(e){setTimeout(s,10)}}s()}document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){n()}})}if(window.addEventListener)window.addEventListener("load",n,false);else if(window.attachEvent)window.attachEvent("onload",n);else{var o=window.onload;window.onload=function(){o&&o();n()}}}var readyListRateIt=[]
|
591
public/js/rateit-uncompressed.js
Normal file
@ -0,0 +1,591 @@
|
||||
var RateItRating;
|
||||
|
||||
function doRateIt() {
|
||||
if (window.MooTools) {
|
||||
var RateItRatings = new Class({
|
||||
|
||||
Implements: Options,
|
||||
|
||||
options: {
|
||||
step: 0.1, /* Schrittweite */
|
||||
readonly: false, /* Bewertungen zulassen */
|
||||
resetable: false /* Nicht zurücksetzbar */
|
||||
},
|
||||
|
||||
initialize: function(options) {
|
||||
|
||||
this.setOptions(options);
|
||||
|
||||
$$('.rateItRating').each(function(el) {
|
||||
this.initMe(el);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
initMe: function(el) {
|
||||
//Does this if the browser is NOT IE6. IE6 users don't deserve fancy ratings. >:(
|
||||
if (!Browser.ie || Browser.version > 6) {
|
||||
el.id = el.getAttribute('id');
|
||||
el.rateable = el.getAttribute('rel') == 'not-rateable' ? false : true;
|
||||
el.wrapper = el.getElement('.wrapper');
|
||||
el.textEl = el.getElement('.ratingText');
|
||||
el.selected = el.wrapper.getElement('.rateItRating-selected');
|
||||
el.hover = el.wrapper.getElement('.rateItRating-hover');
|
||||
el.widthFx = new Fx.Tween(el.selected, {property:'width', link:'chain'});
|
||||
|
||||
var backgroundImage = this.getBackgroundImage(el.wrapper);
|
||||
this.options.starwidth = backgroundImage.width;
|
||||
this.options.starheight = backgroundImage.height / 3; // da immer drei Sterne "übereinander" gebraucht werden
|
||||
if (this.options.starwidth === undefined || this.options.starwidth < 16) {
|
||||
this.options.starwidth = 16;
|
||||
}
|
||||
if (this.options.starheight === undefined || this.options.starheight < 16) {
|
||||
this.options.starheight = 16;
|
||||
}
|
||||
|
||||
this.setBackgroundPosition(el.selected, -1 * this.options.starheight);
|
||||
this.setBackgroundPosition(el.hover, -1 * 2 * this.options.starheight);
|
||||
|
||||
el.starPercent = this.getStarPercent(el.id);
|
||||
el.ratableId = this.getRatableId(el.id);
|
||||
el.ratableType = this.getRatableType(el.id);
|
||||
|
||||
// Maximalwert (=Anzahl Sterne) ermitteln
|
||||
this.options.max = this.getRatableMaxValue(el.id);
|
||||
|
||||
// Höhe für selected und hover einstellen
|
||||
el.selected.setStyle('height', this.options.starheight);
|
||||
el.hover.setStyle('height', this.options.starheight);
|
||||
|
||||
// Wrapper-Größe so anpassen, dass alle Sterne angezeigt werden
|
||||
el.wrapper.setStyle('width', this.options.starwidth * this.options.max);
|
||||
el.wrapper.setStyle('height', this.options.starheight);
|
||||
|
||||
// Breite des rateItRating-selected divs setzen
|
||||
this.fillVote(el.starPercent, el);
|
||||
|
||||
// Breite f<>r rateItRating-selected div ermitteln
|
||||
el.currentFill = this.getFillPercent(el.starPercent);
|
||||
|
||||
if (el.rateable) {
|
||||
el.mouseCrap = function(e) {
|
||||
var fill = e.event.layerX;
|
||||
if (!fill) {
|
||||
fill = e.event.offsetX;
|
||||
}
|
||||
var fillPercent = this.getVotePercent(fill);
|
||||
var nextStep = Math.ceil((fillPercent / 100) * this.options.max);
|
||||
|
||||
var w = nextStep * this.options.starwidth;
|
||||
if (el.hover.getStyle('width').toInt() != w) {
|
||||
el.selected.setStyle('display', 'none');
|
||||
el.hover.setStyle('width', Math.min(w, this.options.starwidth * this.options.max));
|
||||
el.hover.setStyle('display', 'block');
|
||||
}
|
||||
|
||||
var newFill = nextStep / this.options.max * 100;
|
||||
this.fillVote(newFill, el);
|
||||
}.bind(this);
|
||||
|
||||
el.wrapper.addEvent('mouseenter', function(e) {
|
||||
el.wrapper.addEvent('mousemove', el.mouseCrap);
|
||||
});
|
||||
|
||||
el.wrapper.addEvent('mouseleave', function(e) {
|
||||
el.removeEvent('mousemove');
|
||||
|
||||
el.hover.setStyle('width', 0);
|
||||
el.hover.setStyle('display', 'none');
|
||||
el.selected.setStyle('display', 'block');
|
||||
|
||||
el.widthFx.start(el.currentFill);
|
||||
});
|
||||
|
||||
el.wrapper.addEvent('click', function(e) {
|
||||
el.currentFill = el.newFill;
|
||||
el.wrapper.removeEvents();
|
||||
el.textEl.oldTxt = el.textEl.get('text');
|
||||
el.textEl.set('html', ' ');
|
||||
el.textEl.addClass('loading');
|
||||
|
||||
// falls aus LightBox, entsprechendes ursprüngliches Rating aktualisieren
|
||||
if (typeof($('.mbrateItRating')) != 'undefined' && el.id.indexOf('mb') == 0) {
|
||||
var mbid = el.id;
|
||||
mbid = mbid.replace('mb', '');
|
||||
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == mbid) {
|
||||
arrRatings[ri].rated = true;
|
||||
arrRatings[ri].width = el.hover.getStyle('width');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof($(mbid)) != 'undefined') {
|
||||
var origWrapper = $(mbid).getElement('.wrapper');
|
||||
origWrapper.removeEvents();
|
||||
origWrapper.getElement('.rateItRating-selected').setStyle('display', 'none');
|
||||
origWrapper.getElement('.rateItRating-hover').setStyle('width', el.hover.getStyle('width'));
|
||||
origWrapper.getElement('.rateItRating-hover').setStyle('display', 'block');
|
||||
}
|
||||
} else {
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == el.id) {
|
||||
arrRatings[ri].rated = true;
|
||||
arrRatings[ri].width = el.hover.getStyle('width');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var votePercent = this.getVotePercent(el.newFill);
|
||||
if (this.options.url != null) {
|
||||
new Request({
|
||||
url:this.options.url,
|
||||
onComplete:el.updateText
|
||||
})
|
||||
.post({vote:votePercent,id:el.ratableId,type:el.ratableType});
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
el.updateText = function(text) {
|
||||
error = text.split('ERROR:')[1];
|
||||
el.textEl.removeClass('loading');
|
||||
if (error) { el.showError(error); return false; }
|
||||
el.textEl.set('text', text);
|
||||
|
||||
// falls aus LightBox, entsprechendes ursprüngliches Rating aktualisieren
|
||||
if (typeof($('.mbrateItRating')) != 'undefined' && el.id.indexOf('mb') == 0) {
|
||||
var mbid = el.getAttribute('id');
|
||||
mbid = mbid.replace('mb', '');
|
||||
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == mbid) {
|
||||
arrRatings[ri].description = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof($(mbid)) != 'undefined') {
|
||||
$(mbid).getElement('.ratingText').set('text', text);
|
||||
}
|
||||
} else {
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == el.id) {
|
||||
arrRatings[ri].description = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
el.showError = function(error) {
|
||||
el.textEl.addClass('ratingError');
|
||||
el.textEl.set('text', error);
|
||||
(function() {
|
||||
el.textEl.set('text', el.textEl.oldTxt);
|
||||
el.textEl.removeClass('ratingError');
|
||||
}).delay(2000);
|
||||
};
|
||||
} else {
|
||||
//Replaces all the fancy with a text description of the votes for IE6.
|
||||
//If you want IE6 users to have something fancier to look at, add it here.
|
||||
el.getElement('.ratingText').inject(el, 'before');
|
||||
el.remove();
|
||||
}
|
||||
},
|
||||
|
||||
fillVote: function(percent, el) {
|
||||
el.newFill = this.getFillPercent(percent);
|
||||
if (this.getVotePercent(el.newFill) > 100) { el.newFill = this.getFillPercent(100); }
|
||||
el.selected.setStyle('width', el.newFill);
|
||||
},
|
||||
|
||||
getStarPercent: function(id) {
|
||||
/* Format = anyStringHere-<id>-<float(currentStars)>_(scale);
|
||||
* Example: RateItRatings-5-3_5 //Primary key id = 5, 3/5 stars. */
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
if (stars != null) {
|
||||
var score = stars[3].toFloat();
|
||||
var scale = stars[4].toFloat();
|
||||
var percent = (score / scale) * 100;
|
||||
return percent;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
// Ermittelt die Breite des rateItRating-selected divs
|
||||
getFillPercent: function (starPercent) {
|
||||
return (starPercent / 100) * (this.options.starwidth * this.options.max);
|
||||
},
|
||||
|
||||
// Aus der Breite des rateItRating-selected divs die Prozentzahl ermitteln
|
||||
getVotePercent: function(actVote) {
|
||||
var starsWidth = this.options.starwidth * this.options.max;
|
||||
var percent = (actVote / starsWidth * 100).round(2);
|
||||
return percent;
|
||||
},
|
||||
|
||||
getRatableId: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[1] : '';
|
||||
},
|
||||
|
||||
getRatableType: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[2] : '';
|
||||
},
|
||||
|
||||
getRatableMaxValue: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[4].toInt() : 0;
|
||||
},
|
||||
|
||||
setBackgroundPosition: function(el, pos) {
|
||||
el.setStyle('background-position', '0% ' + pos + 'px');
|
||||
},
|
||||
|
||||
getBackgroundImagePath: function(el) {
|
||||
return el.getStyle('background-image');
|
||||
},
|
||||
|
||||
getBackgroundImage: function(el) {
|
||||
var reg_imgFile = /url\s*\(["']?(.*)["']?\)/i;
|
||||
var dummy = document.createElement('img');
|
||||
var string = this.getBackgroundImagePath(el);
|
||||
string = string.match(reg_imgFile)[1];
|
||||
string = string.replace('\"', '');
|
||||
dummy.src = string;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
window.addEvent('domready', function(e) {
|
||||
RateItRating = new RateItRatings({url:'SimpleAjax.php'});
|
||||
});
|
||||
} else if (window.jQuery) {
|
||||
// the rateit plugin as an Object
|
||||
(function() {
|
||||
|
||||
RateItRatings = {
|
||||
|
||||
options: {
|
||||
step: 0.1, /* Schrittweite */
|
||||
readonly: false, /* Bewertungen zulassen */
|
||||
resetable: false /* Nicht zurücksetzbar */
|
||||
},
|
||||
|
||||
// this should be called first before doing anything else
|
||||
initialize: function(options) {
|
||||
if (typeof options == 'object' && typeof options['url'] != 'undefined')
|
||||
this.options.url = options['url'];
|
||||
|
||||
var self = this;
|
||||
jQuery('.rateItRating').each(function(i, element) {
|
||||
self.initMe(element);
|
||||
});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
initMe: function(element) {
|
||||
var self = this;
|
||||
|
||||
//Does this if the browser is NOT IE6. IE6 users don't deserve fancy ratings. >:(
|
||||
if (!Browser.Engine.trident4) {
|
||||
var el = jQuery(element);
|
||||
el.data('id', el.attr('id'));
|
||||
el.data('rateable', el.attr('rel') == 'not-rateable' ? false : true);
|
||||
el.data('wrapper', el.find('.wrapper'));
|
||||
el.data('textEl', el.find('.ratingText'));
|
||||
// el.data('offset', getPosition(element).x);
|
||||
el.data('selected', el.find('.rateItRating-selected'));
|
||||
el.data('hover', el.find('.rateItRating-hover'));
|
||||
|
||||
var backgroundImage = self.getBackgroundImage(el.data('wrapper'));
|
||||
self.options.starwidth = backgroundImage.width;
|
||||
self.options.starheight = backgroundImage.height / 3; // da immer drei Sterne "übereinander" gebraucht werden
|
||||
if (self.options.starwidth === undefined || self.options.starwidth < 16) {
|
||||
self.options.starwidth = 16;
|
||||
}
|
||||
if (self.options.starheight === undefined || self.options.starheight < 16) {
|
||||
self.options.starheight = 16;
|
||||
}
|
||||
|
||||
self.setBackgroundPosition(el.data('selected'), -1 * self.options.starheight);
|
||||
self.setBackgroundPosition(el.data('hover'), -1 * 2 * self.options.starheight);
|
||||
|
||||
el.data('starPercent', self.getStarPercent(el.data('id')));
|
||||
el.data('ratableId', self.getRatableId(el.data('id')));
|
||||
el.data('ratableType', self.getRatableType(el.data('id')));
|
||||
|
||||
// Maximalwert (=Anzahl Sterne) ermitteln
|
||||
self.options.max = self.getRatableMaxValue(el.data('id'));
|
||||
|
||||
// Höhe für selected und hover einstellen
|
||||
el.data('selected').css('height', self.options.starheight);
|
||||
el.data('hover').css('height', self.options.starheight);
|
||||
|
||||
// Wrapper-Größe so anpassen, dass alle Sterne angezeigt werden
|
||||
el.data('wrapper').css('width', self.options.starwidth * self.options.max);
|
||||
el.data('wrapper').css('height', self.options.starheight);
|
||||
|
||||
// Breite des rateItRating-selected divs setzen
|
||||
self.fillVote(el.data('starPercent'), el);
|
||||
|
||||
// Breite für rateItRating-selected div ermitteln
|
||||
el.data('currentFill', self.getFillPercent(el.data('starPercent')));
|
||||
|
||||
if (el.data('rateable')) {
|
||||
el.data('wrapper').mouseenter(function(event) {
|
||||
el.data('selected').hide(500, "easeInOutQuad");
|
||||
el.data('hover').show();
|
||||
el.data('wrapper').mousemove({'el': el, 'self': self}, self.mouseCrap);
|
||||
});
|
||||
|
||||
el.data('wrapper').mouseleave(function(event) {
|
||||
el.data('wrapper').unbind('mousemove');
|
||||
el.data('hover').hide();
|
||||
el.data('selected').show();
|
||||
el.data('selected').animate({width: el.data('currentFill')}, 500);
|
||||
});
|
||||
|
||||
el.data('wrapper').click(function(event) {
|
||||
el.data('currentFill', el.data('newFill'));
|
||||
el.data('wrapper').unbind();
|
||||
el.data('oldTxt', el.data('textEl').text());
|
||||
el.data('textEl').html(' ');
|
||||
el.data('textEl').addClass('loading');
|
||||
|
||||
// falls aus LightBox, entsprechendes ursprüngliches Rating aktualisieren
|
||||
if (typeof(jQuery('.mbrateItRating')) != 'undefined' && el.data('id').indexOf('mb') == 0) {
|
||||
var mbid = el.data('id');
|
||||
mbid = mbid.replace('mb', '');
|
||||
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == mbid) {
|
||||
arrRatings[ri].rated = true;
|
||||
arrRatings[ri].width = el.data('hover').css('width');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(jQuery('#' + jEscape(mbid))) != 'undefined') {
|
||||
var origWrapper = jQuery('#' + jEscape(mbid)).find('.wrapper');
|
||||
origWrapper.unbind();
|
||||
origWrapper.find('.rateItRating-selected').css('display', 'none');
|
||||
origWrapper.find('.rateItRating-hover').css('width', el.data('hover').css('width'));
|
||||
origWrapper.find('.rateItRating-hover').css('display', 'block');
|
||||
}
|
||||
} else {
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == el.data('id')) {
|
||||
arrRatings[ri].rated = true;
|
||||
arrRatings[ri].width = el.data('hover').css('width');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var votePercent = self.getVotePercent(el.data('newFill'));
|
||||
if (self.options.url != null) {
|
||||
jQuery.ajax({
|
||||
url: self.options.url,
|
||||
type: 'post',
|
||||
data: {'vote': votePercent, 'id': el.data('ratableId'), 'type': el.data('ratableType')}
|
||||
}).done(function(data) {
|
||||
el.data('updateText')(el, data);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
el.data('updateText', self.updateText);
|
||||
} else {
|
||||
alert("Ich bin ein IE6");
|
||||
}
|
||||
},
|
||||
|
||||
fillVote: function(percent, el) {
|
||||
el.data('newFill', this.getFillPercent(percent));
|
||||
if (this.getVotePercent(el.data('newFill')) > 100) { el.data('newFill', this.getFillPercent(100)); }
|
||||
el.data('selected').css('width', el.data('newFill'));
|
||||
},
|
||||
|
||||
mouseCrap: function(event) {
|
||||
var el = event.data['el'];
|
||||
var self = event.data['self'];
|
||||
|
||||
var fill = event.originalEvent.layerX;
|
||||
if (!fill) {
|
||||
fill = event.originalEvent.offsetX;
|
||||
}
|
||||
var fillPercent = self.getVotePercent(fill);
|
||||
var nextStep = Math.ceil((fillPercent / 100) * self.options.max);
|
||||
|
||||
var w = nextStep * self.options.starwidth;
|
||||
if (parseInt(el.data('hover').css('width')) != w) {
|
||||
el.data('selected').css('display', 'none');
|
||||
el.data('hover').css('width', Math.min(w, self.options.starwidth * self.options.max));
|
||||
el.data('hover').css('display', 'block');
|
||||
}
|
||||
|
||||
var newFill = nextStep / self.options.max * 100;
|
||||
self.fillVote(newFill, el);
|
||||
},
|
||||
|
||||
getStarPercent: function(id) {
|
||||
/* Format = anyStringHere-<id>-<float(currentStars)>_(scale);
|
||||
* Example: RateItRatings-5-3_5 //Primary key id = 5, 3/5 stars. */
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
if (stars != null) {
|
||||
var score = parseFloat(stars[3]);
|
||||
var scale = parseFloat(stars[4]);
|
||||
var percent = (score / scale) * 100;
|
||||
return percent;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
},
|
||||
|
||||
// Ermittelt die Breite des rateItRating-selected divs
|
||||
getFillPercent: function (starPercent) {
|
||||
return (starPercent / 100) * (this.options.starwidth * this.options.max);
|
||||
},
|
||||
|
||||
// Aus der Breite des rateItRating-selected divs die Prozentzahl ermitteln
|
||||
getVotePercent: function(actVote) {
|
||||
var starsWidth = this.options.starwidth * this.options.max;
|
||||
var percent = (actVote / starsWidth * 100).toFixed(2);
|
||||
return percent;
|
||||
},
|
||||
|
||||
getRatableId: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[1] : '';
|
||||
},
|
||||
|
||||
getRatableType: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? stars[2] : '';
|
||||
},
|
||||
|
||||
getRatableMaxValue: function(id) {
|
||||
var stars = id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic)-(\d*\.?\d+)_(\d*\.?\d+)$/);
|
||||
return stars != null ? parseInt(stars[4]) : 0;
|
||||
},
|
||||
|
||||
setBackgroundPosition: function(el, pos) {
|
||||
el.css('background-position', '0% ' + pos + 'px');
|
||||
},
|
||||
|
||||
getBackgroundImagePath: function(el) {
|
||||
return el.css("background-image");
|
||||
},
|
||||
|
||||
getBackgroundImage: function(el) {
|
||||
var reg_imgFile = /url\s*\(["']?(.*)["']?\)/i;
|
||||
var dummy = document.createElement('img');
|
||||
var string = this.getBackgroundImagePath(el);
|
||||
string = string.match(reg_imgFile)[1];
|
||||
string = string.replace('\"', '');
|
||||
dummy.src = string;
|
||||
return dummy;
|
||||
},
|
||||
|
||||
updateText: function(el, text) {
|
||||
error = text.split('ERROR:')[1];
|
||||
el.data('textEl').removeClass('loading');
|
||||
if (error) { this.RateItRating.showError(el, error); return false; }
|
||||
el.data('textEl').text(text);
|
||||
|
||||
// falls aus LightBox, entsprechendes ursprüngliches Rating aktualisieren
|
||||
if (typeof(jQuery('.mbrateItRating')) != 'undefined' && el.data('id').indexOf('mb') == 0) {
|
||||
var mbid = el.attr('id');
|
||||
mbid = mbid.replace('mb', '');
|
||||
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == mbid) {
|
||||
arrRatings[ri].description = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof(jQuery('#' + jEscape(mbid))) != 'undefined') {
|
||||
jQuery('#' + jEscape(mbid)).find('.ratingText').text(text);
|
||||
}
|
||||
} else {
|
||||
if (typeof(arrRatings) == 'object') {
|
||||
for (var ri = 0; ri < arrRatings.length; ri++) {
|
||||
if (arrRatings[ri].rateItID == el.data('id')) {
|
||||
arrRatings[ri].description = text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
showError: function(el, error) {
|
||||
el.data('textEl').addClass('ratingError');
|
||||
//oldTxt = el.data('textEl').text();
|
||||
el.data('textEl').text(error);
|
||||
setTimeout(function() {
|
||||
el.data('textEl').text(el.data('oldTxt'));
|
||||
el.data('textEl').removeClass('ratingError');
|
||||
}, 2000);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
jQuery(document).ready(function() {
|
||||
jQuery.ajax({
|
||||
type: "GET",
|
||||
url: "system/modules/rateit/public/js/jquery-ui-effects.custom.min.js",
|
||||
dataType: "script",
|
||||
async: false,
|
||||
cache: true
|
||||
});
|
||||
jQuery.ajax({
|
||||
type: "GET",
|
||||
url: "system/modules/rateit/public/js/helper.js",
|
||||
dataType: "script",
|
||||
async: false,
|
||||
cache: true
|
||||
});
|
||||
RateItRating = Object.create(RateItRatings).initialize({url:'SimpleAjax.php'});
|
||||
});
|
||||
|
||||
var jEscape = function(jquery) {
|
||||
jquery = jquery.replace(new RegExp("\\$", "g"), "\\$");
|
||||
jquery = jquery.replace(new RegExp("\~", "g"), "\\~");
|
||||
jquery = jquery.replace(new RegExp("\\[", "g"), "\\[");
|
||||
jquery = jquery.replace(new RegExp("\\]", "g"), "\\]");
|
||||
jquery = jquery.replace(new RegExp("\\|", "g"), "\\|");
|
||||
jquery = jquery.replace(new RegExp("\\.", "g"), "\\.");
|
||||
jquery = jquery.replace(new RegExp("#", "g"), "\\#");
|
||||
return jquery;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
onReadyRateIt(function() {
|
||||
doRateIt();
|
||||
});
|
1
public/js/rateit.js
Normal file
164
public/php/rateit.php
Normal file
@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Contao Open Source CMS
|
||||
* Copyright (C) 2005-2011 Leo Feyer
|
||||
*
|
||||
* Formerly known as TYPOlight Open Source CMS.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation, either
|
||||
* version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this program. If not, please visit the Free
|
||||
* Software Foundation website at <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* PHP version 5
|
||||
* @copyright cgo IT, 2013
|
||||
* @author Carsten Götzinger (info@cgo-it.de)
|
||||
* @package rateit
|
||||
* @license GNU/LGPL
|
||||
* @filesource
|
||||
*/
|
||||
|
||||
namespace cgoIT\rateit;
|
||||
|
||||
define(RETURN_AJAX_HEADER, 'Content-Type: text/html');
|
||||
|
||||
class RateIt extends \Frontend {
|
||||
|
||||
var $allowDuplicates = false;
|
||||
|
||||
/**
|
||||
* Initialize the controller
|
||||
*/
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
|
||||
$this->loadLanguageFile('default');
|
||||
$this->allowDuplicates = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings'];
|
||||
$this->allowDuplicatesForMembers = $GLOBALS['TL_CONFIG']['rating_allow_duplicate_ratings_for_members'];
|
||||
}
|
||||
|
||||
/**
|
||||
* doVote
|
||||
*
|
||||
* This is the function in charge of handling a vote and saving it to the
|
||||
* database.
|
||||
*
|
||||
* NOTE: This method is meant to be called as part of an AJAX request. As
|
||||
* such, it unitlizes the die() function to display its errors. THIS
|
||||
* WOULD BE A VERY BAD FUNCTION TO CALL FROM WITHIN ANOTHER PAGE.
|
||||
*
|
||||
* @param integer id - The id of key to register a rating for.
|
||||
* @param integer percent - The rating in percentages.
|
||||
*/
|
||||
function doVote() {
|
||||
$ip = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
$rkey = $_POST['id'];
|
||||
$percent = $_POST['vote'];
|
||||
$type = $_POST['type'];
|
||||
|
||||
//Make sure that the ratable ID is a number and not something crazy.
|
||||
if (strstr($rkey, '|')) {
|
||||
$arrRkey = explode('|', $rkey);
|
||||
foreach ($arrRkey as $key) {
|
||||
if (!is_numeric($key)) {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating'];
|
||||
exit;
|
||||
}
|
||||
$id = $rkey;
|
||||
}
|
||||
} else {
|
||||
if (is_numeric($rkey)) {
|
||||
$id = $rkey;
|
||||
} else {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating'];
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
//Make sure the percent is a number and under 100.
|
||||
if (is_numeric($percent) && $percent < 101) {
|
||||
$rating = $percent;
|
||||
} else {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_rating'];
|
||||
exit;
|
||||
}
|
||||
|
||||
//Make sure that the ratable type is 'page' or 'ce' or 'module'
|
||||
if (!($type === 'page' || $type === 'article' || $type === 'ce' || $type === 'module' || $type === 'news' || $type === 'faq' || $type === 'galpic')) {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['invalid_type'];
|
||||
exit;
|
||||
}
|
||||
|
||||
$strHash = sha1(session_id() . (!$GLOBALS['TL_CONFIG']['disableIpCheck'] ? \Environment::get('ip') : '') . 'FE_USER_AUTH');
|
||||
|
||||
// FrontendUser auslesen
|
||||
if (FE_USER_LOGGED_IN) {
|
||||
$objUser = $this->Database->prepare("SELECT pid FROM tl_session WHERE hash=?")
|
||||
->limit(1)
|
||||
->execute($strHash);
|
||||
|
||||
if ($objUser->numRows) {
|
||||
$userId = $objUser->pid;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ratableKeyId = $this->Database->prepare('SELECT id FROM tl_rateit_items WHERE rkey=? and typ=?')
|
||||
->execute($id, $type)
|
||||
->fetchAssoc();
|
||||
|
||||
$canVote = false;
|
||||
if (isset($userId)) {
|
||||
$countUser = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and memberid=?')
|
||||
->execute($ratableKeyId['id'], $userId)
|
||||
->count();
|
||||
}
|
||||
$countIp = $this->Database->prepare('SELECT * FROM tl_rateit_ratings WHERE pid=? and ip_address=?')
|
||||
->execute($ratableKeyId['id'], $ip)
|
||||
->count();
|
||||
|
||||
// Die with an error if the insert fails (duplicate IP or duplicate member id for a vote).
|
||||
if (((!$this->allowDuplicates && $countIp == 0) || $this->allowDuplicates) ||
|
||||
((!$this->allowDuplicatesForMembers && (isset($countUser) ? $countUser == 0 : false)) || ($this->allowDuplicatesForMembers && isset($userId)))) {
|
||||
// Insert the data.
|
||||
$arrSet = array('pid' => $ratableKeyId['id'],
|
||||
'tstamp' => time(),
|
||||
'ip_address' => $ip,
|
||||
'memberid' => isset($userId) ? $userId : null,
|
||||
'rating' => $rating,
|
||||
'createdat'=> time()
|
||||
);
|
||||
$this->Database->prepare('INSERT INTO tl_rateit_ratings %s')
|
||||
->set($arrSet)
|
||||
->execute();
|
||||
} else {
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $GLOBALS['TL_LANG']['rateit']['error']['duplicate_vote'];
|
||||
exit;
|
||||
}
|
||||
|
||||
$this->import('rateit\\RateItFrontend', 'RateItFrontend');
|
||||
$rating = $this->RateItFrontend->loadRating($id, $type);
|
||||
|
||||
header(RETURN_AJAX_HEADER);
|
||||
echo $this->RateItFrontend->getStarMessage($rating);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|