Jelajahi Sumber

#1 - Comments.
1. Connections.
2. Layout improvements.

AntonLV 13 tahun lalu
induk
melakukan
e3375afe83

+ 61 - 30
inc/classes/BxDolCmts.php

@@ -24,7 +24,10 @@ define('BX_CMT_BROWSE_CONNECTION', 'connection');
 
 define('BX_CMT_ORDER_BY_DATE', 'date');
 define('BX_CMT_ORDER_BY_POPULAR', 'popular');
-define('BX_CMT_ORDER_BY_CONNECTION', 'connection');
+
+define('BX_CMT_FILTER_ALL', 'all');
+define('BX_CMT_FILTER_FRIENDS', 'friends');
+define('BX_CMT_FILTER_SUBSCRIPTIONS', 'subscriptions');
 
 define('BX_CMT_ORDER_WAY_ASC', 'asc');
 define('BX_CMT_ORDER_WAY_DESC', 'desc');
@@ -142,6 +145,9 @@ class BxDolCmts extends BxDol
 
 	protected $_aImageUploaders;
 
+	protected $_sConnObjFriends;
+	protected $_sConnObjSubscriptions;
+
 	protected $_sViewUrl = '';
 	protected $_sBaseUrl = '';
 	protected $_sListAnchor = '';
@@ -157,7 +163,9 @@ class BxDolCmts extends BxDol
     protected $_iDpMaxLevel = 0;
 
     protected $_sBrowseType = '';
-    protected $_sBpSessionKey = ''; 
+    protected $_sBrowseFilter = '';
+    protected $_sBpSessionKeyType = '';
+    protected $_sBpSessionKeyFilter = ''; 
     protected $_aOrder = array();
 
     protected $_iRememberTime = 2592000;
@@ -187,18 +195,21 @@ class BxDolCmts extends BxDol
         $this->_sDpSessionKey = 'bx_' . $this->_sSystem . '_dp_';
 
         $this->_sBrowseType = $this->_aSystem['browse_type'];
-        $this->_sBpSessionKey = 'bx_' . $this->_sSystem . '_bp_';
+        $this->_sBrowseFilter = BX_CMT_FILTER_ALL;
+        $this->_sBpSessionKeyType = 'bx_' . $this->_sSystem . '_bpt_';
+        $this->_sBpSessionKeyFilter = 'bx_' . $this->_sSystem . '_bpf_';
         $this->_aOrder = array(
         	'by' => BX_CMT_ORDER_BY_DATE, 
         	'way' => BX_CMT_ORDER_WAY_ASC
         );
 
-        list($mixedUserBp, $mixedUserDp) = $this->_getUserChoice();
-        if(!empty($mixedUserBp))
-        	$this->_sBrowseType = $mixedUserBp;
-
+        list($mixedUserDp, $mixedUserBpType, $mixedUserBpFilter) = $this->_getUserChoice();
 		if(!empty($mixedUserDp))
 			$this->_sDisplayType = $mixedUserDp;
+        if(!empty($mixedUserBpType))
+        	$this->_sBrowseType = $mixedUserBpType;
+		if(!empty($mixedUserBpFilter))
+        	$this->_sBrowseFilter = $mixedUserBpFilter;
 
         $this->_sViewUrl = BX_DOL_URL_ROOT . 'cmts.php';
         $this->_sBaseUrl = $this->_aSystem['base_url'];
@@ -216,6 +227,9 @@ class BxDolCmts extends BxDol
 		$this->_sTranscoderPreview = 'sys_cmts_images_preview';
 
 		$this->_aImageUploaders = array('sys_cmts_simple');
+		
+		$this->_sConnObjFriends = 'sys_profiles_friends';
+		$this->_sConnObjSubscriptions = 'sys_profiles_subscriptions';
 
         if ($iInit)
             $this->init($iId);
@@ -356,6 +370,22 @@ class BxDolCmts extends BxDol
     	return sprintf($this->_sListAnchor, str_replace('_', '-', $this->getSystemName()), $this->getId());
     }
 
