AntonLV 13 лет назад
Родитель
Сommit
e6f7ce20b3
52 измененных файлов с 889 добавлено и 1375 удалено
  1. 5 3
      cmts.php
  2. 2 0
      inc/classes/BxDolAcl.php
  3. 73 100
      inc/classes/BxDolCmts.php
  4. 15 7
      inc/classes/BxDolCmtsQuery.php
  5. 249 478
      inc/js/classes/BxDolCmts.js
  6. 7 2
      inc/utils.inc.php
  7. 13 8
      install/sql/v70.sql
  8. 16 21
      modules/boonex/english/data/langs/system.xml
  9. 1 1
      studio/template/scripts/BxBaseStudioStore.php
  10. 30 0
      template/comment.html
  11. 20 0
      template/comment_actions.html
  12. 3 0
      template/comment_hidden.html
  13. 5 0
      template/comment_more.html
  14. 6 0
      template/comment_reply_box.html
  15. 8 0
      template/comment_reply_form.html
  16. 0 0
      template/comments.html
  17. 18 0
      template/comments_block.html
  18. 37 439
      template/css/cmts.css
  19. 2 0
      template/css/common.css
  20. 130 20
      template/css/default.css
  21. BIN
      template/images/icons/cmt-bln-bl.png
  22. BIN
      template/images/icons/cmt-bln-bm.png
  23. BIN
      template/images/icons/cmt-bln-br.png
  24. BIN
      template/images/icons/cmt-bln-ml.png
  25. BIN
      template/images/icons/cmt-bln-mr.png
  26. BIN
      template/images/icons/cmt-bln-tl.png
  27. BIN
      template/images/icons/cmt-bln-tm.png
  28. BIN
      template/images/icons/cmt-bln-tr.png
  29. BIN
      template/images/icons/cmt-delete.png
  30. BIN
      template/images/icons/cmt-edit.png
  31. BIN
      template/images/icons/cmt-frm-bln-bl.png
  32. BIN
      template/images/icons/cmt-frm-bln-bm.png
  33. BIN
      template/images/icons/cmt-frm-bln-br.png
  34. BIN
      template/images/icons/cmt-frm-bln-ml.png
  35. BIN
      template/images/icons/cmt-frm-bln-mr.png
  36. BIN
      template/images/icons/cmt-frm-bln-tl.png
  37. BIN
      template/images/icons/cmt-frm-bln-tm.png
  38. BIN
      template/images/icons/cmt-frm-bln-tr.png
  39. BIN
      template/images/icons/cmt-rate.png
  40. BIN
      template/images/icons/cmt-reply-bln-bl.png
  41. BIN
      template/images/icons/cmt-reply-bln-bm.png
  42. BIN
      template/images/icons/cmt-reply-bln-br.png
  43. BIN
      template/images/icons/cmt-reply-bln-ml.png
  44. BIN
      template/images/icons/cmt-reply-bln-mr.png
  45. BIN
      template/images/icons/cmt-reply-bln-tl.png
  46. BIN
      template/images/icons/cmt-reply-bln-tm.png
  47. BIN
      template/images/icons/cmt-reply-bln-tr.png
  48. BIN
      template/images/icons/cmt-reply-record.png
  49. BIN
      template/images/icons/cmt-reply-write.png
  50. BIN
      template/images/icons/cmt-show-hide.png
  51. 237 296
      template/scripts/BxBaseCmtsView.php
  52. 12 0
      template/scripts/BxBaseServiceAccount.php

+ 5 - 3
cmts.php

@@ -6,10 +6,12 @@
  */
 
 require_once('./inc/header.inc.php');
