blob: 946b4604e02c9563c5fb5a9f2ca0607fcd3de582 (
plain)
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
|
<?php /* Copyright (c) 2024 Freya Murphy */
abstract class Controller {
// the main model
public $main;
// the loader
public $load;
// the database
public $db;
function __construct() {
$this->main = $GLOBALS['__vars']['main'];
$this->load = $GLOBALS['__vars']['load'];
$this->db = $this->main->db;
$info = $this->main->info;
$lang_code = $info['lang'];
$route_name = $info['route'];
$this->load->lang($lang_code);
$this->load->route_lang($lang_code, $route_name);
}
public function index() {}
protected function view($__name, $data = array()) {
$__root = $GLOBALS['webroot'];
$__path = $__root . '/views/' . $__name . '.php';
if (is_file($__path)) {
extract($data);
require($__path);
return;
}
}
protected function app_view($__name, $data = array()) {
$__root = $GLOBALS['webroot'];
$__route = $this->main->info['route'];
$__path = $__root . '/routes/' . $__route . '/views/' . $__name . '.php';
if (is_file($__path)) {
extract($data);
require($__path);
return;
}
}
protected function modal($title, $content, $data = array()) {
$data['title'] = $title;
$data['content'] = $content;
$this->view('template/modal', $data);
}
}
?>
|