2017-11-23 10:23:09 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace router\controller;
|
|
|
|
|
|
|
|
|
|
|
|
class page{
|
|
|
|
|
|
|
|
|
|
|
|
private $pagename;
|
|
|
|
|
|
|
|
/* PRE-CALL
|
|
|
|
*
|
|
|
|
* @url<String> Calling URI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct($url){
|
2017-11-29 11:29:27 +00:00
|
|
|
$this->pagename = isset($url['page']) ? $url['page'] : null;
|
|
|
|
|
2017-11-23 10:23:09 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function load(){
|
2017-11-26 13:40:40 +00:00
|
|
|
if( file_exists(__ROOT__."/view/".$this->pagename.".php") )
|
|
|
|
include __ROOT__."/view/".$this->pagename.".php";
|
2017-11-23 10:23:09 +00:00
|
|
|
else
|
|
|
|
echo "page not found";
|
|
|
|
}
|
|
|
|
|
2017-11-29 11:29:27 +00:00
|
|
|
|
|
|
|
/* Manage bundle hash
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function bundle(){
|
|
|
|
|
|
|
|
/* (1) Extract /public_html/js/ all .js files */
|
|
|
|
$js_scripts = glob(__PUBLIC__.'/js/*.js');
|
|
|
|
|
|
|
|
/* (2) If match pattern 'bundle@*.js' */
|
|
|
|
foreach($js_scripts as $fname){
|
|
|
|
|
|
|
|
$bname = basename($fname);
|
|
|
|
|
|
|
|
// if match -> load it and exit
|
|
|
|
if( preg_match('/bundle@[\da-f]+\.js/', $bname) )
|
|
|
|
header("Location: /js/$bname");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-11-23 10:23:09 +00:00
|
|
|
/* POST-CALL
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __destruct(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|