MDL-44193 theme_afterburner: unified @package use and improved coding style
This commit is contained in:
@@ -1,12 +1,34 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Afterburner theme configuration.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$THEME->name = 'afterburner';
|
||||
|
||||
$THEME->parents = array('base');
|
||||
|
||||
$THEME->sheets = array(
|
||||
'afterburner_pagelayout', /** Must come first: page layout **/
|
||||
'afterburner_styles', /** Must come second: default styles **/
|
||||
'afterburner_pagelayout', // Must come first: page layout.
|
||||
'afterburner_styles', // Must come second: default styles.
|
||||
'afterburner_menu',
|
||||
'afterburner_blocks',
|
||||
'afterburner_mod',
|
||||
@@ -19,7 +41,7 @@ $THEME->sheets = array(
|
||||
);
|
||||
|
||||
$THEME->parents_exclude_sheets = array(
|
||||
'base'=>array(
|
||||
'base' => array(
|
||||
'pagelayout',
|
||||
'dock'
|
||||
),
|
||||
@@ -27,18 +49,18 @@ $THEME->parents_exclude_sheets = array(
|
||||
$THEME->editor_sheets = array('editor');
|
||||
|
||||
$THEME->layouts = array(
|
||||
// Most backwards compatible layout without the blocks - this is the layout used by default
|
||||
// Most backwards compatible layout without the blocks - this is the layout used by default.
|
||||
'base' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array(),
|
||||
),
|
||||
// Standard layout with blocks, this is recommended for most pages with default information
|
||||
// Standard layout with blocks, this is recommended for most pages with default information.
|
||||
'standard' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array('side-pre', 'side-post'),
|
||||
'defaultregion' => 'side-pre',
|
||||
),
|
||||
// Main course page
|
||||
// Main course page.
|
||||
'course' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array('side-pre', 'side-post'),
|
||||
@@ -50,7 +72,7 @@ $THEME->layouts = array(
|
||||
'regions' => array('side-pre', 'side-post'),
|
||||
'defaultregion' => 'side-pre',
|
||||
),
|
||||
// part of course, typical for modules - default page layout if $cm specified in require_login()
|
||||
// part of course, typical for modules - default page layout if $cm specified in require_login().
|
||||
'incourse' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array('side-pre', 'side-post'),
|
||||
@@ -69,14 +91,14 @@ $THEME->layouts = array(
|
||||
'regions' => array('side-pre'),
|
||||
'defaultregion' => 'side-pre',
|
||||
),
|
||||
// My dashboard page
|
||||
// My dashboard page.
|
||||
'mydashboard' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array('side-post'),
|
||||
'defaultregion' => 'side-post',
|
||||
'options' => array('langmenu'=>true),
|
||||
),
|
||||
// My public page
|
||||
// My public page.
|
||||
'mypublic' => array(
|
||||
'file' => 'default.php',
|
||||
'regions' => array('side-pre'),
|
||||
@@ -100,7 +122,7 @@ $THEME->layouts = array(
|
||||
'regions' => array(),
|
||||
'options' => array('nofooter'=>true, 'nocoursefooter'=>true),
|
||||
),
|
||||
// Embedded pages, like iframe/object embeded in moodleform - it needs as much space as possible
|
||||
// Embedded pages, like iframe/object embeded in moodleform - it needs as much space as possible.
|
||||
'embedded' => array(
|
||||
'file' => 'embedded.php',
|
||||
'regions' => array()
|
||||
|
||||
@@ -22,6 +22,12 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Upgrade steps for the Afterburner theme.
|
||||
*
|
||||
* @param int $oldversion
|
||||
* @return bool
|
||||
*/
|
||||
function xmldb_theme_afterburner_upgrade($oldversion) {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 for the afterburner theme.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @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());
|
||||
|
||||
@@ -1,4 +1,30 @@
|
||||
<?php echo $OUTPUT->doctype() ?>
|
||||
<?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 embedded layout.
|
||||
*
|
||||
* This layout is used for content that is embedded within an existing Moodle page.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
echo $OUTPUT->doctype() ?>
|
||||
<html <?php echo $OUTPUT->htmlattributes() ?>>
|
||||
<head>
|
||||
<title><?php echo $PAGE->title ?></title>
|
||||
|
||||
@@ -1,12 +1,44 @@
|
||||
<?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 afterburner theme.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Processes CSS for the afterburner theme before it is cached and delivered.
|
||||
*
|
||||
* This function performs any customisations on the CSS that this theme requires.
|
||||
* This includes setting the theme logo, and including any custom CSS.
|
||||
*
|
||||
* @param string $css The raw CSS.
|
||||
* @param theme_config $theme
|
||||
* @return string The now processed CSS.
|
||||
*/
|
||||
function afterburner_process_css($css, $theme) {
|
||||
|
||||
// Set the background image for the logo
|
||||
// Set the background image for the logo.
|
||||
$logo = $theme->setting_file_url('logo', 'logo');
|
||||
$css = afterburner_set_logo($css, $logo, $theme);
|
||||
|
||||
// Set custom CSS
|
||||
// Set custom CSS.
|
||||
if (!empty($theme->settings->customcss)) {
|
||||
$customcss = $theme->settings->customcss;
|
||||
} else {
|
||||
@@ -17,11 +49,19 @@ function afterburner_process_css($css, $theme) {
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the set logo to the CSS before it is cached and delivered.
|
||||
*
|
||||
* @param string $css
|
||||
* @param string $logo
|
||||
* @param theme_config $theme
|
||||
* @return string
|
||||
*/
|
||||
function afterburner_set_logo($css, $logo, $theme) {
|
||||
$tag = '[[setting:logo]]';
|
||||
$replacement = $logo;
|
||||
if (is_null($replacement)) {
|
||||
$replacement = $theme->pix_url('images/logo','theme');
|
||||
$replacement = $theme->pix_url('images/logo', 'theme');
|
||||
}
|
||||
|
||||
$css = str_replace($tag, $replacement, $css);
|
||||
@@ -29,6 +69,12 @@ function afterburner_set_logo($css, $logo, $theme) {
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds any custom CSS the admin has set to the CSS file before it is cached and delivered.
|
||||
* @param string $css
|
||||
* @param string $customcss
|
||||
* @return string
|
||||
*/
|
||||
function afterburner_set_customcss($css, $customcss) {
|
||||
$tag = '[[setting:customcss]]';
|
||||
$replacement = $customcss;
|
||||
@@ -41,6 +87,18 @@ function afterburner_set_customcss($css, $customcss) {
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serves any theme associated files when they are requested.
|
||||
*
|
||||
* @param stdClass $course
|
||||
* @param cm_info $cm
|
||||
* @param context $context
|
||||
* @param string $filearea
|
||||
* @param array $args
|
||||
* @param bool $forcedownload
|
||||
* @param array $options
|
||||
* @return bool
|
||||
*/
|
||||
function theme_afterburner_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload, array $options = array()) {
|
||||
if ($context->contextlevel == CONTEXT_SYSTEM and $filearea === 'logo') {
|
||||
$theme = theme_config::load('afterburner');
|
||||
|
||||
@@ -1,5 +1,36 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Afterburner overridden renderers.
|
||||
*
|
||||
* This file contains renderers that have been overridden by the afterburner theme.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
/**
|
||||
* Overridden core_renderer.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class theme_afterburner_core_renderer extends core_renderer {
|
||||
|
||||
/**
|
||||
@@ -13,12 +44,12 @@ class theme_afterburner_core_renderer extends core_renderer {
|
||||
*/
|
||||
protected function render_custom_menu(custom_menu $menu) {
|
||||
|
||||
// If the menu has no children return an empty string
|
||||
// If the menu has no children return an empty string.
|
||||
if (!$menu->has_children()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// Add a login or logout link
|
||||
// Add a login or logout link.
|
||||
if (isloggedin()) {
|
||||
$branchlabel = get_string('logout');
|
||||
$branchurl = new moodle_url('/login/logout.php');
|
||||
@@ -28,15 +59,15 @@ class theme_afterburner_core_renderer extends core_renderer {
|
||||
}
|
||||
$branch = $menu->add($branchlabel, $branchurl, $branchlabel, -1);
|
||||
|
||||
// Initialise this custom menu
|
||||
$content = html_writer::start_tag('ul', array('class'=>'dropdown dropdown-horizontal'));
|
||||
// Render each child
|
||||
// Initialise this custom menu.
|
||||
$content = html_writer::start_tag('ul', array('class' => 'dropdown dropdown-horizontal'));
|
||||
// Render each child.
|
||||
foreach ($menu->get_children() as $item) {
|
||||
$content .= $this->render_custom_menu_item($item);
|
||||
}
|
||||
// Close the open tags
|
||||
// Close the open tags.
|
||||
$content .= html_writer::end_tag('ul');
|
||||
// Return the custom menu
|
||||
// Return the custom menu.
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -53,19 +84,19 @@ class theme_afterburner_core_renderer extends core_renderer {
|
||||
* @return string
|
||||
*/
|
||||
protected function render_custom_menu_item(custom_menu_item $menunode) {
|
||||
// Required to ensure we get unique trackable id's
|
||||
// Required to ensure we get unique trackable id's.
|
||||
static $submenucount = 0;
|
||||
$content = html_writer::start_tag('li');
|
||||
if ($menunode->has_children()) {
|
||||
// If the child has menus render it as a sub menu
|
||||
// If the child has menus render it as a sub menu.
|
||||
$submenucount++;
|
||||
if ($menunode->get_url() !== null) {
|
||||
$url = $menunode->get_url();
|
||||
} else {
|
||||
$url = '#cm_submenu_'.$submenucount;
|
||||
}
|
||||
$content .= html_writer::start_tag('span', array('class'=>'customitem'));
|
||||
$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
|
||||
$content .= html_writer::start_tag('span', array('class' => 'customitem'));
|
||||
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
|
||||
$content .= html_writer::end_tag('span');
|
||||
$content .= html_writer::start_tag('ul');
|
||||
foreach ($menunode->get_children() as $menunode) {
|
||||
@@ -73,17 +104,17 @@ class theme_afterburner_core_renderer extends core_renderer {
|
||||
}
|
||||
$content .= html_writer::end_tag('ul');
|
||||
} else {
|
||||
// The node doesn't have children so produce a final menuitem
|
||||
// The node doesn't have children so produce a final menuitem.
|
||||
|
||||
if ($menunode->get_url() !== null) {
|
||||
$url = $menunode->get_url();
|
||||
} else {
|
||||
$url = '#';
|
||||
}
|
||||
$content .= html_writer::link($url, $menunode->get_text(), array('title'=>$menunode->get_title()));
|
||||
$content .= html_writer::link($url, $menunode->get_text(), array('title' => $menunode->get_title()));
|
||||
}
|
||||
$content .= html_writer::end_tag('li');
|
||||
// Return the sub menu
|
||||
// Return the sub menu.
|
||||
return $content;
|
||||
}
|
||||
|
||||
@@ -98,16 +129,16 @@ class theme_afterburner_core_renderer extends core_renderer {
|
||||
$title = $item->get_title();
|
||||
if ($item->icon instanceof renderable && !$item->hideicon) {
|
||||
$icon = $this->render($item->icon);
|
||||
$content = $icon.$content; // use CSS for spacing of icons
|
||||
$content = $icon.$content; // Use CSS for spacing of icons.
|
||||
}
|
||||
if ($item->helpbutton !== null) {
|
||||
$content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton'));
|
||||
$content = trim($item->helpbutton).html_writer::tag('span', $content, array('class' => 'clearhelpbutton'));
|
||||
}
|
||||
if ($content === '') {
|
||||
return '';
|
||||
}
|
||||
if ($item->action instanceof action_link) {
|
||||
//adds class dimmed to hidden courses and categories
|
||||
// Adds class dimmed to hidden courses and categories.
|
||||
$link = $item->action;
|
||||
if ($item->hidden) {
|
||||
$link->add_class('dimmed');
|
||||
|
||||
@@ -1,29 +1,51 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Afterburner theme settings.
|
||||
*
|
||||
* @package theme_afterburner
|
||||
* @copyright 2011 Mary Evans
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
if ($ADMIN->fulltree) {
|
||||
|
||||
// Logo file setting
|
||||
// Logo file setting.
|
||||
$name = 'theme_afterburner/logo';
|
||||
$title = get_string('logo','theme_afterburner');
|
||||
$title = get_string('logo', 'theme_afterburner');
|
||||
$description = get_string('logodesc', 'theme_afterburner');
|
||||
$setting = new admin_setting_configstoredfile($name, $title, $description, 'logo');
|
||||
$setting->set_updatedcallback('theme_reset_all_caches');
|
||||
$settings->add($setting);
|
||||
|
||||
// Foot note setting
|
||||
// Foot note setting.
|
||||
$name = 'theme_afterburner/footnote';
|
||||
$title = get_string('footnote','theme_afterburner');
|
||||
$title = get_string('footnote', 'theme_afterburner');
|
||||
$description = get_string('footnotedesc', 'theme_afterburner');
|
||||
$default = '';
|
||||
$setting = new admin_setting_confightmleditor($name, $title, $description, $default);
|
||||
$setting->set_updatedcallback('theme_reset_all_caches');
|
||||
$settings->add($setting);
|
||||
|
||||
// Custom CSS file
|
||||
// Custom CSS file.
|
||||
$name = 'theme_afterburner/customcss';
|
||||
$title = get_string('customcss','theme_afterburner');
|
||||
$title = get_string('customcss', 'theme_afterburner');
|
||||
$description = get_string('customcssdesc', 'theme_afterburner');
|
||||
$default = '';
|
||||
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
|
||||
|
||||
@@ -26,7 +26,7 @@ defined('MOODLE_INTERNAL') || die;
|
||||
|
||||
$plugin->version = 2013110500; // The current module version (Date: YYYYMMDDXX)
|
||||
$plugin->requires = 2013110500; // Requires this Moodle version
|
||||
$plugin->component = 'theme_afterburner'; // Full name of the plugin (used for diagnostics)
|
||||
$plugin->component = 'theme_afterburner'; // Full name of the plugin (used for diagnostics).
|
||||
$plugin->dependencies = array(
|
||||
'theme_base' => 2013110500,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user