+    public function getConnectionObject($sType)
+    {
+    	$sResult = '';
+
+    	switch($sType) {
+    		case BX_CMT_FILTER_FRIENDS:
+    			$sResult = $this->_sConnObjFriends;
+    			break;
+    		case BX_CMT_FILTER_SUBSCRIPTIONS:
+    			$sResult = $this->_sConnObjSubscriptions;
+    			break;
+    	}
+
+    	return $sResult;
+    } 
+
     public function isNl2br ()
     {
         return $this->_aSystem['nl2br'];
@@ -420,14 +450,14 @@ class BxDolCmts extends BxDol
     	return $this->_oQuery->getObjectTitle ($iObjectId ? $iObjectId : $this->getId());
     }
 
-    public function getObjectCommentsCount ($iObjectId = 0)
+	public function getCommentsCount ($iObjectId = 0, $iCmtVParentId = 0, $sFilter = '')
     {
-        return $this->_oQuery->getObjectCommentsCount ($iObjectId ? $iObjectId : $this->getId());
+        return $this->_oQuery->getCommentsCount ($iObjectId ? $iObjectId : $this->getId(), $iCmtVParentId, $this->_getAuthorId(), $sFilter);
     }
 
-    public function getCommentsArray ($iVParentId, $aOrder, $iStart = 0, $iCount = -1)
+    public function getCommentsArray ($iVParentId, $sFilter, $aOrder, $iStart = 0, $iCount = -1)
     {
-        return $this->_oQuery->getComments ($this->getId(), $iVParentId, $this->_getAuthorId(), $aOrder, $iStart, $iCount);
+        return $this->_oQuery->getComments ($this->getId(), $iVParentId, $this->_getAuthorId(), $sFilter, $aOrder, $iStart, $iCount);
     }
 
     public function getCommentRow ($iCmtId)
@@ -573,8 +603,9 @@ class BxDolCmts extends BxDol
         $iCmtPerView = isset($_REQUEST['CmtPerView']) ? bx_process_input($_REQUEST['CmtPerView'], BX_DATA_INT) : -1;
         $sCmtBrowse = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
         $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
+        $sCmtFilter = isset($_REQUEST['CmtFilter']) ? bx_process_input($_REQUEST['CmtFilter'], BX_DATA_TEXT) : '';
 
-        return $this->getComments(array('vparent_id' => $iCmtVParentId, 'start' => $iCmtStart, 'per_view' => $iCmtPerView, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay));
+        return $this->getComments(array('vparent_id' => $iCmtVParentId, 'start' => $iCmtStart, 'per_view' => $iCmtPerView, 'type' => $sCmtBrowse, 'filter' => $sCmtFilter), array('type' => $sCmtDisplay));
     }
 
 	public function actionGetImage ()
@@ -784,6 +815,7 @@ class BxDolCmts extends BxDol
 	protected function _prepareParams(&$aBp, &$aDp)
     {
     	$aBp['type'] = isset($aBp['type']) && !empty($aBp['type']) ? $aBp['type'] : $this->_sBrowseType;
+    	$aBp['filter'] = isset($aBp['filter']) && !empty($aBp['filter']) ? $aBp['filter'] : $this->_sBrowseFilter;
     	$aBp['parent_id'] = isset($aBp['parent_id']) ? $aBp['parent_id'] : 0;
     	$aBp['start'] = isset($aBp['start']) ? $aBp['start'] : -1;
     	$aBp['per_view'] = isset($aBp['per_view']) ? $aBp['per_view'] : -1;
@@ -810,16 +842,9 @@ class BxDolCmts extends BxDol
 					'way' => BX_CMT_ORDER_WAY_DESC
 				);
 				break;
-
-			case BX_CMT_BROWSE_CONNECTION:
-				$aBp['order'] = array(
-					'by' => BX_CMT_ORDER_BY_CONNECTION,
-					'way' => BX_CMT_ORDER_WAY_DESC
-				);
-				break;
 		}
 
-		$aBp['count'] = $this->_oQuery->getCommentsCount($this->_iId, $aBp['vparent_id']);
+		$aBp['count'] = $this->getCommentsCount($this->_iId, $aBp['vparent_id'], $aBp['filter']);
 		if($aBp['start'] != -1)
 			return;
 
