Move JS/CSS caching to Horde::
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 29 Jul 2009 23:10:56 +0000 (17:10 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 29 Jul 2009 23:22:41 +0000 (17:22 -0600)
26 files changed:
babel/templates/common-header.inc
chora/templates/common-header.inc
crumb/templates/common-header.inc
fima/templates/common-header.inc
folks/templates/common-header.inc
gollem/templates/common-header.inc
imp/compose-dimp.php
imp/config/conf.xml
imp/docs/CHANGES
imp/index-dimp.php
imp/lib/IMP.php
imp/message-dimp.php
imp/templates/common-header.inc
ingo/templates/common-header.inc
jeta/templates/common-header.inc
kastalia/templates/common-header.inc
koward/lib/Koward/View/shared/_header.html.php
kronolith/index.php
kronolith/lib/Kronolith.php
kronolith/templates/common-header.inc
nag/templates/common-header.inc
news/diff.php
news/reads.php
news/templates/common-header.inc
skoli/templates/common-header.inc
turba/templates/common-header.inc

index 93c47fc..d00e416 100644 (file)
@@ -19,7 +19,7 @@ Horde::includeScriptFiles();
 
 ?>
 <title><?php echo $page_title ?></title>
-<?php echo Horde::stylesheetLink('babel') ?>
+<?php Horde::includeStylesheetFiles('babel') ?>
 </head>
 
 <body<?php if (Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bodyClass . '"' ?>>
index 884cd39..558ebc1 100644 (file)
@@ -20,7 +20,7 @@ Horde::includeScriptFiles();
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir() ?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('chora') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index 481396e..50147d4 100644 (file)
@@ -23,7 +23,7 @@ Horde::includeScriptFiles();
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('skeleton') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index d6ecab0..66c6440 100644 (file)
@@ -23,7 +23,7 @@ Horde::includeScriptFiles();
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('fima', empty($print_view) ? '' : 'print') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index d73782b..bb8a9b1 100644 (file)
@@ -27,7 +27,7 @@ Horde::includeScriptFiles();
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'activity') ?>" title="<?php echo _("Friends activity") ?>" />
 <link rel="alternate" type="application/rss+xml" href="<?php echo Folks::getUrlFor('feed', 'know') ?>" title="<?php echo _("People you might know") ?>" />
 <?php endif; ?>
-<?php echo Horde::stylesheetLink('folks') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index b56950f..505922e 100644 (file)
@@ -25,7 +25,7 @@ require GOLLEM_TEMPLATES . '/javascript_defs.php';
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('gollem') ?>
+<?php Horde::includeStylesheetFiles() ?>
 <?php Horde::outputInlineScript(); ?>
 </head>
 
index b515ba1..558571c 100644 (file)
@@ -337,7 +337,7 @@ $scripts = array(
 
 DIMP::header(_("Message Composition"), $scripts);
 echo $t->fetch('compose.html');
-IMP::includeScriptFiles();
+Horde::includeScriptFiles();
 Horde::outputInlineScript();
 echo $compose_result['jsappend'];
 echo "</body>\n</html>";
index a4e6369..4675f65 100644 (file)
    next login. If IMP will be the exclusive means of accessing the mail server,
    or you are not concerned about this behavior, this setting should be set to
    true.">true</configboolean>
-   <configswitch name="cachejs" desc="Cache static javascript and combine into
-   a single page for delivery to the remote browser?">none
-    <case name="none" desc="No" />
-    <case name="filesystem" desc="Filesystem">
-     <configsection name="cachejsparams">
-      <configphp name="file_location" desc="The filesystem directory to write
-      the static files to. THIS DIRECTORY MUST BE AVAILABLE ON THE SERVER
-      RUNNING PHP AND MUST BE WRITABLE BY THE PHP USER."></configphp>
-      <configphp name="file_url" desc="The corresponding base URL to use to
-      access the static files."></configphp>
-      <configinteger name="lifetime" desc="Lifetime, in seconds, after which
-      the garbage collector will remove static files.">86400</configinteger>
-     </configsection>
-    </case>
-    <case name="horde_cache" desc="Horde_Cache">
-     <configdescription>
-      &lt;strong&gt;Requires a configured Horde_Cache backend.&lt;/strong&gt;
-     </configdescription>
-     <configsection name="cachejsparams">
-      <configinteger name="lifetime" desc="Cache lifetime, in seconds.">
-      86400</configinteger>
-     </configsection>
-    </case>
-   </configswitch>
-   <configswitch name="cachecss" desc="Cache static CSS and combine into
-   a single page for delivery to the remote browser?">none
-    <case name="none" desc="No" />
-    <case name="filesystem" desc="Filesystem">
-     <configsection name="cachecssparams">
-      <configphp name="file_location" desc="The filesystem directory to write
-      the static files to. THIS DIRECTORY MUST BE AVAILABLE ON THE SERVER
-      RUNNING PHP AND MUST BE WRITABLE BY THE PHP USER."></configphp>
-      <configphp name="file_url" desc="The corresponding base URL to use to
-      access the static files."></configphp>
-      <configinteger name="lifetime" desc="Lifetime, in seconds, after which
-      the garbage collector will remove static files.">86400</configinteger>
-     </configsection>
-    </case>
-    <case name="horde_cache" desc="Horde_Cache">
-     <configdescription>
-      &lt;strong&gt;Requires a configured Horde_Cache backend.&lt;/strong&gt;
-     </configdescription>
-     <configsection name="cachecssparams">
-      <configinteger name="lifetime" desc="Cache lifetime, in seconds.">
-      86400</configinteger>
-     </configsection>
-    </case>
-   </configswitch>
   </configsection>
  </configtab>
 
  </configtab>
 
  <configtab name="dimp" desc="Dynamic View (dimp) Options">
-  <configheader>Custom Hooks</configheader>
   <configsection name="dimp">
    <configlist name="css_files" required="false" desc="A list of additional CSS
    files to load from the imp/themes/ directory."/>
index c1ad3ee..ba42486 100644 (file)
@@ -2,6 +2,7 @@
 v5.0-git
 --------
 
+[mms] Move JS/CSS caching to Horde framework.
 [mms] Add simple search function to MIMP.
 [mms] DIMP now honors the 'mailbox_start' preference.
 [mms] Logins now handled by Horde login handler.
index 90b55d3..86e582d 100644 (file)
@@ -62,7 +62,7 @@ foreach (DIMP::menuList() as $app) {
 
 echo "<body>\n";
 require IMP_TEMPLATES . '/index/index-dimp.inc';
-IMP::includeScriptFiles();
+Horde::includeScriptFiles();
 Horde::outputInlineScript();
 $notification->notify(array('listeners' => array('javascript')));
 echo "</body>\n</html>";
index 4684e99..46546f0 100644 (file)
@@ -47,9 +47,6 @@ class IMP
     /* hideDeletedMsgs() cache. */
     static private $_delhide = null;
 
-    /* filesystemGC() cache. */
-    static private $_dirlist = array();
-
     /* Has init previously been called? */
     static private $_init = false;
 
@@ -1208,320 +1205,6 @@ class IMP
     }
 
     /**
-     * Outputs the necessary script tags, honoring local configuration
-     * choices as to script caching.
-     */
-    static public function includeScriptFiles()
-    {
-        global $conf;
-
-        $cache_type = @$conf['server']['cachejs'];
-
-        if (empty($cache_type) ||
-            $cache_type == 'none' ||
-            (($cache_type == 'horde_cache') &&
-             !($cache = self::getCache()))) {
-            Horde::includeScriptFiles();
-            return;
-        }
-
-        $js_tocache = $js_force = array();
-        $mtime = array(0);
-
-        $s_list = Horde::listScriptFiles();
-        foreach ($s_list as $app => $files) {
-            foreach ($files as $file) {
-                if ($file['d'] && ($file['f'][0] != '/')) {
-                    $js_tocache[$file['p'] . $file['f']] = false;
-                    $mtime[] = filemtime($file['p'] . $file['f']);
-                } else {
-                    $js_force[] = $file['u'];
-                }
-            }
-        }
-
-        sort($s_list);
-
-        require_once IMP_BASE . '/lib/version.php';
-        $sig = hash('md5', serialize($s_list) . max($mtime) . IMP_VERSION);
-
-        switch ($cache_type) {
-        case 'filesystem':
-            $js_filename = '/' . $sig . '.js';
-            $js_path = $conf['server']['cachejsparams']['file_location'] . $js_filename;
-            $js_url = $conf['server']['cachejsparams']['file_url'] . $js_filename;
-            $exists = file_exists($js_path);
-            break;
-
-        case 'horde_cache':
-            // Do lifetime checking here, not on cache display page.
-            $exists = $cache->exists($sig, empty($conf['server']['cachejsparams']['lifetime']) ? 0 : $conf['server']['cachejsparams']['lifetime']);
-            $js_url = Horde::getCacheUrl('js', array('cid' => $sig));
-            break;
-        }
-
-        if (!$exists) {
-            $out = '';
-            foreach ($js_tocache as $key => $val) {
-                // Separate JS files with a newline since some compressors may
-                // strip trailing terminators.
-                if ($val) {
-                    // Minify these files a bit by removing newlines and
-                    // comments.
-                    $out .= preg_replace(array('/\n+/', '/\/\*.*?\*\//'), array('', ''), file_get_contents($key)) . "\n";
-                } else {
-                    $out .= file_get_contents($key) . "\n";
-                }
-            }
-
-            switch ($cache_type) {
-            case 'filesystem':
-                register_shutdown_function(array('IMP', 'filesystemGC'), 'js');
-                file_put_contents($js_path, $out);
-                break;
-
-            case 'horde_cache':
-                $cache->set($sig, $out);
-                break;
-            }
-        }
-
-        foreach (array_merge(array($js_url), $js_force) as $val) {
-            echo '<script type="text/javascript" src="' . $val . "\"></script>\n";
-        }
-    }
-
-    /**
-     * Outputs the necessary style tags, honoring local configuration
-     * choices as to stylesheet caching.
-     *
-     * @param string $app  The application to load ('dimp' or 'imp').
-     */
-    static public function includeStylesheetFiles($app = 'imp')
-    {
-        global $conf, $prefs, $registry;
-
-        $theme = $prefs->getValue('theme');
-        $themesfs = $registry->get('themesfs');
-        $themesuri = $registry->get('themesuri');
-        if ($app == 'imp') {
-            $css = Horde::getStylesheets('imp', $theme);
-        } else {
-            $css = self::_getDIMPStylesheets($theme);
-        }
-        $css_out = array();
-
-        if ($app == 'dimp') {
-            // Load custom stylesheets.
-            if (!empty($conf['dimp']['css_files'])) {
-                foreach ($conf['css_files'] as $css_file) {
-                    $css[] = array('u' => $themesuri . '/' . $css_file,
-                                   'f' => $themesfs .  '/' . $css_file);
-                }
-            }
-        }
-
-        $cache_type = @$conf['server']['cachecss'];
-
-        if (empty($cache_type) ||
-            $cache_type == 'none' ||
-            (($cache_type == 'horde_cache') &&
-             !($cache = self::getCache()))) {
-            $css_out = array_merge($css, $css_out);
-        } else {
-            $mtime = array(0);
-            $out = '';
-
-            foreach ($css as $file) {
-                $mtime[] = filemtime($file['f']);
-            }
-
-            require_once IMP_BASE . '/lib/version.php';
-            $sig = hash('md5', serialize($css) . max($mtime) . IMP_VERSION);
-
-            switch ($cache_type) {
-            case 'filesystem':
-                $css_filename = '/' . $sig . '.css';
-                $css_path = $conf['server']['cachecssparams']['file_location'] . $css_filename;
-                $css_url = $conf['server']['cachecssparams']['file_url'] . $css_filename;
-                $exists = file_exists($css_path);
-                break;
-
-            case 'horde_cache':
-                // Do lifetime checking here, not on cache display page.
-                $exists = $cache->exists($sig, empty($GLOBALS['conf']['server']['cachecssparams']['lifetime']) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime']);
-                $css_url = Horde::getCacheUrl('css', array('cid' => $sig));
-                break;
-            }
-
-            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('IMP', 'stylesheetCallback'), $tmp);
-                    }
-                    $out .= $tmp;
-                }
-
-                /* Use CSS tidy to clean up file. */
-                try {
-                    $out = Horde_Text_Filter::filter($out, 'csstidy');
-                } catch (Horde_Exception $e) {}
-
-                switch ($cache_type) {
-                case 'filesystem':
-                    register_shutdown_function(array('IMP', 'filesystemGC'), 'css');
-                    file_put_contents($css_path, $out);
-                    break;
-
-                case 'horde_cache':
-                    $cache->set($sig, $out);
-                    break;
-                }
-            }
-
-            $css_out = array_merge(array(array('u' => $css_url)), $css_out);
-        }
-
-        foreach ($css_out as $file) {
-            echo '<link href="' . $file['u'] . "\" rel=\"stylesheet\" type=\"text/css\" />\n";
-        }
-    }
-
-    /**
-     * TODO - Move to Horde core
-     */
-    public function stylesheetCallback($matches)
-    {
-        return $matches[1] . Horde::base64ImgData($matches[2]) . $matches[3];
-    }
-
-    /**
-     * TODO - Temporary DIMP fix/Merge to Horde core
-     */
-    private function _getDIMPStylesheets($theme = '')
-    {
-        if ($theme === '' && isset($GLOBALS['prefs'])) {
-            $theme = $GLOBALS['prefs']->getValue('theme');
-        }
-
-        $css = array();
-        $rtl = isset($GLOBALS['nls']['rtl'][$GLOBALS['language']]);
-
-        /* Collect browser specific stylesheets if needed. */
-        $browser_css = array();
-
-        switch ($GLOBALS['browser']->getBrowser()) {
-        case 'msie':
-            $ie_major = $GLOBALS['browser']->getMajor();
-            // TODO: IE8 specific styling
-            if ($ie_major >= 7) {
-                $browser_css[] = 'ie7.css';
-                $browser_css[] = 'ie7-dimp.css';
-            } elseif ($ie_major < 7) {
-                $browser_css[] = 'ie6_or_less.css';
-                $browser_css[] = 'ie6_or_less-dimp.css';
-                if ($GLOBALS['browser']->getPlatform() == 'mac') {
-                    $browser_css[] = 'ie5mac.css';
-                }
-            }
-            break;
-
-        case 'opera':
-            $browser_css[] = 'opera.css';
-            break;
-
-        case 'mozilla':
-            if ($GLOBALS['browser']->getMajor() >= 5 &&
-                preg_match('/rv:(.*)\)/', $GLOBALS['browser']->getAgentString(), $revision) &&
-                $revision[1] <= 1.4) {
-                $browser_css[] = 'moz14.css';
-            }
-            break;
-
-        case 'webkit':
-            $browser_css[] = 'webkit.css';
-        }
-
-        foreach (array('horde', 'imp') as $app) {
-            $themes_fs = $GLOBALS['registry']->get('themesfs', $app);
-            $themes_uri = Horde::url($GLOBALS['registry']->get('themesuri', $app), false, -1);
-            $css[] = array('u' => $themes_uri . '/screen.css', 'f' => $themes_fs . '/screen.css');
-            if ($app == 'imp') {
-                $css[] = array('u' => $themes_uri . '/screen-dimp.css', 'f' => $themes_fs . '/screen-dimp.css');
-            }
-            if (!empty($theme)) {
-                if (file_exists($themes_fs . '/' . $theme . '/screen.css')) {
-                    $css[] = array('u' => $themes_uri . '/' . $theme . '/screen.css', 'f' => $themes_fs . '/' . $theme . '/screen.css');
-                }
-                if (($app == 'imp') &&
-                    file_exists($themes_fs . '/' . $theme . '/screen-dimp.css')) {
-                    $css[] = array('u' => $themes_uri . '/' . $theme . '/screen-dimp.css', 'f' => $themes_fs . '/' . $theme . '/screen-dimp.css');
-                }
-            }
-
-            if ($rtl) {
-                $css[] = array('u' => $themes_uri . '/rtl.css', 'f' => $themes_fs . '/rtl.css');
-                if (!empty($theme) &&
-                    file_exists($themes_fs . '/' . $theme . '/rtl.css')) {
-                    $css[] = array('u' => $themes_uri . '/' . $theme . '/rtl.css', 'f' => $themes_fs . '/' . $theme . '/rtl.css');
-                }
-            }
-            foreach ($browser_css as $browser) {
-                if (file_exists($themes_fs . '/' . $browser)) {
-                    $css[] = array('u' => $themes_uri . '/' . $browser, 'f' => $themes_fs . '/' . $browser);
-                }
-                if (!empty($theme) &&
-                    file_exists($themes_fs . '/' . $theme . '/' . $browser)) {
-                    $css[] = array('u' => $themes_uri . '/' . $theme . '/' . $browser, 'f' => $themes_fs . '/' . $theme . '/' . $browser);
-                }
-            }
-        }
-
-        return $css;
-    }
-
-    /**
-     * Do garbage collection in the statically served file directory.
-     *
-     * @param string $type  Either 'css' or 'js'.
-     */
-    static public function filesystemGC($type)
-    {
-        $dir_list = &self::$_dirlist;
-
-        $ptr = $GLOBALS['conf']['server'][(($type == 'css') ? 'cachecssparams' : 'cachejsparams')];
-        $dir = $ptr['file_location'];
-        if (in_array($dir, $dir_list)) {
-            return;
-        }
-
-        $c_time = time() - $ptr['lifetime'];
-        $d = dir($dir);
-        $dir_list[] = $dir;
-
-        while (($entry = $d->read()) !== false) {
-            $path = $dir . '/' . $entry;
-            if (in_array($entry, array('.', '..'))) {
-                continue;
-            }
-
-            if ($c_time > filemtime($path)) {
-                $old_error = error_reporting(0);
-                unlink($path);
-                error_reporting($old_error);
-            }
-        }
-        $d->close();
-    }
-
-    /**
      * Returns a Horde_Cache object (if configured) and handles any errors
      * associated with creating the object.
      *
index 978b5a9..b1785a9 100644 (file)
@@ -83,7 +83,7 @@ Horde::addInlineScript(array(DIMP::notify()), 'dom');
 DIMP::header($show_msg_result['subject'], $scripts);
 echo "<body>\n";
 require IMP_TEMPLATES . '/chunks/message.php';
-IMP::includeScriptFiles();
+Horde::includeScriptFiles();
 Horde::outputInlineScript();
 if (!$disable_compose) {
     echo $compose_result['jsappend'];
index ea29eb9..91d1911 100644 (file)
@@ -16,13 +16,24 @@ $imp_view = Horde_Util::nonInputVar('imp_view');
 switch ($imp_view) {
 case 'dimp':
     include IMP_TEMPLATES . '/javascript_defs_dimp.php';
-    IMP::includeStylesheetFiles('dimp');
+
+    $css = array();
+    if (!empty($GLOBALS['conf']['dimp']['css_files'])) {
+        foreach ($GLOBALS['conf']['css_files'] as $css_file) {
+            $css[] = array(
+                'u' => $themesuri . '/' . $css_file,
+                'f' => $themesfs .  '/' . $css_file
+            );
+        }
+    }
+
+    Horde::includeStylesheetFiles(array('additional' => $css, 'sub' => 'dimp'));
     break;
 
 default:
     include IMP_TEMPLATES . '/javascript_defs.php';
-    IMP::includeScriptFiles();
-    IMP::includeStylesheetFiles();
+    Horde::includeScriptFiles();
+    Horde::includeStylesheetFiles();
     break;
 }
 ?>
index 3b67ad6..491d41c 100644 (file)
@@ -17,7 +17,7 @@ if (!empty($title)) {
 <?php Horde::includeScriptFiles(); ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('ingo') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index a9870df..501e08e 100644 (file)
@@ -9,7 +9,7 @@ if (isset($language)) {
 <head>
 <title><?php echo htmlspecialchars($registry->get('name')) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('horde') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body>
index bfcf5a0..787fdff 100755 (executable)
@@ -26,7 +26,7 @@ Horde::includeScriptFiles();
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('kastalia') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index 3d742b1..37b451c 100644 (file)
@@ -29,7 +29,7 @@ Horde::includeScriptFiles();
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
 
-<?php echo Horde::stylesheetLink('koward', empty($this->print_view) ? $this->theme : 'print') ?>
+<?php Horde::includeStylesheetFiles() ?>
 
 </head>
 
index 2ca8c5f..bdeec74 100644 (file)
@@ -62,7 +62,7 @@ $scripts = array(
 Kronolith::header('', $scripts);
 echo "<body class=\"kronolithAjax\">\n";
 require KRONOLITH_TEMPLATES . '/index/index.inc';
-Kronolith::includeScriptFiles();
+Horde::includeScriptFiles();
 Horde::outputInlineScript();
 $notification->notify(array('listeners' => array('javascript')));
 $tac = Horde_Ajax_Imple::factory(array('kronolith', 'TagAutoCompleter'), array('triggerId' => 'kronolithEventTags', 'pretty' => true));
index 0296039..3500d8b 100644 (file)
@@ -111,7 +111,7 @@ class Kronolith
              '<link href="' . $GLOBALS['registry']->getImageDir() . "/favicon.ico\" rel=\"SHORTCUT ICON\" />\n".
              Horde::wrapInlineScript(self::includeJSVars());
 
-        self::includeStylesheetFiles(true);
+        Horde::includeStylesheetFiles();
 
         echo "</head>\n";
 
@@ -227,190 +227,6 @@ class Kronolith
     }
 
     /**
-     * Outputs the necessary script tags, honoring local configuration choices
-     * as to script caching.
-     */
-    public static function includeScriptFiles()
-    {
-        global $conf;
-
-        $cache_type = @$conf['server']['cachejs'];
-
-        if (empty($cache_type) ||
-            $cache_type == 'none' ||
-            ($cache_type == 'horde_cache' &&
-             $conf['cache']['driver'] == 'none')) {
-            Horde::includeScriptFiles();
-            return;
-        }
-
-        $js_tocache = $js_force = array();
-        $mtime = array(0);
-
-        $s_list = Horde::listScriptFiles();
-        foreach ($s_list as $app => $files) {
-            foreach ($files as $file) {
-                if ($file['d'] && ($file['f'][0] != '/')) {
-                    $js_tocache[$file['p'] . $file['f']] = false;
-                    $mtime[] = filemtime($file['p'] . $file['f']);
-                } else {
-                    $js_force[] = $file['u'];
-                }
-            }
-        }
-
-        require_once KRONOLITH_BASE . '/lib/version.php';
-        $sig = hash('md5', serialize($s_list) . max($mtime) . KRONOLITH_VERSION);
-
-        switch ($cache_type) {
-        case 'filesystem':
-            $js_filename = '/' . $sig . '.js';
-            $js_path = $conf['server']['cachejsparams']['file_location'] . $js_filename;
-            $js_url = $conf['server']['cachejsparams']['file_url'] . $js_filename;
-            $exists = file_exists($js_path);
-            break;
-
-        case 'horde_cache':
-            $cache = &Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
-            $exists = $cache->exists($sig, empty($conf['server']['cachejsparams']['lifetime']) ? 0 : $conf['server']['cachejsparams']['lifetime']);
-            $js_url = self::getCacheURL('js', $sig);
-            break;
-        }
-
-        if (!$exists) {
-            $out = '';
-            foreach ($js_tocache as $key => $val) {
-                // Separate JS files with a newline since some compressors may
-                // strip trailing terminators.
-                if ($val) {
-                    // Minify these files a bit by removing newlines and
-                    // comments.
-                    $out .= preg_replace(array('/\n+/', '/\/\*.*?\*\//'), array('', ''), file_get_contents($key)) . "\n";
-                } else {
-                    $out .= file_get_contents($key) . "\n";
-                }
-            }
-
-            switch ($cache_type) {
-            case 'filesystem':
-                register_shutdown_function(array('Kronolith', '_filesystemGC'), 'js');
-                file_put_contents($js_path, $out);
-                break;
-
-            case 'horde_cache':
-                $cache->set($sig, $out);
-                break;
-            }
-        }
-
-        foreach (array_merge(array($js_url), $js_force) as $val) {
-            echo '<script type="text/javascript" src="' . $val . '"></script>' . "\n";
-        }
-    }
-
-    /**
-     * Outputs the necessary style tags, honoring local configuration choices
-     * as to stylesheet caching.
-     *
-     * @param boolean $print  Include print CSS?
-     */
-    public static function includeStylesheetFiles($print = false)
-    {
-        global $conf, $prefs, $registry;
-
-        $theme = $prefs->getValue('theme');
-        $themesfs = $registry->get('themesfs');
-        $themesuri = $registry->get('themesuri');
-        $css = Horde::getStylesheets('kronolith', $theme);
-        $css_out = array();
-
-        // Add print specific stylesheets.
-        if ($print) {
-            // Add Horde print stylesheet
-            $css_out[] = array('u' => $registry->get('themesuri', 'horde') . '/print/screen.css',
-                               'f' => $registry->get('themesfs', 'horde') . '/print/screen.css',
-                               'm' => 'print');
-            $css_out[] = array('u' => $themesuri . '/print/screen.css',
-                               'f' => $themesfs . '/print/screen.css',
-                               'm' => 'print');
-            if (file_exists($themesfs . '/' . $theme . '/print.css')) {
-                $css_out[] = array('u' => $themesuri . '/' . $theme . '/print.css',
-                                   'f' => $themesfs . '/' . $theme . '/print.css',
-                                   'm' => 'print');
-            }
-        }
-
-        // Load custom stylesheets.
-        if (!empty($conf['css_files'])) {
-            foreach ($conf['css_files'] as $css_file) {
-                $css[] = array('u' => $themesuri . '/' . $css_file,
-                               'f' => $themesfs .  '/' . $css_file);
-            }
-        }
-
-        $cache_type = @$conf['server']['cachecss'];
-
-        if (empty($cache_type) ||
-            $cache_type == 'none' ||
-            ($cache_type == 'horde_cache' &&
-             $conf['cache']['driver'] == 'none')) {
-            $css_out = array_merge($css, $css_out);
-        } else {
-            $mtime = array(0);
-            $out = '';
-
-            foreach ($css as $file) {
-                $mtime[] = filemtime($file['f']);
-            }
-
-            require_once KRONOLITH_BASE . '/lib/version.php';
-            $sig = hash('md5', serialize($css) . max($mtime) . KRONOLITH_VERSION);
-
-            switch ($cache_type) {
-            case 'filesystem':
-                $css_filename = '/' . $sig . '.css';
-                $css_path = $conf['server']['cachecssparams']['file_location'] . $css_filename;
-                $css_url = $conf['server']['cachecssparams']['file_url'] . $css_filename;
-                $exists = file_exists($css_path);
-                break;
-
-            case 'horde_cache':
-                $cache = &Horde_Cache::singleton($GLOBALS['conf']['cache']['driver'], Horde::getDriverConfig('cache', $GLOBALS['conf']['cache']['driver']));
-                $exists = $cache->exists($sig, empty($GLOBALS['conf']['server']['cachecssparams']['lifetime']) ? 0 : $GLOBALS['conf']['server']['cachecssparams']['lifetime']);
-                $css_url = self::getCacheURL('css', $sig);
-                break;
-            }
-
-            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, remove multiple whitespaces, and
-                    // strip comments.
-                    $out .= preg_replace(array('/(url\(["\']?)([^\/])/i', '/\s+/', '/\/\*.*?\*\//'), array('$1' . $path . '$2', ' ', ''), implode('', file($file['f'], $flags)));
-                }
-
-                switch ($cache_type) {
-                case 'filesystem':
-                    register_shutdown_function(array('Kronolith', '_filesystemGC'), 'css');
-                    file_put_contents($css_path, $out);
-                    break;
-
-                case 'horde_cache':
-                    $cache->set($sig, $out);
-                    break;
-                }
-            }
-
-            $css_out = array_merge(array(array('u' => $css_url)), $css_out);
-        }
-
-        foreach ($css_out as $file) {
-            echo '<link href="' . $file['u'] . '" rel="stylesheet" type="text/css"' . (isset($file['m']) ? ' media="' . $file['m'] . '"' : '') . ' />' . "\n";
-        }
-    }
-
-    /**
      * Creates a URL for cached Kronolith data.
      *
      * @param string $type  The cache type.
@@ -430,42 +246,6 @@ class Kronolith
     }
 
     /**
-     * Do garbage collection in the statically served file directory.
-     *
-     * @access private
-     *
-     * @param string $type  Either 'css' or 'js'.
-     */
-    public static function _filesystemGC($type)
-    {
-        static $dir_list = array();
-
-        $ptr = $GLOBALS['conf']['server'][(($type == 'css') ? 'cachecssparams' : 'cachejsparams')];
-        $dir = $ptr['file_location'];
-        if (in_array($dir, $dir_list)) {
-            return;
-        }
-
-        $c_time = time() - $ptr['lifetime'];
-        $d = dir($dir);
-        $dir_list[] = $dir;
-
-        while (($entry = $d->read()) !== false) {
-            $path = $dir . '/' . $entry;
-            if (in_array($entry, array('.', '..'))) {
-                continue;
-            }
-
-            if ($c_time > filemtime($path)) {
-                $old_error = error_reporting(0);
-                unlink($path);
-                error_reporting($old_error);
-            }
-        }
-        $d->close();
-    }
-
-    /**
      * Returns all the alarms active on a specific date.
      *
      * @param Horde_Date $date    The date to check for alarms.
index 93dee4c..d556fb8 100644 (file)
@@ -45,7 +45,7 @@ var kronolithPrintLink = '';
 //]]></script>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('kronolith', empty($print_view) ? '' : 'print') ?>
+<?php Horde::includeStylesheetFiles() ?>
 <?php foreach ($GLOBALS['display_calendars'] as $calendar): ?>
 <link href="<?php echo Kronolith::feedUrl($calendar) ?>" rel="alternate" type="application/atom+xml" />
 <?php endforeach; ?>
index f2402a2..7ae491e 100644 (file)
@@ -28,7 +28,7 @@ if ($prefs->getValue('show_panel')) {
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('nag', empty($print_view) ? '' : 'print') ?>
+<?php Horde::includeStylesheetFiles() ?>
 <link href="<?php echo Horde::applicationUrl('themes/categoryCSS.php') ?>" rel="stylesheet" type="text/css" />
 <script src="<?php echo $GLOBALS['registry']->get('jsuri', 'horde') ?>/glow/1.5.1/core/core.js" type="text/javascript"></script>
 <script src="<?php echo $GLOBALS['registry']->get('jsuri', 'horde') ?>/glow/1.5.1/widgets/widgets.js" type="text/javascript"></script>
index 226d9d7..cf1a547 100644 (file)
@@ -46,7 +46,7 @@ if ($version_data instanceof PEAR_Error) {
 
 $version_data = unserialize($version_data);
 
-echo Horde::stylesheetLink('news');
+Horde::includeStylesheetFiles();
 
 while (list($k, $v) = each($current_data)) {
     echo '<hr><strong>' . $nls['languages'][$k] . '</strong><hr>' . "\n";
index 859b8a6..e09bc8e 100644 (file)
@@ -37,7 +37,7 @@ if ($result instanceof PEAR_Error) {
 
 Horde::addScriptFile('tables.js', 'horde', true);
 Horde::includeScriptFiles();
-echo Horde::stylesheetLink('news');
+Horde::includeStylesheetFiles();
 
 // require_once NEWS_TEMPLATES . '/common-header.inc';
 require_once NEWS_TEMPLATES . '/reads/header.inc';
index 6eb6459..dcb2dd7 100644 (file)
@@ -25,7 +25,7 @@ Horde::includeScriptFiles();
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
 <link rel="alternate" title="<?php echo _("Last news") ?>" href="<?php echo Horde::applicationUrl('rss/news.php', true, -1) ?>" type="application/rss+xml" />
 <link rel="alternate" title="<?php echo _("Last comments") ?>" href="<?php echo Horde::applicationUrl('rss/comments.php', true, -1) ?>" type="application/rss+xml" />
-<?php echo Horde::stylesheetLink('news') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>
index 85c2cb5..5772d5c 100644 (file)
@@ -31,7 +31,7 @@ if ($prefs->getValue('show_panel')) {
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('skoli') ?>
+<?php Horde::includeStylesheetFiles() ?>
 <link href="<?php echo Horde::applicationUrl('themes/categoryCSS.php') ?>" rel="stylesheet" type="text/css" />
 </head>
 
index 234db2b..fcf62d5 100644 (file)
@@ -22,7 +22,7 @@ Horde::includeScriptFiles();
 ?>
 <title><?php echo htmlspecialchars($page_title) ?></title>
 <link href="<?php echo $GLOBALS['registry']->getImageDir()?>/favicon.ico" rel="SHORTCUT ICON" />
-<?php echo Horde::stylesheetLink('turba', empty($GLOBALS['print_view']) ? '' : 'print') ?>
+<?php Horde::includeStylesheetFiles() ?>
 </head>
 
 <body<?php if ($bc = Horde_Util::nonInputVar('bodyClass')) echo ' class="' . $bc . '"' ?><?php if ($bi = Horde_Util::nonInputVar('bodyId')) echo ' id="' . $bi . '"'; ?>>