Преглед изворни кода

Ticket #5274 - Comments: make every comments page title unique.

AntonLV пре 11 месеци
родитељ
комит
ada65dbe51

+ 15 - 0
inc/classes/BxDolCmts.php

@@ -539,6 +539,21 @@ class BxDolCmts extends BxDolFactory implements iBxDolReplaceable, iBxDolContent
         return $this->_prepareTextForOutput($mixedItem['cmt_text'], (int)$mixedItem['cmt_id']);
     }
 
+    public function getViewSnippet($mixedItem, $sMaxLength = 20)
+    {
+        if(!is_array($mixedItem))
+            $mixedItem = $this->getCommentSimple((int)$mixedItem);
+
+        if(empty($mixedItem) || !is_array($mixedItem))
+            return '';
+
+        $sResult = bx_process_output(strip_tags($mixedItem['cmt_text']), BX_DATA_TEXT);
+        if(mb_strlen($sResult) > $sMaxLength)
+            $sResult = strmaxtextlen($sResult, $sMaxLength, '...');
+
+        return $sResult;
+    }
+
     public function getBaseUrl($sPrefix = BX_DOL_URL_ROOT)
     {
         $sUrl = $this->_replaceMarkers($this->_sBaseUrl);

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

@@ -2063,7 +2063,7 @@
 	<string name="_cmt_display_threaded"><![CDATA[Threaded]]></string>
 	<string name="_cmt_err_cannot_perform_action"><![CDATA[Cannot perform action. Please report.]]></string>
 	<string name="_cmt_msg_login_required"><![CDATA[<a href="{0}">Login</a> or <a href="{1}">Join</a> to comment.]]></string>
-	<string name="_cmt_page_view_header"><![CDATA[Comment to '{object_title}']]></string>
+	<string name="_cmt_page_view_header"><![CDATA[Comment '{comment_snippet}' to '{object_title}']]></string>
 	<string name="_cmt_page_view_title"><![CDATA[Comment to <a href="{object_url}">{object_title}</a>]]></string>
         <string name="_cmt_page_view_title_author"><![CDATA[Comment author]]></string>
         <string name="_cmt_page_view_title_content"><![CDATA[Comment content]]></string>

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

@@ -2038,7 +2038,7 @@
 	<string name="_cmt_display_threaded"><![CDATA[Поэтапно]]></string>
 	<string name="_cmt_err_cannot_perform_action"><![CDATA[Невозможно выполнить действие. Пожалуйста, оповестите нас об этой проблеме.]]></string>
 	<string name="_cmt_msg_login_required"><![CDATA[Чтобы оставить комментарий, вам необходимо <a href="{0}">войти</a> или <a href="{1}">зарегистрироваться</a>.]]></string>
-	<string name="_cmt_page_view_header"><![CDATA[Комментарий к '{object_title}']]></string>
+	<string name="_cmt_page_view_header"><![CDATA[Комментарий '{comment_snippet}' к '{object_title}']]></string>
 	<string name="_cmt_page_view_title"><![CDATA[Комментарий к <a href="{object_url}">{object_title}</a>]]></string>
         <string name="_cmt_page_view_title_author"><![CDATA[Автор комментария]]></string>
         <string name="_cmt_page_view_title_content"><![CDATA[Прокомментированный контент]]></string>

+ 6 - 5
template/scripts/BxBaseCmtsPageView.php

@@ -15,7 +15,7 @@ class BxBaseCmtsPageView extends BxTemplPage
     public function __construct($aObject, $oTemplate)
     {
         parent::__construct($aObject, $oTemplate);
-        
+
         $sSystem = bx_get('sys');
         $sSystem = $sSystem !== false ? $sSystem = bx_process_input($sSystem) : '';
 
@@ -35,15 +35,16 @@ class BxBaseCmtsPageView extends BxTemplPage
         $sObjectTitle = bx_process_output(strip_tags($this->_oCmts->getObjectTitle($iObjectId)));
         $sObjectUrl = $this->_oCmts->getBaseUrl();
 
-        $this->addMarkers(array(
+        $this->addMarkers([
             'system' => $sSystem,
             'object_id' => $iObjectId,
             'object_title' => $sObjectTitle,
             'object_url' => $sObjectUrl,
-            'comment_id' => $iCommentId
-        ));
+            'comment_id' => $iCommentId,
+            'comment_snippet' => $this->_oCmts->getViewSnippet($iCommentId)
+        ]);
     }
-    
+
     protected function _isAvailablePage ($a)
     {
         if(!$this->_iCmtId)