Przeglądaj źródła

#4943 Storage: getting file error should return some very simple error (maybe json) instead of full featured UNA pages

Alex Trofimov 1 rok temu
rodzic
commit
3ab6c6b4b6
1 zmienionych plików z 16 dodań i 3 usunięć
  1. 16 3
      storage.php

+ 16 - 3
storage.php

@@ -92,10 +92,23 @@ if (!$oStorage->download($sRemoteId, $sToken)) {
 
 function bx_storage_download_error_occured($sMethod = 'displayPageNotFound')
 {
-    require_once(BX_DIRECTORY_PATH_INC . "design.inc.php");
+    bx_import('BxDolLanguages');
 
-    $oTemplate = BxDolTemplate::getInstance();
-    $oTemplate->$sMethod ();
+    if ('displayPageNotFound' == $sMethod) {
+        header('HTTP/1.0 404 Not Found');
+        header('Status: 404 Not Found');
+        echo json_encode(['status' => 404, 'error' => _t("_sys_request_page_not_found_cpt")]);
+    }
+    if ('displayAccessDenied' == $sMethod) {
+        header('HTTP/1.0 403 Forbidden');
+        header('Status: 403 Forbidden');
+        echo json_encode(['status' => 403, 'error' => _t("_Access denied")]);
+    }
+    if ('displayErrorOccured' == $sMethod) {
+        header('HTTP/1.0 500 Internal Server Error');
+        header('Status: 500 Internal Server Error');
+        echo json_encode(['status' => 500, 'error' => _t("_error occured")]);
+    }
 }
 
 /** @} */