wishthis/includes/classes/page.php

76 lines
2.1 KiB
PHP
Raw Normal View History

2021-11-12 15:23:48 +00:00
<?php
/**
* page.php
*/
namespace wishthis;
class Page
{
private string $language = 'en';
/**
* __construct
*
* @param string $filepath The filepath (__FILE__) of the page.
* @param string $title The HTML title of the page.
*/
public function __construct(string $filepath, public string $title = 'wishthis')
{
$this->name = pathinfo($filepath, PATHINFO_FILENAME);
}
public function header(): void
{
?>
<!DOCTYPE html>
<html lang="<?= $this->language ?>">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<?php
/**
* Stylesheets
*/
2022-01-13 13:00:31 +00:00
/** Fomantic UI */
$stylesheetFomantic = 'semantic/dist/semantic.min.css';
$stylesheetFomanticModified = filemtime($stylesheetFomantic);
echo '<link rel="stylesheet" href="' . $stylesheetFomantic . '?m=' . $stylesheetFomanticModified . '" />';
2021-11-12 15:23:48 +00:00
/** Default */
$stylesheetDefault = 'includes/assets/css/default.css';
$stylesheetDefaultModified = filemtime($stylesheetDefault);
echo '<link rel="stylesheet" href="' . $stylesheetDefault . '?m=' . $stylesheetDefaultModified . '" />';
/** Page */
$stylesheetPage = 'includes/assets/css/' . $this->name . '.css';
if (file_exists($stylesheetPage)) {
$stylesheetPageModified = filemtime($stylesheetPage);
echo '<link rel="stylesheet" href="' . $stylesheetPage . '?m=' . $stylesheetPageModified . '" />';
}
?>
2022-01-13 13:00:31 +00:00
<script defer src="/node_modules/jquery/dist/jquery.min.js"></script>
<script defer src="/semantic/dist/semantic.min.js"></script>
2021-11-15 11:20:55 +00:00
<title><?= $this->title ?> - wishthis</title>
2021-11-12 15:23:48 +00:00
</head>
<body>
<?php
}
public function footer(): void
{
?>
</body>
</html>
<?php
}
}