diff options
Diffstat (limited to 'src/web/_model/main.php')
-rw-r--r-- | src/web/_model/main.php | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/web/_model/main.php b/src/web/_model/main.php index 5728932..cbcf498 100644 --- a/src/web/_model/main.php +++ b/src/web/_model/main.php @@ -2,16 +2,16 @@ class Main_model extends Model { // stores the current request info - public $info; + public mixed $info; // the main loader - public $load; + public Loader $load; /** * Loads the main model * @param Loader $load - the main loader object */ - function __construct($load) { + function __construct(Loader $load) { parent::__construct($load, TRUE); $GLOBALS['main_model'] = $this; } @@ -20,7 +20,7 @@ class Main_model extends Model { * Gets the stamp for a asset path * @param string $path */ - private function asset_stamp($path): int { + private function asset_stamp(string $path): int { $root = $GLOBALS['webroot']; $path = $root . '/../public/' . $path; return @filemtime($path); @@ -41,25 +41,36 @@ class Main_model extends Model { /** * Gets the full url including the http scheme and host part * Needed for IE 6 & 7 need. - */ - public function get_url_full($path): string { + * @param string $path + * @param bool $timestamp + */ + public function get_url_full(string $path, bool $timestamp = FALSE): string { $host = $_SERVER['HTTP_HOST']; $base = lang('base_path'); - $time = @filemtime($GLOBALS['rootroot'] . '/' . $path); - $url = "http://{$host}{$base}{$path}?timestamp={$time}"; + + $url = "http://{$host}{$base}{$path}"; + if ($timestamp) { + $time = @filemtime($GLOBALS['rootroot'] . '/' . $path); + $url .= "?timestamp={$time}"; + } return $url; } /** * Gets a full path url from a relative path - */ - public function get_url($path): string { + * @param string $path + * @param bool $timestamp + */ + public function get_url(string $path, bool $timestamp = FALSE): string { if ($this->get_ie_version() <= 7) { - return $this->get_url_full($path); + return $this->get_url_full($path, $timestamp); } $base = lang('base_path'); - $time = @filemtime($GLOBALS['rootroot'] . '/' . $path); - $url = "{$base}{$path}?timestamp={$time}"; + $url = "{$base}{$path}"; + if ($timestamp) { + $time = @filemtime($GLOBALS['rootroot'] . '/' . $path); + $url .= "?timestamp={$time}"; + } return $url; } @@ -67,7 +78,7 @@ class Main_model extends Model { * Loads a css html link * @param string $path - the path to the css file */ - public function link_css($path): string { + public function link_css(string $path): string { $stamp = $this->asset_stamp($path); $href = $this->get_url("public/{$path}?stamp={$stamp}"); return '<link rel="stylesheet" href="'. $href .'">'; @@ -77,7 +88,7 @@ class Main_model extends Model { * Loads a css html link * @param string $path - the path to the css file */ - public function embed_css($path): string { + public function embed_css(string $path): string { $file = $GLOBALS['publicroot'] . '/' . $path; if (file_exists($file)) { $text = file_get_contents($file); @@ -91,7 +102,7 @@ class Main_model extends Model { * Formats a ISO date * @param $iso_date the ISO date */ - public function format_date($iso_date): string { + public function format_date(string $iso_date): string { return date("Y-m-d D H:m", strtotime($iso_date)); } } |