Merge branch 'w15_MDL-39129_m25_afterburner' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2013-04-17 01:06:17 +02:00
commit 91560510dc
5 changed files with 82 additions and 11 deletions

View File

@ -0,0 +1,66 @@
<?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 upgrades.
*
* @package theme
* @subpackage afterburner
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function xmldb_theme_afterburner_upgrade($oldversion) {
global $CFG, $DB, $OUTPUT;
$dbman = $DB->get_manager();
if ($oldversion < 2013041200) {
// Migrate logo URL.
$logo = get_config('theme_afterburner', 'logo');
if ($logo === '') {
// No logo means nothing to do.
} else if ($logo = clean_param($logo, PARAM_URL)) {
require_once("$CFG->libdir/filelib.php");
if ($content = download_file_content($logo)) {
$filename = preg_replace('/^.*\//', '', $logo);
if (!$filename = clean_param($filename, PARAM_FILE)) {
// Some name is better than no name...
$filename = 'logo.jpg';
}
$fs = get_file_storage();
$record = array(
'contextid' => context_system::instance()->id, 'component' => 'theme_afterburner',
'filearea' => 'logo', 'itemid'=>0, 'filepath'=>'/', 'filename'=>$filename);
$fs->create_file_from_string($record, $content);
set_config('logo', '/'.$filename, 'theme_afterburner');
unset($content);
} else {
unset_config('theme_afterburner', 'logo');
}
} else {
// Prompt for new logo, the old setting was invalid.
unset_config('theme_afterburner', 'logo');
}
upgrade_plugin_savepoint(true, 2013041200, 'theme', 'afterburner');
}
return true;
}

View File

@ -27,7 +27,7 @@ $string['pluginname'] = 'Afterburner';
$string['region-side-post'] = 'Right';
$string['region-side-pre'] = 'Left';
$string['logo'] = 'Logo';
$string['logodesc'] = 'Please add the URL to your new logo only if you want to replace the default logo for this theme.<br />For your information, the default logo is a JPG image 320px (wide) by 75px (high)';
$string['logodesc'] = 'Please add your custom logo if you want to replace the default logo for this theme.<br />For your information, the default logo is a JPG image 320px (wide) by 75px (high)';
$string['footnote'] = 'Footnote';
$string['footnotedesc'] = 'Whatever you add to this textarea will be displayed in the footer of every page.';
$string['customcss'] = 'Custom CSS';

View File

@ -3,11 +3,7 @@
function afterburner_process_css($css, $theme) {
// Set the background image for the logo
if (!empty($theme->settings->logo)) {
$logo = $theme->settings->logo;
} else {
$logo = null;
}
$logo = $theme->setting_file_url('logo', 'logo');
$css = afterburner_set_logo($css, $logo);
// Set custom CSS
@ -44,4 +40,13 @@ function afterburner_set_customcss($css, $customcss) {
$css = str_replace($tag, $replacement, $css);
return $css;
}
}
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');
return $theme->setting_file_serve('logo', $args, $forcedownload, $options);
} else {
send_file_not_found();
}
}

View File

@ -8,8 +8,8 @@ if ($ADMIN->fulltree) {
$name = 'theme_afterburner/logo';
$title = get_string('logo','theme_afterburner');
$description = get_string('logodesc', 'theme_afterburner');
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_URL);
$setting = new admin_setting_configstoredfile($name, $title, $description, 'logo');
$setting->set_updatedcallback('theme_reset_all_caches');
$settings->add($setting);
// Foot note setting

View File

@ -25,6 +25,6 @@
defined('MOODLE_INTERNAL') || die;
$plugin->version = 2012112900; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2012112900; // Requires this Moodle version
$plugin->version = 2013041200; // The current module version (Date: YYYYMMDDXX)
$plugin->requires = 2013041100; // Requires this Moodle version
$plugin->component = 'theme_afterburner'; // Full name of the plugin (used for diagnostics)