From: Michael M Slusarz Date: Tue, 9 Nov 2010 08:11:29 +0000 (-0700) Subject: Bug #9358: Add Horde_Themes::addStylesheetFile() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=93b9dd4ab70feb68b2c2fcfa9c4a1a4831063694;p=horde.git Bug #9358: Add Horde_Themes::addStylesheetFile() --- diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 1f1c2a422..e3a3894dd 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -760,22 +760,22 @@ class Ansel $themesuri = $GLOBALS['registry']->get('themesuri', 'ansel'); $themesfs = $GLOBALS['registry']->get('themesfs', 'ansel'); $css = array(); + if (!empty($GLOBALS['ansel_stylesheets'])) { foreach ($GLOBALS['ansel_stylesheets'] as $css_file) { - $css[] = array('u' => Horde::url($themesuri . '/' . $css_file, true), - 'f' => $themesfs . '/' . $css_file); + $css[$themesfs . '/' . $css_file] = Horde::url($themesuri . '/' . $css_file, true); } } /* Use Horde's stylesheet code if we aren't ouputting css directly */ if (!$custom_only) { - Horde_Themes::includeStylesheetFiles(array('additional' => $css)); + foreach ($css as $f => $u) { + Horde_Themes::addStylesheetFile($f, $u); + } + Horde_Themes::includeStylesheetFiles(); } else { - foreach ($css as $file) { - echo '' . "\n"; + foreach ($css as $u) { + echo '' . "\n"; } } } diff --git a/framework/Core/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php b/framework/Core/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php index e29089936..20a9225b8 100644 --- a/framework/Core/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php +++ b/framework/Core/lib/Horde/Core/Mime/Viewer/Syntaxhighlighter.php @@ -40,11 +40,11 @@ class Horde_Core_Mime_Viewer_Syntaxhighlighter extends Horde_Mime_Viewer_Syntaxh $sh_js_fs = $this->getConfigParam('registry')->get('jsfs', 'horde') . '/syntaxhighlighter/styles/'; $sh_js_uri = Horde::url($this->getConfigParam('registry')->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/'; - Horde_Themes::includeStylesheetFiles(array('additional' => array( - array('f' => $sh_js_fs . 'shCoreEclipse.css', 'u' => $sh_js_uri . 'shCoreEclipse.css'), - array('f' => $sh_js_fs . 'shThemeEclipse.css', 'u' => $sh_js_uri . 'shThemeEclipse.css'), - ))); + + Horde_Themes::addStylesheetFile($sh_js_fs . 'shCoreEclipse.css', $sh_js_uri . 'shCoreEclipse.css'); + Horde_Themes::addStylesheetFile($sh_js_fs . 'shThemeEclipse.css', $sh_js_uri . 'shThemeEclipse.css'); } + if (empty(self::$_shBrushes[$brush])) { Horde::addScriptFile('syntaxhighlighter/scripts/shBrush' . $brush . '.js', 'horde', true); self::$_shBrushes[$brush] = true; diff --git a/framework/Core/lib/Horde/Themes.php b/framework/Core/lib/Horde/Themes.php index ae3144f78..c051a07d2 100644 --- a/framework/Core/lib/Horde/Themes.php +++ b/framework/Core/lib/Horde/Themes.php @@ -14,12 +14,28 @@ class Horde_Themes { /** + * A list of additional stylesheet files to add to the output. + * + * @var array + */ + static protected $_cssFiles = array(); + + /** + * Adds an external stylesheet to the output. + * + * @param string $file + */ + static public function addStylesheet($file, $url) + { + $this->_cssFiles[$file] = $url; + } + + /** * Outputs the necessary style tags, honoring configuration choices as * to stylesheet caching. * * @param array $options Additional options: *
-     * 'additional' - (array) TODO
      * 'nohorde' - (boolean) If true, don't load files from Horde.
      * 'sub' - (string) A subdirectory containing additional CSS files to
      *         load as an overlay to the base CSS files.
@@ -39,10 +55,6 @@ class Horde_Themes
         $css = self::getStylesheets(isset($options['theme']) ? $options['theme'] : $prefs->getValue('theme'), $options);
         $css_out = array();
 
-        if (!empty($options['additional'])) {
-            $css = array_merge($css, $options['additional']);
-        }
-
         $cache_type = empty($conf['cachecss'])
             ? 'none'
             : $conf['cachecssparams']['driver'];
@@ -123,8 +135,6 @@ class Horde_Themes
 
     /**
      * Return the list of base stylesheets to display.
-     * Callback for includeStylesheetFiles() to convert images to base64
-     * data strings.
      *
      * @param mixed $theme    The theme to use; specify an empty value to
      *                        retrieve the theme from user preferences, and
@@ -216,6 +226,9 @@ class Horde_Themes
             }
         }
 
+        /* Add additional stylesheets added by code. */
+        $css = array_merge($css, $this->_cssFiles);
+
         /* Add user-defined additional stylesheets. */
         try {
             $css = array_merge($css, Horde::callHook('cssfiles', array($theme), 'horde'));
diff --git a/horde/services/portal/index.php b/horde/services/portal/index.php
index b63dd00c1..170c8ee2e 100644
--- a/horde/services/portal/index.php
+++ b/horde/services/portal/index.php
@@ -51,9 +51,10 @@ $view = new Horde_Block_Layout_View(
     Horde::url('services/portal/index.php', true));
 $layout_html = $view->toHtml();
 
-$horde_css_stylesheets = array();
 foreach ($view->getApplications() as $app) {
-    $horde_css_stylesheets = array_merge($horde_css_stylesheets, Horde_Themes::getStylesheets('', array('app' => $app)));
+    foreach (Horde_Themes::getStylesheets('', array('app' => $app)) as $f => $u) {
+        Horde_Themes::addStylesheetFile($f, $u);
+    }
 }
 
 $linkTags = $view->getLinkTags();
diff --git a/horde/templates/common-header.inc b/horde/templates/common-header.inc
index d222811e8..7aa033028 100644
--- a/horde/templates/common-header.inc
+++ b/horde/templates/common-header.inc
@@ -25,7 +25,7 @@ Horde::outputMetaTags();
 isMobile()): ?>
 
  Horde_Util::nonInputVar('horde_css_stylesheets', array())));
