-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathcontroller.php
More file actions
48 lines (37 loc) · 907 Bytes
/
Copy pathcontroller.php
File metadata and controls
48 lines (37 loc) · 907 Bytes
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
<?php
class Controller {
public function loadModel($name){
require(APP_DIR .'models'. DS . strtolower($name) .'.php');
$model = new $name;
return $model;
}
public function loadView($name){
$view = new View($name);
return $view;
}
public function loadPlugin($name){
require(APP_DIR .'plugins'. DS . strtolower($name) .'.php');
}
public function loadHelper($name){
require(APP_DIR .'helpers'. DS . strtolower($name) .'.php');
$helper = new $name;
return $helper;
}
public function redirect($loc){
global $config;
header('Location: '. $config['base_url'] . $loc);
}
public function render($response=array(), $tipo='json'){
$tipo = strtolower($tipo);
if($tipo === 'json'){
die(json_encode($response));
}
else if($tipo === 'jsonp'){
die($_REQUEST['callback'] . '(' . json_encode($response) . ');' );
}
else{
echo $response;
}
}
}
?>