-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.php
101 lines (77 loc) · 2.88 KB
/
core.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
* Core
* handles the entire framework, from request to render.
*
* @author Philip Blyth
*/
// $time = microtime(true);
// --------------------------------------------------
// INIT
// --------------------------------------------------
require_once(ENDO_ROOT.'configure.php');
require_once(ENDO_ROOT.INCLUDES_DIR.'initialize.php');
require_once(APP_ROOT.INCLUDES_DIR.'initialize.php');
// Sessions
session_start();
// --------------------------------------------------
// URL
// --------------------------------------------------
Url::Parse(array_get($_REQUEST, 'url'));
// --------------------------------------------------
// Controller
// --------------------------------------------------
$Controller = Globe::Init(Url::$data['controller'], 'controller');
if (get_class($Controller)=='stdClass') {
Error::Set("Create Controller '".Url::$data['controllerName']."'!", 'fatal');
$Controller = Globe::Init('missing', 'controller');
}
// --------------------------------------------------
// Action
// --------------------------------------------------
// go through filters
$Controller->call_beforeFilter();
$Controller->call(Url::$data['action'], Url::$data['params'], Url::$data['type']);
$Controller->call_beforeRender();
if (!Error::IsFatal()) {
$Controller->render();
}
$Controller->call_afterRender();
$Controller->call_afterFilter();
// --------------------------------------------------
// Debug
// --------------------------------------------------
$debug_dump = '';
$debug_dump .= d_pre('Url::$data', false).d_arr(Url::$data, false);
$debug_dump .= d_pre('$Controller->LoggedIn', false).d_arr($Controller->LoggedIn, false);
$debug_dump .= d_pre('$Controller->filter', false).d_arr($Controller->filter, false);
// $debug_dump .= d_pre('Error::$errors', false).d_arr(Error::$errors, false);
// $debug_dump .= d_pre('$_SESSION', false).d_arr($_SESSION, false);
// $debug_dump .= d_pre('$_SERVER', false).d_arr($_SERVER, false);
// $debug_dump .= d_pre('CONSTANTS', false).d_arr(get_constants(), false);
// --------------------------------------------------
// Output
// --------------------------------------------------
// create View
$View = new AppView();
// assign standards
$View->assign(array(
// 'id' => Url::$data['controller'].'_'.Url::$data['action'],
'id' => $Controller->name.'_'.$Controller->action,
'url' => Url::$data,
'has_errors' => Error::HasErrors(),
'debug_dump' => $debug_dump
));
// assign content if no fatal
$View->assign('content', !Error::IsFatal() || DEBUG!=0 ? $Controller->output : null);
// assign case-specific
$View->assign(Globe::$variables_for_layout);
// remove junk from xml/json/...
if ($Controller->type!=DEFAULT_REQUEST_TYPE) {
$View->debugging = false;
$View->error_reporting = false;
}
// echo
$View->display(Globe::GetTemplate($Controller->layout, 'layouts', $Controller->type));
// d_pre("execution time:".(microtime(true) - $time));
?>