firt write up of basic page class
This commit is contained in:
parent
a8ecc16e02
commit
575e2b5a85
59
lib/Page.php
Normal file
59
lib/Page.php
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class Page
|
||||||
|
{
|
||||||
|
private $pagecontent = '';
|
||||||
|
private $title = '';
|
||||||
|
private $navigation = '';
|
||||||
|
|
||||||
|
//default boilerplate html code
|
||||||
|
private $template = '
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="de">
|
||||||
|
<head>
|
||||||
|
<title>$$TITLE$$</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<nav>
|
||||||
|
$$NAVIGATION$$
|
||||||
|
</nav>
|
||||||
|
<div>
|
||||||
|
$$PAGECONTENT$$
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
';
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct($title)
|
||||||
|
{
|
||||||
|
$this->title = $title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addContent($content)
|
||||||
|
{
|
||||||
|
$this->pagecontent .= $content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setTemplate($template){
|
||||||
|
$this->template = $template;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNavigation($navigation){
|
||||||
|
$this->navigation = $navigation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayPage(){
|
||||||
|
$page = $this->template;
|
||||||
|
$page = str_replace('$$TITLE$$', $this->title, $page);
|
||||||
|
$page = str_replace('$$NAVIGATION$$', $this->navigation, $page);
|
||||||
|
$page = str_replace('$$PAGECONTENT$$', $this->pagecontent, $page);
|
||||||
|
|
||||||
|
echo $page;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user