Skip to content

Commit

Permalink
fallback to default theme .tpl files for incomplete themes
Browse files Browse the repository at this point in the history
Enables writing themes without copying the full theme files from CleanFS-folder.

This enables to enhance Flyspray if a custom_*.css (colors, paddings, etc) or admin settings (footer areas etc. ) are not enough for customization, but keeps the redundancy of maintaining an extra theme low, because the main theme CleanFS is updated with each Flyspray release.
  • Loading branch information
peterdd committed Jan 23, 2017
1 parent 2dbbac0 commit baca7c4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions includes/class.tpl.php
Expand Up @@ -73,8 +73,8 @@ public function catch_end()
ob_end_clean();
}

public function display($_tpl, $_arg0 = null, $_arg1 = null)
{
public function display($_tpl, $_arg0 = null, $_arg1 = null)
{
// if only plain text
if (is_array($_tpl) && count($tpl)) {
echo $_tpl[0];
Expand All @@ -92,14 +92,17 @@ public function display($_tpl, $_arg0 = null, $_arg1 = null)

extract($this->_vars, EXTR_REFS|EXTR_SKIP);

if (is_readable(BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl)) {
require BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl;
} else {
// This is needed to catch times when there is no theme (for example setup pages)
require BASEDIR . "/templates/" . $_tpl;
}
if (is_readable(BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl)) {
require BASEDIR . '/themes/' . $this->_theme.'templates/'.$_tpl;
} elseif (is_readable(BASEDIR . '/themes/CleanFS/templates/'.$_tpl)) {
# if a custom theme folder only contains a fraction of the .tpl files, use the template of the default full theme as fallback.
require BASEDIR . '/themes/CleanFS/templates/'.$_tpl;
} else {
# This is needed to catch times when there is no theme (for example setup pages, where BASEDIR is ../setup/ not ../)
require BASEDIR . "/templates/" . $_tpl;
}

} // }}}
} // }}}

public function render()
{
Expand Down

0 comments on commit baca7c4

Please sign in to comment.