-require_once(BX_DIRECTORY_PATH_INC . "languages.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "params.inc.php");
 require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
 
+bx_import('BxDolAcl');
+bx_import('BxDolLanguages');
+
 check_logged();
 
 $sSys = isset($_REQUEST['sys']) ? $_REQUEST['sys'] : '';
@@ -17,9 +19,9 @@ $sAction = isset($_REQUEST['action']) && preg_match ('/^[A-Za-z_-]+$/', $_REQUES
 $iId = (int)$_REQUEST['id'];
 
 bx_import ('BxTemplCmtsView');
-$aSystems = BxDolCmts::getSystems ();
+$oCmts = new BxTemplCmtsView($sSys, $iId);
 
-if ($sSys && $sAction && $iId && ($oCmts = BxDolCmts::getObjectInstance($sSys, $iId, true))) {
+if ($sSys && $sAction && $iId && $oCmts) {
     header('Content-Type: text/html; charset=utf-8');
     $sMethod = 'action' . $sAction;
     echo $oCmts->$sMethod();

+ 2 - 0
inc/classes/BxDolAcl.php

@@ -45,6 +45,8 @@ define('ACTION_ID_COMMENTS_POST', 6);
 define('ACTION_ID_COMMENTS_VOTE', 7);
 define('ACTION_ID_COMMENTS_EDIT_OWN', 8);
 define('ACTION_ID_COMMENTS_REMOVE_OWN', 9);
+define('ACTION_ID_COMMENTS_EDIT_ALL', 10);
+define('ACTION_ID_COMMENTS_REMOVE_ALL', 11);
 
 /**
  * Standard membership ID's

+ 73 - 100
inc/classes/BxDolCmts.php

@@ -11,6 +11,10 @@ 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');
+
+
 /** 
  * @page objects 
  * @section comments Comments
@@ -35,16 +39,11 @@ define('BX_OLD_CMT_VOTES', 365*86400); ///< comment votes older than this number
  * - ObjectName - your unique module name, with vendor prefix, lowercase and spaces are underscored
  * - TableCmts - table name where comments are stored
  * - TableTrack - table name where comments ratings are stored
- * - AllowTags - 0 or 1 allow HTML tags in comments or not
  * - Nl2br - convert new lines to <br /> on saving
- * - SecToEdit - number of second to allow author to delete or edit comment
  * - PerView - number of comments on a page
  * - IsRatable - 0 or 1 allow to rate comments or not
  * - ViewingThreshold - comment viewing treshost, if comment is below this number it is hidden by default
- * - AnimationEffect - animation effect for comments, slide or fade
- * - AnimationSpeed - animation speen in milliseconds
  * - IsOn - is this comment object enabled
- * - IsMood - allow user to select comment as negative, positive or neutral
  * - RootStylePrefix - toot comments style prefix, if you need root comments look different
  * - TriggerTable - table to be updated upon each comment
  * - TriggerFieldId - TriggerTable table field with unique record id of
@@ -111,18 +110,11 @@ class BxDolCmts extends BxDol
 
     var $_iId = 0;  ///< obect id to be commented
     var $sTextAreaId;
-    var $iGlobAllowHtml;
-    var $iGlobUseTinyMCE;
     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 = 'desc';
-    var $_aMoodText = array(
-        '-1' => '_sys_txt_cmt_mood_negative',
-        '0' => '_sys_txt_cmt_mood_neutral',
-        '1' => '_sys_txt_cmt_mood_positive',
-    );
+    var $_sOrder = 'asc';
 
     /**
      * Constructor
@@ -133,28 +125,28 @@ class BxDolCmts extends BxDol
     {
         parent::BxDol();
 
-        $this->_aCmtElements = array (
-            'CmtParent'    => array ( 'reg' => '/^[0-9]+$/', 'msg' => _t('_bad comment parent id') ),
-            'CmtText'     => array ( 'reg' => '/^.{3,2048}$/m', 'msg' => _t('_Please enter 3-2048 characters') ),
-            'CmtMood'     => array ( 'reg' => '/^-?[0-9]?$/m', 'msg' => _t('_You need to select the mood') ),
-        );
-
-        $this->_aSystems =& $this->getSystems ();
+        $this->_aSystems = $this->getSystems();
 
         $this->_sSystem = $sSystem;
-        if (isset($this->_aSystems[$sSystem]))
+        if(isset($this->_aSystems[$sSystem]))
             $this->_aSystem = $this->_aSystems[$sSystem];
         else
             return;
 
+		$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'))
+        );
+
         $this->_oQuery = new BxDolCmtsQuery($this->_aSystem);
 
         if ($iInit)
             $this->init($iId);
 
         $this->sTextAreaId = "cmt" . str_replace(' ', '', ucwords(str_replace('_', ' ', $this->_sSystem))) . "TextAreaParent";
-        $this->iGlobAllowHtml = (getParam("enable_tiny_in_comments") == "on") ? 1 : 0;
-        $this->iGlobUseTinyMCE = $this->iGlobAllowHtml;
     }
 
     function & getSystems ()
@@ -167,16 +159,19 @@ class BxDolCmts extends BxDol
                     `ObjectName` AS `name`,
                     `TableCmts` AS `table_cmts`,
                     `TableTrack` AS `table_track`,
-                    `AllowTags` AS `allow_tags`,
+                    `CharsPostMin` AS `chars_post_min`,
+                    `CharsPostMax` AS `chars_post_max`,
+                    `CharsDisplayMax` AS `chars_display_max`,
                     `Nl2br` AS `nl2br`,
-                    `SecToEdit` AS `sec_to_edit`,
                     `PerView` AS `per_view`,
+                    `PerViewReplies` AS `per_view_replies`,
+                    `NumberOfLevels` AS `number_of_levels`,
+                    `IsLevelsSwitch` AS `is_levels_switch`,
+                    `Show` AS `show`,
+                    `IsShowSwitch` AS `is_show_switch`,
                     `IsRatable` AS `is_ratable`,
                     `ViewingThreshold` AS `viewing_threshold`,
-                    `AnimationEffect` AS `animation_effect`,
-                    `AnimationSpeed` AS `animation_speed`,
                     `IsOn` AS `is_on`,
-                    `IsMood` AS `is_mood`,
                     `RootStylePrefix` AS `root_style_prefix`,
                     `TriggerTable` AS `trigger_table`,
                     `TriggerFieldId` AS `trigger_field_id`,
@@ -190,41 +185,47 @@ class BxDolCmts extends BxDol
 
     function init ($iId)
     {
-        if (!$this->isEnabled()) return;
+        if (!$this->isEnabled()) 
+        	return;
+
         if (empty($this->iId) && $iId)
-        {
             $this->setId($iId);
-        }
     }
 
     /**
      * check if user can post/edit or delete own comments
      */
-    function checkAction ($iAction, $isPerformAction = false) {
+    function checkAction ($iAction, $isPerformAction = false)
+    {
         $iId = $this->_getAuthorId();
         $check_res = checkAction($iId, $iAction, $isPerformAction);
         return $check_res[CHECK_ACTION_RESULT] == CHECK_ACTION_RESULT_ALLOWED;
     }
 
-    function checkActionErrorMsg ($iAction) {
+    function checkActionErrorMsg ($iAction)
+    {
         $iId = $this->_getAuthorId();
         $check_res = checkAction($iId, $iAction);
         return $check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED ? $check_res[CHECK_ACTION_MESSAGE] : '';
     }
 
-    function getId () {
+    function getId ()
+    {
         return $this->_iId;
     }
 
-    function isEnabled () {
+    function isEnabled ()
+    {
         return isset($this->_aSystem['is_on']) && $this->_aSystem['is_on'];
     }
 
-    function getSystemName() {
+    function getSystemName()
+    {
         return $this->_sSystem;
     }
 
-    function getOrder () {
+    function getOrder ()
+    {
         return $this->_sOrder;
     }
 
@@ -244,43 +245,21 @@ class BxDolCmts extends BxDol
         return isset($this->_aSystems[$sSystem]);
     }
 
-
-
-    function isTagsAllowed ()
-    {
-        return $this->_aSystem['allow_tags'];
-    }
-
-
-
     function isNl2br ()
     {
         return $this->_aSystem['nl2br'];
     }
 
-
-
     function isRatable ()
     {
         return $this->_aSystem['is_ratable'];
     }
 
-
-
-    function getAllowedEditTime ()
+    function getPerView ($iCmtParentId = 0)
     {
-        return $this->_aSystem['sec_to_edit'];
+        return $iCmtParentId == 0 ? $this->_aSystem['per_view'] : $this->_aSystem['per_view_replies'];
     }
 
-
-
-    function getPerView ()
-    {
-        return $this->_aSystem['per_view'];
-    }
-
-
-
     function getSystemId ()
     {
         return $this->_aSystem['system_id'];
@@ -400,19 +379,17 @@ class BxDolCmts extends BxDol
     /**
      * is edit any comment allowed
      */
-    function isEditAllowedAll () {
-        return isAdmin() ? true : false;
+    function isEditAllowedAll ($isPerformAction = false) {
+        return isAdmin() || $this->checkAction (ACTION_ID_COMMENTS_EDIT_ALL, $isPerformAction) ? true : false;
     }
 
     /**
      * is removing any comment allowed
      */
-    function isRemoveAllowedAll () {
-        return isAdmin() ? true : false;
+    function isRemoveAllowedAll ($isPerformAction = false) {
+        return isAdmin() || $this->checkAction (ACTION_ID_COMMENTS_REMOVE_ALL, $isPerformAction) ? true : false;
     }
 
-
-
     /**
      * actions functions
      */
@@ -421,9 +398,10 @@ class BxDolCmts extends BxDol
            return '';
 
         $iCmtStart = isset($_REQUEST['CmtStart']) ? bx_process_input($_REQUEST['CmtStart'], BX_DATA_INT) : 0;
+        $iCmtNum = isset($_REQUEST['CmtNum']) ? bx_process_input($_REQUEST['CmtNum'], BX_DATA_INT) : -1;
         $iCmtPerPage= isset($_REQUEST['CmtPerPage']) ? bx_process_input($_REQUEST['CmtPerPage'], BX_DATA_INT) : $this->getPerView();
 
-        return $this->getPaginate($iCmtStart, $iCmtPerPage);
+        return $this->getPaginate($iCmtStart, $iCmtNum, $iCmtPerPage);
     }
 
     function actionFormGet () {
@@ -433,7 +411,7 @@ class BxDolCmts extends BxDol
         $sCmtType = isset($_REQUEST['CmtType']) ? bx_process_input($_REQUEST['CmtType']) : 'reply';
         $iCmtParentId= isset($_REQUEST['CmtParent']) ? bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT) : 0;
 
-        return $this->getForm($sCmtType, $iCmtParentId);
+        return $this->getFormBox($sCmtType, $iCmtParentId);
     }
 
     function actionCmtsGet () {
@@ -441,11 +419,9 @@ class BxDolCmts extends BxDol
            return '';
 
         $iCmtParentId = bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT);
-        $sCmtOrder = isset($_REQUEST['CmtOrder']) ? bx_process_input($_REQUEST['CmtOrder']) : $this->_sOrder;
-        $iCmtStart = isset($_REQUEST['CmtStart']) ? bx_process_input($_REQUEST['CmtStart'], BX_DATA_INT) : 0;
-        $iCmtPerPage= isset($_REQUEST['CmtPerPage']) ? bx_process_input($_REQUEST['CmtPerPage'], BX_DATA_INT) : -1;
-
-        return $this->getComments($iCmtParentId, $sCmtOrder, $iCmtStart, $iCmtPerPage);
+        $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);
     }
 
     function actionCmtGet () {
@@ -453,25 +429,27 @@ class BxDolCmts extends BxDol
            return '';
 
         $iCmtId = bx_process_input($_REQUEST['Cmt'], BX_DATA_INT);
-        return $this->getComment ($iCmtId, (isset($_REQUEST['Type']) ? bx_process_input($_REQUEST['Type']) : 'new'));
+        return $this->getComment($iCmtId);
     }
 
     function actionCmtPost ()
     {
-        if (!$this->isEnabled()) return '';
-        if (!$this->isPostReplyAllowed ()) return '';
+        if(!$this->isEnabled())
+        	return '';
+
+        if(!$this->isPostReplyAllowed())
+        	return '';
 
         $iCmtParentId = bx_process_input($_REQUEST['CmtParent'], BX_DATA_INT);
-        $iMood = bx_process_input($_REQUEST['CmtMood'], BX_DATA_INT);
-        $sCmtText = bx_process_input($_REQUEST['CmtText']);
+		$iCmtAuthorId = $this->_getAuthorId();
 
-        if ($this->_isSpam($sCmtText))
+        $sCmtText = bx_process_input($_REQUEST['CmtText']);
+        if($this->_isSpam($sCmtText))
             return sprintf(_t("_sys_spam_detected"), BX_DOL_URL_ROOT . 'contact.php');
 
         $sText = $this->_prepareTextForSave ($sCmtText);
 
-        $iCmtNewId = $this->_oQuery->addComment ($this->getId(), $iCmtParentId, $this->_getAuthorId(), $sText, $iMood);
-
+        $iCmtNewId = $this->_oQuery->addComment ($this->getId(), $iCmtParentId, $iCmtAuthorId, $sText);
         if(false === $iCmtNewId)
             return '';
 
@@ -480,7 +458,7 @@ class BxDolCmts extends BxDol
         $this->isPostReplyAllowed(true);
 
         bx_import('BxDolAlerts');
-        $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $this->getId(), $this->_getAuthorId(), array('comment_id' => $iCmtNewId, 'comment_author_id' => $iCmtAuthorId));
+        $oZ = new BxDolAlerts($this->_sSystem, 'commentPost', $this->getId(), $iCmtAuthorId, array('comment_id' => $iCmtNewId, 'comment_author_id' => $iCmtAuthorId));
         $oZ->alert();
 
         return $iCmtNewId;
@@ -505,7 +483,7 @@ class BxDolCmts extends BxDol
             return _t('_Can not delete comments with replies');
 
         $isRemoveAllowed = $this->isRemoveAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isRemoveAllowed());
-        if (!$isRemoveAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
+        if (!$isRemoveAllowed)
             return $aCmt['cmt_author_id'] == $this->_getAuthorId() && !$this->isRemoveAllowed() ? strip_tags($this->msgErrRemoveAllowed()) : _t('_Access denied');
 
         if (!$this->_oQuery->removeComment ($this->getId(), $aCmt['cmt_id'], $aCmt['cmt_parent_id']))
@@ -530,22 +508,22 @@ class BxDolCmts extends BxDol
      */
     function actionCmtEdit ()
     {
-        if (!$this->isEnabled()) return '';
+        if (!$this->isEnabled())
+        	return '';
 
         $iCmtId = bx_process_input($_REQUEST['Cmt'], BX_DATA_INT);
-        $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
 
+        $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
         if (!$aCmt)
             return 'err'._t('_No such comment');
 
         $isEditAllowed = $this->isEditAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isEditAllowed());
-        if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
+        if(!$isEditAllowed)
             return 'err' . ($aCmt['cmt_author_id'] == $this->_getAuthorId() && !$this->isEditAllowed() ? strip_tags($this->msgErrEditAllowed()) : _t('_Access denied'));
 
-        return $this->_getFormBox (0, $this->_prepareTextForEdit($aCmt['cmt_text']), 'updateComment(this, \''.$iCmtId.'\')');
+        return $this->getForm(0, $this->_prepareTextForEdit($aCmt['cmt_text']), 'cmtUpdate(this, ' . $iCmtId . ')');
     }
 
-
     function actionCmtEditSubmit() {
 
         if (!$this->isEnabled()) return '{}';
@@ -554,7 +532,6 @@ class BxDolCmts extends BxDol
         $oJson = new Services_JSON();
 
         $iCmtId = bx_process_input($_REQUEST['Cmt'], BX_DATA_INT);
-        $iCmtMood = bx_process_input($_REQUEST['CmtMood'], BX_DATA_INT);
         $sCmtText = bx_process_input($_REQUEST['CmtText']);
 
         if ($this->_isSpam($sCmtText))
@@ -567,11 +544,10 @@ class BxDolCmts extends BxDol
             return '{}';
 
         $isEditAllowed = $this->isEditAllowedAll() || ($aCmt['cmt_author_id'] == $this->_getAuthorId() && $this->isEditAllowed());
-
-        if (!$isEditAllowed && $aCmt['cmt_secs_ago'] > ($this->getAllowedEditTime()+20))
+        if (!$isEditAllowed)
             return '{}';
 
-        if (($sTextRet != $aCmt['cmt_text'] || $iCmtMood != $aCmt['cmt_mood']) && $this->_oQuery->updateComment ($this->getId(), $aCmt['cmt_id'], $sText, $iCmtMood)) {
+        if ($sText != $aCmt['cmt_text'] && $this->_oQuery->updateComment ($this->getId(), $aCmt['cmt_id'], $sText)) {
             if ($aCmt['cmt_author_id'] == $this->_getAuthorId())
                $this->isEditAllowed(true);
 
@@ -581,8 +557,7 @@ class BxDolCmts extends BxDol
         }
 
         $aCmt = $this->_oQuery->getCommentSimple ($this->getId(), $iCmtId);
-
-        return $oJson->encode(array('text' => $aCmt['cmt_text'], 'mood' => $aCmt['cmt_mood'], 'mood_text' => _t($this->_aMoodText[$aCmt['cmt_mood']])));
+        return $oJson->encode(array('text' => $aCmt['cmt_text']));
     }
 
     function actionCmtRate () {
@@ -640,11 +615,9 @@ class BxDolCmts extends BxDol
         return $s;
     }
 
-    function _prepareTextForSave ($s) {
-
-        if ($this->iGlobUseTinyMCE || $this->isTagsAllowed())
-            $iDataAction = BX_DATA_HTML;
-        elseif (!$this->iGlobUseTinyMCE && $this->isNl2br())
+    function _prepareTextForSave ($s) 
+    {
+        if ($this->isNl2br())
             $iDataAction = BX_DATA_TEXT_MULTILINE;
         else
             $iDataAction = BX_DATA_TEXT; // TODO: make sure that it is processed before output !

+ 15 - 7
inc/classes/BxDolCmtsQuery.php

@@ -30,16 +30,25 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->_sTable;
     }
 
+	function getCommentsCount ($iId, $iCmtParentId = 0) {
+		$sQuery = $this->prepare("SELECT COUNT(*) FROM `{$this->_sTable}` WHERE `cmt_object_id` = ? AND `cmt_parent_id` = ?", $iId, $iCmtParentId);
+		return (int)$this->getOne($sQuery);
+	}
+
     function getComments ($iId, $iCmtParentId = 0, $iAuthorId = 0, $sCmtOrder = 'ASC', $iStart = 0, $iCount = -1)
     {
         global $sHomeUrl;
         $iTimestamp = time();
         $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->_aSystem['system_id'], $iAuthorId);
         }
+
+        $sLimit = $iCount != -1 ? $this->prepare(' LIMIT ?, ?', (int)$iStart, (int)$iCount) : '';
+
         $sQuery = $this->prepare("SELECT
                 $sFields
                 `c`.`cmt_id`,
@@ -51,13 +60,13 @@ class BxDolCmtsQuery extends BxDolDb
                 `c`.`cmt_rate`,
                 `c`.`cmt_rate_count`,
                 `c`.`cmt_replies`,
-                ($iTimestamp - UNIX_TIMESTAMP(`c`.`cmt_time`)) AS `cmt_secs_ago`,
+                (? - 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`)
             $sJoin
             WHERE `c`.`cmt_object_id` = ? AND `c`.`cmt_parent_id` = ?
-            ORDER BY `c`.`cmt_time` " . (strtoupper($sCmtOrder) == 'ASC' ? 'ASC' : 'DESC') . ($iCount != -1 ? ' LIMIT ' . (int)$iStart . ', ' . (int)$iCount : ''), $iId, $iCmtParentId);
+            ORDER BY `c`.`cmt_time` " . (strtoupper($sCmtOrder) == 'ASC' ? 'ASC' : 'DESC') . $sLimit, $iTimestamp, $iId, $iCmtParentId);
 
         $a = $this->getAll($sQuery);
 
@@ -118,15 +127,14 @@ class BxDolCmtsQuery extends BxDolDb
         return $this->getRow($sQuery);
     }
 
-    function addComment ($iId, $iCmtParentId, $iAuthorId, $sText, $iMood)
+    function addComment ($iId, $iCmtParentId, $iAuthorId, $sText)
     {
         $sQuery = $this->prepare("INSERT INTO {$this->_sTable} SET
             `cmt_parent_id` = ?,
             `cmt_object_id` = ?,
             `cmt_author_id` = ?,
             `cmt_text` = ?,
-            `cmt_mood` = ?,
-            `cmt_time` = NOW()", $iCmtParentId, $iId, $iAuthorId, $sText, $iMood);
+            `cmt_time` = NOW()", $iCmtParentId, $iId, $iAuthorId, $sText);
         if (!$this->query($sQuery))
         {
             return false;
@@ -154,9 +162,9 @@ class BxDolCmtsQuery extends BxDolDb
         return true;
     }
 
-    function updateComment ($iId, $iCmtId, $sText, $iMood)
+    function updateComment ($iId, $iCmtId, $sText)
     {
-        $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_text` = ?, `cmt_mood` = ?  WHERE `cmt_object_id` = ? AND `cmt_id` = ? LIMIT 1", $sText, $iMood, $iId, $iCmtId);
+        $sQuery = $this->prepare("UPDATE {$this->_sTable} SET `cmt_text` = ?  WHERE `cmt_object_id` = ? AND `cmt_id` = ? LIMIT 1", $sText, $iId, $iCmtId);
         return $this->query($sQuery);
     }
 

+ 249 - 478
inc/js/classes/BxDolCmts.js

@@ -67,83 +67,103 @@ function BxDolCmts (options) {
     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._sVideoActionsUrl = options.sBaseUrl + 'flash/XML.php'; // video 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._isEditAllowed = parseInt(undefined == options.isEditAllowed ? 0 : options.isEditAllowed); // is edit allowed
-    this._isRemoveAllowed = parseInt(undefined == options.isRemoveAllowed ? 0 : options.isRemoveAllowed); // is remove allowed
-    this._iSecsToEdit = parseInt(undefined == options.iSecsToEdit ? 0 : options.iSecsToEdit); // number of seconds to allow edit comment
+    this._sAnimationEffect = 'slide';
+    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;
-    this._iGlobAllowHtml = undefined == options.iGlobAllowHtml ? '0' : options.iGlobAllowHtml;
 
     // 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();
     	$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-post-reply form > [name=CmtParent]').val(0);    
     }
+}
 
-    // clicks handler for ratings
+/*--- Main layout functionality ---*/
+BxDolCmts.prototype.cmtSubmit = function (f)
+{
+    var eSubmit = $(f).children().find(':submit').get();
     var $this = this;
-    $('#cmts-box-' + this._sSystem + '-' + this._iObjId).click(function(event) {
-        var iRate = 0;
-        var oLink = $(event.target).parent();
-        if(oLink.hasClass('cmt-pos')) {
-            iRate = 1;
-            event.preventDefault();
-        }
-        else if(oLink.hasClass('cmt-neg')) {
-            iRate = -1;
-            event.preventDefault();
-        }
-        if (iRate != 0 && !$(event.target).parents('.cmt-rate').hasClass('cmt-rate-disabled')) {
-            var e = $(event.target).parents('.cmt-buttons').siblings('.cmt-points').children('span').get();
-            $this._rateComment(e, parseInt(oLink.attr('id').substr(8)), iRate);
-        }
-    });
-}
-/*--- Browsing and Pagination ---*/
-BxDolCmts.prototype.changeOrder = function(oSelectDom) {
-    var oSelect = $(oSelectDom);
+    var oData = this._getDefaultActions();
+
+    // hide any errors before submitting
+    $this._error(eSubmit, false);
 
-    this._sOrder = oSelect.val();
-    this._getCmts(oSelect.siblings(':last'), 0, function(){});
+    // get and check form elements
+    if (!this._getCheckElements (f, oData)) 
+    	return;
+
+    // submit form
+    oData['action'] = 'CmtPost';
+
+    this._loading (eSubmit, true);
+    jQuery.post (
+        this._sActionsUrl,
+        oData,
+        function (s) {
+            $this._loading (eSubmit, false);
+
+            var iNewCmtId = parseInt(s);
+            if(iNewCmtId > 0) {
+                $(f).find(':input:not(:button,:submit,[type = hidden],[type = radio],[type = checkbox])').val('');
+                $this._getCmt(f, oData['CmtParent'], iNewCmtId); // display just posted comment
+            }
+            else if (!jQuery.trim(s).length) {
+                $this._error(eSubmit, true, $this._sDefaultErrMsg); // display error
+            }
+            else {
+                $this._error(eSubmit, true, s); // display error
+            }
+        }
+    );
 };
-BxDolCmts.prototype.expandAll = function(oCheckbox) {
+
+BxDolCmts.prototype.cmtUpdate = function (f, iCmtId)
+{
+    var eSubmit = $(f).find(':submit').get();
     var $this = this;
+    var oData = this._getDefaultActions();
 
-    $.each($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmts > .cmts > .cmt > .cmt-cont .cmt-replies-show'), function(){
-        $(this).trigger('click');
-    });
-};
-BxDolCmts.prototype.changePerPage = function(oDropDown) {
-    var oLoading = $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-browse > .cmt-order > :last').get();
+    $this._error(eSubmit, false); // hide any errors before submitting
 
-    var iPerPage = parseInt(oDropDown.value);
-    this._getCmts(oLoading, 0, function(){}, 0, iPerPage);
-    this._getPaginate(oLoading,0, iPerPage);
-};
-BxDolCmts.prototype.changePage = function(iStart, iPerPage) {
-    var oLoading = $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' > .cmt-browse > .cmt-order > :last').get();
+    if (!this._getCheckElements (f, oData)) return; // get and check form elements
 
-    this._getCmts(oLoading, 0, function(){}, iStart, iPerPage);
-    this._getPaginate(oLoading, iStart, iPerPage);
-};
-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);
-    });
+    this._oSavedTexts[iCmtId] = '';
+
+    // submit form
+    oData['action'] = 'CmtEditSubmit';
+    oData['Cmt'] = iCmtId;
+    this._loading (eSubmit, true);
+    jQuery.post (
+        this._sActionsUrl,
+        oData,
+        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
+            else
+                $('#cmt' + iCmtId + ' .cmt-body').bxdolcmtanim(
+                    'hide',
+                    $this._sAnimationEffect,
+                    $this._iAnimationSpeed,
+                    function() {
+                        $(this).html(oResponse.text).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                    });
+        },
+        'json'
+    );
 };
 
-/*--- Main layout functionality ---*/
-BxDolCmts.prototype.reloadComment = function(iCmtId) {
+BxDolCmts.prototype.cmtReload = function(iCmtId) {
     var $this = this;
     var oData = this._getDefaultActions();
     oData['action'] = 'CmtGet';
@@ -166,122 +186,6 @@ BxDolCmts.prototype.reloadComment = function(iCmtId) {
     );
 
 };
-BxDolCmts.prototype.toggleReply = function(e, iCmtParentId) {
-    //--- Get form for posting comment in Root ---//
-    if(iCmtParentId == 0) {
-        if($('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-reply').children().length) {
-            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
-        }
-        else {
-            var $this = this;
-            var oData = this._getDefaultActions();
-            oData['action'] = 'FormGet';
-            oData['CmtType'] = 'comment';
-            oData['CmtParent'] = iCmtParentId;
-
-            $this._loading (e, true);
-
-            jQuery.post (
-                this._sActionsUrl,
-                oData,
-                function (s) {
-                    $this._loading(e, false);
-                	$('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-reply').append($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).children('.cmt-post-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                        if($this._iGlobAllowHtml == 1)
-                        	$this.createEditor($this._iObjId, $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-post-reply form').find('[name=CmtText][tinypossible=true]'));
-                    });
-                }
-            );
-
-        }
-    }
-    //--- Get form for posting a reply ---//
-    else {
-		if ($('#cmt' + iCmtParentId).children('.cmt-post-reply').length)
-			$('#cmt' + iCmtParentId).children('.cmt-post-reply').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
-        else {
-            var $this = this;
-            var oData = this._getDefaultActions();
-            oData['action'] = 'FormGet';
-            oData['CmtType'] = 'reply';
-            oData['CmtParent'] = iCmtParentId;
-
-            $this._loading (e, true);
-
-            jQuery.post (
-                this._sActionsUrl,
-                oData,
-                function (s) {
-                    $this._loading(e, false);
-                	$('#cmt' + iCmtParentId).children('.cmt-cont').after($(s).addClass('cmt-post-reply-expanded').css('display', 'none')).next('.cmt-post-reply').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                        if($this._iGlobAllowHtml == 1)
-                            $this.createEditor(iCmtParentId, $('#cmt' + iCmtParentId + ' > .cmt-post-reply form').find('[name=CmtText][tinypossible=true]'));
-                    });
-                }
-            );
-        }
-    }
-};
-BxDolCmts.prototype.toggleType = function(oLink) {
-    var aSwitcher = {'cmt-post-reply-text': 'cmt-post-reply-video', 'cmt-post-reply-video': 'cmt-post-reply-text'};
-    var sKey = $(oLink).hasClass('cmt-post-reply-text') ? 'cmt-post-reply-text' : 'cmt-post-reply-video';
-
-    if($(oLink).parents('.cmt-balloon').find('div.' + sKey).is(':hidden')) {
-        $(oLink).addClass('inactive').parents('.cmt-balloon').find('div.' + aSwitcher[sKey]).bxdolcmtanim('hide', this._sAnimationEffect, this._iAnimationSpeed, function(){
-            var sType = sKey.substring(sKey.lastIndexOf('-') + 1, sKey.length);
-
-            $(oLink).siblings(':visible.inactive').removeClass('inactive');
-            $(this).siblings('[name = CmtType]').val(sType);
-            $(this).siblings('div.' + sKey).bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
-            if(sType == 'video')
-                $(this).siblings('.cmt-post-reply-post').children(':submit').attr('disabled', 'disabled');
-            else
-                $(this).siblings('.cmt-post-reply-post').children(':submit').removeAttr('disabled');
-        });
-    }
-};
-
-/**
- * show/hide comment replies
- */
-BxDolCmts.prototype.toggleCmts = function(e, iCmtParentId) {
-    //--- Load Root Comments ---//
-    if(iCmtParentId == 0) {
-        if(!$('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' div.cmts > ul > li').length) {
-            this._getCmts(e, iCmtParentId, function (){});
-        }
-        else
-            $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' div.cmts').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
-
-        $('#cmts-box-' + this._sSystem + '-' + this._iObjId + ' .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
-    }
-    //--- Load Replies ---//
-    else {
-        var sId = '#cmt' + iCmtParentId;
-        if ($(sId + ' > ul').length) {
-            if ($(sId + ' > ul').is(':visible'))
-                $( sId + ' > ul').bxdolcmtanim(
-                   'hide',
-                   this._sAnimationEffect,
-                   this._iAnimationSpeed,
-                   function(){
-                        $(sId + '  > .cmt-cont > .cmt-replies').removeClass('cmt-replies-hover').children('.cmt-replies-hide').hide().siblings('.cmt-replies-show').show();
-                    });
-            else
-                $(sId + ' > ul').bxdolcmtanim(
-                    'show',
-                    this._sAnimationEffect,
-                    this._iAnimationSpeed,
-                    function(){
-                        $(sId + '  > .cmt-cont > .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').hide().siblings('.cmt-replies-hide').show();
-                    });
-        }
-        else
-            this._getCmts(e, iCmtParentId, function (){
-                $(sId + ' > .cmt-cont .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').hide().siblings('.cmt-replies-hide').show();
-            });
-    }
-};
 
 BxDolCmts.prototype.cmtRemove = function(e, iCmtId) {
     if (!this._confirm()) return;
@@ -296,98 +200,156 @@ BxDolCmts.prototype.cmtRemove = function(e, iCmtId) {
     jQuery.post (
         this._sActionsUrl,
         oData,
-        function (s)
-        {
+        function(s) {
             $this._loading (e, false);
 
             if (jQuery.trim(s).length)
                 alert(s);
             else
-                $('#cmt' + iCmtId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function () { $(this).remove(); } );
+                $('#cmt' + iCmtId).bxdolcmtanim('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);
+
+                	$(this).remove();
+                });
         }
     );
 };
 
-BxDolCmts.prototype.cmtEdit = function(e, iCmtId) {
+BxDolCmts.prototype.cmtEdit = function(oLink, iCmtId) {
     var $this = this;
     var oData = this._getDefaultActions();
     oData['action'] = 'CmtEdit';
     oData['Cmt'] = iCmtId;
 
-    if ($('#cmt' + iCmtId + ' .cmt-body > form').length) {
-        $('#cmt' + iCmtId + ' .cmt-body').bxdolcmtanim(
-            'hide',
-            $this._sAnimationEffect,
-            $this._iAnimationSpeed,
-            function() {
-                $(this).html($this._oSavedTexts[iCmtId]).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-            });
+    var sBodyId = this._sRootId + ' #cmt' + iCmtId + ' .cmt-body';
+    
+    this._loading (oLink, true);
+
+    if ($(sBodyId + ' > form').length) {
+        $(sBodyId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+            $(this).html($this._oSavedTexts[iCmtId]).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+        });
         return;
     }
     else
-        this._oSavedTexts[iCmtId] = $('#cmt' + iCmtId + ' .cmt-body').html();
+        this._oSavedTexts[iCmtId] = $(sBodyId).html();
 
     jQuery.post (
         this._sActionsUrl,
         oData,
         function (s) {
+        	$this._loading (oLink, false);
 
-            if ('err' == s.substring(0,3))
-                alert (s.substring(3));
+        	if(s.substring(0,3) == 'err')
+        		alert(s.substring(3));
             else
-                $('#cmt' + iCmtId + ' .cmt-body').bxdolcmtanim(
-                    'hide',
-                    $this._sAnimationEffect,
-                    $this._iAnimationSpeed,
-                    function() {
-                        $(this).html(s).find('[name = CmtMood][value=' + $.trim($('#cmt' + iCmtId + ' .cmt-mood').html()) + ']').attr('checked', 'checked');
-                        $(this).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                            if($this._iGlobAllowHtml == 1)
-                                $this.createEditor(iCmtId, $('#cmt' + iCmtId + ' .cmt-body > form').find('[name=CmtText][tinypossible=true]'));
-                        });
-                    });
+                $(sBodyId).bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
+                    $(this).html(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                });
         }
     );
 };
 
-BxDolCmts.prototype._getPaginate = function(e, iStart, iPerPage) {
+BxDolCmts.prototype.cmtRate = function(e, iCmtId, iRate) 
+{
     var $this = this;
     var oData = this._getDefaultActions();
-    oData['action'] = 'PaginateGet';
-    if(iStart != undefined)
-        oData['CmtStart'] = iStart;
-    if(iPerPage != undefined)
-        oData['CmtPerPage'] = iPerPage;
+    oData['action'] = 'CmtRate';
+    oData['Cmt'] = iCmtId;
+    oData['Rate'] = iRate;
 
-        this._loading (e, true);
+    this._loading (e, true);
 
     jQuery.post (
         this._sActionsUrl,
         oData,
-        function(s) {
-            $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-show-more').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                if(s.length > 0) {
-                    $(this).find('.paginate').remove();
-                    $(this).append(s);
-                    $(this).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                }
-            });
+        function (s) {
             $this._loading (e, false);
+            if(jQuery.trim(s).length)
+                alert(s);
+            else if(iRate == 1) {
+                var oPoints = $(e).parents('.cmt:first').find('.cmt-points span');
+                oPoints.html(parseInt(oPoints.html()) + iRate);
+            }
+            else if(iRate == -1) {
+                $this.cmtReload(iCmtId);
+            }
         }
     );
 };
