Преглед изворни кода

#104 - Live updates engine in Comments.

AntonLV пре 11 година
родитељ
комит
806da09512

+ 21 - 1
inc/classes/BxDolCmts.php

@@ -414,6 +414,11 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         return $oVote;
     }
 
+	public function getNotificationId()
+	{
+		return 'cmts-notification-' . $this->_sSystem . '-' . $this->_iId;
+	}
+
     public function isNl2br ()
     {
         return $this->_aSystem['nl2br'];
@@ -781,6 +786,22 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         $this->_echoResultJson(array('msg' => _t('_cmt_err_cannot_perform_action')));
     }
 
+    public function actionResumeLiveUpdate()
+    {
+    	$sKey = $this->getNotificationId();
+
+    	bx_import('BxDolSession');
+    	BxDolSession::getInstance()->unsetValue($sKey);
+    }
+
+	public function actionPauseLiveUpdate()
+    {
+    	$sKey = $this->getNotificationId();
+
+    	bx_import('BxDolSession');
+    	BxDolSession::getInstance()->setValue($sKey, 1);
+    }
+
     /**
      * Internal functions
      */
@@ -976,7 +997,6 @@ class BxDolCmts extends BxDol implements iBxDolReplaceable
         if(!empty($sBpFilter))
             $oSession->setValue($this->_sBpSessionKeyFilter . $iUserId, $sBpFilter);
     }
-
     protected function _sendNotificationEmail($iCmtId, $iCmtParentId)
     {
         $aCmt = $this->getCommentRow($iCmtId);

+ 4 - 3
inc/classes/BxDolCmtsQuery.php

@@ -157,9 +157,10 @@ class BxDolCmtsQuery extends BxDolDb
         	$sWhereClause .= $this->prepare(" AND `{$this->_sTable}`.`cmt_object_id` = ?" , (int)$aParams['object_id']);
 
         switch($aParams['type']) {
-            case 'latest_ids':
-            	$aMethod['name'] = 'getColumn';
-				$sSelectClause = "`{$this->_sTable}`.`cmt_id`";
+            case 'latest':
+            	if(!empty($aParams['author']))
+            		$sWhereClause .= $this->prepare(" AND `{$this->_sTable}`.`cmt_author_id` " . (isset($aParams['others']) && (int)$aParams['others'] == 1 ? "<>" : "=") . " ?", (int)$aParams['author']);
+
                 $sOrderClause = "ORDER BY `{$this->_sTable}`.`cmt_time` DESC";
                 $sLimitClause = isset($aParams['per_page']) ? "LIMIT " . $aParams['start'] . ", " . $aParams['per_page'] : "";
                 break;

+ 117 - 24
inc/js/classes/BxDolCmts.js

@@ -34,6 +34,8 @@ function BxDolCmts (options) {
 
     // blink (highlight) necessary comments
     this._cmtsBlink($(this._sRootId));
+
+    this._bLiveUpdatePaused = false;
 }
 
 /*--- Main layout functionality ---*/
@@ -286,30 +288,7 @@ BxDolCmts.prototype.cmtChangeFilter = function(oLink, sType)
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
 };
-BxDolCmts.prototype.showLiveUpdate = function(oData)
-{
-	/*
-	 * Note. oData.count_old and oData.count_new are also available and can be checked or used in notification popup.  
-	 */
-	if(!oData.code)
-		return;
-
-	var oNotification = $(oData.code);
-	var sId = oNotification.attr('id');
-	$('#' + sId).remove();
 
-    oNotification.prependTo('body').dolPopup({
-    	position: 'fixed',
-    	top: '0px',
-    	fog: false,
-    	onBeforeShow: function() {
-    		$('body').addClass('cmt-notification-holder');
-    	},
-    	onBeforeHide: function() {
-    		$('body').removeClass('cmt-notification-holder');
-    	}
-    });
-};
 BxDolCmts.prototype.showReplacement = function(iCmtId)
 {
     $('#cmt' + iCmtId + '-hidden').bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function(){
@@ -374,7 +353,7 @@ BxDolCmts.prototype.toggleManagePopup = function(oLink, iCmtId) {
 	});
 };
 
-BxDolCmts.prototype.goTo = function(oLink, sGoToId, sBlinkIds)
+BxDolCmts.prototype.goTo = function(oLink, sGoToId, sBlinkIds, onLoad)
 {
 	$(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
 
@@ -388,10 +367,124 @@ BxDolCmts.prototype.goTo = function(oLink, sGoToId, sBlinkIds)
 	}, function(sListId, sContent) {
 		$this._cmtsReplaceContent($(sListId), sContent, function() {
 			location.hash = sGoToId;
+
+			if(typeof onLoad == 'function')
+				onLoad();
+		});
+	});
+};
+
+BxDolCmts.prototype.goToAndReply = function(oLink, sGoToId, sBlinkIds)
+{
+	var $this = this;
+	this.goTo(oLink, sGoToId, sBlinkIds, function() {
+		var aBlinkIds = sBlinkIds.split(",");
+		$.each(aBlinkIds, function(iIndex, iValue) {
+			$this.toggleReply(null, iValue);
 		});
 	});
 };
 
