summaryrefslogtreecommitdiff
path: root/src/web/core/_model.php
blob: 4c27b1b2049dd09d7dcea0a62922d0eb22e010b1 (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
<?php /* Copyright (c) 2024 Freya Murphy */
abstract class Model {
	// the main model
	// shared by all controllers and models
	public $main;
	public $load;

	// the database
	public $db;

	private $config;

	/**
	 * Creates a model
	 * @param Loader $load - the main loader object
	 */
	function __construct($load, $main = FALSE) {
		$this->load = $load;
		if ($main) {
			$this->main = $this;
		} else {
			$this->main = $this->load->model('main');
		}
		$this->db = $this->load->db();
	}

	/**
	 * @returns the base model data
	 */
	public function get_data(): ?array {
		$data = array();

		$info = $this->main->info;
		$app = $info['app'];

		$data['title'] = lang('first_name');
		$data['desc'] = lang('default_short_desc');
		$data['css'] = array();

		$style = $GLOBALS['style'];
		if (isset($style[$app])) {
			$css = $style[$app];
			if (!is_array($css))
				$css = array($css);
			$data['css'] = $css;
		}

		return $data;
	}
}