+
+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);
+	});
+};
+
+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);
+    });
+};
+
+BxDolCmts.prototype.seeMore = function(oLink)
+{
+	$(oLink).next('span').show().prev('a').remove();
+};
+
+BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
+{
+	var sParentId = this._sRootId + ' #cmt' + iCmtParentId;
+	var sReplyId = sParentId + ' .cmt-reply';
+
+    if ($(sReplyId).length)
+		$(sReplyId).bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+    else {
+        var $this = this;
+        var oData = this._getDefaultActions();
+        oData['action'] = 'FormGet';
+        oData['CmtType'] = 'reply';
+        oData['CmtParent'] = iCmtParentId;
+
+        $this._loading (e, true);
+
+        jQuery.post (
+            this._sActionsUrl,
+            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);
+            }
+        );
+    }
+};
+
+BxDolCmts.prototype.toggleCmts = function(e, iCmtParentId)
+{
+	var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul';
+
+	if(!$(sListId + ' > li').length)
+		this._getCmts(e, iCmtParentId);
+	else
+		$( sListId).bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
+};
+
 // get comment replies via ajax request
-BxDolCmts.prototype._getCmts = function (e, iCmtParentId, onLoad, iStart, iPerPage)
+BxDolCmts.prototype._getCmts = function (e, iCmtParentId, iStart, iPerView, onLoad)
 {
     var $this = this;
-    var oData = this._getDefaultActions();
+    var oData = this._getDefaultActions();    
     oData['action'] = 'CmtsGet';
     oData['CmtParent'] = iCmtParentId;
-    oData['CmtOrder'] = this._sOrder;
-    if(iStart)
+    if(parseInt(iStart) >= 0)
         oData['CmtStart'] = iStart;
-    if(iPerPage)
-        oData['CmtPerPage'] = iPerPage;
+    if(parseInt(iPerView) >= 0)
+        oData['CmtPerView'] = iPerView;
+
+    var sListId =  this._sRootId + ' #cmt' + iCmtParentId + ' > ul:first';
 
     if(e)
         this._loading (e, true);
@@ -396,19 +358,36 @@ BxDolCmts.prototype._getCmts = function (e, iCmtParentId, onLoad, iStart, iPerPa
         this._sActionsUrl,
         oData,
         function(s) {
-            if(iCmtParentId == 0) {
-                $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmts > ul').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {
-                    $(this).replaceWith(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                });
-            }
-            else
-                $('#cmt' + iCmtParentId).append($(s).filter('.cmts').addClass('cmts-margin').hide()).children('.cmts').bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-            onLoad();
-            $this._loading (e, false);
+        	$this._loading(e, false);
+
+        	if(typeof onLoad == 'function')
+    			onLoad(sListId, s);
+        	else
+        		$this._appendCmts(sListId, s);
         }
     );
 };
 
