瀏覽代碼

Ticket #351 - Minor fixes and improvements.

AntonLV 10 年之前
父節點
當前提交
d64f428a84

+ 6 - 0
inc/classes/BxDolVote.php

@@ -86,6 +86,9 @@ class BxDolVote extends BxDolObject
 {
 	protected $_oTemplate;
 
+	protected $_bLike = true;
+	protected $_sType = BX_DOL_VOTE_TYPE_LIKES;
+
     public function __construct($sSystem, $iId, $iInit = true, $oTemplate = false)
     {
         parent::__construct($sSystem, $iId, $iInit);
@@ -98,6 +101,9 @@ class BxDolVote extends BxDolObject
             $this->_oTemplate = $oTemplate;
         else
             $this->_oTemplate = BxDolTemplate::getInstance();
+
+		$this->_bLike = $this->isLikeMode();
+        $this->_sType = $this->_bLike ? BX_DOL_VOTE_TYPE_LIKES : BX_DOL_VOTE_TYPE_STARS;
     }
 
     /**

+ 11 - 11
inc/js/classes/BxDolVote.js

@@ -27,24 +27,24 @@ function BxDolVote(options)
     //--- Init stars based vote ---//
     var $this = this;
     if(!this._iLikeMode) {
-	    var oMainStars = $('#' + this._aHtmlIds['main_stars']);
-	    if(oMainStars) {
-	    	var fRate = oMainStars.attr('bx_vote_data_rate');
-	    	var iStarWidth = this._getStarWidthDo(oMainStars);
+    	$('.' + this._sSP + '.' + this._sSP + '-stars').each(function() {
+    		var oDoVote = $(this);
+	    	var fRate = oDoVote.attr('bx_vote_data_rate');
+	    	var iStarWidth = $this._getStarWidthDo(oDoVote);
 
-	    	this._getSliderDo(oMainStars).width(Math.round(fRate * iStarWidth));
-	    }
+	    	$this._getSliderDo(oDoVote).width(Math.round(fRate * iStarWidth));
+    	});
 
-	    var oLegendStars = $('#' + this._aHtmlIds['legend_stars']);
-	    if(oLegendStars) {
-	    	var iStarWidth = this._getStarWidthLegend(oLegendStars);
+    	$('.' + this._sSP + '-legend.' + this._sSP + '-legend-stars').each(function() {
+    		var oLegend = $(this);
+    		var iStarWidth = $this._getStarWidthLegend(oLegend);
 
-	    	oLegendStars.find('.' + this._sSP + '-legend-item').each(function() {
+	    	oLegend.find('.' + $this._sSP + '-legend-item').each(function() {
 	    		var oItem = $(this);
 
 	    		oItem.find('.' + $this._sSP + '-slider').width(parseInt(oItem.attr('bx_vote_item_value')) * iStarWidth); 
 	    	});
-	    }
+    	});
     }
 }
 

+ 1 - 1
modules/boonex/market/install/sql/install.sql

@@ -414,7 +414,7 @@ INSERT INTO `sys_objects_cmts` (`Name`, `Table`, `CharsPostMin`, `CharsPostMax`,
 
 -- VOTES
 INSERT INTO `sys_objects_vote` (`Name`, `TableMain`, `TableTrack`, `PostTimeout`, `MinValue`, `MaxValue`, `IsUndo`, `IsOn`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldAuthor`, `TriggerFieldRate`, `TriggerFieldRateCount`, `ClassName`, `ClassFile`) VALUES 
-('bx_market', 'bx_market_votes', 'bx_market_votes_track', '604800', '1', '1', '0', '1', 'bx_market_products', 'id', 'author', 'rate', 'votes', 'BxMarketVote', 'modules/boonex/market/classes/BxMarketVote.php');
+('bx_market', 'bx_market_votes', 'bx_market_votes_track', '604800', '1', '5', '0', '1', 'bx_market_products', 'id', 'author', 'rate', 'votes', 'BxMarketVote', 'modules/boonex/market/classes/BxMarketVote.php');
 
 -- REPORTS
 INSERT INTO `sys_objects_report` (`name`, `table_main`, `table_track`, `is_on`, `base_url`, `trigger_table`, `trigger_field_id`, `trigger_field_author`, `trigger_field_count`, `class_name`, `class_file`) VALUES 

+ 9 - 11
template/scripts/BxBaseVote.php

@@ -174,6 +174,7 @@ class BxBaseVote extends BxDolVote
         return $this->_oTemplate->parseHtmlByName($this->_sTmplNameLegend, array(
         	'style_prefix'  => $this->_sStylePrefix,
         	'html_id' => $this->_aHtmlIds['legend_stars'],
+        	'type' => $this->_sType,
         	'bx_repeat:items' => $aTmplVarsItems
         ));
     }
@@ -194,19 +195,16 @@ class BxBaseVote extends BxDolVote
 
     public function getElement($aParams = array())
     {
-		$bLikeMode =  $this->isLikeMode();
-        $sType = $bLikeMode ? BX_DOL_VOTE_TYPE_LIKES : BX_DOL_VOTE_TYPE_STARS;
-
-    	$aParams = array_merge($this->_aElementDefaults[$sType], $aParams);
+    	$aParams = array_merge($this->_aElementDefaults[$this->_sType], $aParams);
     	$bDynamicMode = isset($aParams['dynamic_mode']) && $aParams['dynamic_mode'] === true;
 
         $bShowDoVote = !isset($aParams['show_do_vote']) || $aParams['show_do_vote'] == true;
-        $bShowDoVoteAsButtonSmall = $bLikeMode && isset($aParams['show_do_vote_as_button_small']) && $aParams['show_do_vote_as_button_small'] == true;
-        $bShowDoVoteAsButton = $bLikeMode && !$bShowDoVoteAsButtonSmall && isset($aParams['show_do_vote_as_button']) && $aParams['show_do_vote_as_button'] == true;
+        $bShowDoVoteAsButtonSmall = $this->_bLike && isset($aParams['show_do_vote_as_button_small']) && $aParams['show_do_vote_as_button_small'] == true;
+        $bShowDoVoteAsButton = $this->_bLike && !$bShowDoVoteAsButtonSmall && isset($aParams['show_do_vote_as_button']) && $aParams['show_do_vote_as_button'] == true;
         $bShowCounter = isset($aParams['show_counter']) && $aParams['show_counter'] === true;
-        $bShowLegend = !$bLikeMode && isset($aParams['show_legend']) && $aParams['show_legend'] === true;
+        $bShowLegend = !$this->_bLike && isset($aParams['show_legend']) && $aParams['show_legend'] === true;
 
-        $sMethodDoVote = '_getDoVote' . ucfirst($sType);
+        $sMethodDoVote = '_getDoVote' . ucfirst($this->_sType);
         if(!method_exists($this, $sMethodDoVote))
             return '';
 
@@ -221,7 +219,7 @@ class BxBaseVote extends BxDolVote
         $aParams['is_voted'] = $this->_oQuery->isPerformed($iObjectId, $iAuthorId) ? true : false;
 
         //--- Do Vote
-        $bTmplVarsDoVote = $bShowDoVote && (!$bLikeMode || ($bLikeMode && $isAllowedVote));
+        $bTmplVarsDoVote = $bShowDoVote && (!$this->_bLike || ($this->_bLike && $isAllowedVote));
         $aTmplVarsDoVote = array();
         if($bTmplVarsDoVote)
         	$aTmplVarsDoVote = array(
@@ -251,8 +249,8 @@ class BxBaseVote extends BxDolVote
         $sTmplName = 'vote_element_' . (!empty($aParams['usage']) ? $aParams['usage'] : BX_DOL_VOTE_USAGE_DEFAULT) . '.html';
         return $this->_oTemplate->parseHtmlByName($sTmplName, array(
             'style_prefix' => $this->_sStylePrefix,
-            'html_id' => $this->_aHtmlIds['main_' . $sType],
-            'class' => $this->_sStylePrefix . '-' . $sType . ($bShowDoVoteAsButton ? '-button' : '') . ($bShowDoVoteAsButtonSmall ? '-button-small' : ''),
+            'html_id' => $this->_aHtmlIds['main_' . $this->_sType],
+            'class' => $this->_sStylePrefix . '-' . $this->_sType . ($bShowDoVoteAsButton ? '-button' : '') . ($bShowDoVoteAsButtonSmall ? '-button-small' : ''),
             'rate' => $aVote['rate'],
             'count' => $aVote['count'],
         	'bx_if:show_do_vote' => array(

+ 2 - 4
template/vote_legend.html

@@ -1,4 +1,4 @@
-<div id="__html_id__" class="__style_prefix__-legend bx-def-margin-top-auto">
+<div id="__html_id__" class="__style_prefix__-legend __style_prefix__-legend-__type__ bx-def-margin-top-auto">
 	<bx_repeat:items>
 		<div class="__style_prefix__-legend-item bx-def-margin-thd-topbottom bx-clearfix" bx_vote_item_value="__value__">
 			<div class="bx-vote-element-holder">
@@ -9,9 +9,7 @@
 					<bx_repeat:slider><i class="__style_prefix__-star sys-icon star"></i></bx_repeat:slider>
 				</div>
 			</div>
-			<div class="bx-vote-counter-holder bx-def-margin-sec-left bx-def-font-grayed">
-				__label__
-			</div>
+			<div class="bx-vote-counter-holder bx-def-margin-sec-left bx-def-font-grayed">__label__</div>
 		</div>
 	</bx_repeat:items>
 </div>