+/*----------------------------*/
+/*--- Live Updates methods ---*/
+/*----------------------------*/
+BxDolCmts.prototype.showLiveUpdate = function(oData)
+{
+	/*
+	 * Note. oData.count_old and oData.count_new are also available and can be checked or used in notification popup.  
+	 */
+	if(!oData.code)
+		return;
+
+	var $this = this;
+
+	var oNotifs = $(oData.code);
+	var sId = oNotifs.attr('id');
+	$('#' + sId).remove();
+
+	oNotifs.prependTo('body').dolPopup({
+    	position: 'fixed',
+    	top: '0px',
+    	fog: false,
+    	onBeforeShow: function() {
+    		$('body').addClass('cmt-notif-holder');
+    	},
+    	onBeforeHide: function() {
+    		$('body').removeClass('cmt-notif-holder');
+    	},
+    	onHide: function() {
+    		$this.resumeLiveUpdates();
+    	}
+    });
+};
+
+BxDolCmts.prototype.previousLiveUpdate = function(oLink)
+{
+	var fPrevious = function() {
+		var sClass = 'cmt-notif';
+		$(oLink).parents('.' + sClass + ':first').hide().prev('.' + sClass).show();
+	};
+
+	if(!this.pauseLiveUpdates(fPrevious));
+		fPrevious();
+};
+
+BxDolCmts.prototype.hideLiveUpdate = function(oLink)
+{
+	$(oLink).parents('.bx-popup-applied:visible:first').dolPopupHide();
+};
+
+BxDolCmts.prototype.resumeLiveUpdates = function(onLoad)
+{
+	if(!this._bLiveUpdatePaused)
+		return false;
+
+	var $this = this;
+	this.changeLiveUpdates('ResumeLiveUpdate', function() {
+		$this._bLiveUpdatePaused = false;
+
+		if(typeof onLoad == 'function')
+			onLoad();
+	});
+
+	return true;
+};
+
+BxDolCmts.prototype.pauseLiveUpdates = function(onLoad)
+{
+	if(this._bLiveUpdatePaused)
+		return false;
+
+	var $this = this;
+	this.changeLiveUpdates('PauseLiveUpdate', function() {
+		$this._bLiveUpdatePaused = true;
+
+		if(typeof onLoad == 'function')
+			onLoad();
+	});
+
+	return true;
+};
+
+BxDolCmts.prototype.changeLiveUpdates = function(sAction, onLoad)
+{
+	var $this = this;
+    var oParams = this._getDefaultActions();
+    oParams['action'] = sAction;
+
+	jQuery.get(
+	    this._sActionsUrl,
+	    oParams,
+	    function() {
+	    	if(typeof onLoad == 'function')
+				onLoad();
+	    }
+	);
+};
+
+/*----------------------------------*/
+/*--- Methods for internal usage ---*/
+/*----------------------------------*/
 BxDolCmts.prototype._getCmt = function (e, iCmtId)
 {
     var $this = this;

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

@@ -1295,8 +1295,6 @@
 	<string name="_cmt_err_cannot_perform_action"><![CDATA[Cannot perform action. Please report.]]></string>
 	<string name="_cmt_page_view_header"><![CDATA[Comment to {0}]]></string>
 	<string name="_cmt_page_view_title"><![CDATA[Comment to <a href="{0}">{1}</a>]]></string>
-	<string name="_cmt_txt_n_new_comments"><![CDATA[<span>{0}</span> new comment(s) posted. {1} to see them.]]></string>
-	<string name="_cmt_txt_reload_page"><![CDATA[Reload page]]></string>
 	<string name="_cmt_view_attached_image"><![CDATA[View image]]></string>
 	<string name="_cmt_load_more_comments_head"><![CDATA[See newer comments...]]></string>
 	<string name="_cmt_load_more_comments_tail"><![CDATA[See older comments...]]></string>
@@ -1304,6 +1302,9 @@
 	<string name="_cmt_load_more_replies_head"><![CDATA[See newer replies...]]></string>
 	<string name="_cmt_load_more_replies_tail"><![CDATA[See older replies...]]></string>
 	<string name="_cmt_load_more_replies_popular"><![CDATA[See more replies...]]></string>
+	<string name="_cmt_txt_link_show"><![CDATA[Show]]></string>
+	<string name="_cmt_txt_link_reply"><![CDATA[Reply]]></string>
+	<string name="_cmt_txt_or"><![CDATA[or]]></string>
 	<string name="_copyright"><![CDATA[&copy; {0} Company]]></string>
 	<string name="_delete"><![CDATA[delete]]></string>
 	<string name="_error occured"><![CDATA[Error occurred]]></string>

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

@@ -1295,8 +1295,6 @@
 	<string name="_cmt_err_cannot_perform_action"><![CDATA[Невозможно выполнить действие. Пожалуйста, оповестите нас об этой проблеме.]]></string>
 	<string name="_cmt_page_view_header"><![CDATA[Комментировать {0}]]></string>
 	<string name="_cmt_page_view_title"><![CDATA[Комментировать <a href="{0}">{1}</a>]]></string>
-	<string name="_cmt_txt_n_new_comments"><![CDATA[<span>{0}</span> новых комментариев. {1}, чтобы их увидеть.]]></string>
-	<string name="_cmt_txt_reload_page"><![CDATA[Перегрузить страницу]]></string>
 	<string name="_cmt_view_attached_image"><![CDATA[Просмотреть изображение]]></string>
 	<string name="_cmt_load_more_comments_head"><![CDATA[Увидеть новые комментарии...]]></string>
 	<string name="_cmt_load_more_comments_tail"><![CDATA[Увидеть старые комментарии...]]></string>
@@ -1304,6 +1302,9 @@
 	<string name="_cmt_load_more_replies_head"><![CDATA[Увидеть новые ответы...]]></string>
 	<string name="_cmt_load_more_replies_tail"><![CDATA[Увидеть старые ответы...]]></string>
 	<string name="_cmt_load_more_replies_popular"><![CDATA[Увидеть ещё ответы...]]></string>
+	<string name="_cmt_txt_link_show"><![CDATA[Прочитать]]></string>
+	<string name="_cmt_txt_link_reply"><![CDATA[Ответить]]></string>
+	<string name="_cmt_txt_or"><![CDATA[или]]></string>	
 	<string name="_copyright"><![CDATA[&copy; {0} Компания]]></string>
 	<string name="_delete"><![CDATA[удалить]]></string>
 	<string name="_error occured"><![CDATA[Произошла ошибка]]></string>

+ 39 - 7
template/comments_notification.html

@@ -1,8 +1,40 @@
-<div id="__html_id__" class="__style_prefix__-notification bx-def-border-bottom" style="display:none;">
-	<div class="__style_prefix__-cnt">
-		<div class="__style_prefix__-message bx-def-font-small"><i class="sys-icon info-circle"></i> __message__</div>
-	</div>
-	<div class="__style_prefix__-actions bx-def-padding-sec-right">
-		<a href="javascript:void(0)" onclick="javascript:$(this).parents('.bx-popup-applied:visible:first').dolPopupHide()"><i class="sys-icon times"></i></a>
-	</div>
+<div id="__html_id__" class="__style_prefix__-notifs" style="display:none;">
+	<bx_repeat:notifs>
+		<div class="__style_prefix__-notif bx-def-border-top bx-def-border-bottom"<bx_if:show_as_hidden> style="display:none;"</bx_if:show_as_hidden>>
+			<div class="__style_prefix__-notif-cnt">
+				<div class="__style_prefix__-notif-comment bx-def-thumb-size-max-height bx-def-margin-sec-topbottom">
+					<div class="__style_prefix__-notif-avatar bx-def-thumb bx-def-thumb-size">
+						<bx_if:show_icon>
+							<img class="bx-def-thumb bx-def-thumb-size" src="__author_icon__" />
+						</bx_if:show_icon>
+						<bx_if:show_icon_empty>
+							<i class="sys-icon user"></i>
+						</bx_if:show_icon_empty>
+					</div>
+					<div class="__style_prefix__-notif-info bx-def-thumb-size-min-height bx-def-thumb-size-left-indent bx-def-font-small">
+						<div class="__style_prefix__-notifi-username bx-def-font-grayed">
+							<b class="__style_prefix__-notifi-username">
+								<bx_if:show_author_link><a class="bx-def-font-grayed" href="__author_link__" title="__author_title__">__author_name__</a>: </bx_if:show_author_link>
+								<bx_if:show_author_text>__author_name__: </bx_if:show_author_text>
+							</b>
+							__text__
+						</div>
+						<div class="__style_prefix__-notifi-actions">
+							<a href="javascript:void(0)" onclick="__show_onclick__"><bx_text:_cmt_txt_link_show /></a>
+							<bx_text:_cmt_txt_or />
+							<a href="javascript:void(0)" onclick="__reply_onclick__"><bx_text:_cmt_txt_link_reply /></a>
+						</div>
+					</div>
+				</div>
+			</div>
+			<bx_if:show_previous>
+				<div class="__style_prefix__-notif-actions cmt-na-left bx-def-padding-sec-left">
+					<a href="javascript:void(0)" onclick="javascript:__js_object__.previousLiveUpdate(this);"><i class="sys-icon arrow-left"></i></a>
+				</div>
+			</bx_if:show_previous>
+			<div class="__style_prefix__-notif-actions cmt-na-right bx-def-padding-sec-right">
+				<a href="javascript:void(0)" onclick="javascript:__js_object__.hideLiveUpdate(this);"><i class="sys-icon times"></i></a>
+			</div>
+		</div>
+	</bx_repeat:notifs>
 </div>

+ 68 - 18
template/css/cmts.css

@@ -205,38 +205,88 @@
     }
 
     /*--- Live Update Notification Styles ---*/