+BxDolCmts.prototype._appendCmts = function(sIdTo, sContent)
+{
+	$(sIdTo).append($(sContent).hide()).children(':hidden').bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
+};
+
+BxDolCmts.prototype._prependCmts = function(sIdTo, sContent)
+{
+	$(sIdTo).prepend($(sContent).hide()).children(':hidden').bxdolcmtanim('show', this._sAnimationEffect, this._iAnimationSpeed);
+};
+
+BxDolCmts.prototype._replaceCmts = 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);
+		$(this).remove();
+	});
+};
+
+
 // get just posted 1 comment via ajax request
 BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
 {
@@ -417,201 +396,57 @@ BxDolCmts.prototype._getCmt = function (f, iCmtParentId, iCmtId)
     oData['action'] = 'CmtGet';
     oData['Cmt'] = iCmtId;
 
-    var eUl = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmts > ul').get();
-    this._loading (eUl, true);
+    var sParentId =  this._sRootId + ' #cmt' + iCmtParentId;
+    var sListId =  sParentId + ' > ul';
+
+    var oList = $(sListId).get();
+    this._loading (oList);
 
     jQuery.post (
         this._sActionsUrl,
         oData,
         function (s) {
-            $this._loading (eUl, false);
-            if (iCmtParentId == 0) {
-        	    var oParent = $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmts > ul');
+            $this._loading (oList, false);
 
+            if (iCmtParentId == 0) {
                 //--- Some number of comments already loaded ---//
-                if(oParent.find('li.cmt:last').length)
-                    oParent.find('li.cmt:last').after(s);
-                //--- Some number of comments exists but NOT loaded ---//
-            	else if($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' div.cmt-replies > a').length) {
-                    $this._getCmts(f, 0, function(){
-            	        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').toggle().siblings('.cmt-replies-hide').toggle();
-                        var iCount = parseInt($('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' > .cmt-replies > a > span').html()) + 1;
-            	        $('#cmts-box-' + $this._sSystem + '-' + $this._iObjId + ' .cmt-replies > a > span').html(iCount);
-                    });
-
-                }
+                if($(sListId + ' > li.cmt').length)
+                    $(sListId + ' > li.cmt:last').after($(s).hide()).next('li.cmt:hidden').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
                 //-- There is no comments at all ---//
-                else {
-                    oParent.find('.cmt-no').remove();
-                    oParent.html(s);
-                }
-            }
-            else {
-                $('#cmt' + iCmtParentId + ' > .cmt-post-reply').bxdolcmtanim(
-                    'hide',
-                    $this._sAnimationEffect,
-                    $this._iAnimationSpeed,
-                    function() {
-                        //--- there was no comments and we added new
-                        if(!$('#cmt' + iCmtParentId + ' > ul').length && !$('#cmt' + iCmtParentId + ' > .cmt-cont > .cmt-replies > *').length)
-                            $(s).wrap($('<ul />').addClass('cmts').addClass('cmts-margin')).parent().hide().appendTo('#cmt' + iCmtParentId).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                        //--- there is some number of comments but they are not loaded.
-                        else if(!$('#cmt' + iCmtParentId + ' > ul').length && $('#cmt' + iCmtParentId + ' > .cmt-cont > .cmt-replies').length) {
-                            $this._getCmts(f, iCmtParentId, function() {
-                                $('#cmt' + iCmtParentId + ' > .cmt-cont > .cmt-replies').addClass('cmt-replies-hover').children('.cmt-replies-show').hide().siblings('.cmt-replies-hide').show().parent().find('a > span').html($('#cmt' + iCmtParentId + ' > ul > li').length);
-                            });
-                        }
-                        //--- there is some number of comments and they are loaded.
-                        else if($('#cmt' + iCmtParentId + ' > ul').length) {
-                            $('#cmt' + iCmtParentId + ' > .cmt-cont > .cmt-replies > a > span').html($('#cmt' + iCmtParentId + ' > ul > li').length + 1);
-                            if($('#cmt' + iCmtParentId + ' > ul').is(':visible')) {
-                                $('#cmt' + iCmtParentId + ' > ul').append($(s).hide());
-                                $('#cmt' + iCmtParentId + ' > ul > :last').bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                            }
-                            else
-                                $('#cmt' + iCmtParentId + ' > ul').append(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                        }
+                else
+                    $(sListId + ' > li.cmt-no').bxdolcmtanim('hide', $this._sAnimationEffect, $this._iAnimationSpeed, function() {                    	
+                    	$(this).after($(s).hide()).next('li').bxdolcmtanim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed);
+                    	$(this).remove();
                     });
             }
-            $this._runCountdown(iCmtId);
-        }
-    );
-};
-
-// submit comment and show it after posting
-BxDolCmts.prototype.submitComment = function (f)
-{
-    var eSubmit = $(f).children().find(':submit').get();
-    var $this = this;
-    var oData = this._getDefaultActions();
-
-    $this._err(eSubmit, false); // hide any errors before submitting
-
-    var isVideoComment = ($(f).children('[name = CmtType]').val() == 'video');
-
-    if (!isVideoComment && !this._getCheckElements (f, oData)) return; // get and check form elements
-
-    // submit form
-
-    if (isVideoComment) {
-
-        var iParentId = parseInt($(f).children('[name = CmtParent]').val());
-        oData['module'] = 'video_comments';
-        oData['action'] = 'post';
-        oData['system'] = this._sSystem; 
-        oData['parent'] = iParentId;
-        oData['id'] = this._iObjId;
-        oData['author'] = this._iAuthorId;
-        oData['mood'] = $(f).find('.cmt-post-reply-mood :input:checked').val();
-
-    } else {
-        oData['action'] = 'CmtPost';
-    }
-
-    this._loading (eSubmit, true);
-    jQuery.post (
-        isVideoComment ? this._sVideoActionsUrl : this._sActionsUrl,
-        oData,
-        function (s) {
-            $this._loading (eSubmit, false);
-
-            var iNewCmtId = parseInt(s);
-            if (iNewCmtId > 0) {
-
-                if (isVideoComment) {
-                    $this._getCmt(f, iParentId, iNewCmtId);
-                    var o = getRecorderObject(f);
-                    if (o.removeRecord != undefined)
-                        o.removeRecord();
-                } else {
-                    $(f).find(':input:not(:button,:submit,[type = hidden],[type = radio],[type = checkbox])').val('');
-                    $this._getCmt(f, oData['CmtParent'], iNewCmtId); // display just posted comment
-                }
-
-            } else if (!jQuery.trim(s).length) {
-                $this._err(eSubmit, true, $this._sDefaultErrMsg); // display error
-            } else {
-                $this._err(eSubmit, true, s); // display error
+            else {
+                $(sParentId + ' > .cmt-reply').bxdolcmtanim('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);
+                    //--- 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);
+                        $this._getCmts(f, iCmtParentId);
+                    }
+                    //--- there is some number of comments and they are loaded.
+                    else if($(sListId + ' > li.cmt').length) {
+                    	$(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);
+                        else
+                            $(sListId).append(s).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
+                    }
+                });
             }
         }
     );
 };
 
-// update comment and show it after posting
-BxDolCmts.prototype.updateComment = function (f, iCmtId)
-{
-    var eSubmit = $(f).find(':submit').get();
-    var $this = this;
-    var oData = this._getDefaultActions();
-
-    $this._err(eSubmit, false); // hide any errors before submitting
-
-    if (!this._getCheckElements (f, oData)) return; // get and check form elements
-
-    this._oSavedTexts[iCmtId] = '';
-
-    // submit form
-    oData['action'] = 'CmtEditSubmit';
-    oData['Cmt'] = iCmtId;
-    this._loading (eSubmit, true);
-    jQuery.post (
-        this._sActionsUrl,
-        oData,
-        function (oResponse) {
-            $this._loading (eSubmit, false);
-            if (!jQuery.trim(oResponse.text).length)
-                $this._err(eSubmit, true, jQuery.trim(oResponse.err).length ? oResponse.err : $this._sDefaultErrMsg); // display error
-            else
-                $('#cmt' + iCmtId + ' .cmt-body').bxdolcmtanim(
-                    'hide',
-                    $this._sAnimationEffect,
-                    $this._iAnimationSpeed,
-                    function() {
-                        if($this._iGlobAllowHtml == 1)
-                            $this.toggleEditor($this._sTextAreaId + iCmtId);
-
-                        $('#cmt' + iCmtId + ' .cmt-mood').html(' ' + oResponse.mood + ' ');
-                        $('#cmt' + iCmtId + ' .cmt-mood-text').html(oResponse.mood_text);
-                        $(this).html(oResponse.text).bxdolcmtanim('show', $this._sAnimationEffect, $this._iAnimationSpeed);
-                    });
-        },
-        'json'
-    );
-};
-
-// toggle hidden comment
-BxDolCmts.prototype._toggleHidden = function(e, iCmtId) {
-    $('#cmt'+iCmtId+' > .cmt-cont').bxdolcmtanim('toggle', this._sAnimationEffect, this._iAnimationSpeed);
-};
-
-// rate comment
-BxDolCmts.prototype._rateComment = function(e, iCmtId, iRate) {
-            var $this = this;
-            var oData = this._getDefaultActions();
-            oData['action'] = 'CmtRate';
-            oData['Cmt'] = iCmtId;
-            oData['Rate'] = iRate;
-
-            this._loading (e, true);
-
-            jQuery.post (
-                this._sActionsUrl,
-                oData,
-                function (s) {
-                    $this._loading (e, false);
-                    if(jQuery.trim(s).length)
-                        alert(s);
-                    else if(iRate == 1) {
-                        $(e).html(parseInt($(e).html()) + iRate);
-                        $(e).parent().parent().addClass('cmt-rate-disabled');
-                    }
-                    else if(iRate == -1) {
-                        $this.reloadComment(iCmtId);
-                    }
-                }
-            );
-};
-
 // check and get post new comment form elements
 BxDolCmts.prototype._getCheckElements = function(f, oData) {
     var $this = this;
@@ -624,31 +459,19 @@ BxDolCmts.prototype._getCheckElements = function(f, oData) {
             //--- Check form's data ---//
             if ($this.oCmtElements[this.name]['reg']) {
                 try {
-                    if(this.type == 'textarea' && $this._iGlobAllowHtml == 1 && typeof tinyMCE != 'undefined') {
-                        var ed = tinyMCE.get(this.id);
-			var tinyValue = $(ed.getContent()).text();
-                        eval('var isValid = "'+ tinyValue +'".match(' + $this.oCmtElements[this.name]['reg'] + ');');
-                    } else {
-                        eval('var isValid = this.value.match(' + $this.oCmtElements[this.name]['reg'] + ');');
-                    }
+                	eval('var isValid = this.value.match(' + $this.oCmtElements[this.name]['reg'] + ');');
                 } catch (ex) {};
             }
             if (!isValid) {
                 bSuccess = false;
-                $this._err(this, true, $this.oCmtElements[this.name]['msg']);
+                $this._error(this, true, $this.oCmtElements[this.name]['msg']);
             }
             else {
-                $this._err(this, false);
+                $this._error(this, false);
             }
 
             //--- Fill in data array ---//
-            if(this.type == 'textarea' && $this._iGlobAllowHtml == 1 && typeof tinyMCE != 'undefined') {
-                var edT = tinyMCE.get(this.id);
-                if (edT) {
-                    var tinyValueT = edT.getContent();
-                    oData[this.name] = tinyValueT;
-                }
-            } else if(this.type == 'radio') {
+            if(this.type == 'radio') {
                 if(this.checked)
                     oData[this.name] = this.value;
             }
@@ -659,25 +482,11 @@ BxDolCmts.prototype._getCheckElements = function(f, oData) {
     return bSuccess;
 };
 
-// run countdown timer for just posted comments
-BxDolCmts.prototype._runCountdown = function(iCmtId) {
-    if (this._isEditAllowed || this._isRemoveAllowed || 0 == this._iSecsToEdit) return;
-
-	$('#cmt-jp-' + iCmtId + ' span > b').html(this._iSecsToEdit);
-
-    window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + this._iSecsToEdit +');', 1000);
-};
-
-BxDolCmts.prototype.onCountdown = function(iCmtId, i) {
-	var i = parseInt($('#cmt-jp-' + iCmtId + ' span > b').html());	
-    if(0 == --i) {
-        $('#cmt-jp-' + iCmtId).remove();
-        return;
-    }
-    else {
-		$('#cmt-jp-' + iCmtId + ' span > b').html(i);
-        window.setTimeout(this._sObjName + '.onCountdown(' + iCmtId + ',' + i +');', 1000);
-    }
+BxDolCmts.prototype._getDefaultActions = function() {
+    return {
+        'sys': this._sSystem,
+        'id': this._iObjId
+    };
 };
 
 BxDolCmts.prototype._loading = function(e, bShow) {
@@ -687,7 +496,7 @@ BxDolCmts.prototype._loading = function(e, bShow) {
     	$(e).parent().find('b').remove();
 };
 
-BxDolCmts.prototype._err = function(e, bShow, s) {
+BxDolCmts.prototype._error = function(e, bShow, s) {
     if (bShow && !$(e).next('.cmt-err').length)
         $(e).after(' <b class="cmt-err">' + s + '</b>');
     else if (!bShow && $(e).next('.cmt-err').length)
@@ -696,42 +505,4 @@ BxDolCmts.prototype._err = function(e, bShow, s) {
 
 BxDolCmts.prototype._confirm = function() {
     return confirm(this._sConfirmMsg);
-};
-
-BxDolCmts.prototype._getDefaultActions = function() {
-    return {
-        'sys': this._sSystem,
-        'id': this._iObjId
-    };
-};
-
-BxDolCmts.prototype.createEditor = function(iCmtId, oTextarea, bDelayed) {
-    var sId = this._sTextAreaId + iCmtId;
-
-    if(!oTextarea.length)
-        return;
-
-    if(oTextarea.attr('id') == undefined || oTextarea.attr('id') == '')
-        oTextarea.attr('id', sId);
-
-    if(bDelayed)
-        window.setTimeout(this._sObjName + ".showEditor('" + sId + "');", 1000);
-    else
-        this.showEditor(sId);
-
-};
-
-BxDolCmts.prototype.showEditor = function(sId) {
-    if ('undefined' == typeof(tinyMCE))
-        return;
-    tinyMCE.execCommand('mceAddControl', false, sId);
-};
-
-BxDolCmts.prototype.toggleEditor = function(sId) {
-    if ('undefined' == typeof(tinyMCE))
-        return;
-    if(!tinyMCE.getInstanceById(sId))
-        tinyMCE.execCommand('mceAddControl', false, sId);
-    else
-        tinyMCE.execCommand('mceRemoveControl', false, sId);
-};
+};

+ 7 - 2
inc/utils.inc.php

@@ -24,6 +24,11 @@ define('BX_DATA_DATE', 7); ///< date data type stored as yyyy-mm-dd
 define('BX_DATA_DATE_TS', 8); ///< date data type stored as unixtimestamp
 define('BX_DATA_DATETIME_TS', 9); ///< date/time data type stored as unixtimestamp
 
+define('BX_SLASHES_AUTO', 0);
+define('BX_SLASHES_ADD', 1);
+define('BX_SLASHES_STRIP', 2);
+define('BX_SLASHES_NO_ACTION', 3);
+
 define('BX_ESCAPE_STR_AUTO', 0); ///< turn apostropes and quote signs into html special chars, for use in @see bx_js_string and @see bx_html_attribute
 define('BX_ESCAPE_STR_APOS', 1); ///< escape apostrophes only, for js strings enclosed in apostrophes, for use in @see bx_js_string and @see bx_html_attribute
 define('BX_ESCAPE_STR_QUOTE', 2); ///< escape quotes only, for js strings enclosed in quotes, for use in @see bx_js_string and @see bx_html_attribute
@@ -657,10 +662,10 @@ function _format_when ($iSec) {
     } else {
         if ($iSec > -3600) {
             $i = round($iSec/60);
-            $s .= (0 == $i || 1 == $i) ? _t('_in_x_minute', '1') : _t('_in_x_minute', -$i, 's');
+            $s .= (0 == $i || 1 == $i) ? _t('_in_x_minute', '1', '') : _t('_in_x_minute', -$i, 's');
         } else if ($iSec > -86400) {
             $i = round($iSec/60/60);
-            $s .= (0 == $i || 1 == $i) ? _t('_in_x_hour', '1') : _t('_in_x_hour', -$i, 's');
+            $s .= (0 == $i || 1 == $i) ? _t('_in_x_hour', '1', '') : _t('_in_x_hour', -$i, 's');
         } elseif ($iSec < -86400) {
             $i = round($iSec/60/60/24);
             $s .= (0 == $i || 1 == $i) ? _t('_tomorrow') : _t('_in_x_day', -$i, 's');

+ 13 - 8
install/sql/v70.sql

@@ -150,16 +150,19 @@ CREATE TABLE `sys_objects_cmts` (
   `ObjectName` varchar(50) NOT NULL,
   `TableCmts` varchar(50) NOT NULL,
   `TableTrack` varchar(50) NOT NULL,
-  `AllowTags` smallint(1) NOT NULL,
-  `Nl2br` smallint(1) NOT NULL,
-  `SecToEdit` smallint(6) NOT NULL,
+  `CharsPostMin` int(10) NOT NULL,
+  `CharsPostMax` int(10) NOT NULL,
+  `CharsDisplayMax` int(10) NOT NULL,
+  `Nl2br` smallint(1) NOT NULL,  
   `PerView` smallint(6) NOT NULL,
+  `PerViewReplies` smallint(6) NOT NULL,
+  `NumberOfLevels` smallint(6) NOT NULL,
+  `IsLevelsSwitch` smallint(1) NOT NULL,
+  `Show` varchar(50) NOT NULL,
+  `IsShowSwitch` smallint(1) NOT NULL,
   `IsRatable` smallint(1) NOT NULL,
   `ViewingThreshold` smallint(6) NOT NULL,
-  `AnimationEffect` varchar(50) NOT NULL,
-  `AnimationSpeed` smallint(6) NOT NULL,
   `IsOn` smallint(1) NOT NULL,
-  `IsMood` smallint(1) NOT NULL,
   `RootStylePrefix` varchar(16) NOT NULL default 'cmt',
   `TriggerTable` varchar(32) NOT NULL,
   `TriggerFieldId` varchar(32) NOT NULL,
@@ -637,8 +640,10 @@ INSERT INTO `sys_acl_actions` (`ID`, `Module`, `Name`, `AdditionalParamName`, `T
 (7, 'system', 'comments vote', NULL, '_sys_acl_action_comments_vote', '', 0, 1),
 (8, 'system', 'comments edit own', NULL, '_sys_acl_action_comments_edit_own', '', 0, 1),
 (9, 'system', 'comments remove own', NULL, '_sys_acl_action_comments_remove_own', '', 0, 1),
-(10, 'system', 'create account', NULL, '_sys_acl_action_create_account', '_sys_acl_action_create_account_desc', 0, 2147483646),
-(12, 'system', 'delete account', NULL, '_sys_acl_action_delete_account', '_sys_acl_action_delete_account_desc', 0, 2147483646);
+(10, 'system', 'comments edit all', NULL, '_sys_acl_action_comments_edit_all', '', 0, 1),
+(11, 'system', 'comments remove all', NULL, '_sys_acl_action_comments_remove_all', '', 0, 1),
+(12, 'system', 'create account', NULL, '_sys_acl_action_create_account', '_sys_acl_action_create_account_desc', 0, 2147483646),
+(13, 'system', 'delete account', NULL, '_sys_acl_action_delete_account', '_sys_acl_action_delete_account_desc', 0, 2147483646);
 
 
 CREATE TABLE `sys_acl_actions_track` (

+ 16 - 21
modules/boonex/english/data/langs/system.xml

@@ -1150,23 +1150,27 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_about_BoonEx"><![CDATA[BoonEx - Community Software;  Dating And Social Networking Scripts; Video Chat And More.]]></string>
 	<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="_There_are_no_comments_yet"><![CDATA[There are no comments yet]]></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="_N point"><![CDATA[<span>{0}</span> point]]></string>
-	<string name="_N points"><![CDATA[<span>{0}</span> points]]></string>
-	<string name="_Thumb Up"><![CDATA[Thumb Up]]></string>
-	<string name="_Thumb Down"><![CDATA[Thumb Down]]></string>
+	<string name="_see_more"><![CDATA[see more]]></string>
+	<string name="_N_point"><![CDATA[<span>{0}</span> plus]]></string>
+	<string name="_N_points"><![CDATA[<span>{0}</span> pluses]]></string>
+	<string name="_Plus"><![CDATA[Plus]]></string>
+	<string name="_Minus"><![CDATA[Minus]]></string>
 	<string name="_Remove"><![CDATA[Remove]]></string>
-	<string name="_available_for_n_seconds"><![CDATA[(available for <span>{0}</span> seconds)]]></string>
-	<string name="_Show N replies"><![CDATA[<span>{0}</span> replies]]></string>
-	<string name="_Reply to this comment"><![CDATA[Reply]]></string>
+	<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="_Reply_to_this_comment"><![CDATA[Reply]]></string>
 	<string name="_Add Your Comment"><![CDATA[Comment]]></string>
-	<string name="_Submit Comment"><![CDATA[Post]]></string>
+	<string name="_Submit_Comment"><![CDATA[Post]]></string>
+	<string name="_load_more_comments"><![CDATA[Load More]]></string>
+	<string name="_in_reply_to"><![CDATA[in reply to]]></string>
 	<string name="_Can not delete comments with replies"><![CDATA[Cannot delete comments with replies]]></string>
 	<string name="_Access denied"><![CDATA[Access denied]]></string>
 	<string name="_Save"><![CDATA[Save]]></string>
@@ -1175,7 +1179,6 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_Disapprove"><![CDATA[Disapprove]]></string>
 	<string name="_Select Category"><![CDATA[Select Category]]></string>
 	<string name="_Print As"><![CDATA[Print As]]></string>
-	<string name="_Hide N replies"><![CDATA[<span>{0}</span> replies]]></string>
 	<string name="_Counter"><![CDATA[Counter]]></string>
 	<string name="_Reply to Someone comment"><![CDATA[Reply to {0}\'s comment]]></string>
 	<string name="_See all music of this user"><![CDATA[See all music files of this user]]></string>
@@ -1249,16 +1252,10 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_Latest activity"><![CDATA[Latest activity]]></string>
 	<string name="_Activity"><![CDATA[Activity]]></string>
 	<string name="_In"><![CDATA[In]]></string>
-	<string name="_Reply as text"><![CDATA[Reply]]></string>
-	<string name="_Reply as video"><![CDATA[Record a video reply]]></string>
-	<string name="_Record Your Comment"><![CDATA[Record a video comment]]></string>
-	<string name="_Comment Positive"><![CDATA[Positive]]></string>
-	<string name="_Comment Negative"><![CDATA[Negative]]></string>
-	<string name="_Comment Neutral"><![CDATA[Neutral]]></string>
 	<string name="_Order by"><![CDATA[Order by:]]></string>
 	<string name="_oldest first"><![CDATA[oldest first]]></string>
 	<string name="_newest first"><![CDATA[newest first]]></string>
-	<string name="_expand all"><![CDATA[expand all]]></string>
+	<string name="_expand_all"><![CDATA[expand all]]></string>
 	<string name="_refresh"><![CDATA[refresh]]></string>
 	<string name="_Browse"><![CDATA[Browse]]></string>
 	<string name="_Profile info"><![CDATA[Profile information]]></string>
@@ -1356,9 +1353,6 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_sys_request_page_not_found_cnt"><![CDATA[Page({0}) was not found in module({1})]]></string>
 	<string name="_sys_request_method_not_found_cpt"><![CDATA[Method was not found]]></string>
 	<string name="_sys_request_method_not_found_cnt"><![CDATA[Method({0}) was not found in module({1})]]></string>
-	<string name="_sys_txt_cmt_mood_negative"><![CDATA[negative]]></string>
-	<string name="_sys_txt_cmt_mood_neutral"><![CDATA[neutral]]></string>
-	<string name="_sys_txt_cmt_mood_positive"><![CDATA[positive]]></string>
 	<string name="_sys_txt_cmt_loading"><![CDATA[Loading...]]></string>
 	<string name="_sys_breadcrumb_join"><![CDATA[Join]]></string>
 	<string name="_sys_breadcrumb_account"><![CDATA[Account]]></string>
@@ -1918,6 +1912,8 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
     <string name="_sys_acl_action_comments_vote"><![CDATA[Comments Vote]]></string>
     <string name="_sys_acl_action_comments_edit_own"><![CDATA[Comments Edit Own]]></string>
     <string name="_sys_acl_action_comments_remove_own"><![CDATA[Comments Remove Own]]></string>
+	<string name="_sys_acl_action_comments_edit_all"><![CDATA[Comments Edit All]]></string>
+    <string name="_sys_acl_action_comments_remove_all"><![CDATA[Comments Remove All]]></string>    
     <string name="_sys_acl_action_create_account"><![CDATA[Create Account]]></string>
     <string name="_sys_acl_action_create_account_desc"><![CDATA[It make sence for guests only, you can temporary disable it or set limit by time for example.]]></string>
     <string name="_sys_acl_action_delete_account"><![CDATA[Delete Account]]></string>
@@ -3138,7 +3134,6 @@ Please click "Continue" below to navigate to the home page of the site.]]></stri
 	<string name="_edit_profile_privacy_save"><![CDATA[Save]]></string>
 	<string name="_bad comment parent id"><![CDATA[bad comment parent id]]></string>
 	<string name="_Please enter 3-2048 characters"><![CDATA[Please enter 3-2048 characters]]></string>
-	<string name="_You need to select the mood"><![CDATA[You need to select the mood]]></string>
 	<string name="_Remove friend"><![CDATA[Remove friend]]></string>
 	<string name="_Friend was removed"><![CDATA[Friend was removed]]></string>
 	<string name="_sys_adm_title_dnsbl_log"><![CDATA[DNSBL Block Log]]></string>

+ 1 - 1
studio/template/scripts/BxBaseStudioStore.php

@@ -13,7 +13,7 @@ bx_import('BxDolStudioStore');
 bx_import('BxTemplStudioFunctions');
 
 class BxBaseStudioStore extends BxDolStudioStore {
-	protected $iPerPageDefault = 4;
+	protected $iPerPageDefault = 24;
 
     function BxBaseStudioStore($sPage = "") {
         parent::BxDolStudioStore($sPage);

+ 30 - 0
template/comment.html

@@ -0,0 +1,30 @@
+<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>
+				</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>
+	<ul class="cmts cmts-margin"></ul>
+</li>

+ 20 - 0
template/comment_actions.html

@@ -0,0 +1,20 @@
+<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>
+	<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>
+		<!--
+		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-vote bx-def-font-grayed" title="<bx_text:_Minus />" href="javascript:void(0)" onclick="__js_object__.cmtRate(this, __id__, -1)"><bx_text:_Minus /></a>
+		-->
+	</bx_if:show_rate>
+	<bx_if:show_reply>
+		<span class="bullet">&#183;</span><a class="__style_prefix__-comment-reply bx-def-font-grayed" href="javascript:void(0)" onclick="__js_object__.toggleReply(this, __id__); return false;">__text__</a>
+	</bx_if:show_reply>
+	<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>
+</div>

+ 3 - 0
template/comment_hidden.html

@@ -0,0 +1,3 @@
+<li id="cmt__id__-hidden" class="cmt-replacement">
+	__title__ <bx_if:show_replies>__replies__. </bx_if:show_replies><a href="javascript:void(0)" onclick="javascript:__js_object__.showReplacement(__id__)"><bx_text:_show_replacement /></a>.
+</li>

+ 5 - 0
template/comment_more.html

@@ -0,0 +1,5 @@
+<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>
+</li>

+ 6 - 0
template/comment_reply_box.html

@@ -0,0 +1,6 @@
+<div class="__style_prefix__-reply bx-def-hr bx-def-margin-top">
+	<div class="__style_prefix__-post-reply bx-def-margin-top">
+		<div class="__style_prefix__-icon">__author_icon__</div>
+	    __form__
+	</div>
+</div>

+ 8 - 0
template/comment_reply_form.html

@@ -0,0 +1,8 @@
+<form name="cmt-post-reply" onsubmit="__js_object__.__js_function__; return false;">
+	<input type="hidden" name="CmtParent" value="__parent_id__" />
+	<input type="hidden" name="CmtType" value="text" />
+	<div class="cmt-post-reply-text">
+		<textarea name="CmtText">__text__</textarea>
+	</div>
+	<div class="cmt-post-reply-post"><input type="submit" value="<bx_text:_Submit_Comment />" /></div>
+</form>

+ 0 - 0
template/comments.html


+ 18 - 0
template/comments_block.html

@@ -0,0 +1,18 @@
+<div id="cmts-box-__system__-__id__">
+	<div class="cmt-browse">
+		
+        <div class="bx-clear">&nbsp;</div>
+	</div>
+	<div id="cmt0" class="cmts">
+		<ul class="cmts">
+			<bx_if:show_empty>
+				<li class="__style_prefix__-no">
+					<bx_text:_There_are_no_comments_yet />
+				</li>
+			</bx_if:show_empty>
+			__comments__
+		</ul>
+		__reply__
+	</div>
+</div>
+__script__

+ 37 - 439
template/css/cmts.css

@@ -1,28 +1,22 @@
 /* TODO: remake according to the new design */
-
-    div.clear_both {
-        font-size: 0px;
-    }
     /*--- General Styles ---*/
     div.cmts {
-        padding: 10px 10px 0px 10px;
-        /*position: relativ_e;*/
+		margin-top: 20px;
     }
+
     ul.cmts {
         margin: 0px;
         padding: 0px;
         list-style: none;
     }
-    ul.cmts-margin {
-        margin-left: 5px !important;
-    }
-    ul.cmts ul.cmts {
-        margin-bottom: 5px;
-    }
+    ul.cmts-margin {}
     ul.cmts li.cmt {
-        margin-left: 38px;
+        padding-left: 84px;
     }
-    li.cmt-just-posted {
+    li.cmt-more {
+		padding: 5px 0px;
+    	background-color: #ededed;
+    	text-indent: 5px;
     }
     li.cmt-err {
         color: red;
@@ -44,336 +38,38 @@
        font-size: 11px;
        color: #333333;
     }
-    li.cmt-replacement div.cmt-rate {
-       top: 5px;
-       right: 0px;
-    }
 
-    /*--- Comment/Reply Box Styles ---*/
+    /*--- Comment ---*/
     div.cmt-cont {
-        position: relative;/*keep*/
-    }
-    div.cmt-post-reply {
         position: relative;
+    	min-height: 64px;
     }
-    div.cmt-cont div.thumbnail_block,
-    div.cmt-post-reply div.thumbnail_block {
-        left: -38px;
-        top: 1px;
-        position: absolute;
-    }
-    table.cmt-balloon {
-        width: 100%;
-        padding: 0px;
-        margin: 0px;
-        /*position: relativ_e;*/
-        border: 0px;
-        border-collapse: collapse;
-        font-size: 11px;
-    }
-    table.cmt-balloon tr,
-    table.cmt-balloon td {
-        margin: 0px;
-        padding: 0px;
-        border: 0px;
+	div.cmt-cont .bullet {
+		padding: 0px 3px;
     }
-    tr.cmt-head {
-        height: 22px;
-        /*position: relativ_e;*/
-        line-height: 20px;
+    div.cmt-icon {
+		position: absolute;
+    	top: 0px;
+    	left: -84px;
+    	width: 64px;
+    	height: 64px;
+    	background-color: #cccccc;
     }
-    tr.cmt-jp {
-        padding-bottom: 5px;
-        /*position: relativ_e;*/
+    span.cmt-author {
+		font-weight: bold;
     }
-    /*tr.cmt-head a,
-    tr.cmt-jp a {
+    span.cmt-author a {
         text-decoration: none;
     }
-    tr.cmt-head a:hover,
-    tr.cmt-head a:active,
-    tr.cmt-jp a:hover,
-    tr.cmt-jp a:active {
-        text-decoration: underline;
-    }*/
-   /* td.cmt-head-l,
-    td.cmt-head-m,
-    td.cmt-head-r {
-        position: relativ_e;
-    }*/
-    td.cmt-head-l,
-    td.wcmt-head-l,
-    ul.cmts-margin td.cmt-head-l,
-    div.cmt-post-reply td.cmt-head-l {
-        width: 14px;
-        background-image: url(../images/icons/cmt-bln-tl.png);
-        background-repeat: no-repeat;
-        font-size: 0px;
-    }
-    td.wcmt-head-l,
-    ul.cmts-margin td.cmt-head-l {
-        background-image: url(../images/icons/cmt-reply-bln-tl.png);
-    }
-    div.cmt-post-reply td.cmt-head-l {
-        background-image: url(../images/icons/cmt-frm-bln-tl.png);
-    }
-    td.cmt-head-m,
-    td.wcmt-head-m,
-    ul.cmts-margin td.cmt-head-m,
-    div.cmt-post-reply td.cmt-head-m {
-        background-image: url(../images/icons/cmt-bln-tm.png);
-        background-repeat: repeat-x;
-    }
-    td.wcmt-head-m,
-    ul.cmts-margin td.cmt-head-m {
-        background-image: url(../images/icons/cmt-reply-bln-tm.png);
-    }
-    div.cmt-post-reply td.cmt-head-m {
-        background-image: url(../images/icons/cmt-frm-bln-tm.png);
-    }
-    td.cmt-head-r,
-    td.wcmt-head-r,
-    ul.cmts-margin td.cmt-head-r,
-    div.cmt-post-reply td.cmt-head-r {
-        width: 9px;
-        background-image: url(../images/icons/cmt-bln-tr.png);
-        background-repeat: no-repeat;
-        font-size: 0px;
-    }
-    td.wcmt-head-r,
-    ul.cmts-margin td.cmt-head-r {
-        background-image: url(../images/icons/cmt-reply-bln-tr.png);
-    }
-    div.cmt-post-reply td.cmt-head-r {
-        background-image: url(../images/icons/cmt-frm-bln-tr.png);
-    }
-    /*td.cmt-cont {
-        position: relativ_e;
-    }*/
-    /*td.cmt-cont-l,
-    td.cmt-cont-m,
-    td.cmt-cont-r {
-        position: relativ_e;
-    }*/
-    td.cmt-cont-l,
-    td.wcmt-cont-l,
-    ul.cmts-margin td.cmt-cont-l,
-    div.cmt-post-reply td.cmt-cont-l {
-        width: 14px;
-        background-image: url(../images/icons/cmt-bln-ml.png);
-        background-repeat: repeat-y;
-        font-size: 0px;
-    }
-    td.wcmt-cont-l,
-    ul.cmts-margin td.cmt-cont-l {
-        background-image: url(../images/icons/cmt-reply-bln-ml.png);
-    }
-    div.cmt-post-reply td.cmt-cont-l {
-        background-image: url(../images/icons/cmt-frm-bln-ml.png);
-    }
-    td.cmt-cont-m {
-        background-color: #e9ecff;
-    }
-    td.wcmt-cont-m,
-    ul.cmts-margin td.cmt-cont-m {
-        background-color: #ffffff;
-    }
-    div.cmt-post-reply td.cmt-cont-m {
-        background-color: #ffffcc;
-    }
-    td.cmt-cont-r,
-    td.wcmt-cont-r,
-    ul.cmts-margin td.cmt-cont-r,
-    div.cmt-post-reply td.cmt-cont-r {
-        width: 9px;
-        background-image: url(../images/icons/cmt-bln-mr.png);
-        background-repeat: repeat-y;
-        font-size: 0px;
-    }
-    td.wcmt-cont-r,
-    ul.cmts-margin td.cmt-cont-r {
-        background-image: url(../images/icons/cmt-reply-bln-mr.png);
-    }
-    div.cmt-post-reply td.cmt-cont-r {
-        background-image: url(../images/icons/cmt-frm-bln-mr.png);
-    }
-    /*tr.cmt-foot {
-        height: 8px;
-
-        position: relativ_e;
-
-        font-size: 0px;
-    }*/
-    /*td.cmt-foot-l,
-    td.cmt-foot-m,
-    td.cmt-foot-r {
-        position: relativ_e;
-    }*/
-    td.cmt-foot-l,
-    td.wcmt-foot-l,
-    ul.cmts-margin td.cmt-foot-l,
-    div.cmt-post-reply td.cmt-foot-l {
-        width: 14px;
-        background-image: url(../images/icons/cmt-bln-bl.png);
-        background-repeat: no-repeat;
-        font-size: 0px;
-    }
-    td.wcmt-foot-l,
-    ul.cmts-margin td.cmt-foot-l {
-        background-image: url(../images/icons/cmt-reply-bln-bl.png);
-    }
-    div.cmt-post-reply td.cmt-foot-l {
-        background-image: url(../images/icons/cmt-frm-bln-bl.png);
-    }
-    td.cmt-foot-m,
-    td.wcmt-foot-m,
-    ul.cmts-margin td.cmt-foot-m,
-    div.cmt-post-reply td.cmt-foot-m {
-        background-image: url(../images/icons/cmt-bln-bm.png);
-        background-repeat: repeat-x;
-    }
-    td.wcmt-foot-m,
-    ul.cmts-margin td.cmt-foot-m {
-        background-image: url(../images/icons/cmt-reply-bln-bm.png);
-    }
-    div.cmt-post-reply td.cmt-foot-m {
-        background-image: url(../images/icons/cmt-frm-bln-bm.png);
-    }
-    td.cmt-foot-r,
-    td.wcmt-foot-r,
-    ul.cmts-margin td.cmt-foot-r,
-    div.cmt-post-reply td.cmt-foot-r {
-        width: 9px;
-        background-image: url(../images/icons/cmt-bln-br.png);
-        background-repeat: no-repeat;
-        font-size: 0px;
-    }
-    td.wcmt-foot-r,
-    ul.cmts-margin td.cmt-foot-r {
-        background-image: url(../images/icons/cmt-reply-bln-br.png);
-    }
-    div.cmt-post-reply td.cmt-foot-r {
-        background-image: url(../images/icons/cmt-frm-bln-br.png);
-    }
-    a.cmt-author {
-        text-decoration: none;
-        /*text-transform: capitalize;
-        color: #3333cc;*/
-    }
     span.cmt-posted-ago {
         text-transform: lovercase;
-        font-size: 10px;
-        color: #999999;
-    }
-    /*div.cmt-body,
-    div.cmt-mood {
-        position: relativ_e;
-    }*/
-    div.cmt-mood {
-        display: none;
     }
-
-    /*--- View Replies Styles---*/
-    div.cmt-replies,
-    div.cmt-replies-hover {
-        margin: 0px 0px 5px 5px;
-        /*position: relativ_e;*/
-        font-size: 10px;
-    }
-    div.cmt-replies {
-        clear: left;
-        float: left;
-    }
-    div.cmt-replies a.cmt-replies-show,
-    div.cmt-replies a.cmt-replies-hide {
-        padding-left: 10px;
-        background-image:url(../images/icons/cmt-show-hide.png);
-        background-repeat:no-repeat;
-        text-decoration: none;
-    }
-    div.cmt-replies a.cmt-replies-show {
-        background-position:0px 0px;
-    }
-    div.cmt-replies a.cmt-replies-hide {
-        display: none;
-        background-position: 0px -13px;
-    }
-
-    /*--- Post Reply Styles ---*/
-    div.cmt-reply-to,
-    div.cmt-post-reply-to {
-        margin: 0px 2px 5px 0px;
-        /*position: relativ_e;*/
-        font-size: 10px;
-    }
-    div.cmt-post-reply-to {
-        float: right;
-    }
-    div.cmt-reply-to a,
-    div.cmt-post-reply-to a {
-       text-decoration: none;
-    }
-
-    /*--- Rate Styles ---*/
-    div.cmt-rate {
-        top: 2px;
-        right: 6px;
-        position: absolute;
-        z-index: 7;
-        text-transform: lowercase;
-        text-decoration: none;
-        font-size: 11px;
-    }
-    div.cmt-points,
-    div.cmt-buttons {
-       /*position: relativ_e;*/
-       float: left;
-    }
-    div.cmt-points {
-       padding-right: 3px;
-       line-height: 20px;
-    }
-    div.cmt-buttons {
-       padding: 4px 0px;
-    }
-    div.cmt-buttons a.cmt-pos,
-    div.cmt-buttons a.cmt-pos:active,
-    div.cmt-buttons a.cmt-pos:visited,
-    div.cmt-buttons a.cmt-neg,
-    div.cmt-buttons a.cmt-neg:active,
-    div.cmt-buttons a.cmt-neg:visited {
-        font-size: 10px;
-        text-decoration: none;
-    }
-    div.cmt-buttons a.cmt-pos img,
-    div.cmt-buttons a.cmt-neg img {
-        width: 12px;
-        height: 12px;
-        background-image: url(../images/icons/cmt-rate.png);
-        background-repeat: no-repeat;
-    }
-    a.cmt-pos img,
-    a.cmt-pos:active img,
-    a.cmt-pos:visited img {
-        background-position: 0px 0px;
-    }
-    a.cmt-pos:hover img {
-        background-position:0px -12px;
-    }
-    a.cmt-neg img,
-    a.cmt-neg:active img,
-    a.cmt-neg:visited img {
-        margin-left: 3px;
-        background-position:-12px 0px;
-    }
-    a.cmt-neg:hover img {
-        background-position:-12px -12px;
-    }
-    div.cmt-rate-disabled div.cmt-buttons a.cmt-pos    img {
-        background-position:-0px -24px;
+	span.cmt-points {
+        text-transform: lovercase;
     }
-    div.cmt-rate-disabled div.cmt-buttons a.cmt-neg img {
-        background-position:-12px -24px;
+    div.cmt-actions {}
+    div.cmt-actions span.bullet:first-child {
+		display: none;
     }
 
     /*--- Browse Styles ---*/
@@ -383,94 +79,27 @@
         font-size: 11px;
         color: #666666;
     }
-    div.cmt-order,
-    div.cmt-pages {
-       height: 30px;
-       /*position: relativ_e; */
-       float: left;
-       text-align: left;
-       line-height: 30px;
-    }
-    div.cmt-order {
-        padding-left: 10px;
-    }
-    div.cmt-pages {
-        padding-right: 10px;
-        float: right;
-    }
-    div.cmt-order select,
-    div.cmt-pages select {
-       margin: 0px;
-    }
-
-    /*--- Show More(Paginate) Styles ---*/
-    div.cmt-show-more {
-        height: 30px;
-        background-color: #ededed;
-        text-align: center;
-    }
-    div.cmt-show-more a b,
-    div.cmt-show-more a u {
-        text-decoration: none;
-        font-weight: normal;
-    }
 
     /*--- Add Comment/Reply Styles ---*/
     div.cmt-reply {
-        padding: 10px;
-        /*position: relativ_e;*/
+		position: relative;
+        padding-left: 84px;
     }
+	div.cmt-reply-expanded {}
     div.cmt-post-reply {
-        margin-left: 38px;
-        padding: 0px;
-        /*position: relativ_e;*/
-        font-size: 11px;
-    }
-    div.cmt-post-reply div.cmt-reply-head {
-        padding: 5px 0px;
+        position: relative;
     }
     div.cmt-post-reply form {
         display: block;
     }
     div.cmt-post-reply textarea,
-    div.cmt-post-reply-to textarea,
     div.cmt-body textarea {
         width: 100%;
-        height: 50px;
+        height: 64px;
         padding: 0px;
         margin: 0px;
         border: 0px;
     }
-    div.cmt-post-reply-expanded    {
-        margin: 0px 0px 10px 43px;
-    }
-    td.cmt-head-m a.cmt-post-reply-text,
-    td.cmt-head-m a.cmt-post-reply-video {
-        height: 16px;
-        margin: 10px 0px;
-        padding-left: 20px;
-        /*position: relativ_e;*/
-        float: left;
-        background-repeat: no-repeat;
-        background-position: 0px center;
-        line-height: 16px;
-    }
-    td.cmt-head-m a.cmt-post-reply-text {
-        padding-right: 14px;
-        background-image: url(../images/icons/cmt-reply-write.png);
-    }
-    td.cmt-head-m a.cmt-post-reply-video {
-        background-image: url(../images/icons/cmt-reply-record.png);
-    }
-    td.cmt-head-m a.comment {
-        display: block;
-    }
-    td.cmt-head-m a.reply {
-        display: none;
-    }
-    td.cmt-head-m a.inactive {
-        color: #666666;
-    }
     div.cmt-post-reply-text {
         margin-bottom: 10px;
         /*position: relativ_e;*/
@@ -481,40 +110,9 @@
         /*position: relativ_e;*/
         display: none;
     }
-    div.cmt-post-reply-post {
-        /*position: relativ_e;*/
-        clear: left;
-        float: left;
-    }
-    div.cmt-post-reply-mood {
-        /*position: relativ_e;*/
-        float: right;
-    }
-    div.cmt-post-reply-mood input {
-        margin-top: 0px;
-    }
-    div.cmt-post-mood-ctl,
-    div.cmt-post-mood-lbl {
-        height: 13px;
-        margin-top: 4px;
-        /*position: relativ_e;*/
-        float: left;
-    }
-    div.cmt-post-mood-lbl {
-        line-height: 13px;
-    }
+    div.cmt-post-reply-post {}
+    a.cmt-comment-vote,
     a.cmt-comment-manage-edit,
-    a.cmt-comment-manage-delete {
-        height: 16px;
-        padding: 5px 14px 5px 20px;
-        /*position: relativ_e;*/
-        background-repeat: no-repeat;
-        background-position: 0px center;
-        line-height: 16px;
-    }
-    a.cmt-comment-manage-edit {
-        background-image: url(../images/icons/cmt-edit.png);
-    }
-    a.cmt-comment-manage-delete {
-        background-image: url(../images/icons/cmt-delete.png);
-    }
+    a.cmt-comment-manage-delete,
+    a.cmt-comment-replies {
+    }

+ 2 - 0
template/css/common.css

@@ -30,6 +30,8 @@ blockquote {
     clear:both;
     float:none;
     display:block;
+    width: 0px;
+    height: 0px;
     font-size:1px;
 }
 

Разница между файлами не показана из-за своего большого размера
+ 130 - 20
template/css/default.css


BIN
template/images/icons/cmt-bln-bl.png


BIN
template/images/icons/cmt-bln-bm.png


BIN
template/images/icons/cmt-bln-br.png


BIN
template/images/icons/cmt-bln-ml.png


BIN
template/images/icons/cmt-bln-mr.png


BIN
template/images/icons/cmt-bln-tl.png


BIN
template/images/icons/cmt-bln-tm.png


BIN
template/images/icons/cmt-bln-tr.png


BIN
template/images/icons/cmt-delete.png


BIN
template/images/icons/cmt-edit.png


BIN
template/images/icons/cmt-frm-bln-bl.png


BIN
template/images/icons/cmt-frm-bln-bm.png


BIN
template/images/icons/cmt-frm-bln-br.png


BIN
template/images/icons/cmt-frm-bln-ml.png


BIN
template/images/icons/cmt-frm-bln-mr.png


BIN
template/images/icons/cmt-frm-bln-tl.png


BIN
template/images/icons/cmt-frm-bln-tm.png


BIN
template/images/icons/cmt-frm-bln-tr.png


BIN
template/images/icons/cmt-rate.png


BIN
template/images/icons/cmt-reply-bln-bl.png


BIN
template/images/icons/cmt-reply-bln-bm.png


BIN
template/images/icons/cmt-reply-bln-br.png


BIN
template/images/icons/cmt-reply-bln-ml.png


BIN
template/images/icons/cmt-reply-bln-mr.png


BIN
template/images/icons/cmt-reply-bln-tl.png


BIN
template/images/icons/cmt-reply-bln-tm.png


BIN
template/images/icons/cmt-reply-bln-tr.png


BIN
template/images/icons/cmt-reply-record.png


BIN
template/images/icons/cmt-reply-write.png


BIN
template/images/icons/cmt-show-hide.png


+ 237 - 296
template/scripts/BxBaseCmtsView.php

@@ -7,13 +7,14 @@
 defined('BX_DOL') or die('hack attempt');
 
 bx_import('BxDolCmts');
+bx_import('BxDolProfile');
 bx_import('BxTemplPaginate');
 
 /**
  * @see BxDolCmts
  */
 class BxBaseCmtsView extends BxDolCmts {
-    var $_oPaginate;
+	var $_sJsObjName;
     var $_sStylePrefix;
 
     function BxBaseCmtsView( $sSystem, $iId, $iInit = 1 ) {
@@ -22,18 +23,6 @@ class BxBaseCmtsView extends BxDolCmts {
             return;
 
         $this->_sJsObjName = 'oCmts' . ucfirst($sSystem) . $iId;
-        $this->_oPaginate = new BxTemplPaginate(array(
-            'page_url' => 'javascript:void(0);',
-            'start' => 0,
-            //'count' => $this->_oQuery->getObjectCommentsCount($this->getId(), 0),
-            'per_page' => $this->getPerView(),
-            'sorting' => $this->_sOrder,
-            'per_page_step' => 2,
-            'per_page_interval' => 3,
-            'on_change_page' => $this->_sJsObjName . '.changePage({start}, {per_page})',
-            'on_change_per_page' => $this->_sJsObjName . '.changePerPage(this)',
-            'on_change_sorting' => $this->_sJsObjName . '.changeOrder(this)'
-        ));
         $this->_sStylePrefix = isset($this->_aSystem['root_style_prefix']) ? $this->_aSystem['root_style_prefix'] : 'cmt';
 
         BxDolTemplate::getInstance()->addJsTranslation('_sys_txt_cmt_loading');
@@ -42,17 +31,23 @@ class BxBaseCmtsView extends BxDolCmts {
     /**
      * get full comments block with initializations
      */
-    function getCommentsFirst () {
-        $sRet  = '<div id="cmts-box-' . $this->_sSystem . '-' . $this->getId() . '">';
-        $sRet .= '<div class="cmt-browse">' . $this->_getBrowse() . '</div>';
-        $sRet .= '<div class="cmts">' . $this->getComments (0, $this->_sOrder) . '</div>';
-        if(($sPaginate = $this->getPaginate()) !== "")
-            $sRet .= '<div class="cmt-show-more">' . $sPaginate . '</div>';
-        if($this->isPostReplyAllowed ())
-            $sRet .= '<div class="cmt-reply">' . $this->_getPostReplyBox() . "</div>";
-        $sRet .= '</div>';
-        $sRet .= $this->getCmtsInit ();
-        return $sRet;
+    function getCommentsFirst() {
+    	$sCmts = $this->getComments(0);
+
+    	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 == '',
+				'content' => array(
+					'style_prefix' => $this->_sStylePrefix
+				)
+			),
+    		'comments' => $sCmts,
+    		'reply' => $this->isPostReplyAllowed() ? $this->_getPostReplyBox() : '',
+    		'script' => $this->getCmtsInit()
+    	));
     }
 
     /**
@@ -60,63 +55,20 @@ class BxBaseCmtsView extends BxDolCmts {
      *
      * @param int $iCmtsParentId - parent comment to get child comments from
      */
-    function getComments ($iCmtsParentId = 0, $sCmtOrder = 'asc', $iStart = 0, $iPerPage = -1) {
-        if ($iCmtsParentId == 0 && $iPerPage == -1)
-            $iPerPage = $this->getPerView();
-
-        $sRet = '<ul class="cmts">';
-
-        $aCmts = $this->getCommentsArray ($iCmtsParentId, $sCmtOrder, $iStart, $iPerPage);
-        if (!$aCmts) {
-            $sRet .= '<li class="cmt-no">' . _t('_There are no comments yet') . '</li>';
-        } else {
-            $i = 0;
-            for ( reset($aCmts) ; list ($k, $r) = each ($aCmts) ;  ++$i) {
-                $sClass = '';
-                if ($r['cmt_rated'] == -1 || $r['cmt_rate'] < $this->_aSystem['viewing_threshold']) {
-                    $sRet .= '<li id="cmt' . $r['cmt_id'] . '-hidden" class="cmt-replacement">';
-                    $sRet .= bx_process_output(_t('_hidden_comment', $r['cmt_author_name'])) . ' ' . ($r['cmt_replies'] > 0 ? _t('_Show N replies', $r['cmt_replies']) . '. ' : '') . '<a href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.showReplacement(' . $r['cmt_id'] . ')">' . _t('_show_replacement') . '</a>.';
-                    if ($this->isRatable())
-                        $sRet .= $this->_getRateBox($r);
-                    $sRet .= '</li>';
-
-                    $sClass = ' cmt-hidden';
-                }
-
-
-                $isOwnComment = $r['cmt_author_id'] == $this->_getAuthorId();
-                if ($isOwnComment)
-                    $sClass .= ' cmt-mine';
-
-                $sRet .= '<li id="cmt'.$r['cmt_id'].'" class="cmt' . $sClass . '">';
-
-                $sRet .= '<div class="cmt-cont">';
-                $sRet .= $this->_getAuthorIcon($r);
-                $sRet .= '<table class="cmt-balloon">';
-                $sRet .= $this->_getCommentHeadBox($r);
-
-                $sRet .= '<tr class="cmt-cont" ' . $sStyle . '>';
-                $sRet .= $this->_getCommentBodyBox ($r);
-                $sRet .= '</tr>';
-
-                $sRet .= $this->_getActionsBox ($r, false);
-
-                $sRet .= '<tr class="cmt-foot"><td class="' . $this->_sStylePrefix . '-foot-l">&nbsp;</td><td class="' . $this->_sStylePrefix . '-foot-m">&nbsp;</td><td class="' . $this->_sStylePrefix . '-foot-r">&nbsp;</td></tr>';
-                $sRet .= '</table>';
-
-                $sRet .= '<div class="cmt-replies">' . ($r['cmt_replies'] ? $this->_getRepliesBox($r) : '&nbsp;') . '</div>';
-                if ($this->isPostReplyAllowed())
-                    $sRet .= $this->_getPostReplyBoxTo($r);
-                $sRet .= '<div class="clear_both">&nbsp;</div>';
-
-                if ($this->isRatable())
-                    $sRet .= $this->_getRateBox($r);
-                $sRet .= '</div></li>';
-            }
-        }
-        $sRet .= '</ul>';
+    function getComments ($iCmtParentId = 0, $iStart = -1, $iPerView = -1)
+    {
+    	list($iStart, $iPerView) = $this->_getBrowseParams($iCmtParentId, $iStart, $iPerView);
+
+		$aCmts = $this->getCommentsArray($iCmtParentId, $this->_sOrder, $iStart, $iPerView);
+		if(empty($aCmts) || !is_array($aCmts))
+			return '';
 
-        return $sRet;
+			
+		$sCmts = $iStart > 0 ? $this->_getMoreLink($iCmtParentId, $iStart, $iPerView) : '';
+		foreach($aCmts as $k => $r)
+			$sCmts .= $this->getComment($r);
+
+		return $sCmts;
     }
 
     /**
@@ -125,68 +77,104 @@ class BxBaseCmtsView extends BxDolCmts {
      * @param int $iCmtId - comment id
      * @return string
      */
-    function getComment($iCmtId, $sType = 'new')
+    function getComment($mixedCmt)
     {
-        $r = $this->getCommentRow ($iCmtId);
+    	$oTemplate = BxDolTemplate::getInstance();
+
+    	$iUserId = $this->_getAuthorId();
+    	$r = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
 
-        $sRet = '';
+        $sClass = $sRet = '';
         if($r['cmt_rated'] == -1 || $r['cmt_rate'] < $this->_aSystem['viewing_threshold']) {
-            $sRet .= '<li id="cmt' . $r['cmt_id'] . '-hidden" class="cmt-replacement">';
-            $sRet .= bx_process_output(_t('_hidden_comment', $r['cmt_author_name'])) . ' ' . ($r['cmt_replies'] > 0 ? _t('_Show N replies', $r['cmt_replies']) . '. ' : '') . '<a href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.showReplacement(' . $r['cmt_id'] . ')">' . _t('_show_replacement') . '</a>.';
-            if($this->isRatable())
-                $sRet .= $this->_getRateBox($r);
-            $sRet .= '</li>';
+        	$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'])),
+        		'bx_if:show_replies' => array(
+        			'condition' => $r['cmt_replies'] > 0,
+        			'content' => array(
+						'replies' => _t('_Show N replies', $r['cmt_replies'])
+        			)
+        		)
+        	));
 
             $sClass = ' cmt-hidden';
         }
 
-        $sRet .= '<li id="cmt' . $r['cmt_id'] . '" class="cmt cmt-mine cmt-just-posted' . $sClass . '">';
-
-        $sRet .= '<div class="cmt-cont">';
-
-        if ($this->isRatable())
-            $sRet .= $this->_getRateBox($r);
-
-        $sRet .= $this->_getAuthorIcon($r);
-        $sRet .= '<table class="cmt-balloon">';
-        $sRet .= $this->_getCommentHeadBox($r);
-
-        $sRet .= '<tr class="cmt-cont" ' . $sStyle . '>';
-        $sRet .= $this->_getCommentBodyBox ($r);
-        $sRet .= '</tr>';
-
-        if ($sType == 'new' && ($r['cmt_author_id'] == $this->_getAuthorId() || $this->isEditAllowedAll() || $this->isRemoveAllowedAll()))
-            $sRet .= $this->_getActionsBox ($r, true);
-
-        $sRet .= '<tr class="cmt-foot"><td class="' . $this->_sStylePrefix . '-foot-l">&nbsp;</td><td class="' . $this->_sStylePrefix . '-foot-m">&nbsp;</td><td class="' . $this->_sStylePrefix . '-foot-r">&nbsp;</td></tr>';
-        $sRet .= '</table>';
-
-        $sRet .= '<div class="cmt-replies">' . ($r['cmt_replies'] ? $this->_getRepliesBox($r) : '') . '</div>';
-        if($sType != 'new' && $this->isPostReplyAllowed())
-                    $sRet .= $this->_getPostReplyBoxTo($r);
-        $sRet .= '<div class="clear_both">&nbsp;</div></div></li>';
-
-        return $sRet;
-    }
-    function getPaginate($iStart = -1, $iPerPage = -1) {
-        return $this->_oPaginate->getPaginate($iStart, $iPerPage);
+		if($r['cmt_author_id'] == $iUserId)
+			$sClass .= ' cmt-mine';
+
+        list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($r);
+
+		$sActions = $this->_getActionsBox($r);
+
+		$sText = bx_process_output($r['cmt_text'], BX_DATA_TEXT_MULTILINE);
+		$sTextMore = '';
+
+		$iMaxLength = (int)$this->_aSystem['chars_display_max'];
+		if(strlen($sText) > $iMaxLength) {
+			$iLength = strpos($sText, ' ', $iMaxLength);
+			
+			$sTextMore = substr($sText, $iLength);
+			$sText = substr($sText, 0, $iLength);
+		}
+
+		$aTmplReplyTo = array();
+		if((int)$r['cmt_parent_id'] != 0) {
+			$aParent = $this->getCommentRow($r['cmt_parent_id']);
+			list($sParAuthorName, $sParAuthorLink, $sParAuthorIcon) = $this->_getAuthorInfo($aParent);
+
+			$aTmplReplyTo = array(
+        		'par_cmt_link' => '#' . $r['cmt_parent_id'],
+        		'par_cmt_author' => $sParAuthorName
+        	);
+		}
+ 
+        return $oTemplate->parseHtmlByName('comment.html', array(
+        	'system' => $this->_sSystem,
+        	'id' => $r['cmt_id'],
+        	'style_prefix' => $this->_sStylePrefix,
+        	'class' => $sClass,
+        	'author_icon' => $sAuthorIcon,
+        	'bx_if:show_author_link' => array(
+        		'condition' => !empty($sAuthorLink),
+        		'content' => array(
+        			'author_link' => $sAuthorLink,
+        			'author_name' => $sAuthorName
+        		)
+        	),
+        	'bx_if:show_author_text' => array(
+        		'condition' => empty($sAuthorLink),
+        		'content' => array(
+        			'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
+        	),
+        	'text' => $sText,
+        	'bx_if:show_more' => array(
+        		'condition' => !empty($sTextMore),
+        		'content' => array(
+        			'js_object' => $this->_sJsObjName,
+        			'text_more' => $sTextMore
+        		)
+        	),
+        	'actions' => $sActions
+        ));
     }
-    function getForm($sType, $iParentId) {
+
+    function getFormBox($sType, $iParentId)
+    {
         return $this->_getPostReplyBox($sType, $iParentId);
     }
-    function getActions($iCmtId, $sType = 'reply') {
-        $aParams = array(
-            'cmt_id' => $iCmtId,
-            'cmt_replies' => $this->_oQuery->getObjectCommentsCount($this->getId(), 0),
-            'cmt_type' => $sType
-        );
-
-        $sRet = "";
-        $sRet .= '<div class="cmt-replies">' . ($aParams['cmt_replies'] ? $this->_getRepliesBox($aParams) : '&nbsp;') . '</div>';
-        if($this->isPostReplyAllowed())
-            $sRet .= $this->_getPostReplyBoxTo($aParams);
-        $sRet .= '<div class="clear_both">&nbsp;</div>';
-        return $sRet;
+
+	function getForm($iCmtParentId, $sText, $sFunction)
+	{
+        return $this->_getPostReplyForm($iCmtParentId, $sText, $sFunction);
     }
 
     /**
@@ -204,7 +192,8 @@ class BxBaseCmtsView extends BxDolCmts {
      *
      * @return string
      */
-    function getExtraJs () {
+    function getExtraJs ()
+    {
         BxDolTemplate::getInstance()->addJs('BxDolCmts.js');
     }
 
@@ -213,16 +202,11 @@ class BxBaseCmtsView extends BxDolCmts {
      *
      * @return string
      */
-    function getCmtsInit() {
+    function getCmtsInit()
+    {
         $sToggleAdd = '';
-        $sUseHtmlAdd = '';
-        $ret = '';
-
-        if($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1 && ($this->isEditAllowed() || $this->isEditAllowedAll())) {
-            bx_import('BxTemplConfig');
-            $ret .= BxTemplConfig::getInstance()->sTinyMceEditorMicroJS;
-        }
 
+        $ret = '';
         $ret .= $sToggleAdd . "
             <script  type=\"text/javascript\">
                 var " . $this->_sJsObjName . " = new BxDolCmts({
@@ -235,24 +219,13 @@ class BxBaseCmtsView extends BxDolCmts {
                     sOrder : '" . $this->getOrder() . "',
                     sDefaultErrMsg : '" . bx_js_string(_t('_Error occured')) . "',
                     sConfirmMsg : '" . bx_js_string(_t('_Are you sure?')) . "',
-                    sAnimationEffect : '" . $this->_aSystem['animation_effect'] . "',
-                    sAnimationSpeed : '" . $this->_aSystem['animation_speed'] . "',
-                    isEditAllowed : " . ($this->isEditAllowed() || $this->isEditAllowedAll() ? 1 : 0) . ",
-                    isRemoveAllowed : " . ($this->isRemoveAllowed() || $this->isRemoveAllowedAll() ? 1 : 0) . ",
-                    sTextAreaId: '" . $this->sTextAreaId . "',
-                    iGlobAllowHtml: " . ($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1 ? 1 : 0) . ",
-                    iSecsToEdit : " . (int)$this->getAllowedEditTime() . "});
+                    sTextAreaId: '" . $this->sTextAreaId . "'});
                 " . $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'])) . "\" },";
         }
         $ret = substr($ret, 0, -1);
         $ret .= "\n};\n";
-
-        if ($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1)
-            $ret .= $this->_sJsObjName . ".createEditor(0, $('#cmts-box-" . $this->_sSystem . "-" . $this->_iId . "> .cmt-reply form [name=CmtText][tinypossible=true]'), true);\n";
-
         $ret .= "</script>";
 
         $this->getExtraJs();
@@ -263,161 +236,129 @@ class BxBaseCmtsView extends BxDolCmts {
     /**
      * private functions
      */
-    function _getCommentHeadBox (&$a) {
-        if ($a['cmt_author_id'] && $a['cmt_author_name'])
-            $sAuthor = '<a href="' . getProfileLink($a['cmt_author_id']) . '" class="cmt-author">' . bx_process_output($a['cmt_author_name']) . '</a>';
-        else
-            $sAuthor = _t('_Anonymous');
-
-        $sRet = '<tr class="cmt-head"><td class="' . $this->_sStylePrefix . '-head-l">&nbsp;</td><td class="' . $this->_sStylePrefix . '-head-m">' . bx_process_output($sAuthor) . ' ' . _t('_wrote') . ' <span class="cmt-posted-ago">' . $a['cmt_ago'] . ' (<span class="cmt-mood-text">' . _t($this->_aMoodText[$a['cmt_mood']]) . '</span>)</span></td><td class="' . $this->_sStylePrefix . '-head-r">&nbsp;</td></tr>';
-
-        return $sRet;
-    }
-
-    function _getCommentBodyBox(&$a) {
-        return '
-                <td class="' . $this->_sStylePrefix . '-cont-l">&nbsp;</td>
-                <td class="' . $this->_sStylePrefix . '-cont-m">
-                    <div class="cmt-mood">' . bx_process_output($a['cmt_mood']) . '</div>
-                    <div class="cmt-body">' . bx_process_output($a['cmt_text'], BX_DATA_TEXT_MULTILINE) . '</div>
-                </td>
-                <td class="' . $this->_sStylePrefix . '-cont-r">&nbsp;</td>';
+    function _getMoreLink($iParentId, $iStart, $iPerView)
+    {
+    	return BxDolTemplate::getInstance()->parseHtmlByName('comment_more.html', array(
+			'js_object' => $this->_sJsObjName,
+			'style_prefix' => $this->_sStylePrefix,
+			'parent_id' => $iParentId,
+    		'start' => $iStart,
+    		'per_view' => $iPerView
+		));
     }
 
-    function _getRateBox(&$a)
+	function _getActionsBox(&$a)
     {
-        $sClass = '';
-        if ($a['cmt_rated'] || $a['cmt_rate'] < $this->_aSystem['viewing_threshold'])
-            $sClass = ' cmt-rate-disabled';
-
-        return '
-            <div class="cmt-rate'.$sClass.'">
-                <div class="cmt-points">'._t( (1 == $a['cmt_rate'] || -1 == $a['cmt_rate'])  ? '_N point' : '_N points', $a['cmt_rate']).'</div>
-                <div class="cmt-buttons"><a title="'._t('_Thumb Up').'" href="javascript:void(0)" id="cmt-pos-'.$a['cmt_id'].'" class="cmt-pos"><img src="' . getTemplateIcon('spacer.gif') . '" /></a><a title="'._t('_Thumb Down').'" href="javascript:void(0)" id="cmt-neg-'.$a['cmt_id'].'" class="cmt-neg"><img src="' . getTemplateIcon('spacer.gif') . '" /></a></div>
-                <div class="clear_both">&nbsp;</div>
-            </div>';
+        $iUserId = $this->_getAuthorId();
+        $isEditAllowedPermanently = ($a['cmt_author_id'] == $iUserId && $this->isEditAllowed()) || $this->isEditAllowedAll();
+        $isRemoveAllowedPermanently = ($a['cmt_author_id'] == $iUserId && $this->isRemoveAllowed()) || $this->isRemoveAllowedAll();
+
+        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,
+        		'content' => array(
+        			'js_object' => $this->_sJsObjName,
+        			'style_prefix' => $this->_sStylePrefix,
+        			'id' => $a['cmt_id']
+        		)
+        	),
+        	'bx_if:show_rate' => array(
+				'condition' => $this->isRatable(),
+        		'content' => array(
+        			'js_object' => $this->_sJsObjName,
+        			'style_prefix' => $this->_sStylePrefix,
+        			'id' => $a['cmt_id']
+        		)
+        	),
+        	'bx_if:show_replies' => array(
+				'condition' => (int)$a['cmt_replies'] > 0,
+        		'content' => array(
+        			'js_object' => $this->_sJsObjName,
+        			'style_prefix' => $this->_sStylePrefix,
+        			'id' => $a['cmt_id'],
+        			'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(),
+        		'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')
+        		)
+        	)
+        ));
     }
 
-    function _getActionsBox (&$a, $isJustPosted) {
-
-        $n = $this->getAllowedEditTime();
-
-        $isEditAllowedPermanently = ($a['cmt_author_id'] == $this->_getAuthorId() && $this->isEditAllowed()) || $this->isEditAllowedAll();
-        $isRemoveAllowedPermanently = ($a['cmt_author_id'] == $this->_getAuthorId() && $this->isRemoveAllowed()) || $this->isRemoveAllowedAll();
-
-        if (!($n && $isJustPosted) && !$isEditAllowedPermanently && !$isRemoveAllowedPermanently)
-            return '';
-
-        $sRet  = '<tr id="cmt-jp-'.$a['cmt_id'].'" class="cmt-jp"><td class="' . $this->_sStylePrefix . '-cont-l">&nbsp;</td><td class="' . $this->_sStylePrefix . '-cont-m">';
-
-        if (($isEditAllowedPermanently || ($isJustPosted && $n)) && strpos($a['cmt_text'], 'video_comments') === false)
-            $sRet .= '<a class="cmt-comment-manage-edit" title="'._t('_Edit').'" href="javascript:void(0)" onclick="' . $this->_sJsObjName . '.cmtEdit(this, \'' . $a['cmt_id'] . '\'); return false;">'._t('_Edit').'</a>&nbsp;';
-
-        if ($isRemoveAllowedPermanently || ($isJustPosted && $n))
-            $sRet .= '<a class="cmt-comment-manage-delete" title="'._t('_Remove').'" href="javascript:void(0)" onclick="' . $this->_sJsObjName . '.cmtRemove(this, \'' . $a['cmt_id'] . '\'); return false;">'._t('_Remove').'</a>';
-
-        if ($isJustPosted && $n && !$isEditAllowedPermanently)
-            $sRet .= _t('_available_for_n_seconds', $n);
-
-        $sRet .= '</td><td class="' . $this->_sStylePrefix . '-cont-r">&nbsp;</td></tr>';
-
-        return $sRet;
+    function _getPostReplyBox($sType = 'comment', $iCmtParentId = 0)
+    {
+    	bx_import('BxDolProfile');
+		$oProfile = null; //BxDolProfile::getInstanceAccountProfile($this->_getAuthorId());
+
+    	return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_box.html', array(
+    		'style_prefix' => $this->_sStylePrefix,
+    		'author_icon' => $oProfile ? $oProfile->getThumb() : 'icon',
+			'form' => $this->_getPostReplyForm($iCmtParentId)
+    	));
     }
 
-    function _getRepliesBox (&$a) {
-        $sContentShow = _t((isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Show N comments' : '_Show N replies'), $a['cmt_replies']);
-        $sContentHide = _t((isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Hide N comments' : '_Hide N replies'), $a['cmt_replies']);
-        return '<a class="cmt-replies-show" href="javascript:void(0)" onclick="' . $this->_sJsObjName . '.toggleCmts(this, \'' . $a['cmt_id'] . '\'); return false;">' . $sContentShow . '</a><a class="cmt-replies-hide" href="javascript:void(0)" onclick="' . $this->_sJsObjName . '.toggleCmts(this, \'' . $a['cmt_id'] . '\'); return false;">' . $sContentHide . '</a>';
+    function _getPostReplyForm($iCmtParentId = 0, $sText = "", $sFunction = "cmtSubmit(this)")
+    {
+    	return BxDolTemplate::getInstance()->parseHtmlByName('comment_reply_form.html', array(
+    		'js_object' => $this->_sJsObjName,
+    		'js_function' => $sFunction,
+    		'parent_id' => $iCmtParentId,
+    		'text' => bx_process_output($sText)
+    	));
     }
-
-    function _getPostReplyBoxTo (&$a) {
-        $sContent = _t(isset($a['cmt_type']) && $a['cmt_type'] == 'comment' ? '_Comment to this comment' : '_Reply to this comment');
-        return '<div class="cmt-post-reply-to">
-                    <a href="javascript:void(0)" onclick="' . $this->_sJsObjName . '.toggleReply(this, \''.$a['cmt_id'].'\'); return false;">' . $sContent . '</a>
-                </div>';
+	function _getBrowseParams($iCmtParentId = 0, $iStart = -1, $iPerView = -1)
+    {
+    	$iStart = $iStart != -1 ? $iStart : $this->_oQuery->getCommentsCount($this->_iId, $iCmtParentId);
+    	$iPerView = $iPerView != -1 ? $iPerView : $this->getPerView($iCmtParentId);
+
+    	switch($this->_aSystem['show']) {
+    		case BX_CMT_SHOW_HEAD:
+    			$iStart = 0;
+    			break;
+    		case BX_CMT_SHOW_TAIL:
+    			$iStart = $iStart - $iPerView;
+    			if($iStart < 0) {
+    				$iPerView += $iStart;
+    				$iStart = 0;
+    			}
+    			break;
+    	}
+
+    	return array($iStart, $iPerView);
     }
 
-    function _getPostReplyBox($sType = 'comment', $iCmtParentId = 0) {
-
-        if ($sType == 'comment')
-            $sSwitcher = '<a class="cmt-post-reply-text inactive" href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.toggleType(this)">' . _t('_Add Your Comment') . '</a><a class="cmt-post-reply-video" href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.toggleType(this)">' . _t('_Record Your Comment') . '</a>';
-        else if ($sType == 'reply')
-            $sSwitcher = '<a class="cmt-post-reply-text inactive" href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.toggleType(this)">' . _t('_Reply as text') . '</a><a class="cmt-post-reply-video" href="javascript:void(0)" onclick="javascript:' . $this->_sJsObjName . '.toggleType(this)">' . _t('_Reply as video') . '</a>';
-
-        return '
-                <div class="cmt-post-reply">
-                    ' . $this->_getAuthorIcon(array('cmt_author_id' => $this->_getAuthorId())) . '
-                    <table class="cmt-balloon">
-                        <tr class="cmt-head">
-                            <td class="cmt-head-l">&nbsp;</td>
-                            <td class="cmt-head-m">' . $sSwitcher . '<div class="clear_both"></div></td>
-                            <td class="cmt-head-r">&nbsp;</td>
-                        </tr>
-                        <tr class="cmt-cont">
-                            <td class="cmt-cont-l">&nbsp;</td>
-                            <td class="cmt-cont-m">' . $this->_getFormBox($iCmtParentId) . '</td>
-                            <td class="cmt-cont-r">&nbsp;</td>
-                        </tr>
-                        <tr class="cmt-foot">
-                            <td class="cmt-foot-l">&nbsp;</td>
-                            <td class="cmt-foot-m">&nbsp;</td>
-                            <td class="cmt-foot-r">&nbsp;</td>
-                        </tr>
-                    </table>
-                </div>';
-    }
+    function _getAuthorInfo($r)
+    {
+    	$sAuthorName = _t('_Anonymous');
+    	$sAuthorLink = ''; 
+        $sAuthorIcon = '';
 
-    function _getFormBox($iCmtParentId = 0, $sText = "", $sFunction = "submitComment(this)") {
-
-        $sTinyStyle = ($this->iGlobAllowHtml == 1 && $this->iGlobUseTinyMCE == 1) ? ' tinypossible="true" ' : '';
-
-        if ($this->_aSystem['is_mood'])
-            $sMood = '
-                    <div class="cmt-post-reply-mood">
-                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="1" id="' . $this->_sSystem . '-mood-positive" /></div>
-                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-positive">' . _t('_Comment Positive') . '</label></div>
-                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="-1" id="' . $this->_sSystem . '-mood-negative" /></div>
-                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-negative">' . _t('_Comment Negative') . '</label></div>
-                        <div class="cmt-post-mood-ctl"><input type="radio" name="CmtMood" value="0" id="' . $this->_sSystem . '-mood-neutral" checked="checked" /></div>
-                        <div class="cmt-post-mood-lbl"><label for="' . $this->_sSystem . '-mood-neutral">' . _t('_Comment Neutral') . '</label></div>
-                        <div class="clear_both">&nbsp;</div>
-                    </div>';
-
-        return '
-                <form name="cmt-post-reply" onsubmit="' . $this->_sJsObjName . '.' . $sFunction . '; return false;">
-                    <input type="hidden" name="CmtParent" value="' . $iCmtParentId . '" />
-                    <input type="hidden" name="CmtType" value="text" />
-                    <div class="cmt-post-reply-text">
-                        <textarea name="CmtText" ' . $sTinyStyle . ' >' . bx_process_output($sText) . '</textarea>
-                    </div>
-                    <div class="cmt-post-reply-video">' . getApplicationContent('video_comments', 'recorder', array('user' => $this->_getAuthorId(), 'password' => $this->_getAuthorPassword(), 'extra' => implode('_', array($this->_sSystem . '-' . $this->getId(), $iCmtParentId))), true) . '</div>
-                    <div class="cmt-post-reply-post"><input type="submit" value="' . _t('_Submit Comment') . '" /></div>
-                    ' . $sMood . '
-                </form>';
-    }
+		$bAuthor = false; //$r['cmt_author_id'] && $r['cmt_author_name'];
+		if($bAuthor) {
+			$oProfile = null; //BxDolProfile::getInstanceAccountProfile($r['cmt_author_id']);
 
-	function _getAuthorIcon ($a) {
-        global $oFunctions;
-        if (!$a['cmt_author_id'] || !getProfileInfo($a['cmt_author_id'])) {
-            if (!@include_once (BX_DIRECTORY_PATH_MODULES . 'boonex/avatar/include.php'))
-                return '';
-            return '<div class="thumbnail_block" style="float:none;width:'.(BX_AVA_ICON_W+8).'px;height:'.(BX_AVA_ICON_H+8).'px;"><div class="thumbnail_image" style="width:'.(BX_AVA_ICON_W+4).'px;height:'.(BX_AVA_ICON_H+4).'px;"><img src="' . $oFunctions->getSexPic('', 'small') . '" /></div></div>';
-        } else {
-            return $oFunctions->getMemberIcon($a['cmt_author_id']);
-        }
-    }
+			$sAuthorName = bx_process_output($r['cmt_author_name']);
+			$sAuthorLink = $oProfile->getUrl();
+			$sAuthorIcon = $oProfile->getThumb();
+			
+		}
 
-    function _getBrowse() {
-        return "TODO: cmts browse";
-/*
-        $sRet = '
-            <div class="cmt-order">' . $this->_oPaginate->getSorting(array('asc' => '_oldest first', 'desc' => '_newest first')) . ' 
-                <input type="checkbox" id="cmt-expand" name="cmt-expand" onclick="javascript:' . $this->_sJsObjName . '.expandAll(this)"/><label for="cmt-expand">' . _t('_expand all') . '</label>
-            </div>
-            <div class="cmt-pages">' . $this->_oPaginate->getPages() . '</div>
-            <div class="clear_both">&nbsp;</div>';
-        return $sRet;
-*/
+		return array($sAuthorName, $sAuthorLink, $sAuthorIcon);
     }
 }
-

+ 12 - 0
template/scripts/BxBaseServiceAccount.php

@@ -25,6 +25,18 @@ class BxBaseServiceAccount extends BxDol {
         $this->_oAccountQuery = BxDolAccountQuery::getInstance();
     }
 
+	public function serviceAccountComments ($iAccountId = false) {
+        if (false === $iAccountId)
+            $iAccountId = getLoggedId();
+
+		bx_import('BxTemplCmtsView');
+		$oCmts = new BxTemplCmtsView('profile', (int)$iAccountId);
+		if(!$oCmts->isEnabled())
+			return '';
+
+        return $oCmts->getCommentsFirst();
+    }
+    
     public function serviceCreateAccountForm () {
         return $this->_oAccountForms->createAccountForm();
     }

Некоторые файлы не были показаны из-за большого количества измененных файлов