Commit 5d7bdaea authored by Aaron Wells's avatar Aaron Wells

Reorganizing theme files: Adding "plugintype"; eliminating "static".

Bug 1465107: Use Bootstrap CSS Framework

1. Moving all the pluginfiles for themes into a "plugintype" directory. So
e.g. htdocs/theme/raw/blocktype/clippy/templates/clippy.tpl becomes
htdocs/theme/raw/plugintype/blocktype/clippy/templates/clippy.tpl.

2. Moving all the things under "static" in themes, to the theme's root.
So htdocs/theme/raw/static/style/style.css becomes htdocs/theme/raw/style.css
and htdocs/theme/raw/blocktype/clippy/static/images/clippy.png becomes
htdocs/theme/raw/blocktype/clippy/images/clippy.png

This should make things a little clearer for new theme devs. It's
still confusing to have all the images scattered throughout the plugin
subdirectories, but that's hard to fix because we treat the asset type
as part of the filename, e.g. $THEME->get_url('style/style.css') instead
of $THEME->get_url('style', 'style.css');

Change-Id: Ia216a40fb72624113e56d7eac698bfeb5adafcf0
parent 68d57850
......@@ -62,11 +62,11 @@ class Dwoo_Template_Mahara extends Dwoo_Template_File {
$includePath = array();
// First look for a local override.
$includePath[] = get_config('docroot') . "local/theme/{$pluginpath}/templates";
$includePath[] = get_config('docroot') . "local/theme/plugintype/{$pluginpath}/templates";
// Then look for files in a custom theme
foreach ($THEME->inheritance as $theme) {
$includePath[] = get_config('docroot') . "theme/{$theme}/{$pluginpath}/templates";
$includePath[] = get_config('docroot') . "theme/{$theme}/plugintype/{$pluginpath}/templates";
}
// Lastly look for files in the plugin itself
......
......@@ -1095,10 +1095,22 @@ class Theme {
*/
private function _get_path($filename, $all, $plugindirectory, $returnprefix, $debug=true) {
$list = array();
$plugindirectory = ($plugindirectory && substr($plugindirectory, -1) != '/') ? $plugindirectory . '/' : $plugindirectory;
if ($plugindirectory) {
// If they provided a plugindirectory, make sure it ends with a slash
// (this will save us some if-thens down the road)
if (substr($plugindirectory, -1) != '/') {
// $rawpluginpath is the relative path of the plugin, i.e. blocktype/creativecommons
$rawpluginpath = $plugindirectory . '/';
}
// $pluginpath is the path to the plugin in a theme context, i.e. with "plugintype" in front
$pluginpath = "plugintype/{$rawpluginpath}";
}
else {
$rawpluginpath = $pluginpath = '';
}
// Local theme overrides come first
$localloc = "local/theme/{$plugindirectory}static/{$filename}";
$localloc = "local/theme/{$pluginpath}{$filename}";
if (is_readable(get_config('docroot') . $localloc)) {
if ($all) {
$list['local'] = $returnprefix . $localloc;
......@@ -1112,10 +1124,10 @@ class Theme {
foreach ($this->inheritance as $themedir) {
$searchloc = array();
// Check in the /theme directory
$searchloc[] = "theme/{$themedir}/{$plugindirectory}static/{$filename}";
if ($plugindirectory) {
$searchloc[] = "theme/{$themedir}/{$pluginpath}{$filename}";
if ($rawpluginpath) {
// Then check in the plugin's own directory
$searchloc[] = "{$plugindirectory}theme/{$themedir}/static/{$filename}";
$searchloc[] = "{$rawpluginpath}theme/{$themedir}/{$filename}";
}
foreach($searchloc as $loc) {
if (is_readable(get_config('docroot') . $loc)) {
......@@ -1136,7 +1148,7 @@ class Theme {
$this->log_debug_missing_file($filename, $plugindirectory);
}
return $returnprefix . $plugindirectory . 'theme/' . $themedir . '/static/' . $filename;
return $returnprefix . $rawpluginpath . 'theme/' . $themedir . '/' . $filename;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment