function addStyle($file = '') { if (is_array($file)) { return Gantry::addStyles($file); } $type = 'css'; $paths = array($this->gantryUrl => $this->gantryPath . DS . $type, $this->templateUrl => $this->templatePath . DS . $type); // check to see if this is a full path file $dir = dirname($file); if ($dir != ".") { // full url if (preg_match('/^http/', $file)) { $this->document->addStyleSheet($file); return; } // url path $file_path = $this->_getFilePath($file); $full_path = realpath($file_path); if ($full_path !== false && file_exists($full_path)) { $this->_styles[$full_path] = $file; } return; } $out_files = array(); $ext = substr($file, strrpos($file, '.')); $filename = basename($file, $ext); $checks = Gantry::_getBrowserBasedChecks($filename); $override_file = $filename . "-override"; $override = false; foreach ($paths as $baseurl => $path) { if (file_exists($path) && is_dir($path)) { $check_path = $path . DS . $override_file . $ext; $check_url_path = $baseurl . "/" . $type . "/" . $override_file . $ext; if (file_exists($check_path) && is_readable($check_path)) { $override = true; $out_files[$check_path] = $check_url_path; break; } } } if (!$override) { 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)) { $out_files[$check_path] = $check_url_path; } } } } } foreach ($out_files as $style_path => $style_file) { $this->_styles[$style_path] = $style_file; } }