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

1. Comments.
2. Interactive menu.

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

+ 20 - 6
cmts.php

@@ -15,15 +15,29 @@ bx_import('BxDolLanguages');
 check_logged();
 
 $sSys = isset($_REQUEST['sys']) ? $_REQUEST['sys'] : '';
-$sAction = isset($_REQUEST['action']) && preg_match ('/^[A-Za-z_-]+$/', $_REQUEST['action']) ? $_REQUEST['action'] : '';
 $iId = (int)$_REQUEST['id'];
+$sAction = isset($_REQUEST['action']) && preg_match ('/^[A-Za-z_-]+$/', $_REQUEST['action']) ? $_REQUEST['action'] : '';
 
 bx_import ('BxTemplCmtsView');
 $oCmts = new BxTemplCmtsView($sSys, $iId);
 
-if ($sSys && $sAction && $iId && $oCmts) {
-    header('Content-Type: text/html; charset=utf-8');
-    $sMethod = 'action' . $sAction;
-    echo $oCmts->$sMethod();
-}
+if ($oCmts && $sSys && $iId) {
+	if($sAction) {
+	    header('Content-Type: text/html; charset=utf-8');
+	    $sMethod = 'action' . $sAction;
+	    echo $oCmts->$sMethod();
+	    exit;
+	}
 
+	$iCmtId = bx_get('cmt_id');
+	if($iCmtId !== false) {
+		$sTitle = _t('_cmt_page_header_view');
+		$sContent = DesignBoxContent($sTitle, $oCmts->getCommentBlock($iCmtId), BX_DB_PADDING_DEF);
+
+		$oTemplate = BxDolTemplate::getInstance();
+		$oTemplate->setPageNameIndex(BX_PAGE_DEFAULT);
+		$oTemplate->setPageHeader($sTitle);
+		$oTemplate->setPageContent('page_main_code', $sContent);
+		$oTemplate->getPageCode();
+	}
+}

+ 48 - 20
inc/classes/BxDolCmts.php

@@ -11,8 +11,15 @@ bx_import('BxDolCmtsQuery');
 
 define('BX_OLD_CMT_VOTES', 365*86400); ///< comment votes older than this number of seconds will be deleted automatically 
 
