Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
ees_minify.php
1 <?php
24 error_reporting(E_ALL);
25 if ((php_sapi_name() != 'cli')) {
26  trigger_error("You can only run this script from the command line\n", E_USER_ERROR);
27 }
28 
29 $SYSTEM_ROOT = (isset($_SERVER['argv'][1])) ? $_SERVER['argv'][1] : '';
30 if (empty($SYSTEM_ROOT)) {
31  echo "ERROR: You need to supply the path to the System Root as the first argument\n";
32  exit();
33 }
34 
35 if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT.'/core/include/init.inc')) {
36  echo "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n";
37  exit();
38 }
39 
40 require_once $SYSTEM_ROOT.'/core/include/init.inc';
41 require_once 'jsmin.php';
42 
43 $file = $SYSTEM_ROOT.'/core/lib/js/matrix.min.js';
44 
45 $source_files = Array (
46  $SYSTEM_ROOT.'/fudge/var_serialise/var_serialise.js',
47  $SYSTEM_ROOT.'/core/lib/js/general.js',
48  $SYSTEM_ROOT.'/core/lib/js/debug.js',
49  $SYSTEM_ROOT.'/core/lib/js/layer_handler.js',
50  $SYSTEM_ROOT.'/core/lib/html_form/html_form.js',
51  $SYSTEM_ROOT.'/core/lib/js/detect.js',
52  $SYSTEM_ROOT.'/core/assets/bodycopy/bodycopy/js/bodycopy_edit_divs.js',
53  $SYSTEM_ROOT.'/core/assets/metadata/metadata_fields/metadata_field_select/js/metadata_field_select.js',
54  $SYSTEM_ROOT.'/core/assets/metadata/metadata_fields/metadata_field_multiple_text/js/metadata_field_multiple_text.js',
55  $SYSTEM_ROOT.'/core/assets/metadata/metadata_fields/metadata_field_hierarchy/js/metadata_field_hierarchy.js',
56 );
57 
58 // Output a minified version
59 $string = '';
60 foreach ($source_files as $source) {
61  echo 'processing '.$source."\n";
62  $string .= JSMin::minify(file_get_contents($source));
63 }
64 $result = file_put_contents($file, $string);
65 
66 if($result === FALSE) {
67  trigger_error ("FAILED TO GENREATE MINIFIED JS FILES FOR EES");
68 }
69 
70 echo "Minified js file is completed.\n";
71 echo $file. "\n";
72 ?>