Compare commits
	
		
			3 Commits
		
	
	
		
			3.5.3
			...
			dev-contao
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| fe9436a16f | |||
| fb9540fe2e | |||
| 8ca4aad975 | 
@@ -35,7 +35,7 @@ namespace cgoIT\rateit;
 | 
			
		||||
 */
 | 
			
		||||
class RateItTopRatingsModule extends RateItFrontend
 | 
			
		||||
{
 | 
			
		||||
	//protected $intStars = 5;
 | 
			
		||||
	private static $arrUrlCache = array();
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Initialize the controller
 | 
			
		||||
@@ -123,6 +123,8 @@ class RateItTopRatingsModule extends RateItFrontend
 | 
			
		||||
			
 | 
			
		||||
			$return->rateit_class = 'rateItRating';
 | 
			
		||||
			
 | 
			
		||||
			$return->url = $this->getUrl($result);
 | 
			
		||||
			
 | 
			
		||||
			// Beschriftung ermitteln
 | 
			
		||||
			$rating = array();
 | 
			
		||||
			$rating['totalRatings'] = $result['most'];
 | 
			
		||||
@@ -137,6 +139,103 @@ class RateItTopRatingsModule extends RateItFrontend
 | 
			
		||||
		
 | 
			
		||||
		$this->Template->arrRatings = $objReturn;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private function getUrl($rating) {
 | 
			
		||||
		if ($rating['typ'] === 'page') {
 | 
			
		||||
			return \PageModel::findById($rating['rkey'])->getAbsoluteUrl();
 | 
			
		||||
		}
 | 
			
		||||
		if ($rating['typ'] === 'article') {
 | 
			
		||||
			$objArticle = \ArticleModel::findPublishedById($rating['rkey']);
 | 
			
		||||
			if (!is_null($objArticle)) {
 | 
			
		||||
				return \PageModel::findById($objArticle->pid)->getAbsoluteUrl().'#'.$objArticle->alias;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if ($rating['typ'] === 'news') {
 | 
			
		||||
			$objNews = \NewsModel::findById($rating['rkey']);
 | 
			
		||||
			$objArticle = \NewsModel::findPublishedByPid($objNews->pid);
 | 
			
		||||
			
 | 
			
		||||
			// Internal link
 | 
			
		||||
			if ($objArticle->source != 'external') {
 | 
			
		||||
				return $this->generateNewsUrl($objNews);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// Encode e-mail addresses
 | 
			
		||||
			if (substr($objArticle->url, 0, 7) == 'mailto:') {
 | 
			
		||||
				$strArticleUrl = \StringUtil::encodeEmail($objArticle->url);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// Ampersand URIs
 | 
			
		||||
			else {
 | 
			
		||||
				$strArticleUrl = ampersand($objArticle->url);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			/** @var \PageModel $objPage */
 | 
			
		||||
			global $objPage;
 | 
			
		||||
			
 | 
			
		||||
			// External link
 | 
			
		||||
			return $strArticleUrl;
 | 
			
		||||
		}
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function generateNewsUrl($objItem) {
 | 
			
		||||
		$strCacheKey = 'id_' . $objItem->id;
 | 
			
		||||
		
 | 
			
		||||
		// Load the URL from cache
 | 
			
		||||
		if (isset(self::$arrUrlCache[$strCacheKey])) {
 | 
			
		||||
			return self::$arrUrlCache[$strCacheKey];
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Initialize the cache
 | 
			
		||||
		self::$arrUrlCache[$strCacheKey] = null;
 | 
			
		||||
		
 | 
			
		||||
		switch ($objItem->source) {
 | 
			
		||||
			// Link to an external page
 | 
			
		||||
			case 'external' :
 | 
			
		||||
				if (substr($objItem->url, 0, 7) == 'mailto:') {
 | 
			
		||||
					self::$arrUrlCache[$strCacheKey] = \StringUtil::encodeEmail($objItem->url);
 | 
			
		||||
				} else {
 | 
			
		||||
					self::$arrUrlCache[$strCacheKey] = ampersand($objItem->url);
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			
 | 
			
		||||
			// Link to an internal page
 | 
			
		||||
			case 'internal' :
 | 
			
		||||
				if (($objTarget = $objItem->getRelated('jumpTo')) !== null) {
 | 
			
		||||
					/** @var \PageModel $objTarget */
 | 
			
		||||
					self::$arrUrlCache[$strCacheKey] = ampersand($objTarget->getFrontendUrl());
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			
 | 
			
		||||
			// Link to an article
 | 
			
		||||
			case 'article' :
 | 
			
		||||
				if (($objArticle = \ArticleModel::findByPk($objItem->articleId, array(
 | 
			
		||||
						'eager' => true
 | 
			
		||||
				))) !== null && ($objPid = $objArticle->getRelated('pid')) !== null) {
 | 
			
		||||
					/** @var \PageModel $objPid */
 | 
			
		||||
					self::$arrUrlCache[$strCacheKey] = ampersand($objPid->getFrontendUrl('/articles/' . ((! \Config::get('disableAlias') && $objArticle->alias != '') ? $objArticle->alias : $objArticle->id)));
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		// Link to the default page
 | 
			
		||||
		if (self::$arrUrlCache[$strCacheKey] === null) {
 | 
			
		||||
			$objPage = \PageModel::findWithDetails($objItem->getRelated('pid')->jumpTo);
 | 
			
		||||
			
 | 
			
		||||
			if ($objPage === null) {
 | 
			
		||||
				self::$arrUrlCache[$strCacheKey] = ampersand(\Environment::get('request'), true);
 | 
			
		||||
			} else {
 | 
			
		||||
				self::$arrUrlCache[$strCacheKey] = ampersand($objPage->getFrontendUrl(((\Config::get('useAutoItem') && ! \Config::get('disableAlias')) ? '/' : '/items/') . ((! \Config::get('disableAlias') && $objItem->alias != '') ? $objItem->alias : $objItem->id)));
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			// Add the current archive parameter (news archive)
 | 
			
		||||
			if ($blnAddArchive && \Input::get('month') != '') {
 | 
			
		||||
				self::$arrUrlCache[$strCacheKey] .= (\Config::get('disableAlias') ? '&' : '?') . 'month=' . \Input::get('month');
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return self::$arrUrlCache[$strCacheKey];
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -22,11 +22,10 @@
 | 
			
		||||
		"php":">=5.3",
 | 
			
		||||
		"contao/core":">=3.0",
 | 
			
		||||
		"contao-community-alliance/composer-plugin": "~2.0",
 | 
			
		||||
		"leounglaub/contao-simple-ajax":"3.2.x-dev",
 | 
			
		||||
		"cgo-it/xls_export":"3.0.0"
 | 
			
		||||
	},
 | 
			
		||||
	"replace": {
 | 
			
		||||
		"cgo-it/rate-it": "<3.4.3"
 | 
			
		||||
		"cgo-it/rate-it": "<3.5.4"
 | 
			
		||||
	},
 | 
			
		||||
    "conflict": {
 | 
			
		||||
			"contao/core": "2.11.*"
 | 
			
		||||
 
 | 
			
		||||
@@ -34,7 +34,7 @@ use cgoIT\rateit\RateItBackend;
 | 
			
		||||
 * Hooks
 | 
			
		||||
 */
 | 
			
		||||
$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']['getContentElement'][]      = array('rateit\\RateItFaq', 'getContentElementRateIt');
 | 
			
		||||
$GLOBALS['TL_HOOKS']['parseTemplate'][]          = array('rateit\\RateItArticle', 'parseTemplateRateIt');
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,15 @@
 | 
			
		||||
   height: 16px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.ce_rateit_top_ratings .rateItContainer {
 | 
			
		||||
	display: inline-block;
 | 
			
		||||
	width: 100%;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.ce_rateit_top_ratings .rateItTitle {
 | 
			
		||||
	float: left;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.rateItRating[rel="not-rateable"] { 
 | 
			
		||||
   float: right;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								public/css/rateit.min.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								public/css/rateit.min.css
									
									
									
									
										vendored
									
									
								
							@@ -1 +1 @@
 | 
			
		||||
.rateItRating{position:relative;display:inline-block}.mbrateItRating{position:relative;opacity:1}.mbrateItRating .wrapper,.rateItRating .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.mbrateItRating div.rateItRating-hover,div.mbrateItRating div.rateItRating-selected,div.rateItRating div.rateItRating-hover,div.rateItRating div.rateItRating-selected{position:absolute}.rateItRating .ratingText{color:#000}.mbrateItRating .mbratingText{display:inline-block;color:#ccc}.ratingText.ratingError{color:red}.mbrateItRating .mbratingText.loading,.rateItRating .ratingText.loading{background:url("../images/ajax-loading.gif") no-repeat}span.rating-microdata{display:none}
 | 
			
		||||
.rateItRating{position:relative;display:inline-block}.mbrateItRating{position:relative;opacity:1}.mbrateItRating .wrapper,.rateItRating .wrapper{cursor:pointer;position:relative;diplay:inline-block;height:16px}.ce_rateit_top_ratings .rateItContainer{display:inline-block;width:100%;}.ce_rateit_top_ratings .rateItTitle{float: left;}.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.mbrateItRating div.rateItRating-hover,div.mbrateItRating div.rateItRating-selected,div.rateItRating div.rateItRating-hover,div.rateItRating div.rateItRating-selected{position:absolute}.rateItRating .ratingText{color:#000}.mbrateItRating .mbratingText{display:inline-block;color:#ccc}.ratingText.ratingError{color:red}.mbrateItRating .mbratingText.loading,.rateItRating .ratingText.loading{background:url("../images/ajax-loading.gif") no-repeat}span.rating-microdata{display:none}
 | 
			
		||||
@@ -271,7 +271,7 @@ function doRateIt() {
 | 
			
		||||
		});
 | 
			
		||||
		
 | 
			
		||||
		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) {
 | 
			
		||||
		// the rateit plugin as an Object
 | 
			
		||||
@@ -579,7 +579,7 @@ function doRateIt() {
 | 
			
		||||
				  async: false,
 | 
			
		||||
				  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) {
 | 
			
		||||
 
 | 
			
		||||
@@ -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;}}}
 | 
			
		||||
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.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;}
 | 
			
		||||
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;}}}
 | 
			
		||||
@@ -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 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;}}}
 | 
			
		||||
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();});
 | 
			
		||||
							
								
								
									
										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();
 | 
			
		||||
 | 
			
		||||
?>
 | 
			
		||||
@@ -1,21 +1,29 @@
 | 
			
		||||
 | 
			
		||||
<div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
 | 
			
		||||
<div class="<?= $this->class ?> block"<?= $this->cssID ?><?php if ($this->style): ?> style="<?= $this->style ?>"<?php endif; ?>>
 | 
			
		||||
 | 
			
		||||
  <?php if ($this->headline): ?>
 | 
			
		||||
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
 | 
			
		||||
    <<?= $this->hl ?>><?= $this->headline ?></<?= $this->hl ?>>
 | 
			
		||||
  <?php endif; ?>
 | 
			
		||||
 | 
			
		||||
  <ul>
 | 
			
		||||
    <?php foreach ($this->arrRatings as $rating): ?>
 | 
			
		||||
      <li>
 | 
			
		||||
        <!-- indexer::stop -->
 | 
			
		||||
        <div class="rateItTitle"><?php echo $rating->title; ?></div>
 | 
			
		||||
        <div id="<?php echo $rating->rateItID; ?>" class="<?php echo $rating->rateit_class; ?>" rel="<?php echo $rating->rel; ?>">
 | 
			
		||||
            <div class="wrapper">
 | 
			
		||||
                <div class="rateItRating-selected" style="display: block;"></div>
 | 
			
		||||
                <div class="rateItRating-hover"></div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="<?php echo $rating->descriptionId; ?>" class="ratingText"><?php echo $rating->description; ?></div>
 | 
			
		||||
        <div class="rateItContainer">
 | 
			
		||||
           <div class="rateItTitle">
 | 
			
		||||
           <?php if ($rating->url): ?>
 | 
			
		||||
              <a href="<?= $rating->url ?>"><?= $rating->title ?></a>
 | 
			
		||||
           <?php else: ?>
 | 
			
		||||
              <?= $rating->title ?>
 | 
			
		||||
           <?php endif; ?>
 | 
			
		||||
           </div>
 | 
			
		||||
           <div id="<?= $rating->rateItID ?>" class="<?= $rating->rateit_class ?>" rel="<?= $rating->rel ?>">
 | 
			
		||||
               <div class="wrapper">
 | 
			
		||||
                   <div class="rateItRating-selected" style="display: block;"></div>
 | 
			
		||||
                   <div class="rateItRating-hover"></div>
 | 
			
		||||
               </div>
 | 
			
		||||
               <div id="<?= $rating->descriptionId ?>" class="ratingText"><?= $rating->description ?></div>
 | 
			
		||||
           </div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <!-- indexer::continue -->
 | 
			
		||||
      </li>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,27 @@
 | 
			
		||||
 | 
			
		||||
<div class="<?php echo $this->class; ?> block"<?php echo $this->cssID; ?><?php if ($this->style): ?> style="<?php echo $this->style; ?>"<?php endif; ?>>
 | 
			
		||||
<div class="<?= $this->class; ?> block"<?= $this->cssID; ?><?php if ($this->style): ?> style="<?= $this->style; ?>"<?php endif; ?>>
 | 
			
		||||
 | 
			
		||||
  <?php if ($this->headline): ?>
 | 
			
		||||
    <<?php echo $this->hl; ?>><?php echo $this->headline; ?></<?php echo $this->hl; ?>>
 | 
			
		||||
    <<?= $this->hl ?>><?= $this->headline; ?></<?= $this->hl; ?>>
 | 
			
		||||
  <?php endif; ?>
 | 
			
		||||
 | 
			
		||||
  <ul>
 | 
			
		||||
    <?php foreach ($this->arrRatings as $rating): ?>
 | 
			
		||||
      <li>
 | 
			
		||||
        <!-- indexer::stop -->
 | 
			
		||||
        <div class="rateItTitle"><?php echo $rating->title; ?></div>
 | 
			
		||||
        <div id="<?php echo $rating->rateItID; ?>" class="<?php echo $rating->rateit_class; ?>" rel="<?php echo $rating->rel; ?>">
 | 
			
		||||
        <div class="rateItTitle">
 | 
			
		||||
        <?php if ($rating->url): ?>
 | 
			
		||||
           <a href="<?= $rating->url ?>"><?= $rating->title ?></a>
 | 
			
		||||
        <?php else: ?>
 | 
			
		||||
           <?= $rating->title ?>
 | 
			
		||||
        <?php endif; ?>
 | 
			
		||||
        </div>
 | 
			
		||||
        <div id="<?= $rating->rateItID ?>" class="<?= $rating->rateit_class ?>" rel="<?= $rating->rel ?>">
 | 
			
		||||
            <div class="wrapper">
 | 
			
		||||
                <div class="rateItRating-selected" style="display: block;"></div>
 | 
			
		||||
                <div class="rateItRating-hover"></div>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div id="<?php echo $rating->descriptionId; ?>" class="ratingText"><?php echo $rating->description; ?></div>
 | 
			
		||||
            <div id="<?= $rating->descriptionId ?>" class="ratingText"><?= $rating->description ?></div>
 | 
			
		||||
        </div>
 | 
			
		||||
        <!-- indexer::continue -->
 | 
			
		||||
      </li>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user