-
Notifications
You must be signed in to change notification settings - Fork 0
/
dispatch.php
107 lines (98 loc) · 2.33 KB
/
dispatch.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
102
103
104
105
106
107
<?php
/*-----------------------------------------------------------------------------
cheetan is licensed under the MIT license.
copyright (c) 2006 cheetan all right reserved.
http://php.cheetan.net/
-----------------------------------------------------------------------------*/
class CDispatch extends CObject
{
function dispatch( &$data )
{
$db = &new CDatabase();
if( function_exists( "config_database" ) )
{
config_database( $db );
}
$sanitize = &new CSanitize();
$validate = &new CValidate();
if( function_exists( 'config_controller_class' ) )
{
$controllername = config_controller_class();
$controller = new $controllername();
}
else
{
$controller = new CController();
}
$controller->RequestHandle();
$controller->SetDatabase( $db );
$controller->SetSanitize( $sanitize );
$controller->SetValidate( $validate );
if( function_exists( "config_models" ) )
{
config_models( $controller );
}
if( function_exists( 'config_components' ) )
{
config_components( $controller );
}
if( !function_exists( 'is_session' ) || is_session() )
{
session_start();
}
$this->_check_secure( $controller );
if( function_exists( "config_controller" ) )
{
config_controller( $controller );
}
if( function_exists( "action" ) )
{
action( $controller );
}
if( function_exists( 'after_action' ) )
{
after_action( $controller );
}
$template = $controller->GetTemplateFile();
$viewfile = $controller->GetViewFile();
$variable = $controller->GetVariable();
$sqllog = $controller->GetSqlLog();
$is_debug = $controller->GetDebug();
if( function_exists( 'config_view_class' ) )
{
$viewname = config_view_class();
$view = new $viewname();
}
else
{
$view = new CView();
}
$view->SetFile( $template, $viewfile );
$view->SetVariable( $variable );
$view->SetSanitize( $sanitize );
$view->SetController( $controller );
$view->SetDebug( $is_debug );
$view->SetSqlLog( $sqllog );
$view->display();
if( function_exists( 'after_render' ) )
{
after_render( $controller );
}
$data = $variable;
return $controller;
}
function _check_secure( $controller )
{
if( function_exists( "is_secure" ) )
{
if( is_secure( $controller ) )
{
if( function_exists( "check_secure" ) )
{
check_secure( $controller );
}
}
}
}
}
?>