Skip to content

Commit

Permalink
removed legacythemeinuse plus support to drop $CFG->themes in upgrade.
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyforth committed May 27, 2011
1 parent b3db279 commit 7d10784
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
16 changes: 16 additions & 0 deletions lib/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6114,6 +6114,22 @@ function xmldb_main_upgrade($oldversion) {

//set enable theme detection to the new themes setting.
if ($oldversion < 2011052500.00) {
if (!empty($CFG->themes)) {
$themes = json_decode($themes);

foreach ($themes as $theme) {
if ($theme->name == 'default') {
$varname = 'theme';
} else {
$varname = 'theme' . $theme->name;
}

set_config($varname, $theme->themename);
}

unset_config('themes');
}

set_config('enabledevicedetection', 1);

upgrade_main_savepoint(true, 2011052500.00);
Expand Down
2 changes: 1 addition & 1 deletion lib/outputrenderers.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ public function standard_footer_html() {
// 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->$this->_devicetypeinuse == 'legacy'){
// The legacy theme is in use print the notification
$output .= html_writer::tag('div', get_string('legacythemeinuse'), array('class'=>'legacythemeinuse'));
}
Expand Down
22 changes: 10 additions & 12 deletions lib/pagelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@
* @property-read object $course The current course that we are inside - a row from the
* course table. (Also available as $COURSE global.) If we are not inside
* an actual course, this will be the site course.
* @property-read bool $devicetypeinuse Returns true if the legacy theme is being used.
* @property-read string $docspath The path to the Moodle docs for this page.
* @property-read string $focuscontrol The id of the HTML element to be focused when the page has loaded.
* @property-read bool $headerprinted
* @property-read string $heading The main heading that should be displayed at the top of the <body>.
* @property-read string $headingmenu The menu (or actions) to display in the heading
* @property-read array $layout_options Returns arrays with options for layout file.
* @property-read bool $legacythemeinuse Returns true if the legacy theme is being used.
* @property-read navbar $navbar Returns the navbar object used to display the navbar
* @property-read global_navigation $navigation Returns the global navigation structure
* @property-read xml_container_stack $opencontainers Tracks XHTML tags on this page that have been opened but not closed.
Expand Down Expand Up @@ -217,10 +217,10 @@ class moodle_page {
protected $_legacybrowsers = array('MSIE' => 6.0);

/**
* Is set to true if the chosen legacy theme is in use. False by default.
* @var bool
* Is set to the name of the device type in use.
* @var string
*/
protected $_legacythemeinuse = false;
protected $_devicetypeinuse = 'default';

protected $_https_login_required = false;

Expand Down Expand Up @@ -523,11 +523,11 @@ protected function magic_get_theme() {
}

/**
* Please do not call this method directly, use the ->legacythemeinuse syntax. {@link __get()}.
* Please do not call this method directly, use the ->devicetypeinuse syntax. {@link __get()}.
* @return bool
*/
protected function magic_get_legacythemeinuse() {
return ($this->_legacythemeinuse);
protected function magic_get_devicetypeinuse() {
return ($this->_devicetypeinuse);
}

/**
Expand Down Expand Up @@ -1320,9 +1320,7 @@ protected function resolve_theme() {
return $mnetpeertheme;
}

if ($devicetype == 'legacy') {
$this->_legacythemeinuse = true;
}
$this->_devicetypeinuse = $devicetype;

return get_selected_theme_for_device_type();
}
Expand Down Expand Up @@ -1435,8 +1433,8 @@ protected function initialise_standard_body_classes() {
$this->add_body_class('drag');
}

if ($this->_legacythemeinuse) {
$this->add_body_class('legacytheme');
if ($this->_devicetypeinuse != 'default') {
$this->add_body_class($this->_devicetypeinuse . 'theme');
}
}

Expand Down

0 comments on commit 7d10784

Please sign in to comment.