Преглед на файлове

#173 comments: "page not found" for non existing comments

Alex Trofimov преди 11 години
родител
ревизия
a7d4c71331
променени са 2 файла, в които са добавени 28 реда и са изтрити 14 реда
  1. 18 9
      cmts.php
  2. 10 5
      template/scripts/BxBaseCmts.php

+ 18 - 9
cmts.php

@@ -30,17 +30,26 @@ if ($oCmts && $sSys && $iObjectId) {
 
 
     $iCmtId = bx_get('cmt_id');
     $iCmtId = bx_get('cmt_id');
     if($iCmtId !== false) {
     if($iCmtId !== false) {
-        $sObjectTitle = $oCmts->getObjectTitle($iObjectId);
+        $oTemplate = BxDolTemplate::getInstance();
+        $sComment = $oCmts->getCommentBlock($iCmtId);
+        if ($sComment) {
 
 
-        $sHeader = _t('_cmt_page_view_header', $sObjectTitle);
-        $sTitle = _t('_cmt_page_view_title', $oCmts->getBaseUrl(), $sObjectTitle);
-        $sContent = DesignBoxContent($sTitle, $oCmts->getCommentBlock($iCmtId), BX_DB_PADDING_DEF);
+            $sObjectTitle = $oCmts->getObjectTitle($iObjectId);
 
 
-        $oTemplate = BxDolTemplate::getInstance();
-        $oTemplate->setPageNameIndex(BX_PAGE_DEFAULT);
-        $oTemplate->setPageHeader($sHeader);
-        $oTemplate->setPageContent('page_main_code', $sContent);
-        $oTemplate->getPageCode();
+            $sHeader = _t('_cmt_page_view_header', $sObjectTitle);
+            $sTitle = _t('_cmt_page_view_title', $oCmts->getBaseUrl(), $sObjectTitle);
+            $sContent = DesignBoxContent($sTitle, $sComment, BX_DB_PADDING_DEF);
+            
+            $oTemplate->setPageNameIndex(BX_PAGE_DEFAULT);
+            $oTemplate->setPageHeader($sHeader);
+            $oTemplate->setPageContent('page_main_code', $sContent);
+            $oTemplate->getPageCode();
+
+        } else {
+
+            $oTemplate->displayPageNotFound();
+
+        }
     }
     }
 }
 }
 
 

+ 10 - 5
template/scripts/BxBaseCmts.php

@@ -141,14 +141,17 @@ class BxBaseCmts extends BxDolCmts
      */
      */
     function getCommentBlock($iCmtId = 0, $aBp = array(), $aDp = array())
     function getCommentBlock($iCmtId = 0, $aBp = array(), $aDp = array())
     {
     {
+        $sComment = $this->getComment(
+        	$iCmtId, 
+        	array_merge(array('type' => $this->_sBrowseType), $aBp), 
+        	array_merge(array('type' => BX_CMT_DISPLAY_THREADED), $aDp)
+        );
+        if (!$sComment)
+            return '';
         return BxDolTemplate::getInstance()->parseHtmlByName('comment_block.html', array(
         return BxDolTemplate::getInstance()->parseHtmlByName('comment_block.html', array(
             'system' => $this->_sSystem,
             'system' => $this->_sSystem,
             'id' => $this->getId(),
             'id' => $this->getId(),
-            'comment' => $this->getComment(
-        		$iCmtId, 
-        		array_merge(array('type' => $this->_sBrowseType), $aBp), 
-        		array_merge(array('type' => BX_CMT_DISPLAY_THREADED), $aDp)
-        	),
+            'comment' => $sComment,
         	'view_image_popup' => $this->_getViewImagePopup(), 
         	'view_image_popup' => $this->_getViewImagePopup(), 
             'script' => $this->getJsScript()
             'script' => $this->getJsScript()
         ));
         ));
@@ -166,6 +169,8 @@ class BxBaseCmts extends BxDolCmts
 
 
         $iUserId = $this->_getAuthorId();
         $iUserId = $this->_getAuthorId();
         $aCmt = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
         $aCmt = !is_array($mixedCmt) ? $this->getCommentRow((int)$mixedCmt) : $mixedCmt;
+        if (!$aCmt)
+            return '';
 
 
         list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']);
         list($sAuthorName, $sAuthorLink, $sAuthorIcon) = $this->_getAuthorInfo($aCmt['cmt_author_id']);