Skip to content

Commit

Permalink
MDL-32420 theme_anomaly: Added custom css settings and tagline.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mary Evans committed Jan 27, 2013
1 parent b3778a0 commit 009fb7d
Show file tree
Hide file tree
Showing 11 changed files with 278 additions and 48 deletions.
31 changes: 27 additions & 4 deletions theme/anomaly/config.php
Expand Up @@ -7,12 +7,19 @@

$THEME->name = 'anomaly';

$THEME->sheets = array('base', 'general', 'browser', 'dock', 'menu');
$THEME->sheets = array(
'base',
'general',
'browser',
'dock',
'menu',
'settings'
);
/// This variable is an array containing the names of all the
/// stylesheet files you want included in this theme, and in what order
////////////////////////////////////////////////////////////////////////////////

$THEME->parents = array('base'); // TODO: new themes can not be based on standardold, instead use 'base' as the base
$THEME->parents = array('base');
/// This variable can be set to the name of a parent theme
/// which you want to have included before the current theme.
/// This can make it easy to make modifications to another
Expand Down Expand Up @@ -54,7 +61,7 @@
'options' => array('langmenu' => true)
),
'frontpage' => array(
'file' => 'general.php',
'file' => 'frontpage.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
'options' => array('langmenu' => true)
Expand Down Expand Up @@ -113,16 +120,32 @@
'regions' => array(),
'options' => array('nofooter'=>true, 'nonavbar'=>false, 'noblocks'=>true, 'nocourseheaderfooter'=>true),
),
// The pagelayout used when a redirection is occuring.
'redirect' => array(
'file' => 'embedded.php',
'regions' => array(),
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nocourseheaderfooter'=>true),
),
// The pagelayout used for reports.
'report' => array(
'file' => 'report.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
'options' => array('langmenu' => true)
'options' => array('langmenu' => true),
),
// The pagelayout used for safebrowser and securewindow.
'secure' => array(
'file' => 'general.php',
'regions' => array('side-pre', 'side-post'),
'defaultregion' => 'side-pre',
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nologinlinks'=>true, 'nocourseheaderfooter'=>true),
),
);

$THEME->rendererfactory = 'theme_overridden_renderer_factory';

$THEME->csspostprocess = 'anomaly_process_css';

$THEME->enable_dock = true;

$THEME->editor_sheets = array('editor');
8 changes: 6 additions & 2 deletions theme/anomaly/lang/en/theme_anomaly.php
Expand Up @@ -22,8 +22,12 @@
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