+echo Horde_Themes::includeStylesheetFiles();
 echo Horde::includeScriptFiles();
 echo implode("\n", Horde_Util::nonInputVar('linkTags', array()));
 Horde::outputInlineScript();
diff --git a/imp/templates/common-header.inc b/imp/templates/common-header.inc
index e82344860..d4e4ccaee 100644
--- a/imp/templates/common-header.inc
+++ b/imp/templates/common-header.inc
@@ -36,7 +36,9 @@ Horde::outputMetaTags();
 
 switch ($imp_view) {
 case 'dimp':
-    Horde_Themes::includeStylesheetFiles(array('sub' => 'dimp'));
+    Horde_Themes::includeStylesheetFiles(array(
+        'sub' => 'dimp'
+    ));
     if (!in_array(basename($_SERVER['PHP_SELF']), array('compose-dimp.php', 'index-dimp.php', 'message-dimp.php'))) {
         Horde::includeScriptFiles();
         Horde::outputInlineScript();
diff --git a/jonah/lib/View/StoryView.php b/jonah/lib/View/StoryView.php
index c2b6f49d2..dc774e851 100644
--- a/jonah/lib/View/StoryView.php
+++ b/jonah/lib/View/StoryView.php
@@ -65,10 +65,9 @@ EOT;
 
         $sh_js_fs = $GLOBALS['registry']->get('jsfs', 'horde') . '/syntaxhighlighter/styles/';
         $sh_js_uri = Horde::url($GLOBALS['registry']->get('jsuri', 'horde'), false, -1) . '/syntaxhighlighter/styles/';
-        Horde_Themes::includeStylesheetFiles(array('additional' => array(
-            array('f' => $sh_js_fs . 'shCoreEclipse.css', 'u' => $sh_js_uri . 'shCoreEclipse.css'),
-            array('f' => $sh_js_fs . 'shThemeEclipse.css', 'u' => $sh_js_uri . 'shThemeEclipse.css'),
-        )));
+
+        Horde_Themes::addStylesheetFile($sh_js_fs . 'shCoreEclipse.css', $sh_js_uri . 'shCoreEclipse.css');
+        Horde_Themes::addStylesheetFile($sh_js_fs . 'shThemeEclipse.css', $sh_js_uri . 'shThemeEclipse.css');
 
         $driver = $GLOBALS['injector']->getInstance('Jonah_Driver');
         try {
diff --git a/mnemo/templates/common-header.inc b/mnemo/templates/common-header.inc
index 80159ceac..163c4b067 100644
--- a/mnemo/templates/common-header.inc
+++ b/mnemo/templates/common-header.inc
@@ -20,6 +20,8 @@ if (!empty($title)) {
 Horde::outputMetaTags();
 Horde::includeScriptFiles();
 
+Horde::addStylesheetFile($registry->get('themesfs') . '/categoryCSS.php', $registry->get('themesuri') . '/categoryCSS.php');
+
 $bc = $prefs->getValue('show_panel')
     ? 'rightPanel'
     : '';
@@ -28,7 +30,6 @@ $bc = $prefs->getValue('show_panel')
 <?php echo htmlspecialchars($page_title) ?>
 
 
-
 
 
 >
diff --git a/nag/templates/common-header.inc b/nag/templates/common-header.inc
index 7726b2068..7c8c69222 100644
--- a/nag/templates/common-header.inc
+++ b/nag/templates/common-header.inc
@@ -17,6 +17,8 @@ if (!empty($title)) {
 Horde::outputMetaTags();
 Horde::includeScriptFiles();
 
+Horde::addStylesheetFile($registry->get('themesfs') . '/categoryCSS.php', $registry->get('themesuri') . '/categoryCSS.php');
+
 $bc = $prefs->getValue('show_panel')
     ? 'rightPanel'
     : '';
@@ -25,7 +27,6 @@ $bc = $prefs->getValue('show_panel')
 <?php echo htmlspecialchars($page_title) ?>
 
 
-
 
diff --git a/trean/templates/common-header.inc b/trean/templates/common-header.inc
index 27e515a78..c62cef61d 100644
--- a/trean/templates/common-header.inc
+++ b/trean/templates/common-header.inc
@@ -20,6 +20,8 @@ if (!empty($title)) {
 Horde::outputMetaTags();
 Horde::includeScriptFiles();
 
+Horde_Themes::addStylesheetFile($registry->get('themesfs') . '/grids-min.css', $registry->get('themesuri')  . '/grids-min.css');
+
 $rss = Horde::url('rss.php', true, -1);
 if (Horde_Util::getFormData('f')) {
     $rss = Horde_Util::addParameter($rss, 'f', Horde_Util::getFormData('f'), false);
@@ -38,7 +40,6 @@ if ($prefs->getValue('show_folder_actions')) {
 <?php echo htmlspecialchars($page_title) ?>
 
 
-
 
 
 >