Add 'cssfiles' hook to add custom CSS files to a page
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 3 Mar 2010 22:19:57 +0000 (15:19 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 4 Mar 2010 07:39:59 +0000 (00:39 -0700)
framework/Core/lib/Horde.php
horde/config/hooks.php.dist
horde/docs/CHANGES
imp/config/conf.xml
imp/templates/common-header.inc

index 8202523..569fcd8 100644 (file)
@@ -1640,7 +1640,8 @@ HTML;
      * @param array $options  Additional options:
      * <pre>
      * 'additional' - (array) TODO
-     * 'sub' - (string) TODO
+     * 'sub' - (string) A subdirectory containing additional CSS files to
+     *         load as an overlay to the base CSS files.
      * </pre>
      */
     static public function includeStylesheetFiles($options = array())
@@ -1834,6 +1835,16 @@ HTML;
             }
         }
 
+        /* Add user-defined additional stylesheets. */
+        try {
+            $css = array_merge($css, self::callHook('cssfiles', array($theme), 'horde'));
+        } catch (Horde_Exception_HookNotSet $e) {}
+        if ($curr_app != 'horde') {
+            try {
+                $css = array_merge($css, self::callHook('cssfiles', array($theme), $curr_app));
+            } catch (Horde_Exception_HookNotSet $e) {}
+        }
+
         $css_out = array();
         foreach ($css as $f => $u) {
             if (file_exists($f)) {
index 2a77ebe..952feab 100644 (file)
  *   [mixed] - The data to send to the browser (will be JSON encoded).
  *
  *
+ * CSS Hooks
+ * =========
+ *
+ * cssfiles
+ * --------
+ * This hook allows additional CSS stylesheets to be added to the page
+ * output.
+ *
+ * Parameters in:
+ *   $theme (string): The current theme.
+ *
+ * The return value from this hook is as follows:
+ *   [throw Horde_Ajax_Exception] - Fatal error.
+ *   [array] - An array of CSS files to add. Keys are the filesystem location,
+ *             values are the URI location.
+ *
+ *
  * TODO: groupldap, share_add, share_modify, share_remove
  *
  * $Id$
@@ -439,6 +456,14 @@ class Horde_Hooks
 //        // Code to run if the app is switched to horde
 //    }
 
+    // Add CSS files hook. See above for description of format.
+//    function cssfiles($theme)
+//    {
+//        return array(
+//            '/file/path/to/css' => 'uri/to/css'
+//        );
+//    }
+
     /**
      * Allow altering or validating data submitted by a user during a signup
      * request before any attempts are made to add them to the system.
index 4ecbe06..4839318 100644 (file)
@@ -2,6 +2,7 @@
 v4.0-cvs
 --------
 
+[mms] Add 'cssfiles' hook to add custom CSS files to a page.
 [jan] Add option to not automatically show all available shares.
 [jan] Add option to disallow world permissions for user shares.
 [mms] Allow Mozilla DNS prefetching to be turned off when displaying untrusted
index a0ca9e3..d32932b 100644 (file)
 
  <configtab name="dimp" desc="Dynamic View (dimp) Options">
   <configsection name="dimp">
-   <configlist name="css_files" required="false" desc="A list of additional CSS
-   files to load from the imp/themes/ directory."/>
-
    <configheader>ViewPort Settings</configheader>
    <configsection name="viewport">
     <configinteger name="buffer_pages" desc="The number of viewable pages to
index 9f4b398..f7ccc94 100644 (file)
@@ -35,16 +35,7 @@ if (!empty($refresh_time) && !empty($refresh_url)) {
 
 switch ($imp_view) {
 case 'dimp':
-    $css = array();
-    if (!empty($GLOBALS['conf']['dimp']['css_files'])) {
-        foreach ($GLOBALS['conf']['css_files'] as $css_file) {
-            $css[] = array(
-                'u' => $GLOBALS['registry']->get('themesuri') . '/' . $css_file,
-                'f' => $GLOBALS['registry']->get('themesfs') .  '/' . $css_file
-            );
-        }
-    }
-    Horde::includeStylesheetFiles(array('additional' => $css, 'sub' => 'dimp'));
+    Horde::includeStylesheetFiles(array('sub' => 'dimp'));
     break;
 
 default: