Explorar el Código

#1 - Experimental layout.

AntonLV hace 13 años
padre
commit
416352c7ed

+ 9 - 5
inc/classes/BxDolCmts.php

@@ -30,6 +30,9 @@ define('BX_CMT_PFP_TOP', 'top');
 define('BX_CMT_PFP_BOTTOM', 'bottom');
 define('BX_CMT_PFP_BOTH', 'both');
 
+define('BX_CMT_RATE_VALUE_PLUS', 1);
+define('BX_CMT_RATE_VALUE_MINUS', -1);
+
 
 /** 
  * @page objects 
@@ -660,17 +663,18 @@ class BxDolCmts extends BxDol
     }
 
     function actionCmtRate () {
-        if (!$this->isEnabled()) return _t('_Error occured');
-        if (!$this->isRatable()) return _t('_Error occured');
-        if (!$this->isRateAllowed()) return _t('_Access denied');
+        if (!$this->isEnabled() || !$this->isRatable()) 
+        	return _t('_Error occured');
+        if (!$this->isRateAllowed()) 
+        	return _t('_Access denied');
 
         $iCmtId = bx_process_input($_REQUEST['Cmt'], BX_DATA_INT);
         $iRate = bx_process_input($_REQUEST['Rate'], BX_DATA_INT);
 
         if($iRate >= 1)
-            $iRate = 1;
+            $iRate = BX_CMT_RATE_VALUE_PLUS;
         elseif($iRate <= -1)
-            $iRate = -1;
+            $iRate = BX_CMT_RATE_VALUE_MINUS;
         else
             return _t('_Error occured');
 

+ 27 - 10
inc/classes/BxDolCmtsQuery.php

@@ -224,18 +224,35 @@ class BxDolCmtsQuery extends BxDolDb
 
     function rateComment ($iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp)
     {
+    	$iCount = 0;
         $iTimestamp = time();
-        $sQuery = $this->prepare("INSERT IGNORE INTO {$this->_sTableTrack} SET
-            `cmt_system_id` = ?,
-            `cmt_id` = ?,
-            `cmt_rate` = ?,
-            `cmt_rate_author_id` = ?,
-            `cmt_rate_author_nip` = INET_ATON(?),
-            `cmt_rate_ts` = ?", $iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp, $iTimestamp);
-        if ($this->query($sQuery))
-        {
-            $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_rate` = `cmt_rate` + ?, `cmt_rate_count` = `cmt_rate_count` + 1 WHERE `cmt_id` = ? LIMIT 1", $iRate, $iCmtId);
+
+        if($iRate == BX_CMT_RATE_VALUE_PLUS) {
+        	$iCount = 1;
+	        $sQuery = $this->prepare("INSERT IGNORE INTO `{$this->_sTableTrack}` SET
+	            `cmt_system_id` = ?,
+	            `cmt_id` = ?,
+	            `cmt_rate` = ?,
+	            `cmt_rate_author_id` = ?,
+	            `cmt_rate_author_nip` = INET_ATON(?),
+	            `cmt_rate_ts` = ?", $iSystemId, $iCmtId, $iRate, $iAuthorId, $sAuthorIp, $iTimestamp);
+        }
+        else if($iRate == BX_CMT_RATE_VALUE_MINUS) {
+        	$iCount = -1;
+        	$sQuery = $this->prepare("DELETE FROM `{$this->_sTableTrack}` WHERE
+	            `cmt_system_id` = ? AND 
+	            `cmt_id` = ? AND 
+	            `cmt_rate_author_id` = ?", $iSystemId, $iCmtId, $iAuthorId);
+        }
+
+        if ($this->query($sQuery)) {
+            $sQuery = $this->prepare("UPDATE `{$this->_sTable}` SET 
+            		`cmt_rate` = `cmt_rate` + ?, 
+            		`cmt_rate_count` = `cmt_rate_count` + ? 
+            	WHERE `cmt_id` = ? 
+            	LIMIT 1", $iRate, $iCount, $iCmtId);
             $this->query($sQuery);
+
             return true;
         }
 

+ 7 - 7
inc/js/classes/BxDolCmts.js

@@ -212,15 +212,15 @@ BxDolCmts.prototype.cmtRate = function(e, iCmtId, iRate)
         function (s) {
             $this._loadingInContent (e, false);
 
-            if(jQuery.trim(s).length)
+            if(jQuery.trim(s).length) {
                 alert(s);
-            else if(iRate == 1) {
-                var oPoints = $(e).parents('.cmt:first').find('.cmt-points span');
-                oPoints.html(parseInt(oPoints.html()) + iRate);
-            }
-            else if(iRate == -1) {
-                $this.cmtReload(iCmtId);
+                return;
             }
+
+            var oPoints = $(e).parents('.cmt:first').find('.cmt-points span');
+            oPoints.html(parseInt(oPoints.html()) + iRate).parents('.cmt-points-wrp:first').bx_anim(parseInt(oPoints.html()) > 0 ? 'show' : 'hide');
+
+            $(e).hide().siblings('.cmt-comment-vote:hidden').show();
         }
     );
 };

+ 7 - 7
template/comment.html

@@ -10,23 +10,23 @@
 			</bx_if:show_icon_empty>
 		</div>
 		<div class="cmt-username bx-def-icon-size-min-height">
-			<span class="__style_prefix__-username bx-def-font-h3">
+			<span class="__style_prefix__-username bx-def-padding-right bx-def-font-h3">
 				<bx_if:show_author_link><a href="__author_link__">__author_name__</a> </bx_if:show_author_link>
 				<bx_if:show_author_text>__author_name__ </bx_if:show_author_text>
 			</span>
-			<span class="__style_prefix__-reply-to bx-def-padding-left bx-def-font-small bx-def-font-grayed">
+			<span class="__style_prefix__-reply-to bx-def-font-small">
 				<bx_if:show_reply_to>
-					<span><bx_text:_in_reply_to />&nbsp;</span><a href="__par_cmt_link__">__par_cmt_author__</a>
+					<span class="bx-def-font-grayed"><bx_text:_in_reply_to />&nbsp;</span><a href="__par_cmt_link__">__par_cmt_author__</a><span class="bullet">&#183;</span>
 				</bx_if:show_reply_to>
-				<span class="bullet">&#183;</span><a class="__style_prefix__-ago" href="__view_link__">__ago__</a>
-				<bx_if:show_rate_count>
+				<a class="__style_prefix__-ago" href="__view_link__">__ago__</a>
+				<span class="__style_prefix__-points-wrp" <bx_if:hide_rate_count>style="display:none;"</bx_if:hide_rate_count>>
 					<span class="bullet">&#183;</span><a class="__style_prefix__-points" href="javascript:void(0)" onclick="__js_object__.togglePlusedByPopup(this, __id__); return false;" title="<bx_text:_Plused_by_popup />">__points__</a>
-				</bx_if:show_rate_count>
+				</span>
 			</span>
 		</div>
 	</div>
 	<div class="__style_prefix__-cont bx-def-margin-sec-top bx-def-color-bg-box bx-def-border bx-def-round-corners bx-def-shadow">
-		<div class="__style_prefix__-cont-cnt">
+		<div class="__style_prefix__-cont-cnt bx-def-padding-leftright bx-def-padding-sec-topbottom">
 			<div class="__style_prefix__-body bx-def-margin-thd-topbottom">
 				__text__<bx_if:show_more><span class="__style_prefix__-body-see-more">... <a class="bx-def-font-small" href="javascript:void(0)" onclick="__js_object__.seeMore(this);"><bx_text:_see_more /></a></span><span style="display:none;"> __text_more__</span></bx_if:show_more>
 			</div>

+ 2 - 4
template/comment_actions.html

@@ -3,10 +3,8 @@
 		<a class="__style_prefix__-comment-reply bx-def-margin-sec-left-auto" href="javascript:void(0)" onclick="__js_object__.toggleReply(this, __id__); return false;" title="__text__"><i class="sys-icon reply"></i></a>
 	</bx_if:show_reply>
 	<bx_if:show_rate>
-		<a class="__style_prefix__-comment-vote bx-def-margin-sec-left-auto" title="<bx_text:_Plus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, 1)" title="<bx_text:_Plus />"><i class="sys-icon plus"></i></a>
-		<!--
-		<a class="__style_prefix__-comment-vote bx-def-margin-sec-left-auto" title="<bx_text:_Minus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, -1)" title="<bx_text:_Minus />"><i class="sys-icon minus"></i></a>
-		-->
+		<a class="__style_prefix__-comment-vote bx-def-margin-sec-left-auto" title="<bx_text:_Plus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, 1)" title="<bx_text:_Plus />" <bx_if:hide_rate_plus>style="display:none"</bx_if:hide_rate_plus>><i class="sys-icon plus-sign"></i></a>
+		<a class="__style_prefix__-comment-vote bx-def-margin-sec-left-auto" title="<bx_text:_Minus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, -1)" title="<bx_text:_Minus />" <bx_if:hide_rate_minus>style="display:none"</bx_if:hide_rate_minus>><i class="sys-icon minus-sign"></i></a>
 	</bx_if:show_rate>
 	<bx_if:show_manage>
 		<a class="__style_prefix__-comment-manage bx-def-margin-sec-left-auto" href="javascript:void(0)" onclick="__js_object__.toggleManagePopup(this, __id__); return false;" title="<bx_text:_Manage />"><i class="sys-icon cog"></i></a>

+ 4 - 2
template/comment_reply_box.html

@@ -15,7 +15,9 @@
 			</span>
 		</div>
 	</div>
-	<div class="__style_prefix__-post-reply bx-def-margin-sec-top">
-	    __form__
+	<div class="__style_prefix__-cont __style_prefix__-post-reply bx-def-margin-sec-top bx-def-color-bg-box bx-def-border bx-def-round-corners bx-def-shadow">
+		<div class="__style_prefix__-cont-cnt bx-def-padding-leftright bx-def-padding-sec-topbottom">
+			<div class="__style_prefix__-body bx-def-margin-thd-topbottom">__form__</div>
+		</div>
 	</div>
 </div>

+ 3 - 9
template/css/cmts.css

@@ -135,9 +135,6 @@
     	float: left;
     	line-height: 0.8em;
     }
-    span.cmt-reply-to span.bullet:first-child {
-		display: none;
-    }
     span.cmt-reply-to a.cmt-points span {
 		display: inline;
     	float: none;
@@ -158,8 +155,8 @@
 	div.cmt-author .bullet {
 		padding: 0px 5px;
     }
-    div.cmt-cont.bx-def-border:before,
-    div.cmt-cont.bx-def-border:after {
+    div.cmt-cont:before,
+    div.cmt-cont:after {
 		content:""; 
 		position: absolute; 
 		left: 10px;
@@ -170,13 +167,10 @@
 		border-right: 6px solid transparent;
 		border-bottom: 6px solid #d0d0d0;
     }
-    div.cmt-cont.bx-def-border:after {
+    div.cmt-cont:after {
     	top: -5px;
 		border-bottom-color: #ffffff;
     }
-    div.cmt-cont.bx-def-border div.cmt-cont-cnt {
-		padding: 10px 20px;
-    }
     span.cmt-body-see-more a {
 		font-weight: bold;
     }

+ 1 - 3
template/css/forms.css

@@ -25,9 +25,7 @@
 }
 
 .bx-form-section {
-    padding-top:0px;
-    padding-left:0px;
-    padding-right:0px;
+    padding:0px;
 }
 
 .bx-form-section {

+ 15 - 12
template/scripts/BxBaseCmtsView.php

@@ -220,6 +220,7 @@ class BxBaseCmtsView extends BxDolCmts {
         return $oTemplate->parseHtmlByName('comment.html', array(
         	'system' => $this->_sSystem,
         	'style_prefix' => $this->_sStylePrefix,
+        	'js_object' => $this->_sJsObjName,
         	'id' => $r['cmt_id'],
         	'class' => $sClass,
         	'bx_if:show_icon' => array(
@@ -255,18 +256,11 @@ class BxBaseCmtsView extends BxDolCmts {
         		'cmt_id' => $r['cmt_id']
         	)),
         	'ago' => $r['cmt_ago'],
-        	'bx_if:show_rate_count' => array(
-        		'condition' => (int)$r['cmt_rate'] > 0,
-        		'content' => array(
-        			'style_prefix' => $this->_sStylePrefix,
-        			'js_object' => $this->_sJsObjName,
-        			'id' => $r['cmt_id'],
-        			'points' => _t($r['cmt_rate'] == 1 || $r['cmt_rate'] == -1 ? '_N_point' : '_N_points', $r['cmt_rate']),
-        	
-		        	'points_num' => $r['cmt_rate'],
-		        	'points_txt' => _t($r['cmt_rate'] == 1 || $r['cmt_rate'] == -1 ? '_cmt_point' : '_cmt_points'),
-        		)
+        	'bx_if:hide_rate_count' => array(
+        		'condition' => (int)$r['cmt_rate'] <= 0,
+        		'content' => array()
         	),
+        	'points' => _t(in_array($r['cmt_rate'], array(-1, 0, 1)) ? '_N_point' : '_N_points', $r['cmt_rate']),
         	'text' => $sText,
         	'bx_if:show_more' => array(
         		'condition' => !empty($sTextMore),
@@ -396,6 +390,7 @@ class BxBaseCmtsView extends BxDolCmts {
 	        )));
         }
 
+        $bRated = (int)$a['cmt_rated'] > 0;
         return $oTemplate->parseHtmlByName('comment_actions.html', array(
         	'id' => $a['cmt_id'],
         	'style_prefix' => $this->_sStylePrefix,
@@ -420,7 +415,15 @@ class BxBaseCmtsView extends BxDolCmts {
         		'content' => array(
         			'js_object' => $this->_sJsObjName,
         			'style_prefix' => $this->_sStylePrefix,
-        			'id' => $a['cmt_id']
+        			'id' => $a['cmt_id'],
+        			'bx_if:hide_rate_plus' => array(
+        				'condition' => $bRated,
+        				'content' => array()
+        			),
+        			'bx_if:hide_rate_minus' => array(
+        				'condition' => !$bRated,
+        				'content' => array()
+        			)
         		)
         	),
         	'bx_if:show_manage' => array(