From 944b6b0526032ad8c1b4a2612d6723bec75e0e4c Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 29 Mar 2024 22:29:56 -0400 Subject: start database (user and post), and initial barebones home page --- web/core/controller.php | 55 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 web/core/controller.php (limited to 'web/core/controller.php') diff --git a/web/core/controller.php b/web/core/controller.php new file mode 100644 index 0000000..946b460 --- /dev/null +++ b/web/core/controller.php @@ -0,0 +1,55 @@ +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); + } + +} +?> -- cgit v1.2.3-freya