Added settings to fusion theme. MDL-23299

This commit is contained in:
john St 2010-08-03 15:05:12 +00:00
parent 44fab7fa46
commit 832722480b
7 changed files with 117 additions and 18 deletions

View File

@ -57,6 +57,7 @@ $THEME->sheets = array(
'core',
'pagelayout',
'menus',
'settings',
);
////////////////////////////////////////////////////
@ -253,3 +254,4 @@ $THEME->rarrow = '⟩';
////////////////////////////////////////////////////
// Controls the colours for the MP3 player
////////////////////////////////////////////////////
$THEME->csspostprocess = 'fusion_process_css';

View File

@ -60,12 +60,11 @@ $string['choosereadme'] = '
$string['linkcolor'] = 'Link Color';
$string['linkcolordesc'] = 'This sets the link color for the theme.';
$string['configtitle'] = 'Arialist settings';
$string['configtitle'] = 'Fusion settings';
$string['customcss'] = 'Custom CSS';
$string['customcssdesc'] = 'Any CSS you enter here will be added to every page allowing your to easily customise this theme.';
$string['tagline'] = 'Tagline';
$string['taglinedesc'] = 'A short tagline to be displayed under the site name on the front page.<br /><em>(Will not be displayed with logo.)</em>';
$string['logo'] = 'Logo';
$string['logodesc'] = 'Enter the URL to an image to use as the logo for this site. Should be http://www.yoursite.com/path/to/logo.png';
$string['regionwidth'] = 'Column width';
$string['regionwidthdesc'] = 'This sets the width of the two block regions that form the left and right columns.';
$string['taglinedesc'] = 'A short tagline to be displayed under the site name on the front page.<br />';
$string['footertext'] = 'Footertext';
$string['footertextdesc'] = 'Set a footnote or footer text.';

View File

@ -19,6 +19,19 @@ if ($hascustommenu) {
$bodyclasses[] = 'has_custom_menu';
}
if (!empty($PAGE->theme->settings->tagline)) {
$tagline = $PAGE->theme->settings->tagline;
} else {
$tagline = "Another Moodle Theme";
}
if (!empty($PAGE->theme->settings->footertext)) {
$footnote = $PAGE->theme->settings->footertext;
} else {
$footnote = '<!-- There was no custom footnote set -->';
}
echo $OUTPUT->doctype() ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
@ -77,7 +90,7 @@ echo $OUTPUT->doctype() ?>
<div id="region-header">
<h1 class="headermain"><?php echo $PAGE->heading ?></h1>
<p class="tagline">Another Moodle Theme</p>
<p class="tagline"><?php echo $tagline ?></p>
</div>
<?php echo core_renderer::MAIN_CONTENT_TOKEN ?>
@ -112,6 +125,7 @@ echo $OUTPUT->doctype() ?>
<!-- START OF FOOTER -->
<div id="page-footer" class="wrapper clearfix">
<?php echo $footnote ?>
<p class="helplink"><?php echo page_doc_link(get_string('moodledocslink')) ?></p>
<?php
echo $OUTPUT->login_info();

View File

@ -20,6 +20,13 @@ if ($hascustommenu) {
$bodyclasses[] = 'has_custom_menu';
}
if (!empty($PAGE->theme->settings->footertext)) {
$footnote = $PAGE->theme->settings->footertext;
} else {
$footnote = '<!-- There was no custom footnote set -->';
}
echo $OUTPUT->doctype() ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
@ -136,6 +143,7 @@ echo $OUTPUT->doctype() ?>
<?php if ($hasfooter) { ?>
<div id="page-footer" class="wrapper">
<?php echo $footnote ?>
<p class="helplink"><?php echo page_doc_link(get_string('moodledocslink')) ?></p>
<?php
echo $OUTPUT->login_info();

49
theme/fusion/lib.php Normal file
View File

@ -0,0 +1,49 @@
<?php
function fusion_set_linkcolor($css, $linkcolor) {
$tag = '[[setting:linkcolor]]';
$replacement = $linkcolor;
if (is_null($replacement)) {
$replacement = '#2d83d5';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function fusion_set_customcss($css, $customcss) {
$tag = '[[setting:customcss]]';
$replacement = $customcss;
if (is_null($replacement)) {
$replacement = '';
}
$css = str_replace($tag, $replacement, $css);
return $css;
}
function fusion_process_css($css, $theme) {
if (!empty($theme->settings->linkcolor)) {
$linkcolor = $theme->settings->linkcolor;
} else {
$linkcolor = null;
}
$css = fusion_set_linkcolor($css, $linkcolor);
if (!empty($theme->settings->customcss)) {
$customcss = $theme->settings->customcss;
} else {
$customcss = null;
}
$css = fusion_set_customcss($css, $customcss);
return $css;
}

38
theme/fusion/settings.php Normal file
View File

@ -0,0 +1,38 @@
<?php
// Create our admin page
$temp = new admin_settingpage('theme_fusion', get_string('configtitle','theme_fusion'));
// link color setting
$name = 'theme_fusion/linkcolor';
$title = get_string('linkcolor','theme_fusion');
$description = get_string('linkcolordesc', 'theme_fusion');
$default = '#2d83d5';
$previewconfig = NULL;
$setting = new admin_setting_configcolourpicker($name, $title, $description, $default, $previewconfig);
$temp->add($setting);
// Tag line setting
$name = 'theme_fusion/tagline';
$title = get_string('tagline','theme_fusion');
$description = get_string('taglinedesc', 'theme_fusion');
$setting = new admin_setting_configtextarea($name, $title, $description, '');
$temp->add($setting);
// Foot note setting
$name = 'theme_fusion/footertext';
$title = get_string('footertext','theme_fusion');
$description = get_string('footertextdesc', 'theme_fusion');
$setting = new admin_setting_confightmleditor($name, $title, $description, '');
$temp->add($setting);
// Custom CSS file
$name = 'theme_fusion/customcss';
$title = get_string('customcss','theme_fusion');
$description = get_string('customcssdesc', 'theme_fusion');
$setting = new admin_setting_configtextarea($name, $title, $description, '');
$temp->add($setting);
// Add our page to the structure of the admin tree
$ADMIN->add('themes', $temp);

View File

@ -2,17 +2,6 @@ a {
color:[[setting:linkcolor]];
}
#page-content #region-main-box #region-post-box {
margin-left: -[[setting:regionwidth]];
}
#page-content #region-main-box #region-post-box #region-main-wrap #region-main {
margin-left: [[setting:regionwidth]];
}
#page-content #region-main-box #region-post-box #region-post {
left: [[setting:regionwidth]];
width: [[setting:regionwidth]];
/** Custom CSS **/
[[setting:customcss]]