AntonLV 13 лет назад
Родитель
Сommit
c2bd98ccc3

+ 49 - 9
inc/classes/BxDolCmts.php

@@ -134,11 +134,15 @@ class BxDolCmts extends BxDol
     var $_aCmtElements = array (); ///< comment submit form elements
     var $_aCmtElements = array (); ///< comment submit form elements
 
 
     var $_sDisplayType = '';
     var $_sDisplayType = '';
+    var $_sDpSessionKey = '';
     var $_iDpMaxLevel = 0;
     var $_iDpMaxLevel = 0;
 
 
     var $_sBrowseType = '';
     var $_sBrowseType = '';
+    var $_sBpSessionKey = ''; 
     var $_aOrder = array();
     var $_aOrder = array();
 
 
+    var $_iRememberTime = 2592000;
+
     /**
     /**
      * Constructor
      * Constructor
      * $sSystem - comments system name
      * $sSystem - comments system name
@@ -165,13 +169,22 @@ class BxDolCmts extends BxDol
 
 
         $this->_iDpMaxLevel = (int)$this->_aSystem['number_of_levels'];
         $this->_iDpMaxLevel = (int)$this->_aSystem['number_of_levels'];
         $this->_sDisplayType = $this->_iDpMaxLevel == 0 ? BX_CMT_DISPLAY_FLAT : BX_CMT_DISPLAY_THREADED;
         $this->_sDisplayType = $this->_iDpMaxLevel == 0 ? BX_CMT_DISPLAY_FLAT : BX_CMT_DISPLAY_THREADED;
+        $this->_sDpSessionKey = 'bx_' . $this->_sSystem . '_dp_';
 
 
         $this->_sBrowseType = $this->_aSystem['browse_type'];
         $this->_sBrowseType = $this->_aSystem['browse_type'];
+        $this->_sBpSessionKey = 'bx_' . $this->_sSystem . '_bp_';
         $this->_aOrder = array(
         $this->_aOrder = array(
         	'by' => BX_CMT_ORDER_BY_DATE, 
         	'by' => BX_CMT_ORDER_BY_DATE, 
         	'way' => BX_CMT_ORDER_WAY_ASC
         	'way' => BX_CMT_ORDER_WAY_ASC
         );
         );
 
 
+        list($mixedUserBp, $mixedUserDp) = $this->_getUserChoice();
+        if(!empty($mixedUserBp))
+        	$this->_sBrowseType = $mixedUserBp;
+
+		if(!empty($mixedUserDp))
+			$this->_sDisplayType = $mixedUserDp;
+
         $this->_oQuery = new BxDolCmtsQuery($this);
         $this->_oQuery = new BxDolCmtsQuery($this);
         $this->_sHomeUrl = BX_DOL_URL_ROOT . trim($_SERVER['REQUEST_URI'], '/');
         $this->_sHomeUrl = BX_DOL_URL_ROOT . trim($_SERVER['REQUEST_URI'], '/');
         $this->_sViewUrl = BX_DOL_URL_ROOT . 'cmts.php';
         $this->_sViewUrl = BX_DOL_URL_ROOT . 'cmts.php';
@@ -322,10 +335,8 @@ class BxDolCmts extends BxDol
         return $iDeletedRecords;
         return $iDeletedRecords;
     }
     }
 
 
-
     /** comments functions
     /** comments functions
      *********************************************/
      *********************************************/
-
     function getCommentsArray ($iVParentId, $aOrder, $iStart = 0, $iCount = -1)
     function getCommentsArray ($iVParentId, $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(), $aOrder, $iStart, $iCount);
@@ -341,8 +352,6 @@ class BxDolCmts extends BxDol
         return $this->_oQuery->deleteObjectComments ($iObjectId ? $iObjectId : $this->getId());
         return $this->_oQuery->deleteObjectComments ($iObjectId ? $iObjectId : $this->getId());
     }
     }
 
 
-
-
     /**
     /**
      * delete all profiles comments in all systems, if some replies exist, set this comment to anonymous
      * delete all profiles comments in all systems, if some replies exist, set this comment to anonymous
      */
      */
@@ -356,15 +365,11 @@ class BxDolCmts extends BxDol
         return true;
         return true;
     }
     }
 
 
-
-
     function getCommentsTableName ()
     function getCommentsTableName ()
     {
     {
         return $this->_oQuery->getTableName ();
         return $this->_oQuery->getTableName ();
     }
     }
 
 
-
-
     function getObjectCommentsCount ($iObjectId = 0)
     function getObjectCommentsCount ($iObjectId = 0)
     {
     {
         return $this->_oQuery->getObjectCommentsCount ($iObjectId ? $iObjectId : $this->getId());
         return $this->_oQuery->getObjectCommentsCount ($iObjectId ? $iObjectId : $this->getId());
@@ -373,7 +378,6 @@ class BxDolCmts extends BxDol
 
 
 
 
     /** permissions functions
     /** permissions functions
-
     *********************************************/
     *********************************************/
 
 
     // is rate comment allowed
     // is rate comment allowed
@@ -743,6 +747,8 @@ class BxDolCmts extends BxDol
     			$aBp['start'] = 0;
     			$aBp['start'] = 0;
 			}
 			}
 		}
 		}
+
+		$this->_setUserChoice($aBp['type'], $aDp['type']);
     }
     }
 
 
     function _triggerComment()
     function _triggerComment()
@@ -759,6 +765,40 @@ class BxDolCmts extends BxDol
     function _isSpam($s) {
     function _isSpam($s) {
         return bx_is_spam($s);
         return bx_is_spam($s);
     }
     }
+
+    function _getUserChoice()
+    {
+    	$mixedBp = $mixedDp = false;
+    	if(!isLogged())
+    		return array($mixedBp, $mixedDp);
+
+    	$iUserId = $this->_getAuthorId();
+
+    	bx_import('BxDolSession');
+    	$oSession = BxDolSession::getInstance();
+
+    	$mixedBp = $oSession->getValue($this->_sBpSessionKey . $iUserId);
+    	$mixedDp = $oSession->getValue($this->_sDpSessionKey . $iUserId);
+
+    	return array($mixedBp, $mixedDp);
+    }
+
+    function _setUserChoice($sBp, $sDp)
+    {
+    	if(!isLogged())
+    		return;
+
+    	$iUserId = $this->_getAuthorId();
+
+    	bx_import('BxDolSession');
+    	$oSession = BxDolSession::getInstance();
+
+    	if(!empty($sBp))
+	    	$oSession->setValue($this->_sBpSessionKey . $iUserId, $sBp);
+
+    	if(!empty($sDp))
+    		$oSession->setValue($this->_sDpSessionKey . $iUserId, $sDp);
+    }
 }
 }
 
 
 /** @} */
 /** @} */

+ 15 - 10
inc/js/classes/BxDolCmts.js

@@ -85,12 +85,12 @@ BxDolCmts.prototype.cmtUpdate = function (f, iCmtId)
     // submit form
     // submit form
     oData['action'] = 'CmtEditSubmit';
     oData['action'] = 'CmtEditSubmit';
     oData['Cmt'] = iCmtId;
     oData['Cmt'] = iCmtId;
-    this._loading (eSubmit, true);
+    this._loadingInBlock (eSubmit, true);
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function (oResponse) {
         function (oResponse) {
-            $this._loading (eSubmit, false);
+            $this._loadingInBlock (eSubmit, false);
             if (!jQuery.trim(oResponse.text).length)
             if (!jQuery.trim(oResponse.text).length)
                 $this._error(eSubmit, true, jQuery.trim(oResponse.err).length ? oResponse.err : aDolLang['_Error occured']); // display error
                 $this._error(eSubmit, true, jQuery.trim(oResponse.err).length ? oResponse.err : aDolLang['_Error occured']); // display error
             else
             else
@@ -114,13 +114,13 @@ BxDolCmts.prototype.cmtReload = function(iCmtId) {
     oData['Type'] = 'reload';
     oData['Type'] = 'reload';
 
 
     var eUl = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > div.cmts > ul').get();
     var eUl = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > div.cmts > ul').get();
-    this._loading (eUl, true);
+    this._loadingInBlock (eUl, true);
 
 
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function (s) {
         function (s) {
-            $this._loading (eUl, false);
+            $this._loadingInBlock (eUl, false);
             $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' li#cmt' + iCmtId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
             $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' li#cmt' + iCmtId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                 $(this).replaceWith(s);
                 $(this).replaceWith(s);
             });
             });
@@ -231,13 +231,13 @@ BxDolCmts.prototype.cmtMore = function(oLink, iCmtParentId, iStart, iPerView)
 	if(bButton)
 	if(bButton)
 		this._loadingInButton(oLink, true);
 		this._loadingInButton(oLink, true);
 	else 
 	else 
-		this._loading(oLink, true);
+		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._sBrowseType, this._sDisplayType, function(sListId, sContent) {
 		if(bButton)
 		if(bButton)
 			$this._loadingInButton(oLink, false);
 			$this._loadingInButton(oLink, false);
 		else 
 		else 
-			$this._loading(oLink, false);
+			$this._loading($(oLink).parents('ul.cmts:first'), false);
 
 
 		$this._cmtsReplace($(oLink).parents('li:first'), sContent);
 		$this._cmtsReplace($(oLink).parents('li:first'), sContent);
 	});
 	});
@@ -346,14 +346,14 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sBro
     var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
     var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
 
 
     if(e)
     if(e)
-        this._loading(e, true);
+        this._loadingInBlock(e, true);
 
 
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function(s) {
         function(s) {
         	if(e)
         	if(e)
-        		$this._loading(e, false);
+        		$this._loadingInBlock(e, false);
 
 
         	if(typeof onLoad == 'function')
         	if(typeof onLoad == 'function')
     			onLoad(sListId, s);
     			onLoad(sListId, s);
@@ -399,13 +399,13 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
     oData['CmtBrowse'] = this._sBrowseType;
     oData['CmtBrowse'] = this._sBrowseType;
     oData['CmtDisplay'] = this._sDisplayType;
     oData['CmtDisplay'] = this._sDisplayType;
 
 
-    this._loading (f);
+    this._loadingInBlock (f);
 
 
     jQuery.post (
     jQuery.post (
         this._sActionsUrl,
         this._sActionsUrl,
         oData,
         oData,
         function (oData) {
         function (oData) {
-            $this._loading (f, false);
+            $this._loadingInBlock (f, false);
 
 
             var sListId = $this._sRootId + ' #cmt' + oData.vparent_id + ' > ul';
             var sListId = $this._sRootId + ' #cmt' + oData.vparent_id + ' > ul';
             var sReplyFormId = $this._sRootId + ' #cmt' + oData.parent_id + ' > .cmt-reply';
             var sReplyFormId = $this._sRootId + ' #cmt' + oData.parent_id + ' > .cmt-reply';
@@ -469,6 +469,11 @@ BxDolCmts.prototype._getDefaultActions = function() {
 };
 };
 
 
 BxDolCmts.prototype._loading = function(e, bShow) {
 BxDolCmts.prototype._loading = function(e, bShow) {
+	var oParent = $(e).length ? $(e) : $('body'); 
+	bx_loading(oParent, bShow);
+};
+
+BxDolCmts.prototype._loadingInBlock = function(e, bShow) {
 	var oParent = $(e).length ? $(e).parents('.bx-db-content:first') : $('body'); 
 	var oParent = $(e).length ? $(e).parents('.bx-db-content:first') : $('body'); 
 	bx_loading(oParent, bShow);
 	bx_loading(oParent, bShow);
 };
 };

+ 1 - 1
template/comment.html

@@ -1,4 +1,4 @@
-<li id="cmt__id__" class="__style_prefix____class__">
+<li id="cmt__id__" class="__style_prefix____class__ cmt-border bx-def-margin-top bx-def-padding-top">
 	<a name="__system____id__"></a>
 	<a name="__system____id__"></a>
 	<div class="__style_prefix__-icon">
 	<div class="__style_prefix__-icon">
 		<bx_if:show_icon>
 		<bx_if:show_icon>

+ 1 - 1
template/comment_more.html

@@ -1,4 +1,4 @@
-<li class="__style_prefix__-more<bx_if:is_root>-root</bx_if:is_root> bx-def-margin-top">
+<li class="__style_prefix__-more<bx_if:is_root>-root</bx_if:is_root> cmt-border bx-def-margin-top bx-def-padding-top">
 	<div class="__style_prefix__-more-cont">
 	<div class="__style_prefix__-more-cont">
 		<div class="__style_prefix__-more-line bx-def-hr"></div>
 		<div class="__style_prefix__-more-line bx-def-hr"></div>
 		<a class="<bx_if:is_button>bx-btn</bx_if:is_button>" href="javascript:void(0)" onclick="javascript:__js_object__.cmtMore(this, __parent_id__, __start__, __per_view__)">__title__</a>
 		<a class="<bx_if:is_button>bx-btn</bx_if:is_button>" href="javascript:void(0)" onclick="javascript:__js_object__.cmtMore(this, __parent_id__, __start__, __per_view__)">__title__</a>

+ 1 - 1
template/comment_reply_box.html

@@ -1,4 +1,4 @@
-<div class="__style_prefix__-reply<bx_if:show_class> __class__</bx_if:show_class>">
+<div class="__style_prefix__-reply<bx_if:show_class> __class__</bx_if:show_class> cmt-border bx-def-margin-top bx-def-padding-top">
 	<div class="__style_prefix__-icon">
 	<div class="__style_prefix__-icon">
 		<bx_if:show_icon>
 		<bx_if:show_icon>
 			<img src="__author_icon__" />
 			<img src="__author_icon__" />

+ 6 - 6
template/css/cmts.css

@@ -1,20 +1,21 @@
 /* TODO: remake according to the new design */
 /* TODO: remake according to the new design */
     /*--- General Styles ---*/
     /*--- General Styles ---*/
+	.cmt-border {
+		border-top: 1px solid #eeeeee;
+	}
+
     div.cmts {}
     div.cmts {}
 
 
     ul.cmts {
     ul.cmts {
+    	position: relative;
         margin: 0px;
         margin: 0px;
         padding: 0px;
         padding: 0px;
         list-style: none;
         list-style: none;
     }
     }
     ul.cmts-margin {}
     ul.cmts-margin {}
-    li.cmt,
-    ul.cmts-margin li.cmt {
+    li.cmt {
     	position: relative;
     	position: relative;
-    	padding-top: 20px;
     	padding-left: 84px;
     	padding-left: 84px;
-		margin-top: 20px;
-    	border-top: 1px solid #eeeeee;
     }
     }
     li.cmt:first-child {
     li.cmt:first-child {
 		margin-top: 0px;
 		margin-top: 0px;
@@ -157,7 +158,6 @@
     }
     }
 	div.cmt-post-reply {
 	div.cmt-post-reply {
         position: relative;
         position: relative;
-		padding-top: 20px;
     	padding-left: 84px;
     	padding-left: 84px;
     }
     }
     form.cmt-post-reply .bx-form-input-textarea {
     form.cmt-post-reply .bx-form-input-textarea {