function addScript($file = '') { if (is_array($file)) { return Gantry::addScripts($file); } $type = 'js'; $paths = array($this->templateUrl => $this->templatePath . DS . $type, $this->gantryUrl => $this->gantryPath . DS . $type); //see if this is a full url // check to see if this is a full path file $dir = dirname($file); if ($dir != ".") { // full url if (preg_match('/^http/', $file)) { $this->document->addScript($file); return; } // url path $file_path = $this->_getFilePath($file); $full_path = realpath($file_path); if ($full_path !== false && file_exists($full_path)) { $this->_scripts[$full_path] = $file; } return; } $out_files = array(); $ext = substr($file, strrpos($file, '.')); $filename = basename($file, $ext); $checks = Gantry::_getBrowserBasedChecks($filename); foreach ($paths as $baseurl => $path) { if (file_exists($path) && is_dir($path)) { foreach ($checks as $check) { $check_path = $path . DS . $check . $ext; $check_url_path = $baseurl . "/" . $type . "/" . $check . $ext; if (file_exists($check_path) && is_readable($check_path) && !array_key_exists($check, $out_files)) { $out_files[$check_path] = $check_url_path; } } } } foreach ($out_files as $script_path => $script_url_path) { $this->_scripts[$script_path] = $script_url_path; } }