@@ -832,17 +857,19 @@ class BxDolCmts extends BxDol
 			}
 		}
 
-		$this->_setUserChoice($aBp['type'], $aDp['type']);
+		$this->_setUserChoice($aDp['type'], $aBp['type'], $aBp['filter']);
     }
 
     protected function _triggerComment()
     {
-        if (!$this->_aSystem['trigger_table'])
+        if(!$this->_aSystem['trigger_table'])
             return false;
+
         $iId = $this->getId();
-        if (!$iId)
+        if(!$iId)
             return false;
-        $iCount = $this->_oQuery->getObjectCommentsCount ($iId);
+
+        $iCount = $this->getCommentsCount($iId);
         return $this->_oQuery->updateTriggerTable($iId, $iCount);
     }
 
@@ -881,13 +908,14 @@ class BxDolCmts extends BxDol
     	bx_import('BxDolSession');
     	$oSession = BxDolSession::getInstance();
 
-    	$mixedBp = $oSession->getValue($this->_sBpSessionKey . $iUserId);
     	$mixedDp = $oSession->getValue($this->_sDpSessionKey . $iUserId);
+    	$mixedBpType = $oSession->getValue($this->_sBpSessionKeyType . $iUserId);
+    	$mixedBpFilter = $oSession->getValue($this->_sBpSessionKeyFilter . $iUserId);
 
-    	return array($mixedBp, $mixedDp);
+    	return array($mixedDp, $mixedBpType, $mixedBpFilter);
     }
 
-    protected function _setUserChoice($sBp, $sDp)
+    protected function _setUserChoice($sDp, $sBpType, $sBpFilter)
     {
     	if(!isLogged())
     		return;
@@ -897,11 +925,14 @@ class BxDolCmts extends BxDol
     	bx_import('BxDolSession');
     	$oSession = BxDolSession::getInstance();
 
-    	if(!empty($sBp))
-	    	$oSession->setValue($this->_sBpSessionKey . $iUserId, $sBp);
-
     	if(!empty($sDp))
     		$oSession->setValue($this->_sDpSessionKey . $iUserId, $sDp);
+
+    	if(!empty($sBpType))
+	    	$oSession->setValue($this->_sBpSessionKeyType . $iUserId, $sBpType);
+	    	
+	    if(!empty($sBpFilter))
+	    	$oSession->setValue($this->_sBpSessionKeyFilter . $iUserId, $sBpFilter);
     }
 
 	protected function _sendNotificationEmail($iCmtId, $iCmtParentId)

+ 44 - 41
inc/classes/BxDolCmtsQuery.php

@@ -48,50 +48,62 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->_sTable;
     }
 