$string['choosereadme'] = '<div class="clearfix"><div class="theme_screenshot"><h2>Anomaly</h2><img src="anomaly/pix/screenshot.jpg" /><h3>Theme Discussion Forum:</h3><p><a href="http://moodle.org/mod/forum/view.php?id=46">http://moodle.org/mod/forum/view.php?id=46</a></p><h3>Theme Credits</h3><p><a href="http://docs.moodle.org/en/Theme_credits">http://docs.moodle.org/en/Theme_credits</a></p><h3>Theme Documentation:</h3><p><a href="http://docs.moodle.org/en/Themes">http://docs.moodle.org/en/Themes</a></p><h3>Report a bug:</h3><p><a href="http://tracker.moodle.org">http://tracker.moodle.org</a></p></div><div class="theme_description"><h2>About</h2><p>Anomaly is a fluid-width, three-column Moodle 2.0 theme with rounded corners. <h2>Tweaks</h2><p>This theme is built upon the Base theme inside the Moodle core. If you want to modify this theme, we recommend that you first duplicate it, then rename it before making your changes. This will prevent your customized theme from being overwritten by future Moodle upgrades, and you\'ll still have the original files if you make a mess. More information on modifying themes can be found in the <a href="http://docs.moodle.org/en/Theme">MoodleDocs</a>.</p><h2>Credits</h2><p>This theme was originally designed for Moodle 1.9 by Patrick Malley. It was then coded for 2.0 and is maintained by Sam Hemelryk at Moodle HQ. He can be contacted at sam@moodle.com.</p><h2>License</h2><p>This, and all other themes included in the Moodle core, are licensed under the <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>.</div></div>';
$string['configtitle'] = 'Anomaly Theme';
$string['customcss'] = 'Custom CSS';
$string['customcssdesc'] = 'Whatever CSS rules you add to this Custom CSS box will be reflected in every page, making for easier customization of this theme.';
$string['pluginname'] = 'Anomaly';
$string['region-side-post'] = 'Right';
$string['region-side-pre'] = 'Left';
$string['choosereadme'] = '<div class="clearfix"><div class="theme_screenshot"><h2>Anomaly</h2><img src="anomaly/pix/screenshot.jpg" /><h3>Theme Discussion Forum:</h3><p><a href="http://moodle.org/mod/forum/view.php?id=46">http://moodle.org/mod/forum/view.php?id=46</a></p><h3>Theme Credits</h3><p><a href="http://docs.moodle.org/en/Theme_credits">http://docs.moodle.org/en/Theme_credits</a></p><h3>Theme Documentation:</h3><p><a href="http://docs.moodle.org/en/Themes">http://docs.moodle.org/en/Themes</a></p><h3>Report a bug:</h3><p><a href="http://tracker.moodle.org">http://tracker.moodle.org</a></p></div><div class="theme_description"><h2>About</h2><p>Anomaly is a fluid-width, three-column Moodle 2.0 theme with rounded corners. <h2>Tweaks</h2><p>This theme is built upon the Base theme inside the Moodle core. If you want to modify this theme, we recommend that you first duplicate it, then rename it before making your changes. This will prevent your customized theme from being overwritten by future Moodle upgrades, and you\'ll still have the original files if you make a mess. More information on modifying themes can be found in the <a href="http://docs.moodle.org/en/Theme">MoodleDocs</a>.</p><h2>Credits</h2><p>This theme was originally designed for Moodle 1.9 by Patrick Malley. It was then coded for 2.0 and is maintained by Sam Hemelryk at Moodle HQ. He can be contacted at sam@moodle.com.</p><h2>License</h2><p>This, and all other themes included in the Moodle core, are licensed under the <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>.</div></div>';
$string['tagline'] = 'Tagline';
$string['taglinedesc'] = 'Whatever text you add to this Tagline text box will be displayed below the heading on the front page of your Moodle site only.';
115 changes: 115 additions & 0 deletions theme/anomaly/layout/frontpage.php
@@ -0,0 +1,115 @@
<?php

$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);
$hassidepost = $PAGE->blocks->region_has_content('side-post', $OUTPUT);
$showsidepre = $hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT);
$showsidepost = $hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT);

$hastagline = (!empty($PAGE->theme->settings->tagline));

$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

$bodyclasses = array();
if ($showsidepre && !$showsidepost) {
$bodyclasses[] = 'side-pre-only';
} else if ($showsidepost && !$showsidepre) {
$bodyclasses[] = 'side-post-only';
} else if (!$showsidepost && !$showsidepre) {
$bodyclasses[] = 'content-only';
}
if ($hascustommenu) {
$bodyclasses[] = 'has_custom_menu';
}

echo $OUTPUT->doctype() ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
<title><?php echo $PAGE->title ?></title>
<link rel="shortcut icon" href="<?php echo $OUTPUT->pix_url('favicon', 'theme')?>" />
<meta name="description" content="<?php p(strip_tags(format_text($SITE->summary, FORMAT_HTML))) ?>" />
<?php echo $OUTPUT->standard_head_html() ?>
</head>
<body id="<?php p($PAGE->bodyid) ?>" class="<?php p($PAGE->bodyclasses.' '.join(' ', $bodyclasses)) ?>">
<?php echo $OUTPUT->standard_top_of_body_html() ?>

<div id="page">

<div id="page-header">

<div class="rounded-corner top-left"></div>
<div class="rounded-corner top-right"></div>

<div class="headermenu"><?php
echo $OUTPUT->login_info();
echo $OUTPUT->lang_menu();
echo $PAGE->headingmenu;
?></div>

<h1 class="headermain"><?php echo $PAGE->heading ?></h1>

<?php if ($hastagline) { ?>
<h2 class="tagline"><?php echo $PAGE->theme->settings->tagline;?></h2>
<?php } ?>


<?php
if ($hascustommenu) { ?>
<div id="custommenu"><?php echo $custommenu; ?></div>
<?php
} ?>

</div>
<!-- END OF HEADER -->

<div id="page-content">
<div id="region-main-box">
<div id="region-post-box">

<div id="region-main-wrap">
<div id="region-main">
<div class="region-content">
<?php echo $OUTPUT->main_content() ?>
</div>
</div>
</div>

<?php if ($hassidepre) { ?>
<div id="region-pre" class="block-region">
<div class="region-content">
<?php echo $OUTPUT->blocks_for_region('side-pre') ?>
</div>
</div>
<?php } ?>

<?php if ($hassidepost) { ?>
<div id="region-post" class="block-region">
<div class="region-content">
<?php echo $OUTPUT->blocks_for_region('side-post') ?>
</div>
</div>
<?php } ?>

</div>
</div>
</div>

<!-- START OF FOOTER -->
<div id="page-footer">
<p class="helplink">
<?php echo page_doc_link(get_string('moodledocslink')) ?>
</p>

<?php
echo $OUTPUT->login_info();
echo $OUTPUT->home_link();
echo $OUTPUT->standard_footer_html();
?>
<div class="rounded-corner bottom-left"></div>
<div class="rounded-corner bottom-right"></div>
</div>
<div class="clearfix"></div>
</div>
<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>
35 changes: 19 additions & 16 deletions theme/anomaly/layout/general.php
Expand Up @@ -3,13 +3,26 @@
$hasheading = ($PAGE->heading);
$hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());
$hasfooter = (empty($PAGE->layout_options['nofooter']));
$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);
$hassidepost = $PAGE->blocks->region_has_content('side-post', $OUTPUT);
$showsidepre = $hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT);
$showsidepost = $hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT);
$hassidepre = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-pre', $OUTPUT));
$hassidepost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-post', $OUTPUT));
$haslogininfo = (empty($PAGE->layout_options['nologininfo']));

$showsidepre = ($hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT));
$showsidepost = ($hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT));

$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

$courseheader = $coursecontentheader = $coursecontentfooter = $coursefooter = '';
if (empty($PAGE->layout_options['nocourseheaderfooter'])) {
$courseheader = $OUTPUT->course_header();
$coursecontentheader = $OUTPUT->course_content_header();
if (empty($PAGE->layout_options['nocoursefooter'])) {
$coursecontentfooter = $OUTPUT->course_content_footer();
$coursefooter = $OUTPUT->course_footer();
}
}

$bodyclasses = array();
if ($showsidepre && !$showsidepost) {
$bodyclasses[] = 'side-pre-only';
Expand All @@ -25,16 +38,6 @@
$bodyclasses[] = 'hasnavbar';
}

$courseheader = $coursecontentheader = $coursecontentfooter = $coursefooter = '';
if (empty($PAGE->layout_options['nocourseheaderfooter'])) {
$courseheader = $OUTPUT->course_header();
$coursecontentheader = $OUTPUT->course_content_header();
if (empty($PAGE->layout_options['nocoursefooter'])) {
$coursecontentfooter = $OUTPUT->course_content_footer();
$coursefooter = $OUTPUT->course_footer();
}
}

echo $OUTPUT->doctype() ?>
<html <?php echo $OUTPUT->htmlattributes() ?>>
<head>
Expand Down Expand Up @@ -65,7 +68,7 @@
<?php } ?>
<?php if ($hascustommenu) { ?>
<div id="custommenu"><?php echo $custommenu; ?></div>
<?php } ?>
<?php } ?>

