/** * 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); }
/** * PHP include a file * * either from the conf directory if it exists, otherwise use * file in the template's root directory. * * The function honours config cascade settings and looks for the given * file next to the ´main´ config files, in the order protected, local, * default. * * Note: no escaping or sanity checking is done here. Never pass user input * to this function! * * @author Anika Henke <*****@*****.**> * @author Andreas Gohr <*****@*****.**> */ function tpl_includeFile($file) { global $config_cascade; foreach (array('protected', 'local', 'default') as $config_group) { if (empty($config_cascade['main'][$config_group])) { continue; } foreach ($config_cascade['main'][$config_group] as $conf_file) { $dir = dirname($conf_file); if (file_exists("{$dir}/{$file}")) { include "{$dir}/{$file}"; return; } } } // still here? try the template dir $file = tpl_incdir() . $file; if (file_exists($file)) { include $file; } }
/** * Return an two-dimensional array with strings from the language file of current active template. * * - $lang['js'] must be an array. * - Nothing is returned for template without an entry for $lang['js'] */ function js_templatestrings() { global $conf; $templatestrings = array(); if (@file_exists(tpl_incdir() . "lang/en/lang.php")) { include tpl_incdir() . "lang/en/lang.php"; } if (isset($conf['lang']) && $conf['lang'] != 'en' && @file_exists(tpl_incdir() . "lang/" . $conf['lang'] . "/lang.php")) { include tpl_incdir() . "lang/" . $conf['lang'] . "/lang.php"; } if (isset($lang['js'])) { $templatestrings[$conf['template']] = $lang['js']; } return $templatestrings; }
/** * Load default settings for plugins and templates * * @param string $tpl name of active template * @return array default settings */ function get_plugintpl_default($tpl) { $file = '/conf/default.php'; $default = array(); foreach ($this->get_plugin_list() as $plugin) { $plugin_dir = plugin_directory($plugin); if (file_exists(DOKU_PLUGIN . $plugin_dir . $file)) { $conf = $this->_read_config(DOKU_PLUGIN . $plugin_dir . $file); foreach ($conf as $key => $value) { $default['plugin' . CM_KEYMARKER . $plugin . CM_KEYMARKER . $key] = $value; } } } // the same for the active template if (file_exists(tpl_incdir() . $file)) { $conf = $this->_read_config(tpl_incdir() . $file); foreach ($conf as $key => $value) { $default['tpl' . CM_KEYMARKER . $tpl . CM_KEYMARKER . $key] = $value; } } return $default; }
/** * Returns all git repositories in this DokuWiki install * * Looks in root, template and plugin directories only. * * @return array */ private function findRepos() { $this->msg_info('Looking for .git directories'); $data = array_merge(glob(DOKU_INC . '.git', GLOB_ONLYDIR), glob(DOKU_PLUGIN . '*/.git', GLOB_ONLYDIR), glob(fullpath(tpl_incdir() . '../') . '/*/.git', GLOB_ONLYDIR)); if (!$data) { $this->msg_error('Found no .git directories'); } else { $this->msg_success('Found ' . count($data) . ' .git directories'); } $data = array_map('fullpath', array_map('dirname', $data)); return $data; }
/** * Get the template configuration metadata * * @author Giuseppe Di Terlizzi <*****@*****.**> * * @param string $key * @return array */ function bootstrap3_conf_metadata($key = null) { $meta = array(); $file = tpl_incdir() . 'conf/metadata.php'; include $file; if ($key) { return $meta[$key]; } return $meta; }
/** * INITALIZE TEMPLATE * * Load usefull plugins' helpers. */ function _mixture_init() { global $ID, $conf, $JSINFO; // New global variables global $styleIni, $glyphs, $uhp, $trs; // Parse style.ini file (has to be here rather than in _mixture_init() to be abble to use it's data for fonts declarations) $styleIni = array(); // Look for a customized 'style.ini' generated by Styling plugin if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) { $styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true); } // Or for template's default 'style.ini' if (count($styleIni) == 0) { $styleIni = parse_ini_file("style.ini", true); } // Parse glyphs.conf files $glyphs = array(); // Get template's default glyphs if (is_file(tpl_incdir() . "conf/glyphs.php")) { include tpl_incdir() . "conf/glyphs.php"; } // Get custom glyphs if (is_file(DOKU_CONF . "tpl/mixture/glyphs.php")) { include DOKU_CONF . "tpl/mixture/glyphs.php"; } //dbg($glyphs); // Look for a customized 'style.ini' generated by Styling plugin if (is_file(DOKU_CONF . "tpl/mixture/style.ini")) { $styleIni = parse_ini_file(DOKU_CONF . "tpl/mixture/style.ini", true); } // Store options into $JSINFO for later use $JSINFO['ScrollDelay'] = tpl_getConf('scrollDelay'); // if ((strpos(tpl_getConf('elements'), 'header_landing_changes') !== false) or (strpos(tpl_getConf('elements'), 'header_topbar_date') !== false)) { // $JSINFO['LoadMoment'] = true; // } else { // $JSINFO['LoadMoment'] = false; // } if (strpos(tpl_getConf('elements'), 'header_landing_changes') !== false or strpos(tpl_getConf('elements'), 'header_topbar_lastchanges') !== false) { $JSINFO['LoadNewsTicker'] = true; } else { $JSINFO['LoadNewsTicker'] = false; } // Preparing usefull plugins' helpers $interwiki = getInterwiki(); $mixturePublicId = ltrim(str_replace('{NAME}', $_SERVER['REMOTE_USER'], $interwiki['user']), ':'); if (!plugin_isdisabled('userhomepage')) { $uhpHelper = plugin_load('helper', 'userhomepage'); $uhp = $uhpHelper->getElements(); if (isset($mixturePublicId) and !isset($uhp['public'])) { $uhp['public'] = array(); $uhp['public']['id'] = $mixturePublicId; } } else { // Without Userhomepage plugin, Public Page namespace is set by 'user' value in 'conf/interwiki.conf' $uhp = array(); $uhp['private'] = null; $uhp['public'] = array(); $uhp['public']['id'] = $mixturePublicId; } if (!plugin_isdisabled('translation')) { $trs = array(); $translationHelper = plugin_load('helper', 'translation'); $trs['parts'] = $translationHelper->getTransParts($ID); } else { $trs['parts'] = null; } // Adding test alerts if debug is enabled if ($_GET['debug'] == true) { msg("This is an error alert (-1)", -1); msg("This is an info message (0)", 0); msg("This is a success message (1)", 1); msg("This is a notification (2)", 2); } }
function _setup_localised_plugin_prompts() { global $conf; $langfile = '/lang/' . $conf['lang'] . '/settings.php'; $enlangfile = '/lang/en/settings.php'; if ($dh = opendir(DOKU_PLUGIN)) { while (false !== ($plugin = readdir($dh))) { if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp' || $plugin == 'config') { continue; } if (is_file(DOKU_PLUGIN . $plugin)) { continue; } if (@file_exists(DOKU_PLUGIN . $plugin . $enlangfile)) { $lang = array(); @(include DOKU_PLUGIN . $plugin . $enlangfile); if ($conf['lang'] != 'en') { @(include DOKU_PLUGIN . $plugin . $langfile); } foreach ($lang as $key => $value) { $this->lang['plugin' . CM_KEYMARKER . $plugin . CM_KEYMARKER . $key] = $value; } } // fill in the plugin name if missing (should exist for plugins with settings) if (!isset($this->lang['plugin' . CM_KEYMARKER . $plugin . CM_KEYMARKER . 'plugin_settings_name'])) { $this->lang['plugin' . CM_KEYMARKER . $plugin . CM_KEYMARKER . 'plugin_settings_name'] = ucwords(str_replace('_', ' ', $plugin)); } } closedir($dh); } // the same for the active template $tpl = $conf['template']; if (@file_exists(tpl_incdir() . $enlangfile)) { $lang = array(); @(include tpl_incdir() . $enlangfile); if ($conf['lang'] != 'en') { @(include tpl_incdir() . $langfile); } foreach ($lang as $key => $value) { $this->lang['tpl' . CM_KEYMARKER . $tpl . CM_KEYMARKER . $key] = $value; } } // fill in the template name if missing (should exist for templates with settings) if (!isset($this->lang['tpl' . CM_KEYMARKER . $tpl . CM_KEYMARKER . 'template_settings_name'])) { $this->lang['tpl' . CM_KEYMARKER . $tpl . CM_KEYMARKER . 'template_settings_name'] = ucwords(str_replace('_', ' ', $tpl)); } return true; }
if (!defined('DOKU_INC')) { define('DOKU_INC', dirname(__FILE__) . '/../../'); } if (!defined('NOSESSION')) { define('NOSESSION', true); } // we do not use a session or authentication here (better caching) if (!defined('NL')) { define('NL', "\n"); } require_once DOKU_INC . 'inc/init.php'; // try to be clever about the favicon location if (file_exists(DOKU_INC . 'favicon.ico')) { $ico = DOKU_URL . 'favicon.ico'; } elseif (file_exists(tpl_incdir() . 'images/favicon.ico')) { $ico = DOKU_URL . 'lib/tpl/' . $conf['template'] . '/images/favicon.ico'; } elseif (file_exists(tpl_incdir() . 'favicon.ico')) { $ico = DOKU_URL . 'lib/tpl/' . $conf['template'] . '/favicon.ico'; } else { $ico = DOKU_URL . 'lib/tpl/dokuwiki/images/favicon.ico'; } // output header('Content-Type: application/opensearchdescription+xml; charset=utf-8'); echo '<?xml version="1.0"?>' . NL; echo '<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">' . NL; echo ' <ShortName>' . htmlspecialchars($conf['title']) . '</ShortName>' . NL; echo ' <Image width="16" height="16" type="image/x-icon">' . $ico . '</Image>' . NL; echo ' <Url type="text/html" template="' . DOKU_URL . DOKU_SCRIPT . '?do=search&id={searchTerms}" />' . NL; echo ' <Url type="application/x-suggestions+json" template="' . DOKU_URL . 'lib/exe/ajax.php?call=suggestions&q={searchTerms}" />' . NL; echo '</OpenSearchDescription>' . NL; //Setup VIM: ex: et ts=4 :
/** * 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); }
/** * 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 arrayref $imginfo filled with getimagesize() * @author Andreas Gohr <*****@*****.**> */ function tpl_getMediaFile($search, $abs = false, &$imginfo = null) { // 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; }
/** * Return an two-dimensional array with strings from the language file of current active template. * * - $lang['js'] must be an array. * - Nothing is returned for template without an entry for $lang['js'] * * @param string $tpl * @return array */ function js_templatestrings($tpl) { global $conf, $config_cascade; $path = tpl_incdir() . 'lang/'; $templatestrings = array(); if (file_exists($path . "en/lang.php")) { include $path . "en/lang.php"; } foreach ($config_cascade['lang']['template'] as $config_file) { if (file_exists($config_file . $conf['template'] . '/en/lang.php')) { include $config_file . $conf['template'] . '/en/lang.php'; } } if (isset($conf['lang']) && $conf['lang'] != 'en' && file_exists($path . $conf['lang'] . "/lang.php")) { include $path . $conf['lang'] . "/lang.php"; } if (isset($conf['lang']) && $conf['lang'] != 'en') { if (file_exists($path . $conf['lang'] . "/lang.php")) { include $path . $conf['lang'] . "/lang.php"; } foreach ($config_cascade['lang']['template'] as $config_file) { if (file_exists($config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php')) { include $config_file . $conf['template'] . '/' . $conf['lang'] . '/lang.php'; } } } if (isset($lang['js'])) { $templatestrings[$tpl] = $lang['js']; } return $templatestrings; }
/** * 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); }
tr:hover td { border: 1px solid #ccc; } .color { padding: 0.25em 1em; border: 1px #000 solid; } </style> </head> <body> <?php // get merged style.ini define('SIMPLE_TEST', true); // hack to prevent css output and headers require_once DOKU_INC . 'lib/exe/css.php'; $ini = css_styleini(tpl_incdir()); if ($ini) { echo '<table>'; echo "<caption>" . htmlspecialchars($conf['template']) . "'s style.ini</caption>"; foreach ($ini['replacements'] as $key => $val) { echo '<tr>'; echo '<td>' . htmlspecialchars($key) . '</td>'; echo '<td>' . htmlspecialchars($val) . '</td>'; echo '<td>'; if (preg_match('/^#[0-f]{3,6}$/i', $val)) { echo '<div class="color" style="background-color:' . $val . ';"> </div>'; } echo '</td>'; echo '</tr>'; } echo '</table>';