-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassetLoader.php
More file actions
34 lines (28 loc) · 1.08 KB
/
Copy pathassetLoader.php
File metadata and controls
34 lines (28 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
$cache = 'siteroller/cache/';
include 'classes.php';
if($compress = false) include 'jsPacker.php';
$scriptname = $_POST['assets'];
foreach(array('js'=>'js', 'css2'=>'css') as $folder=>$extension){
$script = array();
foreach(explode('_', $_POST['assets']) as $asset) $script = array_merge($script, (array)$funcs[$asset][$folder]);
array_unique($script);
$file = "$cache$folder/$scriptname.$extension";
$ff = $root.$file;
if($script ){//&& !file_exists($ff)
$data = '';
$paths .= ($paths ? '|' : '')."$extension!/$file";
//var_dump($paths);
foreach($script as $add) $data .= file_get_contents($root."siteroller/classes/$add");
//var_dump($paths);
if($compress){
$packer = new JavaScriptPacker($code, 'Normal', true, false);
$pack = $packer->pack();
file_put_contents($ff, $pack);
} else file_put_contents($ff, $data);
}
}
echo $paths;
//array_splice($array1,count($array1),0,array2); is allegedly much quicker than array merge, and is the same. array_splice($array1,0,0,array2); is twice as fast, but revrses the order.
?>