summaryrefslogtreecommitdiff
path: root/lib/exe/css.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-10-13 13:19:18 +0200
committerAndreas Gohr <andi@splitbrain.org>2012-10-13 13:19:18 +0200
commit51ac8ceac09c3fd35b5bf0a1ae8665c792cc7419 (patch)
tree3bd542088f8732f3e37d33c7795dd949f9295594 /lib/exe/css.php
parent955290461b4caad351e55a5d037492acc9318cd3 (diff)
parent41c22da8bcdc9a844d7605440fa4c5ba19b97471 (diff)
downloadrpg-51ac8ceac09c3fd35b5bf0a1ae8665c792cc7419.tar.gz
rpg-51ac8ceac09c3fd35b5bf0a1ae8665c792cc7419.tar.bz2
Merge branch 'master' into stable
* master: (54 commits) release preparations RTL and IE7 fixes for code blocks beautified code blocks, also using lighter background colour (FS#2444) improved section highlighting styles removed unnecessary print styles fixed interwiki and filetype styles being included in all css modes moved some styles around improved tab styles fixed typo in style.ini Brazilia Portuguese language update #2541, alter section highlighting to insert a container into the DOM to hold the elements being highlighted & later remove it fixed lib/tpl/index.php to reflect recent changes changed local style.ini to be merged with standard one removed template dependencies from underscored CSS files in new default template fixed 2-digit ordered list items in sidebar (FS#2624) improved grammar in preview text (FS#2614) improvements to h1 in sidebar (follow font size scale + vertical grid) adjusted h1 size in sidebar fixed warning in popularity plugin FS#2628 added support for local style.ini files ...
Diffstat (limited to 'lib/exe/css.php')
-rw-r--r--lib/exe/css.php96
1 files changed, 66 insertions, 30 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 8de3db11b..1e662c64a 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -49,44 +49,51 @@ function css_out(){
$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(@file_exists($tplinc.'style.ini')){
- $ini = parse_ini_file($tplinc.'style.ini',true);
- foreach($ini['stylesheets'] as $file => $mode){
+ if ($styleini) {
+ foreach($styleini['stylesheets'] as $file => $mode) {
$tplstyles[$mode][$tplinc.$file] = $tpldir;
}
}
- // start output buffering
- ob_start();
+ // 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) {
- // Array of needed files and their web locations, the latter ones
- // are needed to fix relative paths in the stylesheets
- $files = array();
+ $files[$mediatype] = array();
// load core styles
- $files[DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/';
+ $files[$mediatype][DOKU_INC.'lib/styles/'.$mediatype.'.css'] = DOKU_BASE.'lib/styles/';
// load jQuery-UI theme
if ($mediatype == 'screen') {
- $files[DOKU_INC.'lib/scripts/jquery/jquery-ui-theme/smoothness.css'] = DOKU_BASE.'lib/scripts/jquery/jquery-ui-theme/';
+ $files[$mediatype][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));
+ $files[$mediatype] = array_merge($files[$mediatype], 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'];
+ $files[$mediatype] = array_merge($files[$mediatype], $tplstyles[$mediatype]);
}
// load user styles
if(isset($config_cascade['userstyle'][$mediatype])){
- $files[$config_cascade['userstyle'][$mediatype]] = DOKU_BASE;
+ $files[$mediatype][$config_cascade['userstyle'][$mediatype]] = DOKU_BASE;
}
// load rtl styles
// note: this adds the rtl styles only to the 'screen' media type
@@ -94,30 +101,36 @@ function css_out(){
// 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 = array_merge($files, $tplstyles['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(array_keys($files), getConfigFiles('main'));
- $cache_files[] = $tplinc.'style.ini';
- $cache_files[] = __FILE__;
+ $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)));
- // 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
+ // 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 as $file => $location){
+ foreach($files[$mediatype] as $file => $location){
$css_content .= css_loadfile($file, $location);
}
switch ($mediatype) {
@@ -165,14 +178,37 @@ function css_out(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_applystyle($css,$tplinc){
- if(@file_exists($tplinc.'style.ini')){
- $ini = parse_ini_file($tplinc.'style.ini',true);
- $css = strtr($css,$ini['replacements']);
+ $styleini = css_styleini($tplinc);
+
+ if($styleini){
+ $css = strtr($css,$styleini['replacements']);
}
return $css;
}
/**
+ * Get contents of merged style.ini and style.local.ini as an array.
+ *
+ * @author Anika Henke <anika@selfthinker.org>
+ */
+function css_styleini($tplinc) {
+ $styleini = array();
+
+ foreach (array($tplinc.'style.ini', $tplinc.'style.local.ini') as $ini) {
+ $tmp = (@file_exists($ini)) ? parse_ini_file($ini, true) : array();
+
+ foreach($tmp as $key => $value) {
+ if(array_key_exists($key, $styleini) && is_array($value)) {
+ $styleini[$key] = array_merge($styleini[$key], $tmp[$key]);
+ } else {
+ $styleini[$key] = $value;
+ }
+ }
+ }
+ return $styleini;
+}
+
+/**
* Prints classes for interwikilinks
*
* Interwiki links have two classes: 'interwiki' and 'iw_$name>' where