Abhängigkeit zu SimpleAjax entfernt
Kompatibilität zu PHP 7 hergestellt
This commit is contained in:
parent
11e3e2817c
commit
8ca4aad975
@ -14,19 +14,18 @@
|
|||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"email": "info@cgo-it.de",
|
"email": "info@cgo-it.de",
|
||||||
"issues": "https://bitbucket.org/cgo-it/contao-rate-it/issues?status=new&status=open",
|
"issues": "https://git.cgo-it.de/contao/rate-it/issues",
|
||||||
"forum": "https://community.contao.org/de/showthread.php?38471-Rate-It",
|
"forum": "https://community.contao.org/de/showthread.php?38471-Rate-It",
|
||||||
"source": "https://bitbucket.org/cgo-it/contao-rate-it/src"
|
"source": "https://git.cgo-it.de/contao/rate-it/tree/master"
|
||||||
},
|
},
|
||||||
"require":{
|
"require":{
|
||||||
"php":">=5.3",
|
"php":">=5.3",
|
||||||
"contao/core":">=3.0",
|
"contao/core":">=3.0",
|
||||||
"contao-community-alliance/composer-plugin": "~2.0",
|
"contao-community-alliance/composer-plugin": "~2.0",
|
||||||
"leounglaub/contao-simple-ajax":"3.2.x-dev",
|
|
||||||
"cgo-it/xls_export":"3.0.0"
|
"cgo-it/xls_export":"3.0.0"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"cgo-it/rate-it": "<3.4.3"
|
"cgo-it/rate-it": "<3.5.4"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"contao/core": "2.11.*"
|
"contao/core": "2.11.*"
|
||||||
|
@ -34,7 +34,7 @@ use cgoIT\rateit\RateItBackend;
|
|||||||
* Hooks
|
* Hooks
|
||||||
*/
|
*/
|
||||||
$GLOBALS['TL_HOOKS']['generatePage'][] = array('rateit\\RateItPage', 'generatePage');
|
$GLOBALS['TL_HOOKS']['generatePage'][] = array('rateit\\RateItPage', 'generatePage');
|
||||||
$GLOBALS['TL_HOOKS']['simpleAjax'][] = array('rateit\\RateIt', 'doVote');
|
$GLOBALS['TL_HOOKS']['rateitAjax'][] = array('rateit\\RateIt', 'doVote');
|
||||||
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle');
|
$GLOBALS['TL_HOOKS']['parseArticles'][] = array('rateit\\RateItNews', 'parseArticle');
|
||||||
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt');
|
$GLOBALS['TL_HOOKS']['getContentElement'][] = array('rateit\\RateItFaq', 'getContentElementRateIt');
|
||||||
$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('rateit\\RateItArticle', 'parseTemplateRateIt');
|
$GLOBALS['TL_HOOKS']['parseTemplate'][] = array('rateit\\RateItArticle', 'parseTemplateRateIt');
|
||||||
|
@ -271,7 +271,7 @@ function doRateIt() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEvent('domready', function(e) {
|
window.addEvent('domready', function(e) {
|
||||||
RateItRating = new RateItRatings({url:'SimpleAjax.php?do=rateit'});
|
RateItRating = new RateItRatings({url:'system/modules/rateit/public/php/rateit-ajax.php?do=rateit'});
|
||||||
});
|
});
|
||||||
} else if (window.jQuery) {
|
} else if (window.jQuery) {
|
||||||
// the rateit plugin as an Object
|
// the rateit plugin as an Object
|
||||||
@ -579,7 +579,7 @@ function doRateIt() {
|
|||||||
async: false,
|
async: false,
|
||||||
cache: true
|
cache: true
|
||||||
});
|
});
|
||||||
RateItRating = Object.create(RateItRatings).initialize({url:'SimpleAjax.php?do=rateit'});
|
RateItRating = Object.create(RateItRatings).initialize({url:'system/modules/rateit/public/php/rateit-ajax.php?do=rateit'});
|
||||||
});
|
});
|
||||||
|
|
||||||
var jEscape = function(jquery) {
|
var jEscape = function(jquery) {
|
||||||
|
@ -9,7 +9,7 @@ var votePercent=this.getVotePercent(el.newFill);if(this.options.url!=null){new R
|
|||||||
el.textEl.set('text',text);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;}}}
|
el.textEl.set('text',text);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;}}}}};}
|
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{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.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{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){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\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;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},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|news4ward)-(\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|news4ward)-(\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|news4ward)-(\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?do=rateit'});});}else if(window.jQuery){(function(){RateItRatings={options:{step:0.1,readonly:false,resetable:false},initialize:function(options){if(typeof options=='object'&&typeof options['url']!='undefined')
|
el.selected.setStyle('width',el.newFill);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\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;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},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|news4ward)-(\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|news4ward)-(\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|news4ward)-(\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:'system/modules/rateit/public/php/rateit-ajax.php?do=rateit'});});}else if(window.jQuery){(function(){RateItRatings={options:{step:0.1,readonly:false,resetable:false},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;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('selected',el.find('.rateItRating-selected'));el.data('hover',el.find('.rateItRating-hover'));jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize){self.options.starwidth=backgroundImageSize[0];self.options.starheight=backgroundImageSize[1]/3;});if(self.options.starwidth===undefined||self.options.starwidth<16){self.options.starwidth=16;}
|
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;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('selected',el.find('.rateItRating-selected'));el.data('hover',el.find('.rateItRating-hover'));jQuery.when(self.getBackgroundImage(el.data('wrapper'))).done(function(backgroundImageSize){self.options.starwidth=backgroundImageSize[0];self.options.starheight=backgroundImageSize[1]/3;});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;}
|
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')));self.options.max=self.getRatableMaxValue(el.data('id'));el.data('selected').css('height',self.options.starheight);el.data('hover').css('height',self.options.starheight);el.data('wrapper').css('width',self.options.starwidth*self.options.max);el.data('wrapper').css('height',self.options.starheight);self.fillVote(el.data('starPercent'),el);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');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;}}}
|
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')));self.options.max=self.getRatableMaxValue(el.data('id'));el.data('selected').css('height',self.options.starheight);el.data('hover').css('height',self.options.starheight);el.data('wrapper').css('width',self.options.starwidth*self.options.max);el.data('wrapper').css('height',self.options.starheight);self.fillVote(el.data('starPercent'),el);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');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;}}}
|
||||||
@ -20,5 +20,5 @@ el.data('selected').css('width',el.data('newFill'));},mouseCrap:function(event){
|
|||||||
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 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){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\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;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},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|news4ward)-(\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|news4ward)-(\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|news4ward)-(\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 dfd=jQuery.Deferred();var backgroundImageSize=new Array();var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');jQuery('<img/>').attr('src',string).load(function(){backgroundImageSize.push(this.width);backgroundImageSize.push(this.height);dfd.resolve(backgroundImageSize);});return dfd.promise();},updateText:function(el,text){error=text.split('ERROR:')[1];el.data('textEl').removeClass('loading');if(error){this.RateItRating.showError(el,error);return false;}
|
var newFill=nextStep/self.options.max*100;self.fillVote(newFill,el);},getStarPercent:function(id){var stars=id.match(/(\d*\|?\d*)-(page|article|ce|module|news|faq|galpic|news4ward)-(\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;}},getFillPercent:function(starPercent){return(starPercent/100)*(this.options.starwidth*this.options.max);},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|news4ward)-(\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|news4ward)-(\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|news4ward)-(\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 dfd=jQuery.Deferred();var backgroundImageSize=new Array();var reg_imgFile=/url\s*\(["']?(.*)["']?\)/i;var string=this.getBackgroundImagePath(el);string=string.match(reg_imgFile)[1];string=string.replace('\"','');jQuery('<img/>').attr('src',string).load(function(){backgroundImageSize.push(this.width);backgroundImageSize.push(this.height);dfd.resolve(backgroundImageSize);});return dfd.promise();},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);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;}}}
|
el.data('textEl').text(text);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');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.min.js",dataType:"script",async:false,cache:true});RateItRating=Object.create(RateItRatings).initialize({url:'SimpleAjax.php?do=rateit'});});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;};}}
|
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');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.min.js",dataType:"script",async:false,cache:true});RateItRating=Object.create(RateItRatings).initialize({url:'system/modules/rateit/public/php/rateit-ajax.php?do=rateit'});});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();});
|
onReadyRateIt(function(){doRateIt();});
|
139
public/php/rateit-ajax.php
Normal file
139
public/php/rateit-ajax.php
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
<?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 Leo Unglaub 2012
|
||||||
|
* @author Leo Unglaub <leo@leo-unglaub.net>
|
||||||
|
* @package simple_ajax
|
||||||
|
* @license LGPL
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// simple trick for Contao < 2.10
|
||||||
|
$arrPost = $_POST;
|
||||||
|
unset($_POST);
|
||||||
|
|
||||||
|
|
||||||
|
// inizialize the contao framework
|
||||||
|
define('TL_MODE', 'FE');
|
||||||
|
require('../../../../initialize.php');
|
||||||
|
|
||||||
|
|
||||||
|
// write the post data back into the array
|
||||||
|
$_POST = $arrPost;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class RateitAjax
|
||||||
|
* Contain methods to catch ajax requests and send responses back to the client.
|
||||||
|
*
|
||||||
|
* Description
|
||||||
|
* ```````````
|
||||||
|
*
|
||||||
|
* The usage of the RateitAjax extensions is very easy. The extension provides
|
||||||
|
* the hook $GLOBALS['TL_HOOKS']['rateitAjax'] for extension developers. You
|
||||||
|
* simply have to register your class/method and the extension will call
|
||||||
|
* your class if there is an incomming ajax request.
|
||||||
|
*
|
||||||
|
* You simply have to deside if it's an ajax request for your module and return
|
||||||
|
* the data you want.
|
||||||
|
*
|
||||||
|
* There are a few thinks you should know about the extension:
|
||||||
|
* * YOU have the full controll over the response. That also means
|
||||||
|
* that you have to set the correct header.
|
||||||
|
* * YOU have to terminate the request after you have send the response.
|
||||||
|
* * If the ajax request is not for your method you simply have nothing to
|
||||||
|
* * return.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Usage
|
||||||
|
* `````
|
||||||
|
* // config.php
|
||||||
|
* $GLOBALS['TL_HOOKS']['rateitAjax'][] = array('MyClass', 'myMethod');
|
||||||
|
*
|
||||||
|
* // MyClass.php
|
||||||
|
* class MyClass extends System
|
||||||
|
* {
|
||||||
|
* public function myMethod()
|
||||||
|
* {
|
||||||
|
* if ($this->Input->get('acid') == 'myrequest')
|
||||||
|
* {
|
||||||
|
* $arrReturn = array('foo', 'bar', 'foobar');
|
||||||
|
*
|
||||||
|
* header('Content-Type: application/json');
|
||||||
|
* echo json_encode($arrReturn);
|
||||||
|
* exit;
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
class RateitAjax extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Call the parent constructor.
|
||||||
|
*
|
||||||
|
* !!! DON'T REMOVE THIS !!!
|
||||||
|
*
|
||||||
|
* If you remove this you get the following error message:
|
||||||
|
* Fatal error: Call to protected System::__construct() from invalid
|
||||||
|
* context
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ajax request and call all hooks
|
||||||
|
*
|
||||||
|
* @param void
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function run()
|
||||||
|
{
|
||||||
|
// check if a hook is registered
|
||||||
|
if (is_array($GLOBALS['TL_HOOKS']['rateitAjax']) && count($GLOBALS['TL_HOOKS']['rateitAjax']) > 0)
|
||||||
|
{
|
||||||
|
// execute every registered callback
|
||||||
|
foreach ($GLOBALS['TL_HOOKS']['rateitAjax'] as $callback)
|
||||||
|
{
|
||||||
|
$this->import($callback[0]);
|
||||||
|
$this->{$callback[0]}->{$callback[1]}();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there is no other output, we generate a 412 error response
|
||||||
|
header('HTTP/1.1 412 Precondition Failed');
|
||||||
|
die('Rateit Ajax: Invalid AJAX call.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// create a rateit-ajax instance and run it
|
||||||
|
$objRateitAjax = new RateitAjax();
|
||||||
|
$objRateitAjax->run();
|
||||||
|
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user