}
if (!$exists) {
- $flags = defined('FILE_IGNORE_NEW_LINES')
- ? (FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
- : 0;
-
- foreach ($css as $file) {
- $path = substr($file['u'], 0, strrpos($file['u'], '/') + 1);
-
- // Fix relative URLs, convert graphics URLs to data URLs
- // (if possible), remove multiple whitespaces, and strip
- // comments.
- $tmp = preg_replace(array('/(url\(["\']?)([^\/])/i', '/\s+/', '/\/\*.*?\*\//'), array('$1' . $path . '$2', ' ', ''), implode('', file($file['f'], $flags)));
- if ($GLOBALS['browser']->hasFeature('dataurl')) {
- $tmp = preg_replace_callback('/(background(?:-image)?:[^;}]*(?:url\(["\']?))(.*?)((?:["\']?\)))/i', array(__CLASS__, 'stylesheetCallback'), $tmp);
- }
- $out .= $tmp;
- }
+ $out = self::loadCssFiles($css);
/* Use CSS tidy to clean up file. */
if ($conf['cachecssparams']['compress'] == 'php') {
}
/**
+ * Loads CSS files, cleans up the input, and concatenates to a string.
+ *
+ * @param array $files List of CSS files as returned from
+ * getStylesheets().
+ *
+ * @return string CSS data.
+ */
+ static public function loadCssFiles($files)
+ {
+ $flags = defined('FILE_IGNORE_NEW_LINES')
+ ? (FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES)
+ : 0;
+ $out = '';
+
+ foreach ($files as $file) {
+ $path = substr($file['u'], 0, strrpos($file['u'], '/') + 1);
+
+ // Fix relative URLs, convert graphics URLs to data URLs
+ // (if possible), remove multiple whitespaces, and strip
+ // comments.
+ $tmp = preg_replace(array('/(url\(["\']?)([^\/])/i', '/\s+/', '/\/\*.*?\*\//'), array('$1' . $path . '$2', ' ', ''), implode('', file($file['f'], $flags)));
+ if ($GLOBALS['browser']->hasFeature('dataurl')) {
+ $tmp = preg_replace_callback('/(background(?:-image)?:[^;}]*(?:url\(["\']?))(.*?)((?:["\']?\)))/i', array(__CLASS__, 'stylesheetCallback'), $tmp);
+ }
+ $out .= $tmp;
+ }
+
+ return $out;
+ }
+
+ /**
* Return the path to an image, using the default image if the image does
* not exist in the current theme.
*
}
}
- $css = '';
- foreach (Horde_Themes::getStylesheets() as $val) {
- $css .= file_get_contents($val['f']);
- }
-
- if ($style = Horde_Text_Filter::filter($css, 'csstidy', array('ob' => true))->filterBySelector($selectors)) {
+ if ($style = Horde_Text_Filter::filter(Horde_Themes::loadCssFiles(Horde_Themes::getStylesheets()), 'csstidy', array('ob' => true))->filterBySelector($selectors)) {
$elt->setAttribute('style', ($elt->hasAttribute('style') ? rtrim($elt->getAttribute('style'), ' ;') . ';' : '') . $style);
}
}