summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnika Henke <anika@selfthinker.org>2012-10-07 15:30:38 +0100
committerAnika Henke <anika@selfthinker.org>2012-10-07 15:30:38 +0100
commit0e6f9f08b1c948f45d1867346a4502021afa55bc (patch)
tree0c80d4ee3f48fabab4ecedd2d448baea5d97e2e7
parent3046a46462b44f28b1e5b1b25240a8ac4a859020 (diff)
downloadrpg-0e6f9f08b1c948f45d1867346a4502021afa55bc.tar.gz
rpg-0e6f9f08b1c948f45d1867346a4502021afa55bc.tar.bz2
added support for local style.ini files
-rw-r--r--lib/exe/css.php29
-rw-r--r--lib/tpl/default/style.ini3
-rw-r--r--lib/tpl/dokuwiki/style.ini3
-rw-r--r--lib/tpl/index.php10
4 files changed, 37 insertions, 8 deletions
diff --git a/lib/exe/css.php b/lib/exe/css.php
index 8899ff193..dd69c94cf 100644
--- a/lib/exe/css.php
+++ b/lib/exe/css.php
@@ -49,14 +49,17 @@ 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) {
+ $ini = parse_ini_file($styleini, true);
+ foreach($ini['stylesheets'] as $file => $mode) {
$tplstyles[$mode][$tplinc.$file] = $tpldir;
}
}
@@ -71,7 +74,8 @@ function css_out(){
$files = array();
$cache_files = getConfigFiles('main');
- $cache_files[] = $tplinc.'style.ini';
+ if ($styleini)
+ $cache_files[] = $styleini;
$cache_files[] = __FILE__;
foreach($mediatypes as $mediatype) {
@@ -173,14 +177,27 @@ 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);
+ $styleini = css_styleini($tplinc);
+
+ if($styleini){
+ $ini = parse_ini_file($styleini,true);
$css = strtr($css,$ini['replacements']);
}
return $css;
}
/**
+ * If either exist, get the template's style.local.ini or style.ini file.
+ */
+function css_styleini($tplinc) {
+ if(@file_exists($tplinc.'style.local.ini'))
+ return $tplinc.'style.local.ini';
+ if(@file_exists($tplinc.'style.ini'))
+ return $tplinc.'style.ini';
+ return '';
+}
+
+/**
* Prints classes for interwikilinks
*
* Interwiki links have two classes: 'interwiki' and 'iw_$name>' where
diff --git a/lib/tpl/default/style.ini b/lib/tpl/default/style.ini
index 7d27381c9..b9e1e9424 100644
--- a/lib/tpl/default/style.ini
+++ b/lib/tpl/default/style.ini
@@ -1,6 +1,9 @@
; Please see http://www.php.net/manual/en/function.parse-ini-file.php
; for limitations of the ini format used here
+; Please only make changes in style.local.ini. If it doesn't exist,
+; just create it by copying style.ini.
+
; Define the stylesheets your template uses here. The second value
; defines for which output media the style should be loaded. Currently
; print, screen and rtl are supported. rtl styles are loaded additionally
diff --git a/lib/tpl/dokuwiki/style.ini b/lib/tpl/dokuwiki/style.ini
index 242b43080..bcb5a1a2e 100644
--- a/lib/tpl/dokuwiki/style.ini
+++ b/lib/tpl/dokuwiki/style.ini
@@ -1,6 +1,9 @@
; Please see http://www.php.net/manual/en/function.parse-ini-file.php
; for limitations of the ini format used here
+; Please only make changes in style.local.ini. If it doesn't exist,
+; just create it by copying style.ini.
+
; Define the stylesheets your template uses here. The second value
; defines for which output media the style should be loaded. Currently
; print, screen and all are supported.
diff --git a/lib/tpl/index.php b/lib/tpl/index.php
index 357cc1f0d..7cdec9774 100644
--- a/lib/tpl/index.php
+++ b/lib/tpl/index.php
@@ -43,7 +43,13 @@ require_once(DOKU_INC.'inc/init.php');
</head>
<body>
<?php
-$ini = @parse_ini_file($conf['template'].'/style.ini',true);
+$styleini = '';
+if(@file_exists($conf['template'].'/style.local.ini'))
+ $styleini = $conf['template'].'/style.local.ini';
+else if(@file_exists($conf['template'].'/style.ini'))
+ $styleini = $conf['template'].'/style.ini';
+$ini = @parse_ini_file($styleini, true);
+
if ($ini) {
echo '<table>';
echo "<caption>".htmlspecialchars($conf['template'])."'s style.ini</caption>";
@@ -60,7 +66,7 @@ if ($ini) {
}
echo '</table>';
} else {
- echo "<p>Non-existent template: <strong>".htmlspecialchars($conf['template'])."</strong></p>";
+ echo "<p>Non-existent or invalid template or style.ini: <strong>".htmlspecialchars($conf['template'])."</strong></p>";
}
?>
</body>