<?php if ($hasnavbar) { ?>
<div class="navbar clearfix">
Expand Down Expand Up @@ -131,4 +134,4 @@
</div>
<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>
</html>
15 changes: 10 additions & 5 deletions theme/anomaly/layout/report.php
Expand Up @@ -3,8 +3,13 @@
$hasheading = ($PAGE->heading);
$hasnavbar = (empty($PAGE->layout_options['nonavbar']) && $PAGE->has_navbar());
$hasfooter = (empty($PAGE->layout_options['nofooter']));
$hassidepre = $PAGE->blocks->region_has_content('side-pre', $OUTPUT);
$showsidepre = $hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT);
$hassidepre = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-pre', $OUTPUT));
$hassidepost = (empty($PAGE->layout_options['noblocks']) && $PAGE->blocks->region_has_content('side-post', $OUTPUT));
$haslogininfo = (empty($PAGE->layout_options['nologininfo']));

$showsidepre = ($hassidepre && !$PAGE->blocks->region_completely_docked('side-pre', $OUTPUT));
$showsidepost = ($hassidepost && !$PAGE->blocks->region_completely_docked('side-post', $OUTPUT));

$custommenu = $OUTPUT->custom_menu();
$hascustommenu = (empty($PAGE->layout_options['nocustommenu']) && !empty($custommenu));

Expand Down Expand Up @@ -58,8 +63,8 @@
<div id="course-header"><?php echo $courseheader; ?></div>
<?php } ?>
<?php if ($hascustommenu) { ?>
<div id="custommenu"><?php echo $custommenu; ?></div>
<?php } ?>
<div id="custommenu"><?php echo $custommenu; ?></div>
<?php } ?>

<?php if ($hasnavbar) { ?>
<div class="navbar clearfix">
Expand Down Expand Up @@ -110,4 +115,4 @@
</div>
<?php echo $OUTPUT->standard_end_of_body_html() ?>
</body>
</html>
</html>
30 changes: 24 additions & 6 deletions theme/anomaly/lib.php
@@ -1,8 +1,26 @@
<?php

/**
* Functions needed by the anomaly theme should be put here.
*
* Any functions that get created here should ALWAYS contain the theme name
* to reduce complications for other theme designers who may be copying this theme.
*/
function anomaly_process_css($css, $theme) {

// Set custom CSS
if (!empty($theme->settings->customcss)) {
$customcss = $theme->settings->customcss;
} else {
$customcss = null;
}
$css = anomaly_set_customcss($css, $customcss);

return $css;
}

function anomaly_set_customcss($css, $customcss) {
$tag = '[[setting:customcss]]';
$replacement = $customcss;
if (is_null($replacement)) {
$replacement = '';
}

$css = str_replace($tag, $replacement, $css);

return $css;
}
23 changes: 23 additions & 0 deletions theme/anomaly/settings.php
@@ -0,0 +1,23 @@
<?php

defined('MOODLE_INTERNAL') || die;

if ($ADMIN->fulltree) {

// Tagline setting
$name = 'theme_anomaly/tagline';
$title = get_string('tagline','theme_anomaly');
$description = get_string('taglinedesc', 'theme_anomaly');
$default = '';
$setting = new admin_setting_configtext($name, $title, $description, $default);
$settings->add($setting);

// Custom CSS file
$name = 'theme_anomaly/customcss';
$title = get_string('customcss','theme_anomaly');
$description = get_string('customcssdesc', 'theme_anomaly');
$default = '';
$setting = new admin_setting_configtextarea($name, $title, $description, $default);
$settings->add($setting);

}
2 changes: 1 addition & 1 deletion theme/anomaly/style/base.css
Expand Up @@ -2,7 +2,7 @@
* Core
*/

h1, h2, h3, h4, h5 {
h1, h1.headermain, h2, h2.tagline, h3, h4, h5 {
font-family: Georgia,Times,"Times New Roman",serif;
}

Expand Down

0 comments on commit 009fb7d

Please sign in to comment.