From 49efb238b879bce764d04dad99c7a169e80f93dd Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 14 Jun 2023 22:08:34 -0500 Subject: massive overhaul to implement proper MVC --- src/View/BaseTemplate.php | 35 +++++++++++++++++++++++++++ src/View/class-template.php | 58 --------------------------------------------- 2 files changed, 35 insertions(+), 58 deletions(-) create mode 100644 src/View/BaseTemplate.php delete mode 100644 src/View/class-template.php (limited to 'src/View') diff --git a/src/View/BaseTemplate.php b/src/View/BaseTemplate.php new file mode 100644 index 0000000..17bc39e --- /dev/null +++ b/src/View/BaseTemplate.php @@ -0,0 +1,35 @@ + + + + + <?php echo $this->title; ?> + + + + + + + + + + +
+ + content; ?> +
+ + + + + + diff --git a/src/View/class-template.php b/src/View/class-template.php deleted file mode 100644 index 9a3c598..0000000 --- a/src/View/class-template.php +++ /dev/null @@ -1,58 +0,0 @@ - -*/ -class Template -{ - /** - * @var string - */ - private $canonical_url; - /** - * @var string - */ - private $description; - /** - * @var string - */ - private $title; - /** - * @var string - */ - private $content; - /** - * @var false|string - */ - private $current_year; - - public function __construct(string $canonical_url, string $page_description, string $page_title, string $content_col) { - $this->canonical_url = $canonical_url; - $this->description = $page_description; - $this->title = $page_title; - $this->content = $content_col; - $this->current_year = date("Y"); - } - - public function echo_template(string $template_file) { - // Get the template file - $page = file_get_contents($template_file); - - // Replace the template variables - $page = str_replace('{page_title}', $this->title, $page); - $page = str_replace('{page_description}', $this->description, $page); - $page = str_replace('{canonical_url}', $this->canonical_url, $page); - $page = str_replace('{content}', $this->content, $page); - $page = str_replace('{current_year}', $this->current_year, $page); - - // Echo the filled-out template - echo $page; - } -} - -// EOF - -- cgit v1.2.3-70-g09d2