-	function getCommentsCount ($iId, $iCmtVParentId = 0) {
+	function getCommentsCount ($iId, $iCmtVParentId = 0, $iAuthorId = 0, $sFilter = '') {
 		$sWhereParent = '';
         if((int)$iCmtVParentId >= 0)
-        	$sWhereParent = $this->prepare(" AND `cmt_vparent_id` = ?", $iCmtVParentId);
+        	$sWhereParent = $this->prepare(" AND `{$this->_sTable}`.`cmt_vparent_id` = ?", $iCmtVParentId);
+
+        $sJoin = '';
+		if(in_array($sFilter, array(BX_CMT_FILTER_FRIENDS, BX_CMT_FILTER_SUBSCRIPTIONS))) {
+			bx_import('BxDolConnection');
+			$oConnection = BxDolConnection::getObjectInstance($this->_oMain->getConnectionObject($sFilter));
+			
+			$aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sTable, 'cmt_author_id', $iAuthorId);
+			$sJoin .= ' ' . $aQueryParts['join'];
+		}
+
+		$sQuery = $this->prepare("SELECT 
+				COUNT(*) 
+			FROM `{$this->_sTable}`
+			$sJoin 
+			WHERE `{$this->_sTable}`.`cmt_object_id` = ?" . $sWhereParent, $iId);
 
-		$sQuery = $this->prepare("SELECT COUNT(*) FROM `{$this->_sTable}` WHERE `cmt_object_id` = ?" . $sWhereParent, $iId);
 		return (int)$this->getOne($sQuery);
 	}
 
-    function getComments ($iId, $iCmtVParentId = 0, $iAuthorId = 0, $aOrder = array(), $iStart = 0, $iCount = -1)
+    function getComments ($iId, $iCmtVParentId = 0, $iAuthorId = 0, $sFilter = '', $aOrder = array(), $iStart = 0, $iCount = -1)
     {
         $sFields = "'' AS `cmt_rated`,";
 
         $sJoin = "";
         if ($iAuthorId) {
             $sFields = "`r`.`cmt_rate` AS `cmt_rated`,";
-            $sJoin = $this->prepare(" LEFT JOIN `{$this->_sTableTrack}` AS `r` ON (`r`.`cmt_system_id` = ? AND `r`.`cmt_id` = `c`.`cmt_id` AND `r`.`cmt_rate_author_id` = ?)", $this->_oMain->getSystemId(), $iAuthorId);
+            $sJoin = $this->prepare(" LEFT JOIN `{$this->_sTableTrack}` AS `r` ON (`r`.`cmt_system_id` = ? AND `r`.`cmt_id` = `{$this->_sTable}`.`cmt_id` AND `r`.`cmt_rate_author_id` = ?)", $this->_oMain->getSystemId(), $iAuthorId);
         }
 
         $sWhereParent = '';
         if((int)$iCmtVParentId >= 0)
-        	$sWhereParent = $this->prepare(" AND `c`.`cmt_vparent_id` = ?", $iCmtVParentId);
+        	$sWhereParent = $this->prepare(" AND `{$this->_sTable}`.`cmt_vparent_id` = ?", $iCmtVParentId);
+
+		if(in_array($sFilter, array(BX_CMT_FILTER_FRIENDS, BX_CMT_FILTER_SUBSCRIPTIONS))) {
+			bx_import('BxDolConnection');
+			$oConnection = BxDolConnection::getObjectInstance($this->_oMain->getConnectionObject($sFilter));
+			
+			$aQueryParts = $oConnection->getConnectedContentAsSQLParts($this->_sTable, 'cmt_author_id', $iAuthorId);
+			$sJoin .= ' ' . $aQueryParts['join'];
+		}
 
-        $sOder = " ORDER BY `c`.`cmt_time` ASC";
+        $sOder = " ORDER BY `{$this->_sTable}`.`cmt_time` ASC";
         if(isset($aOrder['by']) && isset($aOrder['way'])) {
         	$aOrder['way'] = strtoupper(in_array($aOrder['way'], array(BX_CMT_ORDER_WAY_ASC, BX_CMT_ORDER_WAY_DESC)) ? $aOrder['way'] : BX_CMT_ORDER_WAY_ASC);
 
         	switch($aOrder['by']) {
         		case BX_CMT_ORDER_BY_DATE:
-        			$sOder = " ORDER BY `c`.`cmt_time` " . $aOrder['way'];
+        			$sOder = " ORDER BY `{$this->_sTable}`.`cmt_time` " . $aOrder['way'];
         			break;
 
         		case BX_CMT_ORDER_BY_POPULAR:
-        			$sOder = " ORDER BY `c`.`cmt_rate` " . $aOrder['way'];
-        			break;
-
-        		case BX_CMT_ORDER_BY_CONNECTION:
-        			$sFields .= " IF(NOT ISNULL(`tcs`.`id`), 1, 0) AS `cmt_author_subscriptions`,";
-        			$sFields .= " IF(NOT ISNULL(`tcc`.`id`), 1, 0) AS `cmt_author_connections`,";
-
-        			$sJoin .= $this->prepare(" LEFT JOIN `sys_profiles_conn_subscriptions` AS `tcs` ON ((`c`.`cmt_author_id`=`tcs`.`initiator` AND `tcs`.`content`=?) OR (`c`.`cmt_author_id`=`tcs`.`content` AND `tcs`.`initiator`=?))", $iAuthorId, $iAuthorId);
-        			$sJoin .= $this->prepare(" LEFT JOIN `sys_profiles_conn_friends` AS `tcc` ON ((`c`.`cmt_author_id`=`tcc`.`initiator` AND `tcc`.`content`=?) OR (`c`.`cmt_author_id`=`tcc`.`content` AND `tcc`.`initiator`=?))", $iAuthorId, $iAuthorId);
-
-        			$sOder = " ORDER BY `cmt_author_connections` " . $aOrder['way'] . ",`cmt_author_subscriptions` " . $aOrder['way'] . ",`c`.`cmt_time` ASC";
+        			$sOder = " ORDER BY `{$this->_sTable}`.`cmt_rate` " . $aOrder['way'];
         			break;
 	        }
         }
@@ -100,20 +112,20 @@ class BxDolCmtsQuery extends BxDolDb
 
         $sQuery = $this->prepare("SELECT
                 $sFields
-                `c`.`cmt_id`,
-                `c`.`cmt_parent_id`,
-                `c`.`cmt_vparent_id`,
-                `c`.`cmt_object_id`,
-                `c`.`cmt_author_id`,
-                `c`.`cmt_level`,
-                `c`.`cmt_text`,
-                `c`.`cmt_rate`,
-                `c`.`cmt_rate_count`,
-                `c`.`cmt_replies`,
-                `c`.`cmt_time`
-            FROM `{$this->_sTable}` AS `c`
+                `{$this->_sTable}`.`cmt_id`,
+                `{$this->_sTable}`.`cmt_parent_id`,
+                `{$this->_sTable}`.`cmt_vparent_id`,
+                `{$this->_sTable}`.`cmt_object_id`,
+                `{$this->_sTable}`.`cmt_author_id`,
+                `{$this->_sTable}`.`cmt_level`,
+                `{$this->_sTable}`.`cmt_text`,
+                `{$this->_sTable}`.`cmt_rate`,
+                `{$this->_sTable}`.`cmt_rate_count`,
+                `{$this->_sTable}`.`cmt_replies`,
+                `{$this->_sTable}`.`cmt_time`
+            FROM `{$this->_sTable}`
             $sJoin
-            WHERE `c`.`cmt_object_id` = ?" . $sWhereParent . $sOder . $sLimit, $iId);
+            WHERE `{$this->_sTable}`.`cmt_object_id` = ?" . $sWhereParent . $sOder . $sLimit, $iId);
 
         return $this->getAll($sQuery);
     }
@@ -259,15 +271,6 @@ class BxDolCmtsQuery extends BxDolDb
         $this->query ("OPTIMIZE TABLE {$this->_sTable}");
     }
 
-    function getObjectCommentsCount ($iObjectId, $iParentId = -1)
-    {
-        $sWhere = '';
-        if ($iParentId != -1)
-            $sWhere = $this->prepare(" AND `cmt_parent_id` = ?", $iParentId);
-        $sQuery = $this->prepare("SELECT COUNT(*) FROM `" . $this->_sTable ."` WHERE `cmt_object_id` = ? " . $sWhere, $iObjectId);
-        return $this->getOne ($sQuery);
-    }
-
 	function getObjectTitle($iId)
     {
         $sQuery = $this->prepare("SELECT `{$this->_sTriggerFieldTitle}` FROM `{$this->_sTriggerTable}` WHERE `{$this->_sTriggerFieldId}` = ? LIMIT 1", $iId);

+ 1 - 0
inc/classes/BxDolTemplate.php

@@ -322,6 +322,7 @@ class BxDolTemplate extends BxDol implements iBxDolSingleton {
         bx_import('BxDolLanguages');
         $this->addJsTranslation(array(
             '_are you sure?',
+        	'_error occured'
         ));
 
         //--- Load injection's cache ---//

+ 18 - 6
inc/js/classes/BxDolCmts.js

@@ -13,8 +13,9 @@ function BxDolCmts (options) {
     this._sActionsUrl = options.sRootUrl + 'cmts.php'; // actions url address
 
     this._sPostFormPosition = undefined == options.sPostFormPosition ? 'top' : options.sPostFormPosition;
-    this._sBrowseType = undefined == options.sBrowseType ? 'tail' : options.sBrowseType;
     this._sDisplayType = undefined == options.sDisplayType ? 'threaded' : options.sDisplayType;
+    this._sBrowseType = undefined == options.sBrowseType ? 'tail' : options.sBrowseType;
+    this._sBrowseFilter = undefined == options.sBrowseFilter ? 'all' : options.sBrowseFilter;
 
     this._sAnimationEffect = 'fade';
     this._iAnimationSpeed = 'slow';
@@ -247,7 +248,7 @@ BxDolCmts.prototype.cmtLoad = function(oLink, iCmtParentId, iStart, iPerView)
 	else 
 		this._loading($(oLink).parents('ul.cmts:first'), true);
 
-	this._getCmts(null, iCmtParentId, iStart, iPerView, this._sBrowseType, this._sDisplayType, function(sListId, sContent) {
+	this._getCmts(null, iCmtParentId, iStart, iPerView, this._sDisplayType, this._sBrowseType, this._sBrowseFilter, function(sListId, sContent) {
 		if(bButton)
 			$this._loadingInButton(oLink, false);
 		else 
@@ -260,7 +261,7 @@ BxDolCmts.prototype.cmtLoad = function(oLink, iCmtParentId, iStart, iPerView)
 BxDolCmts.prototype.cmtChangeDisplay = function(oLink, sType)
 {
 	var $this = this;
-	this._getCmts(oLink, 0, undefined, undefined, this._sBrowseType, sType, function(sListId, sContent) {
+	this._getCmts(oLink, 0, undefined, undefined, sType, this._sBrowseType, this._sBrowseFilter, function(sListId, sContent) {
 		$this._sDisplayType = sType;
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
@@ -269,12 +270,21 @@ BxDolCmts.prototype.cmtChangeDisplay = function(oLink, sType)
 BxDolCmts.prototype.cmtChangeBrowse = function(oLink, sType)
 {
 	var $this = this;
-	this._getCmts(oLink, 0, undefined, undefined, sType, this._sDisplayType, function(sListId, sContent) {
+	this._getCmts(oLink, 0, undefined, undefined, this._sDisplayType, sType, this._sBrowseFilter, function(sListId, sContent) {
 		$this._sBrowseType = sType;
 		$this._cmtsReplaceContent($(sListId), sContent);
 	});
 };
 
+BxDolCmts.prototype.cmtChangeFilter = function(oLink, sType)
+{
+	var $this = this;
+	this._getCmts(oLink, 0, undefined, undefined, this._sDisplayType, $this._sBrowseType, sType, function(sListId, sContent) {
+		$this._sBrowseFilter = sType;
+		$this._cmtsReplaceContent($(sListId), sContent);
+	});
+};
+
 BxDolCmts.prototype.showReplacement = function(iCmtId)
 {
     $('#cmt' + iCmtId + '-hidden').bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function(){
@@ -442,7 +452,7 @@ BxDolCmts.prototype._getCmt = function (e, iCmtId)
     );
 };
 
-BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sBrowseType, sDisplayType, onLoad)
+BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sDisplayType, sBrowseType, sBrowseFilter, onLoad)
 {
     var $this = this;
     var oData = this._getDefaultActions();    
@@ -456,6 +466,8 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sBro
         oData['CmtDisplay'] = sDisplayType;
     if(sBrowseType)
         oData['CmtBrowse'] = sBrowseType;
+    if(sBrowseFilter)
+        oData['CmtFilter'] = sBrowseFilter;
 
     var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
 
@@ -562,5 +574,5 @@ BxDolCmts.prototype._loadingInButton = function(e, bShow) {
 };
 
 BxDolCmts.prototype._confirm = function() {
-    return confirm(aDolLang['_Are you sure?']);
+    return confirm(_t('_are you sure?'));
 };

+ 4 - 4
modules/boonex/english/data/langs/system.xml

@@ -1036,7 +1036,6 @@ We may update our Privacy Statement from time to time so please visit this page
 	<string name="_Week"><![CDATA[Week]]></string>
 	<string name="_Year"><![CDATA[Year]]></string>
 	<string name="_Hacker String"><![CDATA[This may be a hacker string]]></string>
-	<string name="_Error Occured"><![CDATA[Error Occured]]></string>
 	<string name="_Get BoonEx ID"><![CDATA[Get BoonEx ID]]></string>
 	<string name="_Import BoonEx ID"><![CDATA[Import BoonEx ID]]></string>
 	<string name="_Import"><![CDATA[Import]]></string>
@@ -1156,10 +1155,9 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_FieldCaption_TermsOfUse_Join"><![CDATA[I have read and agreed with <a href="terms_of_use.php" target="_blank">Terms of Use</a>.]]></string>
 	<string name="_You must agree with terms of use"><![CDATA[You must agree with terms of use]]></string>
 	<string name="_There_are_no_comments_yet"><![CDATA[There are no comments yet]]></string>
-	<string name="_Error occured"><![CDATA[Error occurred]]></string>
+	<string name="_error occured"><![CDATA[Error occurred]]></string>
 	<string name="_Duplicate vote"><![CDATA[Duplicate vote]]></string>
 	<string name="_No such comment"><![CDATA[No such comment]]></string>
-	<string name="_Are you sure?"><![CDATA[Are you sure?]]></string>
 	<string name="_buried"><![CDATA[buried]]></string>
 	<string name="_toggle"><![CDATA[toggle]]></string>
 	<string name="_see_more"><![CDATA[see more]]></string>
@@ -1178,7 +1176,9 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_cmt_browse_tail"><![CDATA[Newest]]></string>
 	<string name="_cmt_browse_head"><![CDATA[Oldest]]></string>
 	<string name="_cmt_browse_popular"><![CDATA[Popular]]></string>
-	<string name="_cmt_browse_connection"><![CDATA[Connection]]></string>
+	<string name="_cmt_browse_all"><![CDATA[All]]></string>
+	<string name="_cmt_browse_friends"><![CDATA[Friends]]></string>
+	<string name="_cmt_browse_subscriptions"><![CDATA[Subscriptions]]></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_block_comments_title"><![CDATA[Comments ({0})]]></string>

+ 7 - 3
template/comments_controls.html

@@ -1,5 +1,9 @@
 __display_switcher__
-<bx_if:is_divider>
+<bx_if:is_divider_1>
 	<div class="bx-def-hr bx-def-margin-sec-topbottom"></div>
-</bx_if:is_divider>
-__browse_switcher__
+</bx_if:is_divider_1>
+__browse_switcher__
+<bx_if:is_divider_2>
+	<div class="bx-def-hr bx-def-margin-sec-topbottom"></div>
+</bx_if:is_divider_2>
+__filter_switcher__

+ 2 - 4
template/css/cmts.css

@@ -179,10 +179,8 @@
 		text-decoration: none;
 		color: rgba(0, 102, 153, 1.0);
     }
-    div.cmt-comment-manage {
-    	position: relative;
-    	min-width: 150px; 
-    	text-align: left;
+    div.cmt-comment-manage .bx-menu-ver li {
+		white-space: nowrap;
     }
 
     /*--- Comment Plused By ---*/

+ 30 - 14
template/scripts/BxBaseCmtsView.php

@@ -37,10 +37,6 @@ class BxBaseCmtsView extends BxDolCmts {
 
         $oTemplate->addCss(array('cmts.css'));
         $oTemplate->addJs(array('common_anim.js', 'jquery.form.js', 'BxDolCmts.js'));
-        $oTemplate->addJsTranslation(array(
-        	'_Error occured',
-        	'_Are you sure?'
-        ));
 
         bx_import('BxDolForm');
         $oForm = BxDolForm::getObjectInstance($this->_sFormObject, $this->_sFormDisplayPost);
@@ -77,7 +73,7 @@ class BxBaseCmtsView extends BxDolCmts {
 
     	$sCmts = $this->getComments($aBp);
 
-    	$sCaption = _t('_cmt_block_comments_title', $this->_oQuery->getCommentsCount($this->_iId));
+    	$sCaption = _t('_cmt_block_comments_title', $this->getCommentsCount());
     	$sContent = BxDolTemplate::getInstance()->parseHtmlByName('comments_block.html', array(
     		'system' => $this->_sSystem,
     		'list_anchor' => $this->getListAnchor(),
@@ -113,7 +109,7 @@ class BxBaseCmtsView extends BxDolCmts {
     {
     	$this->_prepareParams($aBp, $aDp);
 
-		$aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['order'], $aBp['start'], $aBp['per_view']);
+		$aCmts = $this->getCommentsArray($aBp['vparent_id'], $aBp['filter'], $aBp['order'], $aBp['start'], $aBp['per_view']);
 		if(empty($aCmts) || !is_array($aCmts))
 			return '';
 
@@ -384,31 +380,51 @@ class BxBaseCmtsView extends BxDolCmts {
         	$sDisplay = $oMenu->getCode();
     	}
 
-    	$sBrowse = '';
-    	$bBrowse = (int)$this->_aSystem['is_browse_switch'] == 1;
-    	if($bBrowse) {
+    	$sBrowseType = '';
+    	$bBrowseType = (int)$this->_aSystem['is_browse_switch'] == 1;
+    	if($bBrowseType) {
     		$aBrowseLinks = array(
     			array('id' => $this->_sSystem . '-tail', 'name' => $this->_sSystem . '-tail', 'class' => '', 'title' => '_cmt_browse_tail', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'tail\');'),
 				array('id' => $this->_sSystem . '-head', 'name' => $this->_sSystem . '-head', 'class' => '', 'title' => '_cmt_browse_head', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'head\');'),
 				array('id' => $this->_sSystem . '-popular', 'name' => $this->_sSystem . '-popular', 'class' => '', 'title' => '_cmt_browse_popular', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'popular\');'),
-				array('id' => $this->_sSystem . '-connection', 'name' => $this->_sSystem . '-connection', 'class' => '', 'title' => '_cmt_browse_connection', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeBrowse(this, \'connection\');')
     		);
 
     		bx_import('BxTemplMenuInteractive');
 			$oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $this->_sSystem . '-browse', 'menu_items' => $aBrowseLinks));
 			$oMenu->setSelected('', $this->_sSystem . '-' . $this->_sBrowseType);
-        	$sBrowse = $oMenu->getCode();
+        	$sBrowseType = $oMenu->getCode();
+    	}
+
+    	$sBrowseFilter = '';
+    	$bBrowseFilter = $bBrowseType;
+    	if($bBrowseFilter) {
+    		$aFilterLinks = array(
+	        	array('id' => $this->_sSystem . '-all', 'name' => $this->_sSystem . '-all', 'class' => '', 'title' => '_cmt_browse_all', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeFilter(this, \'all\');'),
+        		array('id' => $this->_sSystem . '-friends', 'name' => $this->_sSystem . '-friends', 'class' => '', 'title' => '_cmt_browse_friends', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeFilter(this, \'friends\');'),
+				array('id' => $this->_sSystem . '-subscriptions', 'name' => $this->_sSystem . '-subscriptions', 'class' => '', 'title' => '_cmt_browse_subscriptions', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeFilter(this, \'subscriptions\');')
+        	);
+
+        	$oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive_vertical.html', 'menu_id'=> $this->_sSystem . '-filter', 'menu_items' => $aFilterLinks));
+			$oMenu->setSelected('', $this->_sSystem . '-' . $this->_sBrowseFilter);
+        	$sBrowseFilter = $oMenu->getCode();
     	}
 
     	return $oTemplate->parseHtmlByName('comments_controls.html', array(
     		'display_switcher' => $bDisplay ? $sDisplay : '',
-    		'bx_if:is_divider' => array(
-    			'condition' => $bDisplay && $bBrowse,
+    		'bx_if:is_divider_1' => array(
+    			'condition' => $bDisplay && $bBrowseType,
+    			'content' => array(
+    				'style_prefix' => $this->_sStylePrefix,
+    			)
+    		),
+    		'browse_switcher' => $bBrowseType ? $sBrowseType : '',
+    		'bx_if:is_divider_2' => array(
+    			'condition' => $bBrowseType && $bBrowseFilter,
     			'content' => array(
     				'style_prefix' => $this->_sStylePrefix,
     			)
     		),
-    		'browse_switcher' => $bBrowse ? $sBrowse : '',
+    		'filter_switcher' => $bBrowseFilter ? $sBrowseFilter : '',
 		));
     }