AntonLV 7 anni fa
parent
commit
122b8d96fa

+ 21 - 1
inc/classes/BxDolCmts.php

@@ -150,6 +150,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
     protected $_oQuery = null;
     protected $_oTemplate = null;
 
+    protected $_bPostQuote;
     protected $_bMinPostForm;
     protected $_sFormObject;
     protected $_sFormDisplayPost;
@@ -241,6 +242,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
 
         $this->_oQuery = new BxDolCmtsQuery($this);
 
+        $this->_bPostQuote = false;
         $this->_bMinPostForm = true;
         $this->_sFormObject = 'sys_comment';
         $this->_sFormDisplayPost = 'sys_comment_post';
@@ -883,6 +885,16 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return $this->msgErrPostAllowed ();
     }
 
+    public function isQuoteAllowed ($mixedCmt, $isPerformAction = false)
+    {
+        return $this->_bPostQuote && $this->isReplyAllowed ($mixedCmt, $isPerformAction);
+    }
+
+    public function msgErrQuoteAllowed ()
+    {
+        return $this->msgErrReplyAllowed ();
+    }
+
     public function isEditAllowed ($aCmt, $isPerformAction = false)
     {
         if(isAdmin())
@@ -958,10 +970,13 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         $sCmtDisplay = bx_get('CmtDisplay');
         $sCmtDisplay = $sCmtDisplay !== false ? bx_process_input($sCmtDisplay, BX_DATA_TEXT) : '';
 
+        $bQuote = bx_get('CmtQuote');
+        $bQuote = $bQuote !== false ? bx_process_input($bQuote, BX_DATA_INT) == 1 : false;
+
         $bMinPostForm = bx_get('CmtMinPostForm');
         $bMinPostForm = $bMinPostForm !== false ? bx_process_input($bMinPostForm, BX_DATA_INT) == 1 : $this->_bMinPostForm;
 
-        return $this->getFormBoxPost(array('parent_id' => $iCmtParentId, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay, 'dynamic_mode' => true, 'min_post_form' => $bMinPostForm));
+        return $this->getFormBoxPost(array('parent_id' => $iCmtParentId, 'type' => $sCmtBrowse), array('type' => $sCmtDisplay, 'dynamic_mode' => true, 'quote' => $bQuote, 'min_post_form' => $bMinPostForm));
     }
 
     public function actionGetFormEdit ()
@@ -1464,6 +1479,10 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         if(bx_get('CmtBlink') !== false) 
             $aDp['blink'] = bx_process_input($_REQUEST['CmtBlink'], BX_DATA_TEXT);
 
+        $aDp['quote'] = isset($aDp['quote']) ? (int)$aDp['quote'] : 0;
+        if(bx_get('CmtQuote') !== false) 
+            $aDp['quote'] = bx_process_input($_REQUEST['CmtQuote'], BX_DATA_INT);
+
         $aDp['min_post_form'] = isset($aDp['min_post_form']) ? (bool)$aDp['min_post_form'] : $this->_bMinPostForm;
         if(bx_get('CmtMinPostForm') !== false)
             $aDp['min_post_form'] = bx_process_input(bx_get('CmtMinPostForm'), BX_DATA_INT) == 1;
@@ -1499,6 +1518,7 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         $aDp['blink'] = !empty($aDp['blink']) ? $aDp['blink'] : array();
         if(!is_array($aDp['blink']))
             $aDp['blink'] = explode(',', $aDp['blink']);
+        $aDp['quote'] = !empty($aDp['quote']) ? (int)$aDp['quote'] : 0;
         if(!isset($aDp['min_post_form']))
             $aDp['min_post_form'] = $this->_bMinPostForm;
 

+ 40 - 21
inc/js/classes/BxDolCmts.js

@@ -97,14 +97,20 @@ BxDolCmts.prototype.cmtAfterPostSubmit = function (oCmtForm, oData)
                 var iCmtId = parseInt(oData.id);
                 if(iCmtId > 0) {
                     $this._getCmt(oCmtForm, iCmtId);
-                    $this._getForm(undefined, parseInt(oData.parent_id), function(sFormWrp) {
-                        if(sFormWrp && sFormWrp.length > 0)
-                            sFormWrp = $(sFormWrp).html();
 
-                        oParent.hide().html(sFormWrp).show();
+                    var iCmtParentId = parseInt(oData.parent_id);
+                    if(iCmtParentId == 0)
+                        $this._getForm(undefined, {CmtParent: iCmtParentId}, function(sFormWrp) {
+                            if(sFormWrp && sFormWrp.length > 0)
+                                sFormWrp = $(sFormWrp).html();
 
-                        $this.cmtInitFormPost(oParent.find('form'));
-                    });
+                            oParent.hide().html(sFormWrp).show();
+
+                            $this.cmtInitFormPost(oParent.find('form'));
+                        });
+                    else
+                        oParent.remove();
+                        
                 }
 
                 return;
