mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
Some changes in the way theme setup is achieved, there is now a function
for it called theme_setup
This commit is contained in:
parent
d65a650133
commit
d74d4f2053
2 changed files with 47 additions and 27 deletions
|
@ -223,20 +223,8 @@ global $THEME;
|
|||
if (!isset($CFG->theme)) {
|
||||
$CFG->theme = 'standard';
|
||||
}
|
||||
$currenttheme = current_theme();
|
||||
include($CFG->dirroot .'/theme/'. $currenttheme .'/config.php');
|
||||
|
||||
if (empty($CFG->custompix)) { // Could be set in the above file
|
||||
$CFG->pixpath = $CFG->wwwroot .'/pix';
|
||||
$CFG->modpixpath = $CFG->wwwroot .'/mod';
|
||||
} else {
|
||||
$CFG->pixpath = $CFG->wwwroot .'/theme/'. $currenttheme .'/pix';
|
||||
$CFG->modpixpath = $CFG->wwwroot .'/theme/'. $currenttheme .'/pix/mod';
|
||||
}
|
||||
|
||||
$CFG->stylesheet = $CFG->wwwroot .'/theme/'. $currenttheme .'/styles.php';
|
||||
$CFG->header = $CFG->dirroot .'/theme/'. $currenttheme .'/header.html';
|
||||
$CFG->footer = $CFG->dirroot .'/theme/'. $currenttheme .'/footer.html';
|
||||
theme_setup(); // Sets up theme global variables
|
||||
|
||||
|
||||
/// A hack to get around magic_quotes_gpc being turned off
|
||||
|
|
|
@ -1490,7 +1490,7 @@ function highlightfast($needle, $haystack) {
|
|||
function print_header ($title='', $heading='', $navigation='', $focus='', $meta='',
|
||||
$cache=true, $button=' ', $menu='', $usexml=false, $bodytags='') {
|
||||
|
||||
global $USER, $CFG, $THEME, $SESSION, $ME;
|
||||
global $USER, $CFG, $SESSION, $ME;
|
||||
|
||||
/// This is an ugly hack to be replaced later by a proper global $COURSE
|
||||
global $course;
|
||||
|
@ -1499,20 +1499,11 @@ function print_header ($title='', $heading='', $navigation='', $focus='', $meta=
|
|||
}
|
||||
|
||||
/// Add the required stylesheets
|
||||
$stylesheets = '';
|
||||
$theme = current_theme();
|
||||
if ($theme != 'standard') { /// The standard sheet is always loaded first
|
||||
$stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
|
||||
$CFG->wwwroot.'/theme/standard/styles.php" />'."\n";
|
||||
$stylesheetshtml = '';
|
||||
foreach ($CFG->stylesheets as $stylesheet) {
|
||||
$stylesheetshtml .= '<link rel="stylesheet" type="text/css" href="'.$stylesheet.'" />'."\n";
|
||||
}
|
||||
if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next
|
||||
$stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
|
||||
$CFG->wwwroot.'/theme/'.$THEME->parent.'/styles.php?parent=true" />'."\n";
|
||||
}
|
||||
$stylesheets .= '<link rel="stylesheet" type="text/css" href="'.
|
||||
$CFG->wwwroot.'/theme/'.$theme.'/styles.php" />'."\n";
|
||||
|
||||
$meta = $stylesheets.$meta;
|
||||
$meta = $stylesheetshtml.$meta;
|
||||
|
||||
|
||||
if ($navigation == 'home') {
|
||||
|
@ -1800,6 +1791,47 @@ function style_sheet_setup($lastmodified=0, $lifetime=300, $themename='') {
|
|||
|
||||
}
|
||||
|
||||
function theme_setup($theme = '', $extraparams='') {
|
||||
/// Sets up global variables related to themes
|
||||
|
||||
global $CFG, $THEME;
|
||||
|
||||
if (empty($theme)) {
|
||||
$theme = current_theme();
|
||||
}
|
||||
if (empty($extraparams)) {
|
||||
$params = '';
|
||||
$paramsparent = '?parent=true';
|
||||
} else {
|
||||
$params = '?'.$extraparams;
|
||||
$paramsparent = '?parent=true&'.$extraparams;
|
||||
}
|
||||
|
||||
$THEME = null;
|
||||
include($CFG->dirroot .'/theme/'. $theme .'/config.php');
|
||||
|
||||
if (empty($CFG->custompix)) { // Could be set in the above file
|
||||
$CFG->pixpath = $CFG->wwwroot .'/pix';
|
||||
$CFG->modpixpath = $CFG->wwwroot .'/mod';
|
||||
} else {
|
||||
$CFG->pixpath = $CFG->wwwroot .'/theme/'. $theme .'/pix';
|
||||
$CFG->modpixpath = $CFG->wwwroot .'/theme/'. $theme .'/pix/mod';
|
||||
}
|
||||
|
||||
$CFG->header = $CFG->dirroot .'/theme/'. $theme .'/header.html';
|
||||
$CFG->footer = $CFG->dirroot .'/theme/'. $theme .'/footer.html';
|
||||
|
||||
$CFG->stylesheets = array();
|
||||
if ($theme != 'standard') { /// The standard sheet is always loaded first
|
||||
$CFG->stylesheets[] = $CFG->wwwroot.'/theme/standard/styles.php'.$params;
|
||||
}
|
||||
if (!empty($THEME->parent)) { /// Parent stylesheets are loaded next
|
||||
$CFG->stylesheets[] = $CFG->wwwroot.'/theme/'.$THEME->parent.'/styles.php'.$paramsparent;
|
||||
}
|
||||
$CFG->stylesheets[] = $CFG->wwwroot.'/theme/'.$theme.'/styles.php'.$params;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns text to be displayed to the user which reflects their login status
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue