@@ -7,33 +7,33 @@ |
||
| 7 | 7 | private static $host; |
| 8 | 8 | private static $config; |
| 9 | 9 | |
| 10 | - public function __construct(){ |
|
| 10 | + public function __construct() { |
|
| 11 | 11 | # Config |
| 12 | 12 | self::$config = (new Config)->get(); |
| 13 | 13 | # Host |
| 14 | 14 | self::$host = parse_url('http://'.$_SERVER['HTTP_HOST']); |
| 15 | - if(isset(self::$host['host'])) self::$host = self::$host['host']; |
|
| 15 | + if (isset(self::$host['host'])) self::$host = self::$host['host']; |
|
| 16 | 16 | else self::$host = '/'; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | - public function add($js){ |
|
| 20 | - if(!is_array($js)) $js = [$js]; |
|
| 21 | - self::$list = array_merge(self::$list,$js); |
|
| 19 | + public function add($js) { |
|
| 20 | + if (!is_array($js)) $js = [$js]; |
|
| 21 | + self::$list = array_merge(self::$list, $js); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function get(){ |
|
| 24 | + public function get() { |
|
| 25 | 25 | $js = array_unique(self::$list); |
| 26 | - if(!empty($js)) $jsQuery = '?'.implode(':',$js); |
|
| 26 | + if (!empty($js)) $jsQuery = '?'.implode(':', $js); |
|
| 27 | 27 | else $jsQuery = ''; |
| 28 | 28 | return '<script async src="http://'.self::$host.'/javascript.js'.$jsQuery.'"></script>'; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function compile($query){ |
|
| 31 | + public function compile($query) { |
|
| 32 | 32 | $js = $query; |
| 33 | 33 | $code = ''; |
| 34 | - foreach($js as $name){ |
|
| 34 | + foreach ($js as $name) { |
|
| 35 | 35 | $file = self::$config['core']['js'].'/'.$name.'.js'; |
| 36 | - if(is_file($file)) $code .= file_get_contents($file); |
|
| 36 | + if (is_file($file)) $code .= file_get_contents($file); |
|
| 37 | 37 | } |
| 38 | 38 | $minifier = new \MatthiasMullie\Minify\JS(); |
| 39 | 39 | $minifier->add($code); |