main/build/router/controller/page.php

65 lines
931 B
PHP
Executable File

<?php
namespace router\controller;
class page{
private $pagename;
/* PRE-CALL
*
* @url<String> Calling URI
*
*/
public function __construct($url){
$this->pagename = isset($url['page']) ? $url['page'] : null;
}
/* CALL
*
*/
public function load(){
if( file_exists(__ROOT__."/view/".$this->pagename.".php") )
include __ROOT__."/view/".$this->pagename.".php";
else
echo "page not found";
}
/* 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");
}
}
/* POST-CALL
*
*/
public function __destruct(){
}
}