MDL-44211 theme_sky_high: unified @package use and improved coding style

This commit is contained in:
Sam Hemelryk 2014-02-17 11:22:44 +13:00
parent 692d247a3a
commit d8c1cddb95
8 changed files with 168 additions and 61 deletions

View File

@ -15,8 +15,6 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
*
*
* DO NOT MODIFY THIS THEME!
* COPY IT FIRST, THEN RENAME THE COPY AND MODIFY IT INSTEAD.
*
@ -24,7 +22,9 @@
* http://docs.moodle.org/dev/Themes_2.0
*
* @package theme_sky_high
*/
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$THEME->name = 'sky_high';

View File

@ -1,5 +1,4 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
@ -16,10 +15,10 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Strings for component 'theme_standard', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component 'theme_sky_high', language 'en'.
*
* @package theme_standard
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

View File

@ -1,4 +1,26 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The frontpage layout.
*
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);
$hassidepost = $PAGE->blocks->region_has_content('side-post', $OUTPUT);

View File

@ -1,4 +1,26 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The default layout.
*
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$hasheading = ($PAGE->heading);
$hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());

View File

@ -1,4 +1,26 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The report layout.
*
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
$hassidepre = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-pre', $OUTPUT));
$hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());

View File

@ -1,21 +1,50 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains functions specific to the needs of the Sky High theme.
*
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Processes CSS applying theme customisations before it is cached and delivered.
*
* @param string $css
* @param theme_config $theme
* @return string
*/
function sky_high_process_css($css, $theme) {
if (!empty($theme->settings->regionwidth)) {
$regionwidth = $theme->settings->regionwidth;
} else {
$regionwidth = null;
}
$css = sky_high_set_regionwidth($css, $regionwidth);
if (!empty($theme->settings->customcss)) {
$customcss = $theme->settings->customcss;
} else {
$customcss = null;
}
$css = sky_high_set_customcss($css, $customcss);
return $css;
}
@ -23,7 +52,7 @@ function sky_high_process_css($css, $theme) {
* Sets the region width variable in CSS
*
* @param string $css
* @param mixed $regionwidth
* @param string $regionwidth
* @return string
*/
function sky_high_set_regionwidth($css, $regionwidth) {
@ -36,9 +65,9 @@ function sky_high_set_regionwidth($css, $regionwidth) {
$replacement = 240;
}
$css = str_replace($tag, $replacement.'px', $css);
$css = str_replace($doubletag, ($replacement*2).'px', $css);
$css = str_replace($rightmargintag, ($replacement*3-5).'px', $css);
$css = str_replace($leftmargintag, ($replacement+5).'px', $css);
$css = str_replace($doubletag, ($replacement * 2).'px', $css);
$css = str_replace($rightmargintag, ($replacement * 3 - 5).'px', $css);
$css = str_replace($leftmargintag, ($replacement + 5).'px', $css);
return $css;
}
@ -46,7 +75,7 @@ function sky_high_set_regionwidth($css, $regionwidth) {
* Sets the custom css variable in CSS
*
* @param string $css
* @param mixed $customcss
* @param string $customcss
* @return string
*/
function sky_high_set_customcss($css, $customcss) {
@ -57,6 +86,4 @@ function sky_high_set_customcss($css, $customcss) {
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
?>
}

View File

@ -1,49 +1,64 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Settings for the sky_high theme
*
* @package theme_sky_high
* @copyright 2010 John Stabinger (http://newschoollearning.com/)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
// Logo file setting
$name = 'theme_sky_high/logo';
$title = get_string('logo','theme_sky_high');
$description = get_string('logodesc', 'theme_sky_high');
$setting = new admin_setting_configtext($name, $title, $description, '', PARAM_URL);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Block region width
$name = 'theme_sky_high/regionwidth';
$title = get_string('regionwidth','theme_sky_high');
$description = get_string('regionwidthdesc', 'theme_sky_high');
$default = 240;
$choices = array(200=>'200px', 240=>'240px', 290=>'290px', 350=>'350px', 420=>'420px');
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Foot note setting
$name = 'theme_sky_high/footnote';
$title = get_string('footnote','theme_sky_high');
$description = get_string('footnotedesc', 'theme_sky_high');
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Custom CSS file
$name = 'theme_sky_high/customcss';
$title = get_string('customcss','theme_sky_high');
$description = get_string('customcssdesc', 'theme_sky_high');
$setting = new admin_setting_configtextarea($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Add our page to the structure of the admin tree
// Logo file setting.
$name = 'theme_sky_high/logo';
$title = get_string('logo', 'theme_sky_high');
$description = get_string('logodesc', 'theme_sky_high');
$setting = new admin_setting_configtext($name, $title, $description, '', PARAM_URL);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
}
?>
// Block region width.
$name = 'theme_sky_high/regionwidth';
$title = get_string('regionwidth', 'theme_sky_high');
$description = get_string('regionwidthdesc', 'theme_sky_high');
$default = 240;
$choices = array(200 => '200px', 240 => '240px', 290 => '290px', 350 => '350px', 420 => '420px');
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Foot note setting.
$name = 'theme_sky_high/footnote';
$title = get_string('footnote', 'theme_sky_high');
$description = get_string('footnotedesc', 'theme_sky_high');
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Custom CSS file.
$name = 'theme_sky_high/customcss';
$title = get_string('customcss', 'theme_sky_high');
$description = get_string('customcssdesc', 'theme_sky_high');
$setting = new admin_setting_configtextarea($name, $title, $description, '');
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Add our page to the structure of the admin tree.
}

View File

@ -24,9 +24,9 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2013110500; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2013110500; // Requires this Moodle version
$plugin->component = 'theme_sky_high'; // Full name of the plugin (used for diagnostics)
$plugin->version = 2013110500; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2013110500; // Requires this Moodle version.
$plugin->component = 'theme_sky_high'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = array(
'theme_canvas' => 2013110500,
);