@@ -9,56 +9,62 @@ class ErrorController extends AppController
9
9
private $ _environment ;
10
10
11
11
public function init ()
12
- {
12
+ {
13
+ parent ::init ();
14
+ $ error = $ this ->_getParam ('error_handler ' );
15
+ if (!isset ($ error )||empty ($ error ))
16
+ {
17
+ return ;
18
+ }
19
+ $ mailer = new Zend_Mail ();
20
+ $ session = new Zend_Session_Namespace ('Auth_User ' );
21
+ $ db = Zend_Registry::get ('dbAdapter ' );
22
+ $ profiler = $ db ->getProfiler ();
23
+ $ environment = Zend_Registry::get ('configGlobal ' )->environment ;
24
+ $ this ->_environment =$ environment ;
25
+ $ this ->Component ->NotifyError ->initNotifier (
26
+ $ environment ,
27
+ $ error ,
28
+ $ mailer ,
29
+ $ session ,
30
+ $ profiler ,
31
+ $ _SERVER
32
+ );
13
33
14
- parent ::init ();
15
- $ error = $ this ->_getParam ('error_handler ' );
16
- if (!isset ($ error )||empty ($ error ))
17
- {
18
- return ;
19
- }
20
- $ mailer = new Zend_Mail ();
21
- $ session = new Zend_Session_Namespace ('Auth_User ' );
22
- $ db = Zend_Registry::get ('dbAdapter ' );
23
- $ profiler = $ db ->getProfiler ();
24
- $ environment = Zend_Registry::get ('configGlobal ' )->environment ;
25
- $ this ->_environment =$ environment ;
26
- $ this ->Component ->NotifyError ->initNotifier (
27
- $ environment ,
28
- $ error ,
29
- $ mailer ,
30
- $ session ,
31
- $ profiler ,
32
- $ _SERVER
33
- );
34
-
35
- $ this ->_error = $ error ;
34
+ $ this ->_error = $ error ;
36
35
37
- $ this ->_environment = $ environment ;
38
- }
36
+ $ this ->_environment = $ environment ;
37
+ }
39
38
40
39
public function errorAction ()
41
- {
42
- $ error = $ this ->_getParam ('error_handler ' );
43
- if (!isset ($ error )||empty ($ error ))
44
- {
45
- $ this ->view ->message = 'Page not found ' ;
46
- return ;
47
- }
48
- switch ($ this ->_error ->type ) {
49
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
50
- case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
51
- $ this ->getResponse ()->setHttpResponseCode (404 );
52
- $ this ->view ->message = 'Page not found ' ;
53
- break ;
54
-
55
- default :
56
- $ this ->getResponse ()->setHttpResponseCode (500 );
57
- $ this ->_applicationError ();
58
- break ;
59
- }
60
- $ fullMessage = $ this ->Component ->NotifyError ->getFullErrorMessage ();
61
- $ this ->getLogger ()->crit ($ fullMessage );
40
+ {
41
+ $ error = $ this ->_getParam ('error_handler ' );
42
+ if (!isset ($ error )||empty ($ error ))
43
+ {
44
+ $ this ->view ->message = 'Page not found ' ;
45
+ return ;
46
+ }
47
+
48
+ $ controller =$ error ->request ->getParams ();
49
+ $ controller =$ controller ['controller ' ];
50
+ if ($ controller !='install ' &&!file_exists (BASE_PATH ."/application/configs/database.local.ini " ))
51
+ {
52
+ $ this ->view ->message ="Midas is not installed. Please go the <a href=' {$ this ->view ->webroot }/install'> install page</a>. " ;
53
+ return ;
54
+ }
55
+ switch ($ this ->_error ->type ) {
56
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER :
57
+ case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION :
58
+ $ this ->getResponse ()->setHttpResponseCode (404 );
59
+ $ this ->view ->message = 'Page not found ' ;
60
+ break ;
61
+
62
+ default :
63
+ $ this ->getResponse ()->setHttpResponseCode (500 );
64
+ $ this ->_applicationError ();
65
+ break ;
66
+ }
67
+ $ fullMessage = $ this ->Component ->NotifyError ->getFullErrorMessage ();
62
68
if (isset ($ this ->fullMessage ))
63
69
{
64
70
$ this ->getLogger ()->crit ($ this ->fullMessage );
@@ -67,28 +73,28 @@ public function errorAction()
67
73
{
68
74
$ this ->getLogger ()->crit ($ this ->view ->message );
69
75
}
70
- }
76
+ }
71
77
72
78
private function _applicationError ()
73
- {
74
- $ fullMessage = $ this ->Component ->NotifyError ->getFullErrorMessage ();
75
- $ shortMessage = $ this ->Component ->NotifyError ->getShortErrorMessage ();
76
- $ this ->fullMessage =$ fullMessage ;
77
-
78
- switch ($ this ->_environment ) {
79
- case 'production ' :
80
- $ this ->view ->message = $ shortMessage ;
81
- break ;
82
- case 'testing ' :
83
- $ this ->_helper ->layout ->setLayout ('blank ' );
84
- $ this ->_helper ->viewRenderer ->setNoRender ();
85
-
86
- $ this ->getResponse ()->appendBody ($ shortMessage );
87
- break ;
88
- default :
89
- $ this ->view ->message = nl2br ($ fullMessage );
90
- }
91
-
92
- $ this ->Component ->NotifyError ->notify ();
93
- }
79
+ {
80
+ $ fullMessage = $ this ->Component ->NotifyError ->getFullErrorMessage ();
81
+ $ shortMessage = $ this ->Component ->NotifyError ->getShortErrorMessage ();
82
+ $ this ->fullMessage =$ fullMessage ;
83
+
84
+ switch ($ this ->_environment ) {
85
+ case 'production ' :
86
+ $ this ->view ->message = $ shortMessage ;
87
+ break ;
88
+ case 'testing ' :
89
+ $ this ->_helper ->layout ->setLayout ('blank ' );
90
+ $ this ->_helper ->viewRenderer ->setNoRender ();
91
+
92
+ $ this ->getResponse ()->appendBody ($ shortMessage );
93
+ break ;
94
+ default :
95
+ $ this ->view ->message = nl2br ($ fullMessage );
96
+ }
97
+
98
+ $ this ->Component ->NotifyError ->notify ();
99
+ }
94
100
}
0 commit comments