-	.cmt-notification-holder {
-		padding-top: 30px;
-    	padding-top: 1.875rem;
+	.cmt-notif-holder {
+		padding-top: 70px;
+    	padding-top: 4.375rem;
     }
+    div.cmt-notifs {
+		position: relative;
 
-    div.cmt-notification {
+    	width: 100%;
+    }
+    div.cmt-notif {
     	position: relative;
 
     	width: 100%;
-    	height: 30px;
-    	height: 1.875rem;
+    	height: 68px;
+    	height: 4.25rem;
 
     	border-color: #000000;
     	background-color: rgba(85, 85, 85, .9);
 
-    	line-height: 30px;
-    	line-height: 1.875rem;
-    	text-align: center;
-
     	color: #ffffff;
     }
-    div.cmt-actions {
+    div.cmt-notif-cnt {
 		position: relative;
+    	padding: 0px 50px;
+    	padding: 0px 3.125rem;
+    }
+    div.cmt-notif-actions {
+		position: absolute;
+    	height: 100%;
+    	top: 0px;
+
+    	line-height: 68px;
+    	line-height: 4.25rem;
     }
-    div.cmt-actions a {
+	div.cmt-na-left {
+    	left: 0px;
+	}
+    div.cmt-na-right {
+    	right: 0px;
+	}
+    div.cmt-notif-actions a {
+    	line-height: initial;
     	text-decoration: none;
+    	font-size: 28px;
+    	font-size: 1.75rem;
+    	color: #9c9c9c;
     }
-    div.cmt-notification div.cmt-cnt a {
-    	text-decoration: underline;
-		color: #ffffff;
+
+    /*--- Comment Styles in Live Update Notification ---*/
+	div.cmt-notif-comment {
+		position: relative;
+		width: 80%;
+		margin-left: auto;
+		margin-right: auto;
+	}
+	div.cmt-notif-avatar {
+		position: absolute;
+		top: 0px;
+		left: 0px;
+    	text-align: center;
+    }
+    div.cmt-notif-avatar .sys-icon {
+    	font-size: 60px;
+		font-size: 3.75rem;
     }
-    div.cmt-notification div.cmt-cnt a:hover,
-    div.cmt-notification div.cmt-cnt a:active {
+    div.cmt-notif-info {
+    	position: realtive;
+	}
+	div.cmt-notifi-username {
+		line-height: 24px;
+		line-height: 1.5rem;
+
+		white-space: nowrap;
+		text-overflow: ellipsis;
+    	overflow: hidden;
+	}
+	div.cmt-notifi-actions a {
+		text-decoration: underline;
+		color: #ffffff;
+	}
+	div.cmt-notifi-actions a:hover,
+    div.cmt-notifi-actions a:active {
     	text-decoration: none;
-	}
+		color: #ffffff;
+    }

+ 103 - 82
template/scripts/BxBaseCmts.php

@@ -82,8 +82,9 @@ class BxBaseCmts extends BxDolCmts
         $aDp['show_empty'] = true;
 
 		//add live update
-		$sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
+		$this->actionResumeLiveUpdate();
 
+		$sServiceCall = BxDolService::getSerializedService('system', 'get_live_updates_comments', array($this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'), 'TemplCmtsServices');
 		BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
 		//add live update
 
@@ -188,20 +189,6 @@ class BxBaseCmts extends BxDolCmts
 
         $sActions = $this->_getActionsBox($aCmt, $aDp);
 
-        $sText = $aCmt['cmt_text'];
-        $sTextMore = '';
-
-        $iMaxLength = (int)$this->_aSystem['chars_display_max'];
-        if(strlen($sText) > $iMaxLength) {
-            $iLength = strpos($sText, ' ', $iMaxLength);
-
-            $sTextMore = trim(substr($sText, $iLength));
-            $sText = trim(substr($sText, 0, $iLength));
-        }
-
-        $sText = $this->_prepareTextForOutput($sText, $aCmt['cmt_id']);
-        $sTextMore = $this->_prepareTextForOutput($sTextMore, $aCmt['cmt_id']);
-
         $aTmplReplyTo = array();
         if((int)$aCmt['cmt_parent_id'] != 0) {
             $aParent = $this->getCommentRow($aCmt['cmt_parent_id']);
@@ -240,38 +227,13 @@ class BxBaseCmts extends BxDolCmts
         }
 
 		$sAgo = bx_time_js($aCmt['cmt_time']);
-        $bAuthorIcon = !empty($sAuthorIcon);
         $bObjectTitle = !empty($this->_aSystem['trigger_field_title']);
-        return $oTemplate->parseHtmlByName('comment.html', array(
+        return $oTemplate->parseHtmlByName('comment.html', array_merge(array(
             'system' => $this->_sSystem,
             'style_prefix' => $this->_sStylePrefix,
             'js_object' => $this->_sJsObjName,
             'id' => $aCmt['cmt_id'],
             'class' => $sClass,
-            'bx_if:show_icon' => array(
-                'condition' => $bAuthorIcon,
-                'content' => array(
-                    'author_icon' => $sAuthorIcon
-                )
-            ),
-            'bx_if:show_icon_empty' => array(
-                'condition' => !$bAuthorIcon,
-                'content' => array()
-            ),
-            'bx_if:show_author_link' => array(
-                'condition' => !empty($sAuthorLink),
-                'content' => array(
-                    'author_link' => $sAuthorLink,
-            		'author_title' => bx_html_attribute($sAuthorName),
-                    'author_name' => $sAuthorName
-                )
-            ),
-            'bx_if:show_author_text' => array(
-                'condition' => empty($sAuthorLink),
-                'content' => array(
-                    'author_name' => $sAuthorName
-                )
-            ),
             'bx_if:show_reply_to' => array(
                 'condition' => !empty($aTmplReplyTo),
                 'content' => $aTmplReplyTo
@@ -290,15 +252,6 @@ class BxBaseCmts extends BxDolCmts
                     'ago' => $sAgo
                 )
             ),
-            'text' => $sText,
-            'bx_if:show_more' => array(
-                'condition' => !empty($sTextMore),
-                'content' => array(
-                    'style_prefix' => $this->_sStylePrefix,
-                    'js_object' => $this->_sJsObjName,
-                    'text_more' => $sTextMore
-                )
-            ),
             'bx_if:show_attached' => array(
                 'condition' => !empty($aTmplImages),
                 'content' => array(
@@ -308,7 +261,7 @@ class BxBaseCmts extends BxDolCmts
             ),
             'actions' => $sActions,
             'replies' =>  $sReplies
-        ));
+        ), $this->_getTmplVarsAuthor($aCmt), $this->_getTmplVarsText($aCmt)));
     }
 
 	/**
@@ -366,43 +319,50 @@ class BxBaseCmts extends BxDolCmts
 
     function getNotification($iCountOld = 0, $iCountNew = 0)
     {
-    	$sUrl = $this->getBaseUrl();
-    	$sOnClick = '';
-
     	$iCount = (int)$iCountNew - (int)$iCountOld;
-    	if($iCount > 0) {
-    		$aCommentsIds = $this->_oQuery->getCommentsBy(array('type' => 'latest_ids', 'object_id' => $this->_iId, 'start' => '0', 'per_page' => $iCount));
-    		if(!empty($aCommentsIds) && is_array($aCommentsIds)) {
-    			$sBlink = implode(',', $aCommentsIds);
-    			$iCommentId = array_pop($aCommentsIds);
-
-				$sUrl = "javascript:void(0)";
-				$sOnClick = "javascript:" . $this->getJsObjectName() . ".goTo(this, '" . $this->_sSystem . $iCommentId . "', '" . $sBlink . "');";
-    		}
-    	}
-
-    	$oTemplate = BxDolTemplate::getInstance();
-
-    	$sReloadLinkContent = _t('_cmt_txt_reload_page');
-    	$aReloadLinkAttrs = array();
-    	if(!empty($sOnClick))
-    		$aReloadLinkAttrs[] = array('key' => 'onclick', 'value' => $sOnClick);
 
-    	$sReloadLink = $oTemplate->parseHtmlByName('bx_a.html', array(
-    		'href' => $sUrl,
-    		'title' => $sReloadLinkContent,
-    		'bx_repeat:attrs' => $aReloadLinkAttrs,
-    		'content' => $sReloadLinkContent,
-    	));
+		$aComments = $this->_oQuery->getCommentsBy(array('type' => 'latest', 'object_id' => $this->_iId, 'author' => $this->_getAuthorId(), 'others' => 1, 'start' => '0', 'per_page' => $iCount));
+		if(empty($aComments) || !is_array($aComments))
+			return '';
+
+		$sJsObject = $this->getJsObjectName();
+
+		$aComments = array_reverse($aComments);
+		$iComments = count($aComments);
+
+		$aTmplVarsNotifs = array();
+		foreach($aComments as $iIndex => $aComment) {
+			$iCommentId = $aComment['cmt_id'];
+
+			$sShowOnClick = "javascript:" . $sJsObject . ".goTo(this, '" . $this->_sSystem . $iCommentId . "', '" . $iCommentId . "');";
+			$sReplyOnClick = "javascript:" . $sJsObject . ".goToAndReply(this, '" . $this->_sSystem . $iCommentId . "', '" . $iCommentId . "');";
+
+	    	$aTmplVarsNotifs[] = array_merge(array(
+	    		'style_prefix' => $this->_sStylePrefix,
+	    		'js_object' => $sJsObject,
+	    		'bx_if:show_as_hidden' => array(
+	    			'condition' => $iIndex < ($iComments - 1),
+	    			'content' => array(),
+	    		),
+				'show_onclick' => $sShowOnClick,
+	    		'reply_onclick' => $sReplyOnClick,
+	    		'bx_if:show_previous' => array(
+	    			'condition' => $iIndex > 0,
+	    			'content' => array(
+	    				'style_prefix' => $this->_sStylePrefix,
+	    				'js_object' => $sJsObject
+	    			)
+	    		)
+			), $this->_getTmplVarsAuthor($aComment), $this->_getTmplVarsText($aComment));
+		}
 
-    	$sContent = $oTemplate->parseHtmlByName('comments_notification.html', array(
-    		'html_id' => 'cmts-notification-' . $this->_sSystem . '-' + $this->_iId,
+		return BxDolTemplate::getInstance()->parseHtmlByName('comments_notification.html', array(
+			'html_id' => $this->getNotificationId(),
 			'style_prefix' => $this->_sStylePrefix,
-			'message' => _t('_cmt_txt_n_new_comments', (int)$iCountNew - (int)$iCountOld, $sReloadLink)
+			'bx_repeat:notifs' => $aTmplVarsNotifs
 		));
-
-		return $sContent;
     }
+
     /**
      * private functions
      */
@@ -760,6 +720,67 @@ class BxBaseCmts extends BxDolCmts
 
     	return BxTemplFunctions::getInstance()->transBox($sViewImagePopupId, $sViewImagePopupContent, true);
     }
+
+    protected function _getTmplVarsAuthor($aCmt)
+    {
+    	list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']);
+    	$bAuthorIcon = !empty($sAuthorIcon);
+
+    	return array(
+    		'bx_if:show_icon' => array(
+                'condition' => $bAuthorIcon,
+                'content' => array(
+                    'author_icon' => $sAuthorIcon
+                )
+            ),
+            'bx_if:show_icon_empty' => array(
+                'condition' => !$bAuthorIcon,
+                'content' => array()
+            ),
+            'bx_if:show_author_link' => array(
+                'condition' => !empty($sAuthorLink),
+                'content' => array(
+                    'author_link' => $sAuthorLink,
+            		'author_title' => bx_html_attribute($sAuthorName),
+                    'author_name' => $sAuthorName
+                )
+            ),
+            'bx_if:show_author_text' => array(
+                'condition' => empty($sAuthorLink),
+                'content' => array(
+                    'author_name' => $sAuthorName
+                )
+            ),
+    	);
+    }
+    protected function _getTmplVarsText($aCmt)
+    {
+    	$sText = $aCmt['cmt_text'];
+        $sTextMore = '';
+
+        $iMaxLength = (int)$this->_aSystem['chars_display_max'];
+        if(strlen($sText) > $iMaxLength) {
+            $iLength = strpos($sText, ' ', $iMaxLength);
+
+            $sTextMore = trim(substr($sText, $iLength));
+            $sText = trim(substr($sText, 0, $iLength));
+        }
+
+        $sText = $this->_prepareTextForOutput($sText, $aCmt['cmt_id']);
+        $sTextMore = $this->_prepareTextForOutput($sTextMore, $aCmt['cmt_id']);
+
+        return array(
+			'text' => $sText,
+            'bx_if:show_more' => array(
+                'condition' => !empty($sTextMore),
+                'content' => array(
+                    'style_prefix' => $this->_sStylePrefix,
+                    'js_object' => $this->_sJsObjName,
+                    'text_more' => $sTextMore
+                )
+            ),
+        );
+    }
     protected function _echoResultJson($a, $isAutoWrapForFormFileSubmit = false)
     {
 

+ 7 - 1
template/scripts/BxBaseCmtsServices.php

@@ -34,8 +34,14 @@ class BxBaseCmtsServices extends BxDol
         if(!$oCmts || !$oCmts->isEnabled())
             return false;
 
+		$sKey = $oCmts->getNotificationId();
+
+		bx_import('BxDolSession');
+    	if((int)BxDolSession::getInstance()->getValue($sKey) == 1)
+    		return false;
+    	
 		$iCountNew = $oCmts->getCommentsCount($iContentId, 0, BX_CMT_FILTER_OTHERS);
-		if($iCountNew < $iCount)
+		if($iCountNew <= $iCount)
 			return false;
 
     	return array(