Skip to content

Commit

Permalink
fix: switch extensions if stylesheet in style.ini doesn't exist
Browse files Browse the repository at this point in the history
This should give us some backwards compatibility for changing files in
dokuwiki template from .css to .less

This way template authors get a warning to adjust their template, it
won't break right away.

This should prevent breaking search pages in other templates due to
pull request #2286 .
  • Loading branch information
micgro42 committed Apr 5, 2018
1 parent d9e82b0 commit 432cf0d
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion inc/StyleUtils.php
Expand Up @@ -42,7 +42,18 @@ public function cssStyleini($tpl, $preview=false) {

// stylesheets
if(is_array($data['stylesheets'])) foreach($data['stylesheets'] as $file => $mode){
$stylesheets[$mode][$incbase.$file] = $webbase;
if (!file_exists($incbase . $file)) {
list($extension, $basename) = array_map('strrev', explode('.', strrev($file), 2));
$newExtension = $extension === 'css' ? 'less' : 'css';
if (file_exists($incbase . $basename . '.' . $newExtension)) {
$stylesheets[$mode][$incbase . $basename . '.' . $newExtension] = $webbase;
if ($conf['allowdebug']) {
msg("Stylesheet $file not found, using $basename.$newExtension instead. Please contact developer of \"{$conf['template']}\" template.", 2);
}
continue;
}
}
$stylesheets[$mode][$incbase . $file] = $webbase;
}

// replacements
Expand Down

0 comments on commit 432cf0d

Please sign in to comment.