Browse Source

Ticket #5145 - Studio: Fix for view page of non-existent module.

AntonLV 1 year ago
parent
commit
efc95b781c

+ 1 - 1
inc/classes/BxDolTemplate.php

@@ -294,7 +294,7 @@ class BxDolTemplate extends BxDolFactory implements iBxDolSingleton
         $this->_sCachePublicFolderUrl = BX_DOL_URL_CACHE_PUBLIC;
         $this->_sCachePublicFolderPath = BX_DIRECTORY_PATH_CACHE_PUBLIC;
         $this->_sCacheFilePrefix = "bx_templ_";
-        $this->_aCacheExceptions = ['menu_icon.html', 'unit_showcase.html'];
+        $this->_aCacheExceptions = ['pt_standard.html', 'menu_icon.html', 'unit_showcase.html'];
 
         $this->_bImagesInline = getParam('sys_template_cache_image_enable') == 'on';
         $this->_iImagesMaxSize = (int)getParam('sys_template_cache_image_max_size') * 1024;

+ 12 - 3
studio/classes/BxDolStudioPage.php

@@ -35,6 +35,7 @@ class BxDolStudioPage extends BxDol
 
     protected $aMarkers;
 
+    protected $iError;
     protected $sError;
     
     protected $_bShowHeaderRightSearch;
@@ -66,6 +67,7 @@ class BxDolStudioPage extends BxDol
             'url_studio' => BX_DOL_URL_STUDIO
         );
 
+        $this->iError = 0;
         $this->sError = false;
 
         $this->_bShowHeaderRightSearch = getParam('sys_std_show_header_right_search') == 'on';
@@ -159,14 +161,21 @@ class BxDolStudioPage extends BxDol
         return true;
     }
 
-    public function setError($sError)
+    public function setError($mixedError)
     {
-        $this->sError = $sError;
+        if(is_array($mixedError))
+            list($this->iError, $this->sError) = $mixedError;
+        else
+            $this->sError = $mixedError;
     }
 
     public function getError($bToDisplay = true)
     {
-        return $bToDisplay ? MsgBox(_t($this->sError)) : $this->sError;
+        $sError = $this->sError;
+        if($bToDisplay)
+            $sError = MsgBox(_t($sError));
+
+        return $this->iError ? [$this->iError, $sError]: $sError;
     }
 
     protected function getSystemName($sValue)

+ 21 - 2
studio/classes/BxDolStudioTemplate.php

@@ -166,9 +166,28 @@ class BxDolStudioTemplate extends BxDolTemplate implements iBxDolSingleton
         return $this->parseHtmlByName('breadcrumb.html', array('bx_repeat:items' => $aItems));
     }
 
-    function displayMsg ($s, $bTranslate = false, $iPage = BX_PAGE_DEFAULT, $iDesignBox = BX_DB_CONTENT_ONLY)
+    function displayMsg ($mixed, $bTranslate = false, $iPage = BX_PAGE_DEFAULT, $iDesignBox = BX_DB_CONTENT_ONLY)
     {
-        $sTitle = $bTranslate ? _t($s) : $s;
+        $iCode = 200;
+        $sMessage = '';
+        if(is_array($mixed))
+            list($iCode, $sMessage) = $mixed;
+        else
+            $sMessage = $mixed;
+
+        switch($iCode) {
+            case 403:
+                header('HTTP/1.0 403 Forbidden');
+                header('Status: 403 Forbidden');
+                break;
+
+            case 404:
+                header('HTTP/1.0 404 Not Found');
+                header('Status: 404 Not Found');
+                break;
+        }
+        
+        $sTitle = $bTranslate ? _t($sMessage) : $sMessage;
         $sContent = $this->parseHtmlByName('page_not_found.html', [
             'content' => DesignBoxContent('', MsgBox($sTitle), $iDesignBox)
         ]);

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

@@ -182,7 +182,7 @@ class BxBaseStudioPage extends BxDolStudioPage
 
     public function getPageCode($sPage = '', $bWrap = true) {
         if(empty($this->aPage) || !is_array($this->aPage)) {
-            $this->setError('_sys_txt_not_found');
+            $this->setError([404, '_sys_request_page_not_found_cpt']);
             return false;
         }