public function getJSblock($root = array()) { if (!is_array($root)) { $root = array($root); } $root[] = '/js'; $out = ''; $groups = Mtpl::getJSgroups(); if (count($groups) > 0) { $assetsversion = (int) file_get_contents(APP_ROOT . 'app/ASSETSVERSION'); foreach (Mtpl::getJSgroups() as $group) { $jsfile = '/cache/' . $group . $assetsversion . '.js'; $out .= ' <script type="text/javascript" src="' . $jsfile . '"></script>'; } } foreach (Mtpl::getJS() as $js) { if (preg_match('`^https*`', $js)) { $jsfile = $js; } else { $jsfile = self::first_in_assets($root, $js . '.js'); } if (!$jsfile) { throw new Exception('non exist ' . $js); } $out .= ' <script type="text/javascript" src="' . $jsfile . '"></script>'; } return $out; }