diff options
author | Romain d'Alverny <rda@mageia.org> | 2012-06-11 12:15:16 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2012-06-11 12:15:16 +0000 |
commit | 0a410429a63f58e9a55ed167b68991ad846414be (patch) | |
tree | 792c180c35610a70cbb26e6a0bca22f14c3d96dd /lib.php | |
parent | c8583d2ce236c7ddd8fddf5e93924d6b7e1a9bf6 (diff) | |
download | nav-0a410429a63f58e9a55ed167b68991ad846414be.tar nav-0a410429a63f58e9a55ed167b68991ad846414be.tar.gz nav-0a410429a63f58e9a55ed167b68991ad846414be.tar.bz2 nav-0a410429a63f58e9a55ed167b68991ad846414be.tar.xz nav-0a410429a63f58e9a55ed167b68991ad846414be.zip |
cache full HTML output when possible
Diffstat (limited to 'lib.php')
-rw-r--r-- | lib.php | 30 |
1 files changed, 20 insertions, 10 deletions
@@ -189,24 +189,31 @@ P; * @param boolean $wrap = false should it be wrapped in a <header id="nav" /> element? * @param string $lang = 'en' * @param string $inject = null - * @param string $vhost = '//www.mageia.org' + * @param string $vhost = 'www.mageia.org' + * @param object $cache * * @return string HTML code */ -function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = '//www.mageia.org') +function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = 'www.mageia.org', $cache = null) { + $key = array($wrap, $lang, $inject, $vhost); + + if (!is_null($cache) && ($h = $cache->get($key))) { + return $h; + } + $lang = _lang_check($lang); - l10n::load($lang); + l10n::load($lang, $cache); $tn = array( - array('mageia', '$S/$L/map/', 'Mageia', l10n::_t('Go to mageia.org site map.')), - array('about', '$S/$L/about/', l10n::_t('About us', $_t), l10n::_t('Learn more about Mageia.')), - array('downloads', '$S/$L/downloads/', l10n::_t('Downloads', $_t), l10n::_t('Download Mageia ISO and updates.')), - array('support', '$S/$L/support/', l10n::_t('Support', $_t), l10n::_t('Get support from Mageia community.')), - array('community', '$S/$L/community/', l10n::_t('Community', $_t), l10n::_t('')), - array('contribute', '$S/$L/contribute/', l10n::_t('Contribute', $_t), l10n::_t('You too can build Mageia with us!')), - array('you', '//identity.mageia.org/', l10n::_t('You', $_t), l10n::_t('Your Mageia online account.')) + array('mageia', '//$S/$L/map/', 'Mageia', l10n::_t('Go to mageia.org site map.')), + array('about', '//$S/$L/about/', l10n::_t('About us'), l10n::_t('Learn more about Mageia.')), + array('downloads', '//$S/$L/downloads/', l10n::_t('Downloads'), l10n::_t('Download Mageia ISO and updates.')), + array('support', '//$S/$L/support/', l10n::_t('Support'), l10n::_t('Get support from Mageia community.')), + array('community', '//$S/$L/community/', l10n::_t('Community'), l10n::_t('')), + array('contribute', '//$S/$L/contribute/', l10n::_t('Contribute'), l10n::_t('You too can build Mageia with us!')), + array('you', '//identity.mageia.org/', l10n::_t('You'), l10n::_t('Your Mageia online account.')) // <search> ); @@ -233,6 +240,9 @@ function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = '//ww if ($wrap) $h = sprintf('<header id="hmgn">%s</header>', $h); + if (!is_null($cache)) + $cache->set($key, $h); + return $h; } |