@@ -10,9 +10,10 @@ class MIDAS_GlobalController extends Zend_Controller_Action
10
10
protected $ Models = array ();
11
11
protected $ ModelLoader = null ;
12
12
13
+ /** contructor*/
13
14
public function __construct (Zend_Controller_Request_Abstract $ request , Zend_Controller_Response_Abstract $ response , array $ invokeArgs = array ())
14
15
{
15
- if ($ this ->isDebug ())
16
+ if ($ this ->isDebug ())
16
17
{
17
18
$ this ->_controllerTimer = microtime (true );
18
19
}
@@ -28,63 +29,63 @@ public function __construct(Zend_Controller_Request_Abstract $request, Zend_Cont
28
29
public function preDispatch ()
29
30
{
30
31
// Init the translater
31
- if (!$ this ->isDebug ())
32
+ if (!$ this ->isDebug ())
32
33
{
33
- $ frontendOptions= array (
34
- 'lifetime ' => 86400 ,'automatic_serialization ' => true
34
+ $ frontendOptions = array (
35
+ 'lifetime ' => 86400 , 'automatic_serialization ' => true
35
36
);
36
37
37
- $ backendOptions= array (
38
- 'cache_dir ' => BASE_PATH .'/tmp/cache/translation '
38
+ $ backendOptions = array (
39
+ 'cache_dir ' => BASE_PATH .'/tmp/cache/translation '
39
40
);
40
- $ cache= Zend_Cache::factory ('Core ' ,'File ' ,$ frontendOptions ,$ backendOptions );
41
+ $ cache = Zend_Cache::factory ('Core ' , 'File ' , $ frontendOptions , $ backendOptions );
41
42
Zend_Translate::setCache ($ cache );
42
43
}
43
- $ translate= new Zend_Translate ('csv ' ,BASE_PATH .'/core/translation/fr-main.csv ' ,'en ' );
44
- Zend_Registry::set ('translater ' ,$ translate );
44
+ $ translate = new Zend_Translate ('csv ' , BASE_PATH .'/core/translation/fr-main.csv ' , 'en ' );
45
+ Zend_Registry::set ('translater ' , $ translate );
45
46
46
- $ translaters= array ();
47
- $ configs= array ();
48
- $ modulesEnable = Zend_Registry::get ('modulesEnable ' );
47
+ $ translaters = array ();
48
+ $ configs = array ();
49
+ $ modulesEnable = Zend_Registry::get ('modulesEnable ' );
49
50
foreach ($ modulesEnable as $ module )
50
51
{
51
- $ translaters [$ module ]= new Zend_Translate ('csv ' ,BASE_PATH ."/modules/ $ module/translation/fr-main.csv " ,"en " );
52
- if (file_exists (BASE_PATH ."/modules/ $ module/configs/module.local.ini " ))
52
+ $ translaters [$ module ] = new Zend_Translate ('csv ' , BASE_PATH ."/modules/ " . $ module. " /translation/fr-main.csv " , "en " );
53
+ if (file_exists (BASE_PATH ."/modules/ " . $ module. " /configs/module.local.ini " ))
53
54
{
54
- $ configs [$ module ]= new Zend_Config_Ini (BASE_PATH ."/modules/ $ module/configs/module.local.ini " , 'global ' );
55
+ $ configs [$ module ] = new Zend_Config_Ini (BASE_PATH ."/modules/ " . $ module. " /configs/module.local.ini " , 'global ' );
55
56
}
56
57
else
57
58
{
58
- $ configs [$ module ]= new Zend_Config_Ini (BASE_PATH ."/modules/ $ module/configs/module.ini " , 'global ' );
59
+ $ configs [$ module ] = new Zend_Config_Ini (BASE_PATH ."/modules/ " . $ module. " /configs/module.ini " , 'global ' );
59
60
}
60
61
}
61
- Zend_Registry::set ('translatersModules ' ,$ translaters );
62
- Zend_Registry::set ('configsModules ' ,$ configs );
62
+ Zend_Registry::set ('translatersModules ' , $ translaters );
63
+ Zend_Registry::set ('configsModules ' , $ configs );
63
64
64
- $ forward= $ this ->_getParam ("forwardModule " );
65
+ $ forward = $ this ->_getParam ("forwardModule " );
65
66
$ request = $ this ->getRequest ();
66
67
$ response = $ this ->getResponse ();
67
68
if (!isset ($ forward ))
68
69
{
69
70
foreach ($ configs as $ key => $ config )
70
71
{
71
- if ($ config ->system == 1 )
72
+ if ($ config ->system == 1 )
72
73
{
73
74
if (file_exists (BASE_PATH .'/modules/ ' .$ key .'/controllers/ ' . ucfirst ($ request ->getControllerName ()).'CoreController.php ' ))
74
75
{
75
76
include_once BASE_PATH .'/modules/ ' .$ key .'/controllers/ ' . ucfirst ($ request ->getControllerName ()).'CoreController.php ' ;
76
- $ name= ucfirst ($ key ).'_ ' .ucfirst ($ request ->getControllerName ()).'CoreController ' ;
77
- $ controller= new $ name ($ request ,$ response );
77
+ $ name = ucfirst ($ key ).'_ ' .ucfirst ($ request ->getControllerName ()).'CoreController ' ;
78
+ $ controller = new $ name ($ request , $ response );
78
79
if (method_exists ($ controller , $ request ->getActionName ().'Action ' ))
79
80
{
80
- $ this ->_forward ($ request ->getActionName (), $ request ->getControllerName ().'Core ' , $ key ,array ('forwardModule ' => true ));
81
+ $ this ->_forward ($ request ->getActionName (), $ request ->getControllerName ().'Core ' , $ key , array ('forwardModule ' => true ));
81
82
}
82
83
}
83
84
}
84
85
}
85
86
}
86
87
parent ::preDispatch ();
87
- if (!$ this ->isDebug ())
88
+ if (!$ this ->isDebug ())
88
89
{
89
90
$ frontendOptions = array (
90
91
'lifetime ' => 86400 ,
@@ -117,17 +118,17 @@ public function postDispatch()
117
118
{
118
119
119
120
parent ::postDispatch ();
120
- if ($ this ->isDebug () && $ this ->getEnvironment () != 'testing ' )
121
+ if ($ this ->isDebug () && $ this ->getEnvironment () != 'testing ' )
121
122
{
122
- $ time_end = microtime (true );
123
+ $ timeEnd = microtime (true );
123
124
$ writer = new Zend_Log_Writer_Firebug ();
124
125
$ logger = new Zend_Log ($ writer );
125
- $ logger ->info ("---Timers--- Controller timer: " . round (1000 *( $ time_end - $ this ->_controllerTimer ),3 )." ms - Global timer: " . round (1000 *( $ time_end - START_TIME ),3 )." ms " );
126
+ $ logger ->info ("---Timers--- Controller timer: " . round (1000 * ( $ timeEnd - $ this ->_controllerTimer ), 3 )." ms - Global timer: " . round (1000 * ( $ timeEnd - START_TIME ), 3 )." ms " );
126
127
127
- $ logger ->info ("---Memory Usage--- " .round ((memory_get_usage () / (1024 * 1024 )),3 ) . " MB " );
128
+ $ logger ->info ("---Memory Usage--- " .round ((memory_get_usage () / (1024 * 1024 )), 3 ) . " MB " );
128
129
}
129
130
130
- if (Zend_Registry::get ("configDatabase " )->database ->profiler == 1 )
131
+ if (Zend_Registry::get ("configDatabase " )->database ->profiler == 1 )
131
132
{
132
133
$ this ->showProfiler ();
133
134
}
@@ -156,14 +157,14 @@ public function loadElements()
156
157
$ this ->ModelLoader ->loadModels ($ this ->_models );
157
158
}
158
159
$ modelsArray = Zend_Registry::get ('models ' );
159
- foreach ($ modelsArray as $ key => $ tmp )
160
+ foreach ($ modelsArray as $ key => $ tmp )
160
161
{
161
162
$ this ->$ key = $ tmp ;
162
163
}
163
164
164
165
if (isset ($ this ->_daos ))
165
166
{
166
- foreach ($ this ->_daos as $ dao )
167
+ foreach ($ this ->_daos as $ dao )
167
168
{
168
169
Zend_Loader::loadClass ($ dao . "Dao " , BASE_PATH . '/core/models/dao ' );
169
170
}
@@ -173,7 +174,7 @@ public function loadElements()
173
174
174
175
if (isset ($ this ->_components ))
175
176
{
176
- foreach ($ this ->_components as $ component )
177
+ foreach ($ this ->_components as $ component )
177
178
{
178
179
$ nameComponent = $ component . "Component " ;
179
180
Zend_Loader::loadClass ($ nameComponent , BASE_PATH . '/core/controllers/components ' );
@@ -184,7 +185,7 @@ public function loadElements()
184
185
Zend_Registry::set ('forms ' , array ());
185
186
if (isset ($ this ->_forms ))
186
187
{
187
- foreach ($ this ->_forms as $ forms )
188
+ foreach ($ this ->_forms as $ forms )
188
189
{
189
190
$ nameForm = $ forms . "Form " ;
190
191
@@ -202,45 +203,45 @@ public function showProfiler()
202
203
$ writer = new Zend_Log_Writer_Firebug ();
203
204
$ logger = new Zend_Log ($ writer );
204
205
$ configDatabase = Zend_Registry::get ('configDatabase ' );
205
- if ($ configDatabase ->database ->profiler != '1 ' )
206
+ if ($ configDatabase ->database ->profiler != '1 ' )
206
207
{
207
208
return ;
208
209
}
209
210
$ db = Zend_Registry::get ('dbAdapter ' );
210
211
211
- if (method_exists ($ db ,"getProfiler " ))
212
+ if (method_exists ($ db , "getProfiler " ))
212
213
{
213
214
$ profiler = $ db ->getProfiler ();
214
215
$ totalTime = $ profiler ->getTotalElapsedSecs ();
215
216
$ queryCount = $ profiler ->getTotalNumQueries ();
216
- if ($ queryCount == 0 )
217
+ if ($ queryCount == 0 )
217
218
{
218
219
return ;
219
220
}
220
221
}
221
222
222
223
$ longestTime = 0 ;
223
224
$ longestQuery = null ;
224
- if (isset ($ profiler )&& !empty ($ profiler ))
225
+ if (isset ($ profiler ) && !empty ($ profiler ))
225
226
{
226
- $ querys= $ profiler ->getQueryProfiles ();
227
+ $ querys = $ profiler ->getQueryProfiles ();
227
228
if (!empty ($ querys ))
228
229
{
229
- foreach ($ profiler ->getQueryProfiles () as $ query )
230
+ foreach ($ profiler ->getQueryProfiles () as $ query )
230
231
{
231
- if ($ query ->getElapsedSecs () > $ longestTime )
232
+ if ($ query ->getElapsedSecs () > $ longestTime )
232
233
{
233
234
$ longestTime = $ query ->getElapsedSecs ();
234
235
$ longestQuery = $ query ->getQuery ();
235
236
}
236
237
}
237
- $ stats= '--- Profiler --- Executed ' . $ queryCount . ' queries in ' . round (1000 * $ totalTime ,3 ) .' ms ' ;
238
- $ stats .= ' Longest query length: ' . round (1000 * $ longestTime ,3 ).' ms : ' .$ longestQuery ;
239
- $ logger ->log (str_replace ("' " ,"` " ,$ stats ), Zend_Log::INFO );
238
+ $ stats = '--- Profiler --- Executed ' . $ queryCount . ' queries in ' . round (1000 * $ totalTime , 3 ) .' ms ' ;
239
+ $ stats .= ' Longest query length: ' . round (1000 * $ longestTime , 3 ).' ms : ' .$ longestQuery ;
240
+ $ logger ->log (str_replace ("' " , "` " , $ stats ), Zend_Log::INFO );
240
241
241
- foreach ($ profiler ->getQueryProfiles () as $ query )
242
+ foreach ($ profiler ->getQueryProfiles () as $ query )
242
243
{
243
- $ logger ->log (str_replace ("' " ,"` " ,round (1000 * ($ query ->getElapsedSecs ()),3 ). " ms | " . $ query ->getQuery ()), Zend_Log::INFO );
244
+ $ logger ->log (str_replace ("' " , "` " , round (1000 * ($ query ->getElapsedSecs ()), 3 ). " ms | " . $ query ->getQuery ()), Zend_Log::INFO );
244
245
}
245
246
}
246
247
}
@@ -254,7 +255,7 @@ public function showProfiler()
254
255
public function isDebug ()
255
256
{
256
257
$ config = Zend_Registry::get ('config ' );
257
- if ($ config ->mode ->debug == 1 )
258
+ if ($ config ->mode ->debug == 1 )
258
259
{
259
260
return true ;
260
261
}
@@ -291,14 +292,13 @@ public function getFormAsArray(Zend_Form $form)
291
292
$ array = array ();
292
293
$ array ['action ' ] = $ form ->getAction ();
293
294
$ array ['method ' ] = $ form ->getMethod ();
294
- foreach ( $ form ->getElements () as $ element ) {
295
- $ element ->removeDecorator ('HtmlTag ' );
296
- $ element ->removeDecorator ('Label ' );
297
- $ element ->removeDecorator ('DtDdWrapper ' );
298
- $ array [$ element ->getName ()] = $ element ;
299
- }
295
+ foreach ($ form ->getElements () as $ element )
296
+ {
297
+ $ element ->removeDecorator ('HtmlTag ' );
298
+ $ element ->removeDecorator ('Label ' );
299
+ $ element ->removeDecorator ('DtDdWrapper ' );
300
+ $ array [$ element ->getName ()] = $ element ;
301
+ }
300
302
return $ array ;
301
- }
302
-
303
- } // end class
304
- ?>
303
+ }
304
+ } // end class
0 commit comments