MDL-25394 Improved support for mobile and device themes

This commit is contained in:
Anthony Forth 2011-05-31 14:25:52 +08:00 committed by Sam Hemelryk
parent 16b5541dd2
commit 37959dd471
11 changed files with 534 additions and 70 deletions

View file

@ -212,6 +212,8 @@ class core_renderer extends renderer_base {
protected $contenttype;
/** @var string used by {@link redirect_message()} method to communicate with {@link header()}. */
protected $metarefreshtag = '';
/** @var set if the theme links function has been called **/
protected $switchlinkdisplayed;
/**
* Get the DOCTYPE declaration that should be used with this page. Designed to
@ -362,10 +364,13 @@ class core_renderer extends renderer_base {
// but some of the content won't be known until later, so we return a placeholder
// for now. This will be replaced with the real content in {@link footer()}.
$output = self::PERFORMANCE_INFO_TOKEN;
if ($this->page->legacythemeinuse) {
if ($this->page->devicetypeinuse == 'legacy'){
// The legacy theme is in use print the notification
$output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse'));
}
$output .= $this->theme_switch_links();
if (!empty($CFG->debugpageinfo)) {
$output .= '<div class="performanceinfo pageinfo">This page is: ' . $this->page->debug_summary() . '</div>';
}
@ -2496,6 +2501,42 @@ EOD;
// Return the sub menu
return $content;
}
/*
* Renders theme links for switching between default and other themes.
*/
protected function theme_switch_links() {
if ($this->switchlinkdisplayed) {
return '';
}
global $USER;
$type = get_device_type();
$this->switchlinkdisplayed = true;
if ($type == 'default') {
return '';
}
$switched = get_user_switched_device();
if ($switched) {
$linktext = get_string('switchdevicerecommended');
} else {
$linktext = get_string('switchdevicedefault');
}
$content = html_writer::start_tag('div', array('id'=>'theme_switch_link'));
$linkurl = new moodle_url('/theme/switch.php', array('url' => $this->page->url));
$content .= html_writer::link($linkurl, $linktext);
$content .= html_writer::end_tag('div');
return $content;
}
}