-define('BX_CMT_SHOW_HEAD', 'head');
-define('BX_CMT_SHOW_TAIL', 'tail');
+define('BX_CMT_DISPLAY_FLAT', 'flat');
+define('BX_CMT_DISPLAY_THREADED', 'threaded');
+
+define('BX_CMT_BROWSE_HEAD', 'head');
+define('BX_CMT_BROWSE_TAIL', 'tail');
+
+define('BX_CMT_PFP_TOP', 'top');
+define('BX_CMT_PFP_BOTTOM', 'bottom');
+define('BX_CMT_PFP_BOTH', 'both');
 
 
 /** 
@@ -107,14 +114,22 @@ define('BX_CMT_SHOW_TAIL', 'tail');
  */
 class BxDolCmts extends BxDol
 {
+	var $_oQuery = null;
+	var $_sHomeUrl = '';
+	var $_sViewUrl = '';
+
+	var $_sSystem = 'profile'; ///< current comment system name
+    var $_aSystem = array (); ///< current comments system array
+    var $_iId = 0; ///< obect id to be commented
 
-    var $_iId = 0;  ///< obect id to be commented
-    var $sTextAreaId;
-    var $_sSystem = 'profile';  ///< current comment system name
-    var $_aSystem = array ();   ///< current comments system array
     var $_aCmtElements = array (); ///< comment submit form elements
-    var $_oQuery = null;
-    var $_sOrder = 'asc';
+
+    var $_sDisplayType = '';
+    var $_iDpMaxLevel = 0;
+    var $_bDpOpened = false; ///< applied for Threaded comments only
+
+    var $_sBrowseType = '';
+    var $_sOrder = '';
 
     /**
      * Constructor
@@ -135,18 +150,24 @@ class BxDolCmts extends BxDol
 
 		$iCmtTextMin = (int)$this->_aSystem['chars_post_min'];
 		$iCmtTextMax = (int)$this->_aSystem['chars_post_max'];
-		
 		$this->_aCmtElements = array (
-            'CmtParent' => array ('reg' => '/^[0-9]+$/', 'msg' => _t('_bad comment parent id')),
-            'CmtText' => array ('reg' => '/^.{' . $iCmtTextMin . ',' . $iCmtTextMax . '}$/m', 'msg' => _t('_Please enter ' . $iCmtTextMin . '-' . $iCmtTextMax . ' characters'))
+            'CmtParent' => array ('reg' => '^[0-9]+$', 'msg' => _t('_bad comment parent id')),
+            'CmtText' => array ('reg' => '^.{' . $iCmtTextMin . ',' . $iCmtTextMax . '}$', 'msg' => _t('_Please enter ' . $iCmtTextMin . '-' . $iCmtTextMax . ' characters'))
         );
 
+        $this->_iDpMaxLevel = 3;//(int)$this->_aSystem['number_of_levels'];
+        $this->_sDisplayType = $this->_iDpMaxLevel == 0 ? BX_CMT_DISPLAY_FLAT : BX_CMT_DISPLAY_THREADED;
+        $this->_bDpOpened = true;
+
+        $this->_sBrowseType = $this->_aSystem['browse_type'];
+        $this->_sOrder = 'asc';
+
         $this->_oQuery = new BxDolCmtsQuery($this->_aSystem);
+        $this->_sHomeUrl = BX_DOL_URL_ROOT . trim($_SERVER['REQUEST_URI'], '/');
+        $this->_sViewUrl = BX_DOL_URL_ROOT . 'cmts.php';
 
         if ($iInit)
             $this->init($iId);
-
-        $this->sTextAreaId = "cmt" . str_replace(' ', '', ucwords(str_replace('_', ' ', $this->_sSystem))) . "TextAreaParent";
     }
 
     function & getSystems ()
@@ -165,10 +186,11 @@ class BxDolCmts extends BxDol
                     `Nl2br` AS `nl2br`,
                     `PerView` AS `per_view`,
                     `PerViewReplies` AS `per_view_replies`,
+                    `BrowseType` AS `browse_type`,
+                    `IsBrowseSwitch` AS `is_browse_switch`,
+                    `PostFormPosition` AS `post_form_position`,
                     `NumberOfLevels` AS `number_of_levels`,
-                    `IsLevelsSwitch` AS `is_levels_switch`,
-                    `Show` AS `show`,
-                    `IsShowSwitch` AS `is_show_switch`,
+                    `IsDisplaySwitch` AS `is_display_switch`,
                     `IsRatable` AS `is_ratable`,
                     `ViewingThreshold` AS `viewing_threshold`,
                     `IsOn` AS `is_on`,
@@ -408,10 +430,11 @@ class BxDolCmts extends BxDol
         if (!$this->isEnabled())
            return '';
 
-        $sCmtType = isset($_REQUEST['CmtType']) ? bx_process_input($_REQUEST['CmtType']) : 'reply';
         $iCmtParentId= isset($_REQUEST['CmtParent']) ? bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT) : 0;
+        $sCmtBrowse = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
+        $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
 
-        return $this->getFormBox($sCmtType, $iCmtParentId);
+        return $this->getFormBox(array('parent_id' => $iCmtParentId, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay));
     }
 
     function actionCmtsGet () {
@@ -421,7 +444,10 @@ class BxDolCmts extends BxDol
         $iCmtParentId = bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT);
         $iCmtStart = isset($_REQUEST['CmtStart']) ? bx_process_input($_REQUEST['CmtStart'], BX_DATA_INT) : -1;
         $iCmtPerView = isset($_REQUEST['CmtPerView']) ? bx_process_input($_REQUEST['CmtPerView'], BX_DATA_INT) : -1;
-        return $this->getComments($iCmtParentId, $iCmtStart, $iCmtPerView);
+        $sCmtBrowse = isset($_REQUEST['CmtBrowse']) ? bx_process_input($_REQUEST['CmtBrowse'], BX_DATA_TEXT) : '';
+        $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
+
+        return $this->getComments(array('parent_id' => $iCmtParentId, 'start' => $iCmtStart, 'per_view' => $iCmtPerView, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay));
     }
 
     function actionCmtGet () {
@@ -429,7 +455,9 @@ class BxDolCmts extends BxDol
            return '';
 
         $iCmtId = bx_process_input($_REQUEST['Cmt'], BX_DATA_INT);
-        return $this->getComment($iCmtId);
+        $sCmtDisplay = isset($_REQUEST['CmtDisplay']) ? bx_process_input($_REQUEST['CmtDisplay'], BX_DATA_TEXT) : '';
+
+        return $this->getComment($iCmtId, array('type' => $sCmtDisplay));
     }
 
     function actionCmtPost ()

+ 27 - 19
inc/classes/BxDolCmtsQuery.php

@@ -31,7 +31,11 @@ class BxDolCmtsQuery extends BxDolDb
     }
 
 	function getCommentsCount ($iId, $iCmtParentId = 0) {
-		$sQuery = $this->prepare("SELECT COUNT(*) FROM `{$this->_sTable}` WHERE `cmt_object_id` = ? AND `cmt_parent_id` = ?", $iId, $iCmtParentId);
+		$sWhereParent = '';
+        if((int)$iCmtParentId >= 0)
+        	$sWhereParent = $this->prepare(" AND `cmt_parent_id` = ?", $iCmtParentId);
+
+		$sQuery = $this->prepare("SELECT COUNT(*) FROM `{$this->_sTable}` WHERE `cmt_object_id` = ?" . $sWhereParent, $iId);
 		return (int)$this->getOne($sQuery);
 	}
 
@@ -41,13 +45,17 @@ class BxDolCmtsQuery extends BxDolDb
         $iTimestamp = time();
         $sFields = "'' AS `cmt_rated`,";
 
-        $sJoin = '';
+        $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->_aSystem['system_id'], $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->_aSystem['system_id'], $iAuthorId);
         }
 
-        $sLimit = $iCount != -1 ? $this->prepare(' LIMIT ?, ?', (int)$iStart, (int)$iCount) : '';
+        $sWhereParent = '';
+        if((int)$iCmtParentId >= 0)
+        	$sWhereParent = $this->prepare(" AND `c`.`cmt_parent_id` = ?", $iCmtParentId);
+
+        $sLimit = $iCount != -1 ? $this->prepare(" LIMIT ?, ?", (int)$iStart, (int)$iCount) : '';
 
         $sQuery = $this->prepare("SELECT
                 $sFields
@@ -55,18 +63,17 @@ class BxDolCmtsQuery extends BxDolDb
                 `c`.`cmt_parent_id`,
                 `c`.`cmt_object_id`,
                 `c`.`cmt_author_id`,
+                `c`.`cmt_level`,
                 `c`.`cmt_text`,
                 `c`.`cmt_mood`,
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_replies`,
-                (? - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
-                `p`.`id` AS `cmt_author_name`
-            FROM {$this->_sTable} AS `c`
-            LEFT JOIN `sys_profiles` AS `p` ON (`p`.`id` = `c`.`cmt_author_id`)
+                (? - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`
+            FROM `{$this->_sTable}` AS `c`
             $sJoin
-            WHERE `c`.`cmt_object_id` = ? AND `c`.`cmt_parent_id` = ?
-            ORDER BY `c`.`cmt_time` " . (strtoupper($sCmtOrder) == 'ASC' ? 'ASC' : 'DESC') . $sLimit, $iTimestamp, $iId, $iCmtParentId);
+            WHERE `c`.`cmt_object_id` = ?" . $sWhereParent . "
+            ORDER BY `c`.`cmt_time` " . (strtoupper($sCmtOrder) == 'ASC' ? 'ASC' : 'DESC') . $sLimit, $iTimestamp, $iId);
 
         $a = $this->getAll($sQuery);
 
@@ -95,15 +102,14 @@ class BxDolCmtsQuery extends BxDolDb
                 `c`.`cmt_parent_id`,
                 `c`.`cmt_object_id`,
                 `c`.`cmt_author_id`,
+                `c`.`cmt_level`,
                 `c`.`cmt_text`,
                 `c`.`cmt_mood`,
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_replies`,
-                ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
-                `p`.`NickName` AS `cmt_author_name`
+                ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`
             FROM {$this->_sTable} AS `c`
-            LEFT JOIN `Profiles` AS `p` ON (`p`.`ID` = `c`.`cmt_author_id`)
             $sJoin
             WHERE `c`.`cmt_object_id` = ? AND `c`.`cmt_id` = ?
             LIMIT 1", $iId, $iCmtId);
@@ -129,20 +135,22 @@ class BxDolCmtsQuery extends BxDolDb
 
     function addComment ($iId, $iCmtParentId, $iAuthorId, $sText)
     {
+    	$sQuery = $this->prepare("SELECT `cmt_level`+1 FROM {$this->_sTable} WHERE `cmt_id`=? LIMIT 1", $iCmtParentId);
+    	$iLevel = (int)$iCmtParentId > 0 ? (int)$this->getOne($sQuery) : 0;
+
         $sQuery = $this->prepare("INSERT INTO {$this->_sTable} SET
             `cmt_parent_id` = ?,
             `cmt_object_id` = ?,
             `cmt_author_id` = ?,
+            `cmt_level` = ?,
             `cmt_text` = ?,
-            `cmt_time` = NOW()", $iCmtParentId, $iId, $iAuthorId, $sText);
-        if (!$this->query($sQuery))
-        {
+            `cmt_time` = NOW()", $iCmtParentId, $iId, $iAuthorId, $iLevel, $sText);
+        if(!$this->query($sQuery))
             return false;
-        }
 
         $iRet = $this->lastId();
 
-        if ($iCmtParentId) {
+        if($iCmtParentId) {
             $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_replies` = `cmt_replies` + 1 WHERE `cmt_id` = ? LIMIT 1", $iCmtParentId);
             $this->query ($sQuery);
         }

+ 105 - 107
inc/js/classes/BxDolCmts.js

@@ -4,60 +4,6 @@
  * @license     CC-BY - http://creativecommons.org/licenses/by/3.0/
  */
 
-$.fn.bxdolcmtanim = function(action, effect, speed, h)
-{
-   return this.each(function()
-   {
-           var sFunc = '';
-           var sEval;
-
-           if (0 == speed)
-               effect = 'default';
-
-          switch (action)
-          {
-              case 'show':
-                  switch (effect)
-                  {
-                      case 'slide': sFunc = 'slideDown'; break;
-                      case 'fade': sFunc = 'fadeIn'; break;
-                      default: sFunc = 'show';
-                  }
-                  break;
-              case 'hide':
-                  switch (effect)
-                  {
-                      case 'slide': sFunc = 'slideUp'; break;
-                      case 'fade': sFunc = 'fadeOut'; break;
-                      default: sFunc = 'hide';
-                  }
-                  break;
-              default:
-              case 'toggle':
-                  switch (effect)
-                  {
-                      case 'slide': sFunc = 'slideToggle'; break;
-                      case 'fade': sFunc = ($(this).filter(':visible').length) ? 'fadeOut' : 'fadeIn'; break;
-                      default: sFunc = 'toggle';
-                  }
-          }
-
-          if ((0 == speed || undefined == speed) && undefined == h) {
-              sEval = '$(this).' + sFunc + '();';
-          }
-          else if ((0 == speed || undefined == speed) && undefined != h) {
-              sEval = '$(this).' + sFunc + '(); $(this).each(h);';
-          }
-          else {
-              sEval = '$(this).' + sFunc + "('" + speed + "', h);";
-          }
-          eval(sEval);
-
-          return this;
-   });
-};
-
-
 function BxDolCmts (options) {
     this.oCmtElements = {}; // form elements
     this._sObjName = undefined == options.sObjName ? 'oCmts' : options.sObjName;    // javascript object name, to run current object instance from onTimer
@@ -65,22 +11,18 @@ function BxDolCmts (options) {
     this._sSystemTable = options.sSystemTable; // current comment system table name
     this._iAuthorId = options.iAuthorId; // this comment's author ID.
     this._iObjId = options.iObjId; // this object id comments
-    this._sOrder = options.sOrder == 'asc' || options.sOrder == 'desc' ? options.sOrder : 'asc'; // comments' order
     this._sActionsUrl = options.sBaseUrl + 'cmts.php'; // actions url address
-    this._sDefaultErrMsg = undefined == options.sDefaultErrMsg ? 'Errod Occured' : options.sDefaultErrMsg; // default error message
-    this._sConfirmMsg = undefined == options.sConfirmMsg ? 'Are you sure?' : options.sConfirmMsg; // confirm message
-    this._sAnimationEffect = 'slide';
+
+    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._sAnimationEffect = 'fade';
     this._iAnimationSpeed = 'slow';
 
     this._oSavedTexts = {};
-
-    this._sAnimationEffect = undefined == options.sAnimationEffect ? 'slide' : options.sAnimationEffect;
-    this._iAnimationSpeed = undefined == options.sAnimationSpeed ? 'slow' : options.sAnimationSpeed;
     this._sRootId = '#cmts-box-' + this._sSystem + '-' + this._iObjId;
 
-    //'A' Use global allow HTML param
-    this._sTextAreaId = undefined == options.sTextAreaId || options.sTextAreaId == '' ? 'cmtTextAreaParent' : options.sTextAreaId;
-
     // init post comment form (because browser remeber last inputs, we need to clear it)
     if ($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form').length) {
     	$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form')[0].reset();
@@ -118,7 +60,7 @@ BxDolCmts.prototype.cmtSubmit = function (f)
                 $this._getCmt(f, oData['CmtParent'], iNewCmtId); // display just posted comment
             }
             else if (!jQuery.trim(s).length) {
-                $this._error(eSubmit, true, $this._sDefaultErrMsg); // display error
+                $this._error(eSubmit, true, aDolLang['_Error occured']); // display error
             }
             else {
                 $this._error(eSubmit, true, s); // display error
@@ -149,14 +91,14 @@ BxDolCmts.prototype.cmtUpdate = function (f, iCmtId)
         function (oResponse) {
             $this._loading (eSubmit, false);
             if (!jQuery.trim(oResponse.text).length)
-                $this._error(eSubmit, true, jQuery.trim(oResponse.err).length ? oResponse.err : $this._sDefaultErrMsg); // display error
+                $this._error(eSubmit, true, jQuery.trim(oResponse.err).length ? oResponse.err : aDolLang['_Error occured']); // display error
             else
-                $('#cmt' + iCmtId + ' .cmt-body').bxdolcmtanim(
+                $('#cmt' + iCmtId + ' .cmt-body').bx_anim(
                     'hide',
                     $this._sAnimationEffect,
                     $this._iAnimationSpeed,
                     function() {
-                        $(this).html(oResponse.text).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                        $(this).html(oResponse.text).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                     });
         },
         'json'
@@ -178,7 +120,7 @@ BxDolCmts.prototype.cmtReload = function(iCmtId) {
         oData,
         function (s) {
             $this._loading (eUl, false);
-            $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' li#cmt' + iCmtId).bxdolcmtanim('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);
             });
 
@@ -206,7 +148,7 @@ BxDolCmts.prototype.cmtRemove = function(e, iCmtId) {
             if (jQuery.trim(s).length)
                 alert(s);
             else
-                $('#cmt' + iCmtId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                $('#cmt' + iCmtId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
                 	var oCounter = $(this).parent('ul.cmts').siblings('.cmt-cont').find('.cmt-actions a.cmt-comment-replies span');
                 	if(oCounter)
                 		oCounter.html(oCounter.html() - 1);
@@ -223,19 +165,18 @@ BxDolCmts.prototype.cmtEdit = function(oLink, iCmtId) {
     oData['action'] = 'CmtEdit';
     oData['Cmt'] = iCmtId;
 
-    var sBodyId = this._sRootId + ' #cmt' + iCmtId + ' .cmt-body';
-    
-    this._loading (oLink, true);
-
+    var sBodyId = this._sRootId + ' #cmt' + iCmtId + ' .cmt-body:first';
     if ($(sBodyId + ' > form').length) {
-        $(sBodyId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-            $(this).html($this._oSavedTexts[iCmtId]).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+        $(sBodyId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+            $(this).html($this._oSavedTexts[iCmtId]).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
         });
         return;
     }
     else
         this._oSavedTexts[iCmtId] = $(sBodyId).html();
 
+    this._loading (oLink, true);
+
     jQuery.post (
         this._sActionsUrl,
         oData,
@@ -245,8 +186,8 @@ BxDolCmts.prototype.cmtEdit = function(oLink, iCmtId) {
         	if(s.substring(0,3) == 'err')
         		alert(s.substring(3));
             else
-                $(sBodyId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                    $(this).html(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                $(sBodyId).bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                    $(this).html(s).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                 });
         }
     );
@@ -283,15 +224,33 @@ BxDolCmts.prototype.cmtRate = function(e, iCmtId, iRate)
 BxDolCmts.prototype.cmtMore = function(oLink, iCmtParentId, iStart, iPerView)
 {
 	var $this = this;
-	this._getCmts(oLink, iCmtParentId, iStart, iPerView, function(sListId, sContent) {
-		$this._replaceCmts($(oLink).parent('.cmt-more'), sContent);
+	this._getCmts(oLink, iCmtParentId, iStart, iPerView, this._sBrowseType, this._sDisplayType, function(sListId, sContent) {
+		$this._cmtsReplace($(oLink).parents('.cmt-more'), sContent);
+	});
+};
+
+BxDolCmts.prototype.cmtChangeDisplay = function(oLink, sType)
+{
+	var $this = this;
+	this._getCmts(oLink, 0, undefined, undefined, this._sBrowseType, sType, function(sListId, sContent) {
+		$this._sDisplayType = sType;
+		$this._cmtsReplaceContent($(sListId), sContent);
+	});
+};
+
+BxDolCmts.prototype.cmtChangeBrowse = function(oLink, sType)
+{
+	var $this = this;
+	this._getCmts(oLink, 0, undefined, undefined, sType, this._sDisplayType, function(sListId, sContent) {
+		$this._sBrowseType = sType;
+		$this._cmtsReplaceContent($(sListId), sContent);
 	});
 };
 
 BxDolCmts.prototype.showReplacement = function(iCmtId)
 {
-    $('#cmt' + iCmtId + '-hidden').bxdolcmtanim('hide', this._sAnimationEffect, this._iAnimationSpeed, function(){
-        $(this).next('#cmt' + iCmtId).bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
+    $('#cmt' + iCmtId + '-hidden').bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function(){
+        $(this).next('#cmt' + iCmtId).bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
     });
 };
 
@@ -303,16 +262,18 @@ BxDolCmts.prototype.seeMore = function(oLink)
 BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
 {
 	var sParentId = this._sRootId + ' #cmt' + iCmtParentId;
-	var sReplyId = sParentId + ' .cmt-reply';
+	var sReplyId = sParentId + ' > .cmt-reply';
 
     if ($(sReplyId).length)
-		$(sReplyId).bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+		$(sReplyId).bx_anim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
     else {
         var $this = this;
         var oData = this._getDefaultActions();
         oData['action'] = 'FormGet';
         oData['CmtType'] = 'reply';
         oData['CmtParent'] = iCmtParentId;
+        oData['CmtBrowse'] = this._sBrowseType;
+        oData['CmtDisplay'] = this._sDisplayType;
 
         $this._loading (e, true);
 
@@ -321,7 +282,32 @@ BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
             oData,
             function (s) {
                 $this._loading(e, false);
-            	$(sParentId).append($(s).addClass('cmt-reply-expanded').css('display', 'none')).children('.cmt-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
+
+                var oForm = $(s).css('display', 'none');
+                var sFormClass = oForm.attr('class');
+                var oFormSibling = $(sParentId + ' > ul.cmts:first');
+                switch($this._sPostFormPosition) {
+                	case 'top':
+                		oForm.addClass(sFormClass + '-' + $this._sPostFormPosition);
+                		oFormSibling.before(oForm);
+                		break;
+
+                	case 'bottom':
+                		oForm.addClass(sFormClass + '-' + $this._sPostFormPosition);
+                		oFormSibling.after(oForm);
+                		break;
+
+                	case 'both':
+                		var oFormClone = oForm.clone();
+
+                		oForm.addClass(sFormClass + '-top');
+                		oFormSibling.before(oForm);
+
+                		oFormClone.addClass(sFormClass + '-bottom');
+                		oFormSibling.after(oFormClone);
+                		break;
+                }
+            	$(sParentId).children('.cmt-reply').bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
             }
         );
     }
@@ -332,13 +318,13 @@ BxDolCmts.prototype.toggleCmts = function(e, iCmtParentId)
 	var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul';
 
 	if(!$(sListId + ' > li').length)
-		this._getCmts(e, iCmtParentId);
+		this._getCmts(e, iCmtParentId, undefined, undefined, this._sBrowseType, this._sDisplayType);
 	else
-		$( sListId).bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+		$( sListId).bx_anim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
 // get comment replies via ajax request
-BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, onLoad)
+BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, sBrowseType, sDisplayType, onLoad)
 {
     var $this = this;
     var oData = this._getDefaultActions();    
@@ -348,6 +334,10 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, onLo
         oData['CmtStart'] = iStart;
     if(parseInt(iPerView) >= 0)
         oData['CmtPerView'] = iPerView;
+    if(sDisplayType)
+        oData['CmtDisplay'] = sDisplayType;
+    if(sBrowseType)
+        oData['CmtBrowse'] = sBrowseType;
 
     var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
 
@@ -363,30 +353,36 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, onLo
         	if(typeof onLoad == 'function')
     			onLoad(sListId, s);
         	else
-        		$this._appendCmts(sListId, s);
+        		$this._cmtsAppend(sListId, s);
         }
     );
 };
 
-BxDolCmts.prototype._appendCmts = function(sIdTo, sContent)
+BxDolCmts.prototype._cmtsAppend = function(sIdTo, sContent)
 {
-	$(sIdTo).append($(sContent).hide()).children(':hidden').bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
+	$(sIdTo).append($(sContent).hide()).children(':hidden').bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
-BxDolCmts.prototype._prependCmts = function(sIdTo, sContent)
+BxDolCmts.prototype._cmtsPrepend = function(sIdTo, sContent)
 {
-	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
+	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bx_anim('show', this._sAnimationEffect, this._iAnimationSpeed);
 };
 
-BxDolCmts.prototype._replaceCmts = function(oReplace, sContent)
+BxDolCmts.prototype._cmtsReplace = function(oReplace, sContent)
 {
 	var $this = this;
-	$(oReplace).bxdolcmtanim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
-		$(this).after($(sContent).hide()).nextAll(':hidden').bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+	$(oReplace).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
+		$(this).after($(sContent).hide()).nextAll(':hidden').bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
 		$(this).remove();
 	});
 };
-
+BxDolCmts.prototype._cmtsReplaceContent = function(oParent, sContent)
+{
+	var $this = this;
+	$(oParent).bx_anim('hide', this._sAnimationEffect, this._iAnimationSpeed, function() {
+		$(this).html(sContent).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+	});
+};
 
 // get just posted 1 comment via ajax request
 BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
@@ -395,6 +391,7 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
     var oData = this._getDefaultActions();
     oData['action'] = 'CmtGet';
     oData['Cmt'] = iCmtId;
+    oData['CmtDisplay'] = this._sDisplayType;
 
     var sParentId =  this._sRootId + ' #cmt' + iCmtParentId;
     var sListId =  sParentId + ' > ul';
@@ -411,22 +408,22 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
             if (iCmtParentId == 0) {
                 //--- Some number of comments already loaded ---//
                 if($(sListId + ' > li.cmt').length)
-                    $(sListId + ' > li.cmt:last').after($(s).hide()).next('li.cmt:hidden').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
+                    $(sListId + ' > li.cmt:last').after($(s).hide()).next('li.cmt:hidden').bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
                 //-- There is no comments at all ---//
                 else
-                    $(sListId + ' > li.cmt-no').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {                    	
-                    	$(this).after($(s).hide()).next('li').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
+                    $(sListId + ' > li.cmt-no').bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {                    	
+                    	$(this).after($(s).hide()).next('li').bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
                     	$(this).remove();
                     });
             }
             else {
-                $(sParentId + ' > .cmt-reply').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                	var sRepliesId = sParentId + ' > .cmt-cont > .cmt-actions > a.cmt-comment-replies';
+                $(sParentId + ' > .cmt-reply').bx_anim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                	var sRepliesId = sParentId + ' .cmt-cont > .cmt-actions > a.cmt-comment-replies';
                 	var sCounterId = sRepliesId + ' > span';
                 	
                     //--- there was no comments and we added new
                     if(!$(sListId + ' > li.cmt').length && !$(sRepliesId).length)
-                        $(sListId).hide().append(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                        $(sListId).hide().append(s).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                     //--- there is some number of comments but they are not loaded.
                     else if(!$(sListId + ' > li.cmt').length && parseInt($(sCounterId).html()) > 0) {
                     	$(sCounterId).html(parseInt($(sCounterId).html()) + 1);
@@ -437,9 +434,9 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
                     	$(sCounterId).html(parseInt($(sCounterId).html()) + 1);
 
                         if($(sListId).is(':visible'))
-                            $(sListId).append($(s).hide()).children('li.cmt:last-of-type').bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                            $(sListId).append($(s).hide()).children('li.cmt:last-of-type').bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                         else
-                            $(sListId).append(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                            $(sListId).append(s).bx_anim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
                     }
                 });
             }
@@ -459,7 +456,8 @@ BxDolCmts.prototype._getCheckElements = function(f, oData) {
             //--- Check form's data ---//
             if ($this.oCmtElements[this.name]['reg']) {
                 try {
-                	eval('var isValid = this.value.match(' + $this.oCmtElements[this.name]['reg'] + ');');
+                	var r = new RegExp($this.oCmtElements[this.name]['reg']); 
+                 	isValid = r.test(this.value.replace(/(\n|\r)/g, ''));
                 } catch (ex) {};
             }
             if (!isValid) {
@@ -504,5 +502,5 @@ BxDolCmts.prototype._error = function(e, bShow, s) {
 };
 
 BxDolCmts.prototype._confirm = function() {
-    return confirm(this._sConfirmMsg);
+    return confirm(aDolLang['_Are you sure?']);
 };

+ 13 - 2
install/index.php

@@ -61,8 +61,8 @@ ini_set('magic_quotes_sybase', 0);
 /*----------Vars----------------*/
     $aConf = array();
     $aConf['release'] = '24.03.11';
-    $aConf['iVersion'] = '7.0';
-    $aConf['iPatch'] = '6';
+    $aConf['iVersion'] = '8.0';
+    $aConf['iPatch'] = '0';
     $aConf['dolFile'] = '../inc/header.inc.php';
     $aConf['confDir'] = '../inc/';
     $aConf['headerTempl'] = <<<EOS
@@ -141,6 +141,17 @@ define('BX_DOL_DIR_STUDIO_INC', BX_DOL_DIR_STUDIO . 'inc/');
 define('BX_DOL_DIR_STUDIO_CLASSES', BX_DOL_DIR_STUDIO . 'classes/');
 define('BX_DOL_DIR_STUDIO_BASE', BX_DOL_DIR_STUDIO . 'template/');
 
+//--- BoonEx Unity Settings ---//
+define('BX_DOL_UNITY_URL_ROOT', 'http://www.boonex.com/');
+define('BX_DOL_UNITY_URL_MARKET', BX_DOL_UNITY_URL_ROOT . 'market/');
+define('BX_DOL_UNITY_URL_PRODUCT', BX_DOL_UNITY_URL_ROOT . 'm/');
+
+//--- BoonEx OAuth Settings ---//
+define('BX_DOL_OAUTH_URL_REQUEST_TOKEN', BX_DOL_UNITY_URL_ROOT . 'scripts_public/oauth_request_token.php5');
+define('BX_DOL_OAUTH_URL_AUTHORIZE', BX_DOL_UNITY_URL_ROOT . 'scripts_public/oauth_authorize.php5');
+define('BX_DOL_OAUTH_URL_ACCESS_TOKEN', BX_DOL_UNITY_URL_ROOT . 'scripts_public/oauth_access_token.php5');
+define('BX_DOL_OAUTH_URL_FETCH_DATA', BX_DOL_UNITY_URL_ROOT . 'scripts_public/oauth_fetch_data.php5');
+
 //--- User Roles ---//
 define('BX_DOL_ROLE_GUEST', 0);
 define('BX_DOL_ROLE_MEMBER', 1);

+ 5 - 4
install/sql/v70.sql

@@ -153,13 +153,14 @@ CREATE TABLE `sys_objects_cmts` (
   `CharsPostMin` int(10) NOT NULL,
   `CharsPostMax` int(10) NOT NULL,
   `CharsDisplayMax` int(10) NOT NULL,
-  `Nl2br` smallint(1) NOT NULL,  
+  `Nl2br` smallint(1) NOT NULL,
   `PerView` smallint(6) NOT NULL,
   `PerViewReplies` smallint(6) NOT NULL,
+  `BrowseType` varchar(50) NOT NULL,
+  `IsBrowseSwitch` smallint(1) NOT NULL,
+  `PostFormPosition` varchar(50) NOT NULL,
   `NumberOfLevels` smallint(6) NOT NULL,
-  `IsLevelsSwitch` smallint(1) NOT NULL,
-  `Show` varchar(50) NOT NULL,
-  `IsShowSwitch` smallint(1) NOT NULL,
+  `IsDisplaySwitch` smallint(1) NOT NULL,
   `IsRatable` smallint(1) NOT NULL,
   `ViewingThreshold` smallint(6) NOT NULL,
   `IsOn` smallint(1) NOT NULL,

+ 7 - 0
modules/boonex/english/data/langs/system.xml

@@ -1166,6 +1166,13 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_N_replies"><![CDATA[<span>{0}</span> replies]]></string>
 	<string name="_N_comments"><![CDATA[<span>{0}</span> comments]]></string>
 	<string name="_Comment_to_this_comment"><![CDATA[Comment]]></string>
+	<string name="_cmt_display_flat"><![CDATA[Flat]]></string>
+	<string name="_cmt_display_threaded"><![CDATA[Threaded]]></string>
+	<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_page_header_view"><![CDATA[View comment]]></string>
 	<string name="_Reply_to_this_comment"><![CDATA[Reply]]></string>
 	<string name="_Add Your Comment"><![CDATA[Comment]]></string>
 	<string name="_Submit_Comment"><![CDATA[Post]]></string>

+ 22 - 0
modules/boonex/uni/data/template/system/scripts/BxTemplMenuInteractive.php

@@ -0,0 +1,22 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxBaseMenuInteractive');
+
+/**
+ * @see BxDolMenu
+ */
+class BxTemplMenuInteractive extends BxBaseMenuInteractive {
+
+    public function __construct ($aObject, $oTemplate = false) {
+        parent::__construct ($aObject, $oTemplate);
+    }
+}
+
+/** @} */

+ 6 - 5
samples/comments.php

@@ -15,14 +15,15 @@
 /**
  * DB Queries.
 
-INSERT INTO `sys_objects_cmts` (`ObjectName`, `TableCmts`, `TableTrack`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `NumberOfLevels`, `IsLevelsSwitch`, `Show`, `IsShowSwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
-('profile', 'sys_cmts_profile', 'sys_cmts_track', 3, 2048, 100, 1, 5, 3, 0, 0, 'tail', 0, 1, -3, 1, 'cmt', '', '', '', '', '');
+INSERT INTO `sys_objects_cmts` (`ID`, `ObjectName`, `TableCmts`, `TableTrack`, `CharsPostMin`, `CharsPostMax`, `CharsDisplayMax`, `Nl2br`, `PerView`, `PerViewReplies`, `BrowseType`, `IsBrowseSwitch`, `PostFormPosition`, `NumberOfLevels`, `IsDisplaySwitch`, `IsRatable`, `ViewingThreshold`, `IsOn`, `RootStylePrefix`, `TriggerTable`, `TriggerFieldId`, `TriggerFieldComments`, `ClassName`, `ClassFile`) VALUES
+(1, 'profile', 'sys_cmts_sample', 'sys_cmts_sample_track', 3, 2048, 100, 1, 5, 3, 'tail', 1, 'both', 1, 1, 1, -3, 1, 'cmt', '', '', '', '', '');
 
-CREATE TABLE IF NOT EXISTS `sys_cmts_profile` (
+CREATE TABLE IF NOT EXISTS `sys_cmts_sample` (
   `cmt_id` int(11) NOT NULL AUTO_INCREMENT,
   `cmt_parent_id` int(11) NOT NULL DEFAULT '0',
   `cmt_object_id` int(11) NOT NULL DEFAULT '0',
   `cmt_author_id` int(10) unsigned NOT NULL DEFAULT '0',
+  `cmt_level` int(11) NOT NULL DEFAULT '0',
   `cmt_text` text NOT NULL,
   `cmt_mood` tinyint(4) NOT NULL DEFAULT '0',
   `cmt_rate` int(11) NOT NULL DEFAULT '0',
@@ -33,7 +34,7 @@ CREATE TABLE IF NOT EXISTS `sys_cmts_profile` (
   KEY `cmt_object_id` (`cmt_object_id`,`cmt_parent_id`)
 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8;
 
-CREATE TABLE IF NOT EXISTS `sys_cmts_track` (
+CREATE TABLE IF NOT EXISTS `sys_cmts_sample_track` (
   `cmt_system_id` int(11) NOT NULL DEFAULT '0',
   `cmt_id` int(11) NOT NULL DEFAULT '0',
   `cmt_rate` tinyint(4) NOT NULL DEFAULT '0',
@@ -72,7 +73,7 @@ function PageCompMainCode() {
 	if(!$oCmts->isEnabled())
 		return '';
 
-    return DesignBoxContent("Comments",  $oCmts->getCommentsFirst(), BX_DB_PADDING_DEF);
+    return DesignBoxContent("Comments",  $oCmts->getCommentsBlock(), BX_DB_PADDING_DEF);
 }
 
 

+ 25 - 26
template/comment.html

@@ -1,30 +1,29 @@
-<li id="cmt__id__" class="__style_prefix____class__ bx-def-hr bx-def-margin-top">
-	<a name="__system__-__id__"></a>
-	<div class="__style_prefix__-cont bx-def-margin-top">
-		<div class="__style_prefix__-icon">__author_icon__</div>
-		<div class="__style_prefix__-head">
-			<span class="__style_prefix__-author">
-				<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__-posted-ago bx-def-padding-sec-left bx-def-font-grayed">
-				<a class="bx-def-font-grayed" href="#">__ago__</a>
-			</span>
-			<span class="bullet bx-def-font-grayed">&#183;</span><span class="__style_prefix__-points bx-def-font-grayed">__points__</span>
-			<bx_if:show_reply_to>
-				<span class="bullet bx-def-font-grayed">&#183;</span><span class="__style_prefix__-reply-to bx-def-font-grayed">
-					<bx_text:_in_reply_to /> <a href="__par_cmt_link__">__par_cmt_author__</a>
+<li id="cmt__id__" class="__style_prefix____class__">
+	<div class="__style_prefix__" style="margin-left:__margin__px;">
+		<a name="__system____id__"></a>
+		<div class="bx-def-hr bx-def-margin-bottom"></div>
+		<div class="__style_prefix__-cont">
+			<div class="__style_prefix__-icon">__author_icon__</div>
+			<div class="__style_prefix__-head">
+				<span class="__style_prefix__-author">
+					<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>
-			</bx_if:show_reply_to>
+				<bx_if:show_reply_to>
+					<span class="__style_prefix__-reply-to bx-def-padding-left bx-def-font-grayed">
+						<bx_text:_in_reply_to /> <a href="__par_cmt_link__">__par_cmt_author__</a>
+					</span>
+				</bx_if:show_reply_to>
+			</div>
+			<div class="__style_prefix__-body bx-def-margin-thd-topbottom">
+				__text__
+				<bx_if:show_more>
+					<a href="javascript:void(0)" onclick="__js_object__.seeMore(this);"> <bx_text:_see_more /></a>
+					<span style="display:none;">__text_more__</span>
+				</bx_if:show_more>
+			</div>
+			__actions__
 		</div>
-		<div class="__style_prefix__-body bx-def-margin-thd-topbottom">
-			__text__
-			<bx_if:show_more>
-				<a href="javascript:void(0)" onclick="__js_object__.seeMore(this);"> <bx_text:_see_more /></a>
-				<span style="display:none;">__text_more__</span>
-			</bx_if:show_more>
-		</div>
-		__actions__
 	</div>
-	<ul class="cmts cmts-margin"></ul>
+	<ul class="cmts cmts-margin">__replies__</ul>
 </li>

+ 8 - 6
template/comment_actions.html

@@ -1,10 +1,6 @@
 <div class="__style_prefix__-actions">
-	<bx_if:show_edit>
-		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-manage-edit bx-def-font-grayed" title="<bx_text:_Edit />" href="javascript:void(0)" onclick="__js_object__.cmtEdit(this, __id__); return false;"><bx_text:_Edit /></a>
-	</bx_if:show_edit>
-	<bx_if:show_delete>
-		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-manage-delete bx-def-font-grayed" title="<bx_text:_Delete />" href="javascript:void(0)" onclick="__js_object__.cmtRemove(this, __id__); return false;"><bx_text:_Delete /></a>
-	</bx_if:show_delete>
+	<span class="bullet">&#183;</span><a class="bx-def-font-grayed" href="__view_link__">__ago__</a>
+	<span class="bullet">&#183;</span><span class="__style_prefix__-points bx-def-font-grayed">__points__</span>
 	<bx_if:show_rate>
 		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-vote bx-def-font-grayed" title="<bx_text:_Plus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, 1)"><bx_text:_Plus /></a>
 		<!--
@@ -17,4 +13,10 @@
 	<bx_if:show_replies>
 		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-replies bx-def-font-grayed" href="javascript:void(0)" onclick="__js_object__.toggleCmts(this, __id__); return false;">__text__</a>
 	</bx_if:show_replies>
+	<bx_if:show_edit>
+		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-manage-edit bx-def-font-grayed" title="<bx_text:_Edit />" href="javascript:void(0)" onclick="__js_object__.cmtEdit(this, __id__); return false;"><bx_text:_Edit /></a>
+	</bx_if:show_edit>
+	<bx_if:show_delete>
+		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-manage-delete bx-def-font-grayed" title="<bx_text:_Delete />" href="javascript:void(0)" onclick="__js_object__.cmtRemove(this, __id__); return false;"><bx_text:_Delete /></a>
+	</bx_if:show_delete>
 </div>

+ 8 - 0
template/comment_block.html

@@ -0,0 +1,8 @@
+<div id="cmts-box-__system__-__id__">
+	<div id="cmt0" class="cmts">
+		<ul class="cmts">
+			__comment__
+		</ul>
+	</div>
+</div>
+__script__

+ 5 - 3
template/comment_more.html

@@ -1,5 +1,7 @@
 <li class="__style_prefix__-more bx-def-margin-top">
-	<a href="javascript:void(0)" onclick="javascript:__js_object__.cmtMore(this, __parent_id__, __start__, __per_view__)">
-		<bx_text:_load_more_comments />
-	</a>
+	<div class="__style_prefix__-more-cont" style="margin-left:__margin__px;">
+		<a href="javascript:void(0)" onclick="javascript:__js_object__.cmtMore(this, __parent_id__, __start__, __per_view__)">
+			<bx_text:_load_more_comments />
+		</a>
+	</div>
 </li>

+ 2 - 2
template/comment_reply_box.html

@@ -1,6 +1,6 @@
-<div class="__style_prefix__-reply bx-def-hr bx-def-margin-top">
+<div class="__style_prefix__-reply<bx_if:show_class> __class__</bx_if:show_class>" style="margin-left:__margin__px;">
+	<div class="__style_prefix__-icon">__author_icon__</div>
 	<div class="__style_prefix__-post-reply bx-def-margin-top">
-		<div class="__style_prefix__-icon">__author_icon__</div>
 	    __form__
 	</div>
 </div>

+ 4 - 6
template/comments_block.html

@@ -1,9 +1,7 @@
 <div id="cmts-box-__system__-__id__">
-	<div class="cmt-browse">
-		
-        <div class="bx-clear">&nbsp;</div>
-	</div>
-	<div id="cmt0" class="cmts">
+	__post_form_top__
+	__controls__
+	<div id="cmt0" class="cmts bx-def-margin-top">
 		<ul class="cmts">
 			<bx_if:show_empty>
 				<li class="__style_prefix__-no">
@@ -12,7 +10,7 @@
 			</bx_if:show_empty>
 			__comments__
 		</ul>
-		__reply__
 	</div>
+	__post_form_bottom__
 </div>
 __script__

+ 12 - 0
template/comments_controls.html

@@ -0,0 +1,12 @@
+<div class="__style_prefix__-browse bx-def-margin-top-auto">
+	<div class="__style_prefix__-browse-left bx-def-font-h3">__comments_count__</div>
+	<div class="__style_prefix__-browse-right bx-def-font-small">
+		__display_switcher__
+		<bx_if:is_divider>
+			<div class="__style_prefix__-browse-type-div">|</div>
+		</bx_if:is_divider>
+		__browse_switcher__
+		<div class="bx-clear"></div>
+	</div>
+	<div class="bx-clear"></div>
+</div>

+ 43 - 12
template/css/cmts.css

@@ -1,8 +1,6 @@
 /* TODO: remake according to the new design */
     /*--- General Styles ---*/
-    div.cmts {
-		margin-top: 20px;
-    }
+    div.cmts {}
 
     ul.cmts {
         margin: 0px;
@@ -10,10 +8,15 @@
         list-style: none;
     }
     ul.cmts-margin {}
-    ul.cmts li.cmt {
-        padding-left: 84px;
+    li.cmt,
+    ul.cmts-margin li.cmt {
+		margin-top: 20px;
     }
-    li.cmt-more {
+    li.cmt:first-child {
+		margin-top: 0px;
+    }
+    li.cmt-more {}
+    div.cmt-more-cont {
 		padding: 5px 0px;
     	background-color: #ededed;
     	text-indent: 5px;
@@ -42,6 +45,7 @@
     /*--- Comment ---*/
     div.cmt-cont {
         position: relative;
+    	padding-left: 84px;
     	min-height: 64px;
     }
 	div.cmt-cont .bullet {
@@ -50,7 +54,7 @@
     div.cmt-icon {
 		position: absolute;
     	top: 0px;
-    	left: -84px;
+    	left: 0px;
     	width: 64px;
     	height: 64px;
     	background-color: #cccccc;
@@ -74,20 +78,47 @@
 
     /*--- Browse Styles ---*/
     div.cmt-browse {
-        /*position: relativ_e;*/
-        background-color: #ededed;
-        font-size: 11px;
-        color: #666666;
+
     }
+    div.cmt-browse-left {
+		position: relative;
+    	float: left;
+    }
+    div.cmt-browse-right {
+    	position: relative;
+    	float: right;
+	}
+	div.cmt-browse-right ul.bx-menu-inter  {
+		float: left;
+	}
+
+	div.cmt-browse-item,
+	div.cmt-browse-item-div,
+	div.cmt-browse-type-div {
+		position: relative;
+		float: left;
+	}
+	div.cmt-browse-item-div {
+		padding: 0px 3px;
+	}
+	div.cmt-browse-type-div {
+		padding: 0px 5px;
+	}
 
     /*--- Add Comment/Reply Styles ---*/
     div.cmt-reply {
 		position: relative;
-        padding-left: 84px;
+    }
+    div.cmt-reply-top {
+		margin-bottom: 40px;
+    }
+	div.cmt-reply-bottom {
+		margin-top: 40px;
     }
 	div.cmt-reply-expanded {}
     div.cmt-post-reply {
         position: relative;
+    	padding-left: 84px;
     }
     div.cmt-post-reply form {
         display: block;

+ 22 - 0
template/css/menu.css

@@ -335,3 +335,25 @@ ul.bx-menu-floating-blocks {
 .bx-menu-floating-blocks-title {
     text-align:center;
 }
+
+
+/* --------------- interactive block menu */
+ul.bx-menu-inter {
+	padding:0;
+    margin:0;
+	list-style:none;
+}
+ul.bx-menu-inter li {
+    float:left;
+}
+li.bx-menu-inter-div {
+	padding: 0px 3px;
+}
+li.bx-menu-inter-div:first-child {
+	display: none;
+}
+li.bx-menu-inter-act {}
+li.bx-menu-inter-pas {}
+li.bx-menu-inter-hidden {
+	display: none;
+}

+ 20 - 0
template/menu_interactive.html

@@ -0,0 +1,20 @@
+<ul id="bx-menu-inter-__id__" class="bx-menu-inter">
+	<bx_repeat:menu_items>
+		<li class="bx-menu-inter-div"><span>&#183;</span></li>
+	    <li id="__id__-act" class="bx-menu-inter-act __class_wrp_act__">
+	        <span class="__class__">__title__</span>
+	    </li>
+	    <li id="__id__-pas" class="bx-menu-inter-pas __class_wrp_pas__">
+	        <a id="__id__" class="__class__" href="__link__" target="__target__" onclick="__onclick__">__title__</a>
+	    </li>
+	</bx_repeat:menu_items>
+    <div class="bx-clear"></div>
+</ul>
+<script type="text/javascript" language="javascript">
+    $(document).ready(function() {
+    	$('#bx-menu-inter-__id__').find('a').bind('click', function() {
+    		var sId = $(this).attr('id');
+			$(this).parent().siblings('.bx-menu-inter-act:visible').hide().siblings('.bx-menu-inter-pas:hidden').show().siblings('#' + sId + '-pas:visible').hide().siblings('#' + sId + '-act:hidden').show();
+    	});
+    });
+</script>

+ 246 - 73
template/scripts/BxBaseCmtsView.php

@@ -31,12 +31,13 @@ class BxBaseCmtsView extends BxDolCmts {
     /**
      * get full comments block with initializations
      */
-    function getCommentsFirst() {
-    	$sCmts = $this->getComments(0);
+    function getCommentsBlock($iParentId = 0) {
+    	$aBp = array('parent_id' => $iParentId);
+
+    	$sCmts = $this->getComments($aBp);
 
     	return BxDolTemplate::getInstance()->parseHtmlByName('comments_block.html', array(
     		'system' => $this->_sSystem,
-    		'js_object' => $this->_sJsObjName,
     		'id' => $this->getId(),
     		'bx_if:show_empty' => array(
 				'condition' => $sCmts == '',
@@ -44,8 +45,10 @@ class BxBaseCmtsView extends BxDolCmts {
 					'style_prefix' => $this->_sStylePrefix
 				)
 			),
+			'controls' => $this->_getControlsBox(),
     		'comments' => $sCmts,
-    		'reply' => $this->isPostReplyAllowed() ? $this->_getPostReplyBox() : '',
+    		'post_form_top' => $this->_getPostReplyBox($aBp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_TOP)),
+			'post_form_bottom'  => $this->_getPostReplyBox($aBp, array('type' => $this->_sDisplayType, 'position' => BX_CMT_PFP_BOTTOM)),
     		'script' => $this->getCmtsInit()
     	));
     }
@@ -53,43 +56,60 @@ class BxBaseCmtsView extends BxDolCmts {
     /**
      * get comments list for specified parent comment
      *
-     * @param int $iCmtsParentId - parent comment to get child comments from
+     * @param array $aBp - browse params array
+     * @param array $aDp - display params array
+     * 
      */
-    function getComments ($iCmtParentId = 0, $iStart = -1, $iPerView = -1)
+    function getComments($aBp = array(), $aDp = array())
     {
-    	list($iStart, $iPerView) = $this->_getBrowseParams($iCmtParentId, $iStart, $iPerView);
+    	$this->_prepareParams($aBp, $aDp);
 
-		$aCmts = $this->getCommentsArray($iCmtParentId, $this->_sOrder, $iStart, $iPerView);
+		$aCmts = $this->getCommentsArray($aBp['parent_id'], $aBp['order'], $aBp['start'], $aBp['per_view']);
 		if(empty($aCmts) || !is_array($aCmts))
 			return '';
 
-			
-		$sCmts = $iStart > 0 ? $this->_getMoreLink($iCmtParentId, $iStart, $iPerView) : '';
+		$sCmts = '';
 		foreach($aCmts as $k => $r)
-			$sCmts .= $this->getComment($r);
+			$sCmts .= $this->getComment($r, $aDp);
 
+		$sCmts = $this->_getMoreLink($sCmts, $aBp, $aDp);
 		return $sCmts;
     }
 
+    /**
+     * get comment view block with initializations
+     */
+    function getCommentBlock($iCmtId = 0)
+    {
+    	return BxDolTemplate::getInstance()->parseHtmlByName('comment_block.html', array(
+    		'system' => $this->_sSystem,
+    		'id' => $this->getId(),
+    		'comment' => $this->getComment($iCmtId, array('type' => BX_CMT_DISPLAY_THREADED, 'opened' => true)),
+    		'script' => $this->getCmtsInit()
+    	));
+    }
+
     /**
      * get one just posted comment
      *
      * @param int $iCmtId - comment id
      * @return string
      */
-    function getComment($mixedCmt)
+    function getComment($mixedCmt, $aDp = array())
     {
     	$oTemplate = BxDolTemplate::getInstance();
 
     	$iUserId = $this->_getAuthorId();
     	$r = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
 
+        list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($r);
+
         $sClass = $sRet = '';
         if($r['cmt_rated'] == -1 || $r['cmt_rate'] < $this->_aSystem['viewing_threshold']) {
         	$oTemplate->pareseHtmlByName('comment_hidden.html', array(
         		'js_object' => $this->_sJsObjName,
         		'id' => $r['cmt_id'],
-        		'title' => bx_process_output(_t('_hidden_comment', $r['cmt_author_name'])),
+        		'title' => bx_process_output(_t('_hidden_comment', $sAuthorName)),
         		'bx_if:show_replies' => array(
         			'condition' => $r['cmt_replies'] > 0,
         			'content' => array(
@@ -104,9 +124,7 @@ class BxBaseCmtsView extends BxDolCmts {
 		if($r['cmt_author_id'] == $iUserId)
 			$sClass .= ' cmt-mine';
 
-        list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($r);
-
-		$sActions = $this->_getActionsBox($r);
+		$sActions = $this->_getActionsBox($r, $aDp);
 
 		$sText = bx_process_output($r['cmt_text'], BX_DATA_TEXT_MULTILINE);
 		$sTextMore = '';
@@ -125,16 +143,22 @@ class BxBaseCmtsView extends BxDolCmts {
 			list($sParAuthorName, $sParAuthorLink, $sParAuthorIcon) = $this->_getAuthorInfo($aParent);
 
 			$aTmplReplyTo = array(
-        		'par_cmt_link' => '#' . $r['cmt_parent_id'],
+				'style_prefix' => $this->_sStylePrefix,
+        		'par_cmt_link' => $this->_sHomeUrl. '#' . $this->_sSystem . $r['cmt_parent_id'],
         		'par_cmt_author' => $sParAuthorName
         	);
 		}
  
+		$sReplies = '';
+		if((int)$r['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED && $aDp['opened'])
+			$sReplies = $this->getComments(array('parent_id' => $r['cmt_id']));
+
         return $oTemplate->parseHtmlByName('comment.html', array(
         	'system' => $this->_sSystem,
-        	'id' => $r['cmt_id'],
         	'style_prefix' => $this->_sStylePrefix,
+        	'id' => $r['cmt_id'],
         	'class' => $sClass,
+        	'margin' => $this->_getLevelGap($r, $aDp),
         	'author_icon' => $sAuthorIcon,
         	'bx_if:show_author_link' => array(
         		'condition' => !empty($sAuthorLink),
@@ -149,8 +173,6 @@ class BxBaseCmtsView extends BxDolCmts {
         			'author_name' => $sAuthorName
         		)
         	),
-        	'ago' => $r['cmt_ago'],
-        	'points' => _t($r['cmt_rate'] == 1 || $r['cmt_rate'] == -1 ? '_N_point' : '_N_points', $r['cmt_rate']),
         	'bx_if:show_reply_to' => array(
         		'condition' => !empty($aTmplReplyTo),
         		'content' => $aTmplReplyTo
@@ -163,13 +185,14 @@ class BxBaseCmtsView extends BxDolCmts {
         			'text_more' => $sTextMore
         		)
         	),
-        	'actions' => $sActions
+        	'actions' => $sActions,
+        	'replies' =>  $sReplies
         ));
     }
 
-    function getFormBox($sType, $iParentId)
+    function getFormBox($aBp = array(), $aDp = array())
     {
-        return $this->_getPostReplyBox($sType, $iParentId);
+        return $this->_getPostReplyBox($aBp, $aDp);
     }
 
 	function getForm($iCmtParentId, $sText, $sFunction)
@@ -194,7 +217,7 @@ class BxBaseCmtsView extends BxDolCmts {
      */
     function getExtraJs ()
     {
-        BxDolTemplate::getInstance()->addJs('BxDolCmts.js');
+        BxDolTemplate::getInstance()->addJs(array('common_anim.js', 'BxDolCmts.js'));
     }
 
     /**
@@ -210,16 +233,16 @@ class BxBaseCmtsView extends BxDolCmts {
         $ret .= $sToggleAdd . "
             <script  type=\"text/javascript\">
                 var " . $this->_sJsObjName . " = new BxDolCmts({
-                    sObjName : '" . $this->_sJsObjName . "',
-                    sBaseUrl : '" . BX_DOL_URL_ROOT . "',
-                    sSystem : '" . $this->getSystemName() . "',
+                    sObjName: '" . $this->_sJsObjName . "',
+                    sBaseUrl: '" . BX_DOL_URL_ROOT . "',
+                    sSystem: '" . $this->getSystemName() . "',
                     sSystemTable: '" . $this->_aSystem['table_cmts'] . "',
                     iAuthorId: '" . $this->_getAuthorId() . "',
-                    iObjId : '" . $this->getId () . "',
-                    sOrder : '" . $this->getOrder() . "',
-                    sDefaultErrMsg : '" . bx_js_string(_t('_Error occured')) . "',
-                    sConfirmMsg : '" . bx_js_string(_t('_Are you sure?')) . "',
-                    sTextAreaId: '" . $this->sTextAreaId . "'});
+                    iObjId: '" . $this->getId () . "',
+                    sOrder: '" . $this->getOrder() . "',
+                    sPostFormPosition: '" . $this->_aSystem['post_form_position'] . "',
+    				sBrowseType: '" . $this->_sBrowseType . "',
+    				sDisplayType: '" . $this->_sDisplayType . "'});
                 " . $this->_sJsObjName . ".oCmtElements = {";
         for (reset($this->_aCmtElements); list($k,$r) = each ($this->_aCmtElements); ) {
             $ret .= "\n'$k' : { 'reg' : '{$r['reg']}', 'msg' : \"". bx_js_string(trim($r['msg'])) . "\" },";
@@ -230,24 +253,67 @@ class BxBaseCmtsView extends BxDolCmts {
 
         $this->getExtraJs();
         $this->getExtraCss();
+        BxDolTemplate::getInstance()->addJsTranslation(array(
+        	'_Error occured',
+        	'_Are you sure?'
+        ));
+        
         return $ret;
     }
 
     /**
      * private functions
      */
-    function _getMoreLink($iParentId, $iStart, $iPerView)
+    function _getControlsBox()
     {
-    	return BxDolTemplate::getInstance()->parseHtmlByName('comment_more.html', array(
+    	$oTemplate = BxDolTemplate::getInstance();
+
+    	$sDisplay = '';
+    	$bDisplay = (int)$this->_aSystem['is_display_switch'] == 1;
+    	if($bDisplay) {
+			$aDisplayLinks = array(
+				array('id' => $this->_sSystem . '-flat', 'name' => $this->_sSystem . '-flat', 'class' => '', 'title' => '_cmt_display_flat', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeDisplay(this, \'flat\');'),
+				array('id' => $this->_sSystem . '-threaded', 'name' => $this->_sSystem . '-threaded', 'class' => '', 'title' => '_cmt_display_threaded', 'target' => '_self', 'onclick' => 'javascript:' . $this->_sJsObjName . '.cmtChangeDisplay(this, \'threaded\');')
+			);
+
+    		bx_import('BxTemplMenuInteractive');
+			$oMenu = new BxTemplMenuInteractive(array('template' => 'menu_interactive.html', 'menu_id'=> $this->_sSystem . '-display', 'menu_items' => $aDisplayLinks));
+			$oMenu->setSelected('', $this->_sSystem . '-' . $this->_sDisplayType);
+        	$sDisplay = $oMenu->getCode();
+    	}
+
+    	$sBrowse = '';
+    	$bBrowse = (int)$this->_aSystem['is_browse_switch'] == 1;
+    	if($bBrowse) {
+    		$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.html', 'menu_id'=> $this->_sSystem . '-browse', 'menu_items' => $aBrowseLinks));
+			$oMenu->setSelected('', $this->_sSystem . '-' . $this->_sBrowseType);
+        	$sBrowse = $oMenu->getCode();
+    	}
+    	
+    	return $oTemplate->parseHtmlByName('comments_controls.html', array(
 			'js_object' => $this->_sJsObjName,
 			'style_prefix' => $this->_sStylePrefix,
-			'parent_id' => $iParentId,
-    		'start' => $iStart,
-    		'per_view' => $iPerView
+			'comments_count' => _t('_N_comments', $this->_oQuery->getCommentsCount($this->_iId)),
+    		'display_switcher' => $bDisplay ? $sDisplay : '',
+    		'bx_if:is_divider' => array(
+    			'condition' => $bDisplay && $bBrowse,
+    			'content' => array(
+    				'style_prefix' => $this->_sStylePrefix,
+    			)
+    		),
+    		'browse_switcher' => $bBrowse ? $sBrowse : '',
 		));
     }
 
-	function _getActionsBox(&$a)
+	function _getActionsBox(&$a, $aDp = array())
     {
         $iUserId = $this->_getAuthorId();
         $isEditAllowedPermanently = ($a['cmt_author_id'] == $iUserId && $this->isEditAllowed()) || $this->isEditAllowedAll();
@@ -256,20 +322,20 @@ class BxBaseCmtsView extends BxDolCmts {
         return BxDolTemplate::getInstance()->parseHtmlByName('comment_actions.html', array(
         	'id' => $a['cmt_id'],
         	'style_prefix' => $this->_sStylePrefix,
-        	'bx_if:show_edit' => array(
-				'condition' => $isEditAllowedPermanently,
-        		'content' => array(
-        			'js_object' => $this->_sJsObjName,
-        			'style_prefix' => $this->_sStylePrefix,
-        			'id' => $a['cmt_id']
-        		)
-        	),
-        	'bx_if:show_delete' => array(
-				'condition' => $isRemoveAllowedPermanently,
+        	'view_link' => bx_append_url_params($this->_sViewUrl, array(
+        		'sys' => $this->_sSystem,
+        		'id' => $this->_iId,
+        		'cmt_id' => $a['cmt_id']
+        	)),
+        	'ago' => $a['cmt_ago'],
+        	'points' => _t($a['cmt_rate'] == 1 || $a['cmt_rate'] == -1 ? '_N_point' : '_N_points', $a['cmt_rate']),
+        	'bx_if:show_reply' => array(
+				'condition' => $this->isPostReplyAllowed(),
         		'content' => array(
         			'js_object' => $this->_sJsObjName,
         			'style_prefix' => $this->_sStylePrefix,
-        			'id' => $a['cmt_id']
+        			'id' => $a['cmt_id'],
+        			'text' => _t(isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Comment_to_this_comment' : '_Reply_to_this_comment')
         		)
         	),
         	'bx_if:show_rate' => array(
@@ -281,7 +347,7 @@ class BxBaseCmtsView extends BxDolCmts {
         		)
         	),
         	'bx_if:show_replies' => array(
-				'condition' => (int)$a['cmt_replies'] > 0,
+				'condition' => (int)$a['cmt_replies'] > 0 && !empty($aDp) && $aDp['type'] == BX_CMT_DISPLAY_THREADED && !$aDp['opened'],
         		'content' => array(
         			'js_object' => $this->_sJsObjName,
         			'style_prefix' => $this->_sStylePrefix,
@@ -289,26 +355,50 @@ class BxBaseCmtsView extends BxDolCmts {
         			'text' => _t((isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_N_comments' : '_N_replies'), $a['cmt_replies'])
         		)
         	),
-        	'bx_if:show_reply' => array(
-				'condition' => $this->isPostReplyAllowed(),
+        	'bx_if:show_edit' => array(
+				'condition' => $isEditAllowedPermanently,
         		'content' => array(
         			'js_object' => $this->_sJsObjName,
         			'style_prefix' => $this->_sStylePrefix,
-        			'id' => $a['cmt_id'],
-        			'text' => _t(isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Comment_to_this_comment' : '_Reply_to_this_comment')
+        			'id' => $a['cmt_id']
+        		)
+        	),
+        	'bx_if:show_delete' => array(
+				'condition' => $isRemoveAllowedPermanently,
+        		'content' => array(
+        			'js_object' => $this->_sJsObjName,
+        			'style_prefix' => $this->_sStylePrefix,
+        			'id' => $a['cmt_id']
         		)
-        	)
+        	),
         ));
     }
 
-    function _getPostReplyBox($sType = 'comment', $iCmtParentId = 0)
+    function _getPostReplyBox($aBp, $aDp)
     {
+    	$iCmtParentId = isset($aBp['parent_id']) ? (int)$aBp['parent_id'] : 0;
+    	$sPosition = isset($aDp['position']) ? $aDp['position'] : '';
+
+    	if(!$this->isPostReplyAllowed())
+    		return '';
+
     	bx_import('BxDolProfile');
-		$oProfile = null; //BxDolProfile::getInstanceAccountProfile($this->_getAuthorId());
+		$oProfile = BxDolProfile::getInstanceAccountProfile($this->_getAuthorId());
+
+		$sPositionSystem = $this->_aSystem['post_form_position'];
+		if(!empty($sPosition) && $sPositionSystem != BX_CMT_PFP_BOTH && $sPositionSystem != $sPosition)
+			return '';
 
     	return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_box.html', array(
     		'style_prefix' => $this->_sStylePrefix,
-    		'author_icon' => $oProfile ? $oProfile->getThumb() : 'icon',
+    		'margin' => $this->_getLevelGapByParent($iCmtParentId, $aDp),
+    		'bx_if:show_class' => array(
+    			'condition' => !empty($sPosition),
+    			'content' => array(
+    				'class' => $this->_sStylePrefix . '-reply-' . $sPosition
+    			)
+    		),
+    		'author_icon' => $oProfile->getThumb(),
 			'form' => $this->_getPostReplyForm($iCmtParentId)
     	));
     }
@@ -322,43 +412,126 @@ class BxBaseCmtsView extends BxDolCmts {
     		'text' => bx_process_output($sText)
     	));
     }
-	function _getBrowseParams($iCmtParentId = 0, $iStart = -1, $iPerView = -1)
+
+	function _getMoreLink($sCmts, $aBp = array(), $aDp = array())
     {
-    	$iStart = $iStart != -1 ? $iStart : $this->_oQuery->getCommentsCount($this->_iId, $iCmtParentId);
-    	$iPerView = $iPerView != -1 ? $iPerView : $this->getPerView($iCmtParentId);
+    	$iStart = $iPerView = 0;
+    	switch($aBp['type']) {
+    		case BX_CMT_BROWSE_HEAD:
+    			$iPerView = $aBp['per_view'];
+
+    			$iStart = $aBp['start'] + $iPerView;
+    			if($iStart >= $aBp['count'])
+    				return $sCmts;
 
-    	switch($this->_aSystem['show']) {
-    		case BX_CMT_SHOW_HEAD:
-    			$iStart = 0;
     			break;
-    		case BX_CMT_SHOW_TAIL:
-    			$iStart = $iStart - $iPerView;
+
+    		case BX_CMT_BROWSE_TAIL:
+    			$iPerView = $aBp['per_view'];
+
+				$iStart = $aBp['start'] - $iPerView;
     			if($iStart < 0) {
     				$iPerView += $iStart;
     				$iStart = 0;
     			}
+
+    			if($iStart == 0 && $iPerView == 0)
+					return $sCmts;
+
     			break;
     	}
 
-    	return array($iStart, $iPerView);
+    	$sMore = BxDolTemplate::getInstance()->parseHtmlByName('comment_more.html', array(
+			'js_object' => $this->_sJsObjName,
+			'style_prefix' => $this->_sStylePrefix,
+    		'margin' => $this->_getLevelGapByParent($aBp['parent_id'], $aDp),
+			'parent_id' => $aBp['parent_id'],
+    		'start' => $iStart,
+    		'per_view' => $iPerView
+		));
+
+    	switch($aBp['type']) {
+    		case BX_CMT_BROWSE_HEAD:
+    			$sCmts .= $sMore;
+    			break;
+
+    		case BX_CMT_BROWSE_TAIL:
+				$sCmts = $sMore . $sCmts;
+    			break;
+    	}
+
+    	return $sCmts;
     }
 
-    function _getAuthorInfo($r)
+    function _getLevelGap($a, $aDp = array())
+    {
+    	if($aDp['type'] != BX_CMT_DISPLAY_THREADED || !is_array($a) || !isset($a['cmt_level']))
+    		return 0;
+
+    	return 84 * ((int)$a['cmt_level'] <= $this->_iDpMaxLevel ? (int)$a['cmt_level'] : $this->_iDpMaxLevel);
+    }
+
+    function _getLevelGapByParent($iParentId, $aDp = array()) {
+		if($aDp['type'] != BX_CMT_DISPLAY_THREADED || (int)$iParentId == 0)
+    		return 0;
+
+		$a = $this->getCommentRow($iParentId);
+		if(isset($a['cmt_level']))
+			$a['cmt_level'] += 1;
+
+		return $this->_getLevelGap($a, $aDp);
+    }
+
+	function _getAuthorInfo($r)
     {
     	$sAuthorName = _t('_Anonymous');
     	$sAuthorLink = ''; 
         $sAuthorIcon = '';
 
-		$bAuthor = false; //$r['cmt_author_id'] && $r['cmt_author_name'];
-		if($bAuthor) {
-			$oProfile = null; //BxDolProfile::getInstanceAccountProfile($r['cmt_author_id']);
+		if((int)$r['cmt_author_id'] != 0) {
+			$oProfile = BxDolProfile::getInstanceAccountProfile($r['cmt_author_id']);
 
-			$sAuthorName = bx_process_output($r['cmt_author_name']);
+			$sAuthorName = $oProfile->getDisplayName();
 			$sAuthorLink = $oProfile->getUrl();
 			$sAuthorIcon = $oProfile->getThumb();
-			
 		}
 
 		return array($sAuthorName, $sAuthorLink, $sAuthorIcon);
     }
+
+	function _prepareParams(&$aBp, &$aDp)
+    {
+    	$aBp['type'] = isset($aBp['type']) && !empty($aBp['type']) ? $aBp['type'] : $this->_sBrowseType;
+    	$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;
+    	$aBp['order'] = isset($aBp['order']) ? $aBp['order'] : $this->_sOrder;
+
+    	$aDp['type'] = isset($aDp['type']) && !empty($aDp['type']) ? $aDp['type'] : $this->_sDisplayType;
+    	$aDp['opened'] = isset($aDp['opened']) ? $aDp['opened'] : $this->_bDpOpened;
+
+		switch($aDp['type']) {
+			case BX_CMT_DISPLAY_FLAT:
+				$aBp['parent_id'] = -1;
+				$aBp['per_view'] = $aBp['per_view'] != -1 ? $aBp['per_view'] : $this->getPerView(0);
+				break;
+
+			case BX_CMT_DISPLAY_THREADED:
+				$aBp['per_view'] = $aBp['per_view'] != -1 ? $aBp['per_view'] : $this->getPerView($aBp['parent_id']);
+				break;
+		}
+
+		$aBp['count'] = $this->_oQuery->getCommentsCount($this->_iId, $aBp['parent_id']);
+		if($aBp['start'] != -1)
+			return;
+
+		$aBp['start'] = 0;
+		if($aBp['type'] == BX_CMT_BROWSE_TAIL) {
+			$aBp['start'] = $aBp['count'] - $aBp['per_view'];
+			if($aBp['start'] < 0) {
+    			$aBp['per_view'] += $aBp['start'];
+    			$aBp['start'] = 0;
+			}
+		}
+    }
 }

+ 98 - 0
template/scripts/BxBaseMenuInteractive.php

@@ -0,0 +1,98 @@
+<?php defined('BX_DOL') or die('hack attempt');
+/**
+ * Copyright (c) BoonEx Pty Limited - http://www.boonex.com/
+ * CC-BY License - http://creativecommons.org/licenses/by/3.0/
+ *
+ * @defgroup    DolphinCore Dolphin Core
+ * @{
+ */
+
+bx_import('BxTemplMenu');
+
+/**
+ * Menu representation.
+ * @see BxDolMenu
+ */
+class BxBaseMenuInteractive extends BxTemplMenu {
+
+    protected $_oTemplate;
+
+    public function __construct ($aObject, $oTemplate) {
+        parent::__construct ($aObject);
+
+        if ($oTemplate)
+            $this->_oTemplate = $oTemplate;
+        else
+            $this->_oTemplate = BxDolTemplate::getInstance();
+    }
+
+    /** 
+     * Get menu code.
+     * @return string
+     */
+    public function getCode () {
+    	$sCode = parent::getCode();
+		if($sCode !== false)
+			$sCode = $this->_oTemplate->parseHtmlByContent($sCode, array(
+				'id' => $this->_aObject['menu_id']
+			));
+
+    	return $sCode;
+    }
+    
+    /** 
+     * Get menu items array, which are ready to pass to template.
+     * @return array
+     */
+    protected function _getMenuItems () {
+        $aRet = array();
+        if (!isset($this->_aObject['menu_items']))
+            $this->_aObject['menu_items'] = $this->_oQuery->getMenuItems();
+
+        foreach ($this->_aObject['menu_items'] as $a) {
+
+            if (isset($a['active']) && !$a['active'])
+                continue;
+
+            if (isset($a['visible_for_levels']) && !$this->_isVisible($a))
+                continue;
+
+            $a = $this->_replaceMarkers($a);
+
+            list ($sIcon, $sIconUrl) = $this->_getMenuIcon($a);
+
+            $a['class_wrp_act'] = 'bx-menu-inter-hidden';
+			$a['class_wrp_pas'] = '';
+            if($this->_isSelected($a)) {
+				$a['class_wrp_act'] = '';
+				$a['class_wrp_pas'] = 'bx-menu-inter-hidden';
+            }
+            
+            
+            $a['link'] = isset($a['link']) ? $this->_oPermalinks->permalink($a['link']) : 'javascript:void(0);';
+            $a['title'] = _t($a['title']);
+            $a['bx_if:image'] = array (
+                'condition' => (bool)$sIconUrl,
+                'content' => array('icon_url' => $sIconUrl), 
+            );
+            $a['bx_if:icon'] = array (
+                'condition' => (bool)$sIcon,
+                'content' => array('icon' => $sIcon), 
+            );
+
+            $aRet[] = $a;
+        }
+
+        return $aRet;
+    }
+
+    /**
+     * Add css/js files which are needed for menu display and functionality.
+     */    
+    protected function _addJsCss() {
+        $this->_oTemplate->addCss('menu.css');
+    }
+
+}
+
+/** @} */