]> git.wh0rd.org - tt-rss.git/commitdiff
fix fatalError() not working properly
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 18 Feb 2011 09:28:03 +0000 (12:28 +0300)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 18 Feb 2011 09:28:03 +0000 (12:28 +0300)
errors.php
functions.js
login_form.php
tt-rss.js
tt-rss.php

index b2e0841a3a7577e48979f92faaa3fe0926ced9c8..cd76d10a680261f72e74832cb63724306731b598 100644 (file)
@@ -1,4 +1,5 @@
 <?php
+       require_once "functions.php";
 
        $ERRORS[0] = __("Unknown error");
 
        $ERRORS[11] = "[This error is not returned by server]";
 
        $ERRORS[12] = __("SQL escaping test failed, check your database and PHP configuration");
+
+       if ($_REQUEST['mode'] == 'js') {
+               header("Content-Type: text/plain; charset=UTF-8");
+
+               print "var ERRORS = [];\n";
+
+               foreach ($ERRORS as $id => $error) {
+
+                       $error = preg_replace("/\n/", "", $error);
+                       $error = preg_replace("/\"/", "\\\"", $error);
+
+                       print "ERRORS[$id] = \"$error\";\n";
+               }
+       }
 ?>
index 67d7b4f230a893655d69421b73e20211b63c8814..88365d70a555df4bbde50c7e37eba40f487d22de 100644 (file)
@@ -503,8 +503,6 @@ function setInitParam(key, value) {
 function fatalError(code, msg, ext_info) {
        try {   
 
-               if (!ext_info) ext_info = "N/A";
-
                if (code == 6) {
                        window.location.href = "tt-rss.php";                    
                } else if (code == 5) {
@@ -513,28 +511,36 @@ function fatalError(code, msg, ext_info) {
        
                        if (msg == "") msg = "Unknown error";
 
-                       var ebc = $("xebContent");
-       
-                       if (ebc) {
-       
-                               Element.show("dialog_overlay");
-                               Element.show("errorBoxShadow");
-                               Element.hide("xebBtn");
-
-                               if (ext_info) {
-                                       if (ext_info.responseText) {
-                                               ext_info = ext_info.responseText;
-                                       }
+                       if (ext_info) {
+                               if (ext_info.responseText) {
+                                       ext_info = ext_info.responseText;
                                }
+                       }
+
+                       if (ERRORS && ERRORS[code] && !msg) {
+                               msg = ERRORS[code];
+                       }
        
-                               ebc.innerHTML = 
-                                       "<div><b>Error message:</b></div>" +
-                                       "<pre>" + msg + "</pre>" +
-                                       "<div><b>Additional information:</b></div>" +
-                                       "<textarea readonly=\"1\">" + ext_info + "</textarea>";
+                       var content = "<div><b>Error code:</b> " + code + "</div>" +
+                               "<p>" + msg + "</p>";
+
+                       if (ext_info) {
+                               content = content + "<div><b>Additional information:</b></div>" +
+                                       "<textarea style='width: 100%' readonly=\"1\">" + 
+                                       ext_info + "</textarea>";
                        }
+
+                       var dialog = new dijit.Dialog({
+                               title: "Fatal error",
+                               style: "width: 600px",
+                               content: content});
+
+                       dialog.show();
+
                }
 
+               return false;
+
        } catch (e) {
                exception_error("fatalError", e);
        }
index 14882b34f1a348433746b8f6b659e874e768eef2..141f3f0bfe3c1b5841a9e3d8998e54fe2bd0f135 100644 (file)
@@ -1,19 +1,30 @@
 <html>
 <head>
        <title>Tiny Tiny RSS : Login</title>
+       <link rel="stylesheet" type="text/css" href="lib/dijit/themes/claro/claro.css"/>
        <link rel="stylesheet" type="text/css" href="tt-rss.css">
        <link rel="shortcut icon" type="image/png" href="images/favicon.png">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+       <script type="text/javascript" src="lib/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
        <script type="text/javascript" src="lib/prototype.js"></script>
        <script type="text/javascript" src="lib/scriptaculous/scriptaculous.js?load=effects,dragdrop,controls"></script>
        <script type="text/javascript" src="functions.js"></script>
+       <script type="text/javascript" charset="utf-8" src="errors.php?mode=js"></script>
 </head>
 
-<body id="ttrssLogin">
+<body id="ttrssLogin" class="claro">
 
 <script type="text/javascript">
 function init() {
 
+       dojo.require("dijit.Dialog");
+
+       var test = setCookie("ttrss_test", "TEST");
+
+       if (getCookie("ttrss_test") != "TEST") {
+               return fatalError(2);
+       }
+
        var limit_set = getCookie("ttrss_bwlimit");
 
        if (limit_set == "true") {
index 5884d8d4e3f79bb59c2cf5f8e37be2c37a2dfdf9..5b4947b4c5b19079c4acca340e163cc1f6d5b605 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -266,7 +266,7 @@ function genericSanityCheck() {
        setCookie("ttrss_test", "TEST");
        
        if (getCookie("ttrss_test") != "TEST") {
-               fatalError(2);
+               return fatalError(2);
        }
 
        return true;
@@ -314,7 +314,7 @@ function init() {
                });
 
                if (!genericSanityCheck()) 
-                       return;
+                       return false;
 
                loading_set_progress(20);
 
index b4f8dc293211865f6895f57b29ec577181ba87fe..49c882db0bb52d2f36bbe281321d773cc498d534 100644 (file)
@@ -41,6 +41,7 @@
        <script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
        <script type="text/javascript" charset="utf-8" src="feedlist.js?<?php echo $dt_add ?>"></script>
        <script type="text/javascript" charset="utf-8" src="viewfeed.js?<?php echo $dt_add ?>"></script>
+       <script type="text/javascript" charset="utf-8" src="errors.php?mode=js"></script>
 
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>