2018-02-17 17:18:58 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace router\controller;
|
|
|
|
|
|
|
|
|
|
|
|
class page{
|
|
|
|
|
|
|
|
|
|
|
|
private $pagename;
|
|
|
|
|
|
|
|
/* PRE-CALL
|
|
|
|
*
|
|
|
|
* @url<String> Calling URI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct($url){
|
|
|
|
$this->pagename = $url['page'];
|
2018-02-20 16:17:53 +00:00
|
|
|
$this->uri = $url['uri'];
|
2018-02-17 17:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function load(){
|
2018-02-20 16:17:53 +00:00
|
|
|
|
|
|
|
/* (1) Build page file name */
|
|
|
|
$page_fname = __PUBLIC__."/page/".$this->pagename.".php";
|
|
|
|
|
|
|
|
/* (2) If page does not exist -> 404 */
|
|
|
|
if( !file_exists($page_fname) ){
|
|
|
|
http_response_code(404);
|
|
|
|
die('Page not found');
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (3) Set URI arguments */
|
|
|
|
$_GET['uri'] = explode('/', $this->uri);
|
|
|
|
|
|
|
|
/* (4) Load page */
|
|
|
|
include __PUBLIC__."/page/".$this->pagename.".php";
|
|
|
|
|
2018-02-17 17:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* POST-CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __destruct(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|