/** * Output all needed JavaScript * * @author Andreas Gohr <*****@*****.**> */ function js_out() { global $conf; global $lang; global $config_cascade; // The generated script depends on some dynamic options $cache = new cache('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'], '.js'); $cache->_event = 'JS_CACHE_USE'; // load minified version for some files $min = $conf['compress'] ? '.min' : ''; // array of core files $files = array(DOKU_INC . "lib/scripts/jquery/jquery{$min}.js", DOKU_INC . 'lib/scripts/jquery/jquery.cookie.js', DOKU_INC . "lib/scripts/jquery/jquery-ui{$min}.js", DOKU_INC . "lib/scripts/fileuploader.js", DOKU_INC . "lib/scripts/fileuploaderextended.js", DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/tw-sack.js', DOKU_INC . 'lib/scripts/qsearch.js', DOKU_INC . 'lib/scripts/tree.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/drag.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/editor.js', DOKU_INC . 'lib/scripts/locktimer.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/compatibility.js', DOKU_INC . 'lib/scripts/behaviour.js', DOKU_INC . 'lib/scripts/page.js', tpl_incdir() . 'script.js'); // add possible plugin scripts and userscript $files = array_merge($files, js_pluginscripts()); if (isset($config_cascade['userscript']['default'])) { $files[] = $config_cascade['userscript']['default']; } $cache_files = array_merge($files, getConfigFiles('main')); $cache_files[] = __FILE__; // check cache age & handle conditional request // This may exit if a cache can be used $cache_ok = $cache->useCache(array('files' => $cache_files)); http_cached($cache->cache, $cache_ok); // start output buffering and build the script ob_start(); // add some global variables print "var DOKU_BASE = '" . DOKU_BASE . "';"; print "var DOKU_TPL = '" . tpl_basedir() . "';"; // FIXME: Move those to JSINFO print "var DOKU_UHN = " . (int) useHeading('navigation') . ";"; print "var DOKU_UHC = " . (int) useHeading('content') . ";"; // load JS specific translations $json = new JSON(); $lang['js']['plugins'] = js_pluginstrings(); echo 'LANG = ' . $json->encode($lang['js']) . ";\n"; // load toolbar toolbar_JSdefines('toolbar'); // load files foreach ($files as $file) { echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; js_load($file); echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; } // init stuff if ($conf['locktime'] != 0) { js_runonstart("dw_locktimer.init(" . ($conf['locktime'] - 60) . "," . $conf['usedraft'] . ")"); } // init hotkeys - must have been done after init of toolbar # disabled for FS#1958 js_runonstart('initializeHotkeys()'); // end output buffering and get contents $js = ob_get_contents(); ob_end_clean(); // compress whitespace and comments if ($conf['compress']) { $js = js_compress($js); } $js .= "\n"; // https://bugzilla.mozilla.org/show_bug.cgi?id=316033 http_cached_finish($cache->cache, $js); }
/** * Load style ini contents * * Loads and merges style.ini files from template and config and prepares * the stylesheet modes * * @author Andreas Gohr <*****@*****.**> * * @param string $tpl the used template * @param bool $preview load preview replacements * @return array with keys 'stylesheets' and 'replacements' */ function css_styleini($tpl, $preview = false) { global $conf; $stylesheets = array(); // mode, file => base $replacements = array(); // placeholder => value // load template's style.ini $incbase = tpl_incdir($tpl); $webbase = tpl_basedir($tpl); $ini = $incbase . 'style.ini'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // stylesheets if (is_array($data['stylesheets'])) { foreach ($data['stylesheets'] as $file => $mode) { $stylesheets[$mode][$incbase . $file] = $webbase; } } // replacements if (is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } // load configs's style.ini $webbase = DOKU_BASE; $ini = DOKU_CONF . "tpl/{$tpl}/style.ini"; $incbase = dirname($ini) . '/'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // stylesheets if (isset($data['stylesheets']) && is_array($data['stylesheets'])) { foreach ($data['stylesheets'] as $file => $mode) { $stylesheets[$mode][$incbase . $file] = $webbase; } } // replacements if (isset($data['replacements']) && is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } // allow replacement overwrites in preview mode if ($preview) { $webbase = DOKU_BASE; $ini = $conf['cachedir'] . '/preview.ini'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // replacements if (is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } } return array('stylesheets' => $stylesheets, 'replacements' => $replacements); }
/** * Tries to find a ressource file in the given locations. * * If a given location starts with a colon it is assumed to be a media * file, otherwise it is assumed to be relative to the current template * * @param array $search locations to look at * @param bool $abs if to use absolute URL * @param array &$imginfo filled with getimagesize() * @return string * @author Andreas Gohr <*****@*****.**> */ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) { $img = ''; $file = ''; $ismedia = false; // loop through candidates until a match was found: foreach ($search as $img) { if (substr($img, 0, 1) == ':') { $file = mediaFN($img); $ismedia = true; } else { $file = tpl_incdir() . $img; $ismedia = false; } if (file_exists($file)) { break; } } // fetch image data if requested if (!is_null($imginfo)) { $imginfo = getimagesize($file); } // build URL if ($ismedia) { $url = ml($img, '', true, '', $abs); } else { $url = tpl_basedir() . $img; if ($abs) { $url = DOKU_URL . substr($url, strlen(DOKU_REL)); } } return $url; }
?> images/button-php.gif" width="80" height="15" alt="Powered by PHP" /></a> <a href="http://validator.w3.org/check/referer" title="Valid HTML5" <?php echo $target; ?> ><img src="<?php echo tpl_basedir(); ?> images/button-html5.png" width="80" height="15" alt="Valid HTML5" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS" <?php echo $target; ?> ><img src="<?php echo tpl_basedir(); ?> images/button-css.png" width="80" height="15" alt="Valid CSS" /></a> <a href="http://dokuwiki.org/" title="Driven by DokuWiki" <?php echo $target; ?> ><img src="<?php echo tpl_basedir(); ?> images/button-dw.png" width="80" height="15" alt="Driven by DokuWiki" /></a> </div> </div></div><!-- /footer --> <?php tpl_includeFile('footer.html');
/** * Output all needed JavaScript * * @author Andreas Gohr <*****@*****.**> */ function js_out() { global $conf; global $lang; global $config_cascade; global $INPUT; // decide from where to get the template $tpl = trim(preg_replace('/[^\\w-]+/', '', $INPUT->str('t'))); if (!$tpl) { $tpl = $conf['template']; } // The generated script depends on some dynamic options $cache = new cache('scripts' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'] . DOKU_BASE . $tpl, '.js'); $cache->_event = 'JS_CACHE_USE'; // load minified version for some files $min = $conf['compress'] ? '.min' : ''; // array of core files $files = array(DOKU_INC . "lib/scripts/jquery/jquery{$min}.js", DOKU_INC . 'lib/scripts/jquery/jquery.cookie.js', DOKU_INC . "lib/scripts/jquery/jquery-ui{$min}.js", DOKU_INC . "lib/scripts/jquery/jquery-migrate{$min}.js", DOKU_INC . 'inc/lang/' . $conf['lang'] . '/jquery.ui.datepicker.js', DOKU_INC . "lib/scripts/fileuploader.js", DOKU_INC . "lib/scripts/fileuploaderextended.js", DOKU_INC . 'lib/scripts/helpers.js', DOKU_INC . 'lib/scripts/delay.js', DOKU_INC . 'lib/scripts/cookie.js', DOKU_INC . 'lib/scripts/script.js', DOKU_INC . 'lib/scripts/qsearch.js', DOKU_INC . 'lib/scripts/tree.js', DOKU_INC . 'lib/scripts/index.js', DOKU_INC . 'lib/scripts/textselection.js', DOKU_INC . 'lib/scripts/toolbar.js', DOKU_INC . 'lib/scripts/edit.js', DOKU_INC . 'lib/scripts/editor.js', DOKU_INC . 'lib/scripts/locktimer.js', DOKU_INC . 'lib/scripts/linkwiz.js', DOKU_INC . 'lib/scripts/media.js', DOKU_INC . 'lib/scripts/compatibility.js', DOKU_INC . 'lib/scripts/behaviour.js', DOKU_INC . 'lib/scripts/page.js', tpl_incdir($tpl) . 'script.js'); // add possible plugin scripts and userscript $files = array_merge($files, js_pluginscripts()); if (!empty($config_cascade['userscript']['default'])) { foreach ($config_cascade['userscript']['default'] as $userscript) { $files[] = $userscript; } } $cache_files = array_merge($files, getConfigFiles('main')); $cache_files[] = __FILE__; // check cache age & handle conditional request // This may exit if a cache can be used $cache_ok = $cache->useCache(array('files' => $cache_files)); http_cached($cache->cache, $cache_ok); // start output buffering and build the script ob_start(); $json = new JSON(); // add some global variables print "var DOKU_BASE = '" . DOKU_BASE . "';"; print "var DOKU_TPL = '" . tpl_basedir($tpl) . "';"; print "var DOKU_COOKIE_PARAM = " . $json->encode(array('path' => empty($conf['cookiedir']) ? DOKU_REL : $conf['cookiedir'], 'secure' => $conf['securecookie'] && is_ssl())) . ";"; // FIXME: Move those to JSINFO print "var DOKU_UHN = " . (int) useHeading('navigation') . ";"; print "var DOKU_UHC = " . (int) useHeading('content') . ";"; // load JS specific translations $lang['js']['plugins'] = js_pluginstrings(); $templatestrings = js_templatestrings($tpl); if (!empty($templatestrings)) { $lang['js']['template'] = $templatestrings; } echo 'LANG = ' . $json->encode($lang['js']) . ";\n"; // load toolbar toolbar_JSdefines('toolbar'); // load files foreach ($files as $file) { if (!file_exists($file)) { continue; } $ismin = substr($file, -7) == '.min.js'; $debugjs = $conf['allowdebug'] && strpos($file, DOKU_INC . 'lib/scripts/') !== 0; echo "\n\n/* XXXXXXXXXX begin of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; if ($ismin) { echo "\n/* BEGIN NOCOMPRESS */\n"; } if ($debugjs) { echo "\ntry {\n"; } js_load($file); if ($debugjs) { echo "\n} catch (e) {\n logError(e, '" . str_replace(DOKU_INC, '', $file) . "');\n}\n"; } if ($ismin) { echo "\n/* END NOCOMPRESS */\n"; } echo "\n\n/* XXXXXXXXXX end of " . str_replace(DOKU_INC, '', $file) . " XXXXXXXXXX */\n\n"; } // init stuff if ($conf['locktime'] != 0) { js_runonstart("dw_locktimer.init(" . ($conf['locktime'] - 60) . "," . $conf['usedraft'] . ")"); } // init hotkeys - must have been done after init of toolbar # disabled for FS#1958 js_runonstart('initializeHotkeys()'); // end output buffering and get contents $js = ob_get_contents(); ob_end_clean(); // strip any source maps stripsourcemaps($js); // compress whitespace and comments if ($conf['compress']) { $js = js_compress($js); } $js .= "\n"; // https://bugzilla.mozilla.org/show_bug.cgi?id=316033 http_cached_finish($cache->cache, $js); }
/** * Load the template assets (Bootstrap, AnchorJS, etc) * * @author Giuseppe Di Terlizzi <*****@*****.**> * * @param Doku_Event $event * @param array $param */ function bootstrap3_metaheaders(Doku_Event &$event, $param) { global $INPUT; global $ACT; // Bootstrap Theme $bootstrap_styles = array(); $bootstrap_theme = bootstrap3_conf('bootstrapTheme'); $fixed_top_navbar = bootstrap3_conf('fixedTopNavbar'); switch ($bootstrap_theme) { case 'optional': $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap.min.css'; $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap-theme.min.css'; break; case 'custom': $bootstrap_styles[] = bootstrap3_conf('customTheme'); break; case 'bootswatch': $bootswatch_theme = bootstrap3_bootswatch_theme(); $bootswatch_url = bootstrap3_conf('useLocalBootswatch') ? tpl_basedir() . 'assets/bootstrap' : '//maxcdn.bootstrapcdn.com/bootswatch/3.3.6'; $bootstrap_styles[] = "{$bootswatch_url}/{$bootswatch_theme}/bootstrap.min.css"; break; case 'default': default: $bootstrap_styles[] = tpl_basedir() . 'assets/bootstrap/default/bootstrap.min.css'; break; } foreach ($bootstrap_styles as $style) { array_unshift($event->data['link'], array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => $style)); } $event->data['link'][] = array('type' => 'text/css', 'rel' => 'stylesheet', 'href' => tpl_basedir() . 'assets/font-awesome/css/font-awesome.min.css'); $event->data['script'][] = array('type' => 'text/javascript', 'src' => tpl_basedir() . 'assets/bootstrap/js/bootstrap.min.js'); $event->data['script'][] = array('type' => 'text/javascript', 'src' => tpl_basedir() . 'assets/anchorjs/anchor.min.js'); // Apply some FIX if ($ACT || defined('DOKU_MEDIADETAIL')) { // Default Padding $navbar_padding = 20; if ($fixed_top_navbar) { if ($bootstrap_theme == 'bootswatch') { // Set the navbar height for all Bootswatch Themes (values from @navbar-height in bootswatch/*/variables.less) switch (bootstrap3_bootswatch_theme()) { case 'simplex': case 'superhero': $navbar_height = 40; break; case 'yeti': $navbar_height = 45; break; case 'cerulean': case 'cosmo': case 'custom': case 'cyborg': case 'lumen': case 'slate': case 'spacelab': case 'united': $navbar_height = 50; break; case 'darkly': case 'flatly': case 'journal': case 'sandstone': $navbar_height = 60; break; case 'paper': $navbar_height = 64; break; case 'readable': $navbar_height = 65; break; default: $navbar_height = 50; } } else { $navbar_height = 50; } $navbar_padding += $navbar_height; } $style = ''; $style .= '@media screen {'; $style .= " body { padding-top: {$navbar_padding}px; }"; $style .= ' #dokuwiki__toc.affix { top: ' . ($navbar_padding - 10) . 'px; position: fixed !important; }'; if (bootstrap3_conf('tocCollapseSubSections')) { $style .= ' #dokuwiki__toc .nav .nav .nav { display: none; }'; } $style .= '}'; $event->data['style'][] = array('type' => 'text/css', '_data' => $style); $js = ''; $js .= "jQuery('body').scrollspy({ target: '#dokuwiki__toc', offset: " . ($navbar_padding + 10) . " });"; if (bootstrap3_conf('tocAffix')) { $js .= 'jQuery("#dokuwiki__toc").affix({ offset: { top: (jQuery("main").position().top), bottom: (jQuery(document).height() - jQuery("main").height()) } });'; } if ($fixed_top_navbar) { $js .= "if (location.hash) { setTimeout(function() { scrollBy(0, -{$navbar_padding}); }, 1); }"; } if (bootstrap3_conf('useAnchorJS')) { $js .= "jQuery(document).trigger('bootstrap3:anchorjs');"; } $event->data['script'][] = array('type' => 'text/javascript', '_data' => "jQuery(document).ready(function() { {$js} });"); } }
/** * Load style ini contents * * Loads and merges style.ini files from template and config and prepares * the stylesheet modes * * @author Andreas Gohr <*****@*****.**> * @param string $tpl the used template * @return array with keys 'stylesheets' and 'replacements' */ function css_styleini($tpl) { $stylesheets = array(); // mode, file => base $replacements = array(); // placeholder => value // load template's style.ini $incbase = tpl_incdir($tpl); $webbase = tpl_basedir($tpl); $ini = $incbase . 'style.ini'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // stylesheets if (is_array($data['stylesheets'])) { foreach ($data['stylesheets'] as $file => $mode) { $stylesheets[$mode][$incbase . $file] = $webbase; } } // replacements if (is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } // load template's style.local.ini // @deprecated 2013-08-03 $ini = $incbase . 'style.local.ini'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // stylesheets if (is_array($data['stylesheets'])) { foreach ($data['stylesheets'] as $file => $mode) { $stylesheets[$mode][$incbase . $file] = $webbase; } } // replacements if (is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } // load configs's style.ini $webbase = DOKU_BASE; $ini = DOKU_CONF . "tpl/{$tpl}/style.ini"; $incbase = dirname($ini) . '/'; if (file_exists($ini)) { $data = parse_ini_file($ini, true); // stylesheets if (is_array($data['stylesheets'])) { foreach ($data['stylesheets'] as $file => $mode) { $stylesheets[$mode][$incbase . $file] = $webbase; } } // replacements if (is_array($data['replacements'])) { $replacements = array_merge($replacements, css_fixreplacementurls($data['replacements'], $webbase)); } } return array('stylesheets' => $stylesheets, 'replacements' => $replacements); }
?> > <img src="<?php echo dirname(tpl_basedir()); ?> /dokuwiki/images/button-html5.png" width="80" height="15" alt="Valid HTML5" /> </a> <a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3" title="Valid CSS" <?php echo $target; ?> > <img src="<?php echo dirname(tpl_basedir()); ?> /dokuwiki/images/button-css.png" width="80" height="15" alt="Valid CSS" /> </a> <a href="http://dokuwiki.org/" title="Driven by DokuWiki" <?php echo $target; ?> > <img src="<?php echo dirname(tpl_basedir()); ?> /dokuwiki/images/button-dw.png" width="80" height="15" alt="Driven by DokuWiki" /> </a> </p> </div> <?php } ?>
/** * Output all needed Styles * * @author Andreas Gohr <*****@*****.**> */ function css_out() { global $conf; global $lang; global $config_cascade; global $INPUT; if ($INPUT->str('s') == 'feed') { $mediatypes = array('feed'); $type = 'feed'; } else { $mediatypes = array('screen', 'all', 'print'); $type = ''; } $tpl = trim(preg_replace('/[^\\w-]+/', '', $INPUT->str('t'))); if ($tpl) { $tplinc = DOKU_INC . 'lib/tpl/' . $tpl . '/'; $tpldir = DOKU_BASE . 'lib/tpl/' . $tpl . '/'; } else { $tplinc = tpl_incdir(); $tpldir = tpl_basedir(); } // used style.ini file $styleini = css_styleini($tplinc); // The generated script depends on some dynamic options $cache = new cache('styles' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'] . DOKU_BASE . $tplinc . $type, '.css'); // load template styles $tplstyles = array(); if ($styleini) { foreach ($styleini['stylesheets'] as $file => $mode) { $tplstyles[$mode][$tplinc . $file] = $tpldir; } } // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility if (isset($config_cascade['userstyle']['default'])) { $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; } // Array of needed files and their web locations, the latter ones // are needed to fix relative paths in the stylesheets $files = array(); $cache_files = getConfigFiles('main'); $cache_files[] = $tplinc . 'style.ini'; $cache_files[] = $tplinc . 'style.local.ini'; $cache_files[] = __FILE__; foreach ($mediatypes as $mediatype) { $files[$mediatype] = array(); // load core styles $files[$mediatype][DOKU_INC . 'lib/styles/' . $mediatype . '.css'] = DOKU_BASE . 'lib/styles/'; // load jQuery-UI theme if ($mediatype == 'screen') { $files[$mediatype][DOKU_INC . 'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE . 'lib/scripts/jquery/jquery-ui-theme/'; } // load plugin styles $files[$mediatype] = array_merge($files[$mediatype], css_pluginstyles($mediatype)); // load template styles if (isset($tplstyles[$mediatype])) { $files[$mediatype] = array_merge($files[$mediatype], $tplstyles[$mediatype]); } // load user styles if (isset($config_cascade['userstyle'][$mediatype])) { $files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE; } // load rtl styles // note: this adds the rtl styles only to the 'screen' media type // @deprecated 2012-04-09: rtl will cease to be a mode of its own, // please use "[dir=rtl]" in any css file in all, screen or print mode instead if ($mediatype == 'screen') { if ($lang['direction'] == 'rtl') { if (isset($tplstyles['rtl'])) { $files[$mediatype] = array_merge($files[$mediatype], $tplstyles['rtl']); } if (isset($config_cascade['userstyle']['rtl'])) { $files[$mediatype][$config_cascade['userstyle']['rtl']] = DOKU_BASE; } } } $cache_files = array_merge($cache_files, array_keys($files[$mediatype])); } // check cache age & handle conditional request // This may exit if a cache can be used http_cached($cache->cache, $cache->useCache(array('files' => $cache_files))); // start output buffering ob_start(); // build the stylesheet foreach ($mediatypes as $mediatype) { // print the default classes for interwiki links and file downloads if ($mediatype == 'screen') { print '@media screen {'; css_interwiki(); css_filetypes(); print '}'; } // load files $css_content = ''; foreach ($files[$mediatype] as $file => $location) { $css_content .= css_loadfile($file, $location); } switch ($mediatype) { case 'screen': print NL . '@media screen { /* START screen styles */' . NL . $css_content . NL . '} /* /@media END screen styles */' . NL; break; case 'print': print NL . '@media print { /* START print styles */' . NL . $css_content . NL . '} /* /@media END print styles */' . NL; break; case 'all': case 'feed': default: print NL . '/* START rest styles */ ' . NL . $css_content . NL . '/* END rest styles */' . NL; break; } } // end output buffering and get contents $css = ob_get_contents(); ob_end_clean(); // apply style replacements $css = css_applystyle($css, $tplinc); // place all @import statements at the top of the file $css = css_moveimports($css); // compress whitespace and comments if ($conf['compress']) { $css = css_compress($css); } // embed small images right into the stylesheet if ($conf['cssdatauri']) { $base = preg_quote(DOKU_BASE, '#'); $css = preg_replace_callback('#(url\\([ \'"]*)(' . $base . ')(.*?(?:\\.(png|gif)))#i', 'css_datauri', $css); } http_cached_finish($cache->cache, $css); }
/** * Output all needed Styles * * @author Andreas Gohr <*****@*****.**> */ function css_out() { global $conf; global $lang; global $config_cascade; $mediatype = 'screen'; if (isset($_REQUEST['s']) && in_array($_REQUEST['s'], array('all', 'print', 'feed'))) { $mediatype = $_REQUEST['s']; } $tpl = trim(preg_replace('/[^\\w-]+/', '', $_REQUEST['t'])); if ($tpl) { $tplinc = DOKU_INC . 'lib/tpl/' . $tpl . '/'; $tpldir = DOKU_BASE . 'lib/tpl/' . $tpl . '/'; } else { $tplinc = tpl_incdir(); $tpldir = tpl_basedir(); } // The generated script depends on some dynamic options $cache = new cache('styles' . $_SERVER['HTTP_HOST'] . $_SERVER['SERVER_PORT'] . DOKU_BASE . $tplinc . $mediatype, '.css'); // load template styles $tplstyles = array(); if (@file_exists($tplinc . 'style.ini')) { $ini = parse_ini_file($tplinc . 'style.ini', true); foreach ($ini['stylesheets'] as $file => $mode) { $tplstyles[$mode][$tplinc . $file] = $tpldir; } } // Array of needed files and their web locations, the latter ones // are needed to fix relative paths in the stylesheets $files = array(); // load core styles $files[DOKU_INC . 'lib/styles/' . $mediatype . '.css'] = DOKU_BASE . 'lib/styles/'; // load jQuery-UI theme $files[DOKU_INC . 'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE . 'lib/scripts/jquery/jquery-ui-theme/'; // load plugin styles $files = array_merge($files, css_pluginstyles($mediatype)); // load template styles if (isset($tplstyles[$mediatype])) { $files = array_merge($files, $tplstyles[$mediatype]); } // if old 'default' userstyle setting exists, make it 'screen' userstyle for backwards compatibility if (isset($config_cascade['userstyle']['default'])) { $config_cascade['userstyle']['screen'] = $config_cascade['userstyle']['default']; } // load user styles if (isset($config_cascade['userstyle'][$mediatype])) { $files[$config_cascade['userstyle'][$mediatype]] = DOKU_BASE; } // load rtl styles // @todo: this currently adds the rtl styles only to the 'screen' media type // but 'print' and 'all' should also be supported if ($mediatype == 'screen') { if ($lang['direction'] == 'rtl') { if (isset($tplstyles['rtl'])) { $files = array_merge($files, $tplstyles['rtl']); } } } $cache_files = array_merge(array_keys($files), getConfigFiles('main')); $cache_files[] = $tplinc . 'style.ini'; $cache_files[] = __FILE__; // check cache age & handle conditional request // This may exit if a cache can be used http_cached($cache->cache, $cache->useCache(array('files' => $cache_files))); // start output buffering and build the stylesheet ob_start(); // print the default classes for interwiki links and file downloads css_interwiki(); css_filetypes(); // load files foreach ($files as $file => $location) { print css_loadfile($file, $location); } // end output buffering and get contents $css = ob_get_contents(); ob_end_clean(); // apply style replacements $css = css_applystyle($css, $tplinc); // place all @import statements at the top of the file $css = css_moveimports($css); // compress whitespace and comments if ($conf['compress']) { $css = css_compress($css); } // embed small images right into the stylesheet if ($conf['cssdatauri']) { $base = preg_quote(DOKU_BASE, '#'); $css = preg_replace_callback('#(url\\([ \'"]*)(' . $base . ')(.*?(?:\\.(png|gif)))#i', 'css_datauri', $css); } http_cached_finish($cache->cache, $css); }