@@ -350,21 +356,29 @@ BxDolCmts.prototype.showImage = function(oLink, sUrl) {
 	$(this._sRootId + '-view-image-popup').dolPopupImage(sUrl, $(oLink).parents('.cmt-attached:first'));
 };
 
-BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
+BxDolCmts.prototype.toggleReply = function(e, iCmtParentId, iQuote)
 {
     var $this = this;
-    var sParentId = this._sRootId + ' #cmt' + iCmtParentId;
+    var aParams = {
+        CmtParent: iCmtParentId,
+        CmtQuote: iQuote != undefined ? parseInt(iQuote) : 0
+    };
     var fOnShow = function() {
         $(this).find('textarea:first').focus();
     };
 
-    var sReplyId = sParentId + ' > .cmt-reply';
-    if ($(sReplyId).length) {
-        $(sReplyId).bx_anim('toggle', this._sAnimationEffect, this._iAnimationSpeed, fOnShow);
+    var sParentId = this._sRootId + ' #cmt' + iCmtParentId;
+    var sReplyQuoteId = '.cmt-reply-quote';
+    if(!aParams['CmtQuote'])
+        sReplyQuoteId = ':not(' + sReplyQuoteId + ')';
+    var sReplyId = '.cmt-reply' + sReplyQuoteId;
+
+    if ($(sParentId + ' > ' + sReplyId).length) {
+        $(sParentId + ' > ' + sReplyId).bx_anim('toggle', this._sAnimationEffect, this._iAnimationSpeed, fOnShow);
         return;
     }
 
-    this._getForm(e, iCmtParentId, function(sForm) {
+    this._getForm(e, aParams, function(sForm) {
         var oForm = $(sForm).hide().addClass('cmt-reply-' + $this._sPostFormPosition).addClass('cmt-reply-margin');
         var oFormSibling = $(sParentId + ' > ul.cmts:first');
         switch($this._sPostFormPosition) {
@@ -379,10 +393,15 @@ BxDolCmts.prototype.toggleReply = function(e, iCmtParentId)
 
         $this.cmtInitFormPost(oForm.find('form'));
 
-        $(sParentId).children('.cmt-reply').bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, fOnShow);
+        $(sParentId).children(sReplyId).bx_anim('toggle', $this._sAnimationEffect, $this._iAnimationSpeed, fOnShow);
     });
 };
 
+BxDolCmts.prototype.toggleQuote = function(e, iCmtParentId)
+{
+    this.toggleReply(e, iCmtParentId, 1);
+};
+
 BxDolCmts.prototype.goTo = function(oLink, sGoToId, sBlinkIds, onLoad)
 {
     $(oLink).parents('.bx-popup-applied:first:visible').dolPopupHide();
@@ -623,16 +642,16 @@ BxDolCmts.prototype._getCmts = function (oElement, oRequestParams, onLoad)
     );
 };
 
-BxDolCmts.prototype._getForm = function (e, iCmtParentId, onLoad)
+BxDolCmts.prototype._getForm = function (e, oParams, onLoad)
 {
     var $this = this;
-    var oData = this._getDefaultActions();
-    oData['action'] = 'GetFormPost';
-    oData['CmtType'] = 'reply';
-    oData['CmtParent'] = iCmtParentId;
-    oData['CmtBrowse'] = this._sBrowseType;
-    oData['CmtDisplay'] = this._sDisplayType;
-    oData['CmtMinPostForm'] = this._iMinPostForm;
+    var oData = $.extend({}, this._getDefaultActions(), {
+        action: 'GetFormPost',
+        CmtType: 'reply',
+        CmtBrowse: this._sBrowseType, 
+        CmtDisplay: this._sDisplayType, 
+        CmtMinPostForm: this._iMinPostForm
+    }, oParams);
 
     if(e)
     	this._loadingInContent(e, true);

+ 2 - 1
install/sql/system.sql

@@ -3806,7 +3806,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl
 ('sys_cmts_item_actions', 'system', 'item-reaction', '_sys_menu_item_title_system_cmts_item_reaction', '_sys_menu_item_title_cmts_item_reaction', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 0, 0, 1, 1),
 ('sys_cmts_item_actions', 'system', 'item-score', '_sys_menu_item_title_system_cmts_item_score', '_sys_menu_item_title_cmts_item_score', 'javascript:void(0)', '', '', '', '', '', 0, 2147483647, 0, 0, 1, 2),
 ('sys_cmts_item_actions', 'system', 'item-reply', '_sys_menu_item_title_system_cmts_item_reply', '_sys_menu_item_title_cmts_item_reply', 'javascript:void(0)', 'javascript:{reply_onclick}', '_self', 'reply', '', '', 0, 2147483647, 1, 0, 1, 3),
-('sys_cmts_item_actions', 'system', 'item-more', '_sys_menu_item_title_system_cmts_item_more', '_sys_menu_item_title_cmts_item_more', 'javascript:void(0)', 'bx_menu_popup(''sys_cmts_item_manage'', this, {''id'':''sys_cmts_item_manage_{cmt_system}_{cmt_id}''}, {cmt_system:''{cmt_system}'', cmt_object_id:{cmt_object_id}, cmt_id:{cmt_id}});', '', 'ellipsis-h', '', 'sys_cmts_item_manage', 1, 2147483647, 1, 0, 1, 4);
+('sys_cmts_item_actions', 'system', 'item-quote', '_sys_menu_item_title_system_cmts_item_quote', '_sys_menu_item_title_cmts_item_quote', 'javascript:void(0)', 'javascript:{quote_onclick}', '_self', 'quote-right', '', '', 0, 2147483647, 1, 0, 1, 4),
+('sys_cmts_item_actions', 'system', 'item-more', '_sys_menu_item_title_system_cmts_item_more', '_sys_menu_item_title_cmts_item_more', 'javascript:void(0)', 'bx_menu_popup(''sys_cmts_item_manage'', this, {''id'':''sys_cmts_item_manage_{cmt_system}_{cmt_id}''}, {cmt_system:''{cmt_system}'', cmt_object_id:{cmt_object_id}, cmt_id:{cmt_id}});', '', 'ellipsis-h', '', 'sys_cmts_item_manage', 1, 2147483647, 1, 0, 1, 5);
 
 -- comment meta info menu
 INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `title`, `link`, `onclick`, `target`, `icon`, `addon`, `submenu_object`, `submenu_popup`, `visible_for_levels`, `active`, `copyable`, `editable`, `order`) VALUES 

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

@@ -2277,6 +2277,7 @@ If it is not enabled then please consider implement this optimization, since it
   <string name="_sys_menu_item_title_cmts_administration"><![CDATA[Comments]]></string>
 	<string name="_sys_menu_item_title_cmts_item_delete"><![CDATA[Delete]]></string>
 	<string name="_sys_menu_item_title_cmts_item_edit"><![CDATA[Edit]]></string>
+        <string name="_sys_menu_item_title_cmts_item_quote"><![CDATA[]]></string>
         <string name="_sys_menu_item_title_cmts_item_reaction"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_cmts_item_score"><![CDATA[]]></string>
@@ -2339,9 +2340,10 @@ If it is not enabled then please consider implement this optimization, since it
 	<string name="_sys_menu_item_title_system_account_settings_pwd"><![CDATA[Password]]></string>
 	<string name="_sys_menu_item_title_system_add_content"><![CDATA[Add Content]]></string>
 	<string name="_sys_menu_item_title_system_cart"><![CDATA[Shopping Cart]]></string>
-  <string name="_sys_menu_item_title_system_cmts_administration"><![CDATA[Comments]]></string>
+        <string name="_sys_menu_item_title_system_cmts_administration"><![CDATA[Comments]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_delete"><![CDATA[Delete]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_edit"><![CDATA[Edit]]></string>
+        <string name="_sys_menu_item_title_system_cmts_item_quote"><![CDATA[Quote]]></string>
         <string name="_sys_menu_item_title_system_cmts_item_reaction"><![CDATA[Reaction]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_reply"><![CDATA[Reply]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_report"><![CDATA[Report]]></string>

+ 5 - 3
modules/boonex/forum/classes/BxForumCmts.php

@@ -11,10 +11,10 @@
 
 class BxForumCmts extends BxTemplCmts
 {
-	protected $MODULE;
-	protected $_oModule;
+    protected $MODULE;
+    protected $_oModule;
 
-	public function __construct($sSystem, $iId, $iInit = 1)
+    public function __construct($sSystem, $iId, $iInit = 1)
     {
     	$this->MODULE = 'bx_forum';
     	$this->_oModule = BxDolModule::getInstance($this->MODULE);
@@ -22,6 +22,8 @@ class BxForumCmts extends BxTemplCmts
         $this->_sTableImages = 'bx_forum_files';
 
         parent::__construct($sSystem, $iId, $iInit, $this->_oModule->_oTemplate);
+
+        $this->_bPostQuote = true;
     }
 
     public function registerTranscoders()

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

@@ -2278,6 +2278,7 @@
 	<string name="_sys_menu_item_title_cmts_administration"><![CDATA[Комментарии]]></string>
 	<string name="_sys_menu_item_title_cmts_item_delete"><![CDATA[Удалить]]></string>
 	<string name="_sys_menu_item_title_cmts_item_edit"><![CDATA[Редактировать]]></string>
+        <string name="_sys_menu_item_title_cmts_item_quote"><![CDATA[]]></string>
         <string name="_sys_menu_item_title_cmts_item_reaction"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_cmts_item_reply"><![CDATA[]]></string>
 	<string name="_sys_menu_item_title_cmts_item_score"><![CDATA[]]></string>
@@ -2342,6 +2343,7 @@
   <string name="_sys_menu_item_title_system_cmts_administration"><![CDATA[Комментарии]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_delete"><![CDATA[Удалить]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_edit"><![CDATA[Редактировать]]></string>
+        <string name="_sys_menu_item_title_system_cmts_item_quote"><![CDATA[Цитировать]]></string>
         <string name="_sys_menu_item_title_system_cmts_item_reaction"><![CDATA[Реагировать]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_reply"><![CDATA[Ответить]]></string>
 	<string name="_sys_menu_item_title_system_cmts_item_report"><![CDATA[Пожаловаться]]></string>

+ 2 - 0
template/comment_quote.html

@@ -0,0 +1,2 @@
+<blockquote>__content__</blockquote>
+<p></p>

+ 13 - 1
template/scripts/BxBaseCmts.php

@@ -735,7 +735,8 @@ class BxBaseCmts extends BxDolCmts
     {
         $iCmtParentId = isset($aBp['parent_id']) ? (int)$aBp['parent_id'] : 0;
         $sPosition = isset($aDp['position']) ? $aDp['position'] : '';
-        $bFormMin = $iCmtParentId == 0 && isset($aDp['min_post_form']) ? $aDp['min_post_form'] : false;
+        $bQuote = isset($aDp['quote']) && (bool)$aDp['quote'];
+        $bFormMin = $iCmtParentId == 0 && isset($aDp['min_post_form']) && (bool)$aDp['min_post_form'];
 
         $sPositionSystem = $this->_aSystem['post_form_position'];
         if(!empty($sPosition) && $sPositionSystem != $sPosition)
@@ -744,6 +745,8 @@ class BxBaseCmts extends BxDolCmts
         $sClass = '';
         if(!empty($sPosition))
             $sClass .= ' ' . $this->_sStylePrefix . '-reply-' . $sPosition;
+        if($bQuote)
+            $sClass .= ' ' . $this->_sStylePrefix . '-reply-quote';
         if($bFormMin)
             $sClass .= ' ' . $this->_sStylePrefix . '-reply-min';
         if(!empty($aDp['class']))
@@ -808,10 +811,19 @@ class BxBaseCmts extends BxDolCmts
             return array('msg' => _t('_Access denied'));
 
         $bDynamic = isset($aDp['dynamic_mode']) && (bool)$aDp['dynamic_mode'];
+        $bQuote = isset($aDp['quote']) && (bool)$aDp['quote'];
 
         $oForm = $this->_getForm(BX_CMT_ACTION_POST, $iCmtParentId);
         $oForm->aInputs['cmt_parent_id']['value'] = $iCmtParentId;
 
+        if($bQuote) {
+            $aCmtParent = $this->getCommentRow((int)$iCmtParentId);
+            if(!empty($aCmtParent['cmt_text']))
+                $oForm->aInputs['cmt_text']['value'] = $this->_oTemplate->parseHtmlByName('comment_quote.html', array(
+                    'content' => $aCmtParent['cmt_text']
+                ));
+        }
+
         $oForm->initChecker();
         if($oForm->isSubmittedAndValid()) {
             $iCmtAuthorId = $this->_getAuthorId();

+ 9 - 2
template/scripts/BxBaseCmtsMenuActions.php

@@ -38,9 +38,10 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
             'js_object' => $sJsObject,
             'cmt_system' => $this->_oCmts->getSystemName(),
             'cmt_object_id' => $this->_oCmts->getId(),
-        	'cmt_id' => $iCmtId,
+            'cmt_id' => $iCmtId,
             'content_id' => $iCmtId,
-            'reply_onclick' => $sJsObject . '.toggleReply(this, ' . $iCmtId . ')'
+            'reply_onclick' => $sJsObject . '.toggleReply(this, ' . $iCmtId . ')',
+            'quote_onclick' => $sJsObject . '.toggleQuote(this, ' . $iCmtId . ')'
         ));
     }
 
@@ -115,6 +116,12 @@ class BxBaseCmtsMenuActions extends BxTemplMenuCustom
                     $aCheckFuncParams = array($this->_aCmt);
                 break;
 
+            case 'item-quote':
+                $sCheckFuncName = 'isQuoteAllowed';
+                if(!empty($this->_aCmt))
+                    $aCheckFuncParams = array($this->_aCmt);
+                break;
+
             case 'item-vote':
                 $sCheckFuncName = 'isVoteAllowed';
                 if(!empty($this->_aCmt))