Просмотр исходного кода

#85 - Change "Plus" to "Thank you".

AntonLV 12 лет назад
Родитель
Сommit
67093625cc

+ 15 - 2
inc/classes/BxDolVote.php

@@ -236,6 +236,7 @@ class BxDolVote extends BxDolObject
         $iObjectId = $this->getId();
         $iAuthorId = $this->_getAuthorId();
         $iAuthorIp = $this->_getAuthorIp();
+        $bLikeMode = $this->isLikeMode();
 
         $bUndo = $this->isUndo() && $this->_oQuery->isVoted($iObjectId, $iAuthorId) ? true : false;
 
@@ -244,7 +245,7 @@ class BxDolVote extends BxDolObject
             return;
         }
 
-        if(!$this->isLikeMode() && !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorIp)) {
+        if(!$bLikeMode && !$this->_oQuery->isPostTimeoutEnded($iObjectId, $iAuthorIp)) {
             $this->_echoResultJson(array('code' => 3, 'msg' => _t('_vote_err_duplicate_vote')));
             return;
         }
@@ -280,7 +281,9 @@ class BxDolVote extends BxDolObject
             'code' => 0,
             'rate' => $aVote['rate'],
             'count' => $aVote['count'],
-            'countf' => (int)$aVote['count'] > 0 ? $this->_getLabelCounter($aVote['count']) : ''
+            'countf' => (int)$aVote['count'] > 0 ? $this->_getLabelCounter($aVote['count']) : '',
+        	'label_icon' => $bLikeMode ? $this->_getIconDoLike(!$bUndo) : '',
+        	'label_title' => $bLikeMode ? _t($this->_getTitleDoLike(!$bUndo)) : ''
         ));
     }
 
@@ -364,6 +367,16 @@ class BxDolVote extends BxDolObject
         return $oProfile;
     }
 
+    protected function _getIconDoLike($bVoted)
+    {
+    	return $bVoted ?  'thumbs-down' : 'thumbs-up';
+    }
+
+    protected function _getTitleDoLike($bVoted)
+    {
+    	return $bVoted ? '_vote_do_unlike' : '_vote_do_like';
+    }
+
     protected function _triggerVote()
     {
         if(!$this->_aSystem['trigger_table'])

+ 10 - 0
inc/js/classes/BxDolVote.js

@@ -78,6 +78,16 @@ BxDolVote.prototype.vote = function (oLink, iValue)
     		if(oData && oData.code != 0)
                 return;
 
+    		if($this._iLikeMode) {
+	    		if(oData && oData.label_icon)
+	    			$(oLink).find('.sys-icon').attr('class', 'sys-icon ' + oData.label_icon);
+
+	    		if(oData && oData.label_title) {
+	    			$(oLink).attr('title', oData.label_title);
+	    			$(oLink).find('span').html(oData.label_title);
+	    		}
+    		}
+
     		if(!$this._iLikeMode)
     			$this._iSaveWidth = Math.round(oData.rate * $this._getStarWidth(oLink));
 

+ 3 - 2
modules/boonex/english/data/langs/system.xml

@@ -2043,8 +2043,9 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_top"><![CDATA[Top]]></string>
 	<string name="_uknown"><![CDATA[unknown]]></string>
 	<string name="_undefined"><![CDATA[undefined]]></string>
-	<string name="_vote_do_like"><![CDATA[Plus]]></string>
-	<string name="_vote_do_like_by"><![CDATA[Plused by]]></string>
+	<string name="_vote_do_like"><![CDATA[Thank you]]></string>
+	<string name="_vote_do_unlike"><![CDATA[Unthank you]]></string>
+	<string name="_vote_do_like_by"><![CDATA[Thanked by]]></string>
 	<string name="_vote_err_duplicate_vote"><![CDATA[Duplicate vote]]></string>
 	<string name="_week_fri"><![CDATA[Friday]]></string>
 	<string name="_week_mon"><![CDATA[Monday]]></string>

+ 1 - 0
template/bx_span.html

@@ -0,0 +1 @@
+<span <bx_repeat:attrs>__key__="__value__"</bx_repeat:attrs>>__content__</span>

+ 13 - 3
template/scripts/BxBaseVote.php

@@ -145,8 +145,12 @@ class BxBaseVote extends BxDolVote
         if(!method_exists($this, $sMethodDoVote))
             return '';
 
-        $aVote = $this->_oQuery->getVote($this->getId());
+		$iObjectId = $this->getId();
+		$iAuthorId = $this->_getAuthorId();
+        $aVote = $this->_oQuery->getVote($iObjectId);
+
         $aParams = array_merge($this->_aElementDefaults[$sType], $aParams);
+        $aParams['is_voted'] = $this->isUndo() && $this->_oQuery->isVoted($iObjectId, $iAuthorId) ? true : false;
 
         $sTmplName = 'vote_element_' . (!empty($aParams['usage']) ? $aParams['usage'] : BX_DOL_VOTE_USAGE_DEFAULT) . '.html';
         return BxDolTemplate::getInstance()->parseHtmlByName($sTmplName, array(
@@ -233,12 +237,18 @@ class BxBaseVote extends BxDolVote
 
     protected function _getLabelDoLike($aParams = array())
     {
+    	$bVoted = isset($aParams['is_voted']) && $aParams['is_voted'] === true;
+    	$oTemplate = BxDolTemplate::getInstance();
+
         $sResult = '';
         if(isset($aParams['show_do_vote_icon']) && $aParams['show_do_vote_icon'] == true)
-            $sResult .= BxDolTemplate::getInstance()->parseHtmlByName('bx_icon.html', array('name' => 'plus'));
+            $sResult .= $oTemplate->parseHtmlByName('bx_icon.html', array('name' => $this->_getIconDoLike($bVoted)));
 
         if(isset($aParams['show_do_vote_label']) && $aParams['show_do_vote_label'] == true)
-            $sResult .= ($sResult != '' ? ' ' : '') . _t('_vote_do_like');
+            $sResult .= ($sResult != '' ? ' ' : '') . $oTemplate->parseHtmlByName('bx_span.html', array(
+            	'bx_repeat:attrs' => array(),
+            	'content' => _t($this->_getTitleDoLike($bVoted))
+            ));
 
         return $sResult;
     }