2017-11-30 15:45:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace router\controller;
|
|
|
|
|
|
|
|
|
|
|
|
class js{
|
|
|
|
|
|
|
|
|
|
|
|
private $pagename;
|
|
|
|
|
|
|
|
/* PRE-CALL
|
|
|
|
*
|
|
|
|
* @url<String> Calling URI
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function __construct($url){
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Generate _SERVER.js
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function server(){
|
|
|
|
header('Content-Type: text/javascript; charset=utf-8');
|
|
|
|
|
|
|
|
echo "window._SERVER = ".json_encode([
|
|
|
|
|
2017-12-04 10:22:10 +00:00
|
|
|
'session' => [
|
|
|
|
'name' => $_SESSION['NAME']
|
|
|
|
]
|
2017-11-30 15:45:26 +00:00
|
|
|
|
|
|
|
])."\n";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 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(){
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|