MDL-19077 - Finish eliminating customcorners-specific code in core.

The custom-corners-specific code now in theme/customcornser/renderers.php
and lib/deprecatedlib.php.

Also, $CFG->pixpath is now causing more problems than ever. If it is
giving your problems, please call $OUTPUT->initialise_deprecated_cfg_pixpath()
as a temporary fix. As you can imagine, we are thinking about a better
long-term fix, which is why that method as a silly, and easy to grep name.
This commit is contained in:
tjhunt 2009-06-29 08:17:31 +00:00
parent 82afb58797
commit a5cb8d6987
9 changed files with 537 additions and 366 deletions

View File

@ -1,7 +1,7 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// 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
@ -11,7 +11,7 @@
// 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/>.
@ -130,7 +130,7 @@ function isguest($userid=0) {
/**
* Get the guest user information from the database
*
* @todo Is object(user) a correct return type? Or is array the proper return type with a
* @todo Is object(user) a correct return type? Or is array the proper return type with a
* note that the contents include all details for a user.
*
* @return object(user) An associative array with the details of the guest user account.
@ -1567,7 +1567,7 @@ function update_record($table, $dataobject) {
* @param mixed $fields
* @param mixed $limitfrom
* @param mixed $limitnum
*
* @return void Throws an error and does nothing
*/
function get_records($table, $field='', $value='', $sort='', $fields='*', $limitfrom='', $limitnum='') {
@ -1727,7 +1727,7 @@ function require_js($lib) {
/**
* Makes an upload directory for a particular module.
*
* This funciton has been deprecated by the file API changes in Moodle 2.0.
* This function has been deprecated by the file API changes in Moodle 2.0.
*
* @deprecated
* @param int $courseid The id of the course in question - maps to id field of 'course' table.
@ -1739,6 +1739,32 @@ function make_mod_upload_directory($courseid) {
return make_upload_directory($courseid .'/'. $CFG->moddata);
}
/**
* This is a slight variatoin on the standard_renderer_factory that uses
* custom_corners_core_renderer instead of moodle_core_renderer.
*
* This generates the slightly different HTML that the custom_corners theme expects.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @deprecated Required to make the old $THEME->customcorners setting work.
*/
class custom_corners_renderer_factory extends standard_renderer_factory {
/**
* Constructor.
* @param object $theme the theme we are rendering for.
* @param moodle_page $page the page we are doing output for.
*/
public function __construct($theme, $page) {
global $CFG;
parent::__construct($theme, $page);
require_once($CFG->themedir . '/customcorners/renderers.php');
$this->renderers = array('core' => new custom_corners_core_renderer($this->opencontainers, $this->page, $this));
}
}
/**
* Prints some red text using echo
*
@ -1959,7 +1985,7 @@ function print_container_end($return=false) {
* @param string $style Optional style to display message text in
* @param string $align Alignment option
* @param bool $return whether to return an output string or echo now
* @return string|bool Depending on $result
* @return string|bool Depending on $result
*/
function notify($message, $classes = 'notifyproblem', $align = 'center', $return = false) {
global $OUTPUT;
@ -2111,4 +2137,77 @@ function print_footer($course = NULL, $usercourse = NULL, $return = false) {
} else {
echo $output;
}
}
}
/**
* Prints a nice side block with an optional header. The content can either
* be a block of HTML or a list of text with optional icons.
*
* @todo Finish documenting this function. Show example of various attributes, etc.
*
* @static int $block_id Increments for each call to the function
* @param string $heading HTML for the heading. Can include full HTML or just
* plain text - plain text will automatically be enclosed in the appropriate
* heading tags.
* @param string $content HTML for the content
* @param array $list an alternative to $content, it you want a list of things with optional icons.
* @param array $icons optional icons for the things in $list.
* @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
* @param array $attributes an array of attribute => value pairs that are put on the
* outer div of this block. If there is a class attribute ' sideblock' gets appended to it. If there isn't
* already a class, class='sideblock' is used.
* @param string $title Plain text title, as embedded in the $heading.
* @deprecated
*/
function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
global $OUTPUT;
$bc = new block_contents();
$bc->heading = $heading;
$bc->content = $content;
$bc->list = $list;
$bc->icons = $icons;
$bc->footer = $footer;
$bc->title = $title;
if (isset($attributes['id'])) {
$bc->id = $attributes['id'];
unset($attributes['id']);
}
if (isset($attributes['class'])) {
$bc->set_classes($attributes['class']);
unset($attributes['class']);
}
$bc->attributes = $attributes;
echo $OUTPUT->block($bc);
}
/**
* Starts a nice side block with an optional header.
*
* @todo Finish documenting this function
*
* @global object
* @global object
* @param string $heading HTML for the heading. Can include full HTML or just
* plain text - plain text will automatically be enclosed in the appropriate
* heading tags.
* @param array $attributes HTML attributes to apply if possible
* @deprecated
*/
function print_side_block_start($heading='', $attributes = array()) {
throw new coding_exception('print_side_block_start has been deprecated. Please cahnge your code to use $OUTPUT->block().');
}
/**
* Print table ending tags for a side block box.
*
* @global object
* @global object
* @param array $attributes HTML attributes to apply if possible [id]
* @param string $title
* @deprecated
*/
function print_side_block_end($attributes = array(), $title='') {
throw new coding_exception('print_side_block_end has been deprecated. Please cahnge your code to use $OUTPUT->block().');
}

View File

@ -196,29 +196,6 @@ class standard_renderer_factory extends renderer_factory_base {
}
/**
* This is a slight variatoin on the standard_renderer_factory that uses
* custom_corners_core_renderer instead of moodle_core_renderer.
*
* This generates the slightly different HTML that the custom_corners theme expects.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class custom_corners_renderer_factory extends standard_renderer_factory {
/**
* Constructor.
* @param object $theme the theme we are rendering for.
* @param moodle_page $page the page we are doing output for.
*/
public function __construct($theme, $page) {
parent::__construct($theme, $page);
$this->renderers = array('core' => new custom_corners_core_renderer($this->opencontainers, $this->page, $this));
}
}
/**
* This is a slight variation on the standard_renderer_factory used by CLI scripts.
*
@ -242,7 +219,7 @@ class cli_renderer_factory extends standard_renderer_factory {
/**
* This is renderer factory allows themes to override the standard renderers using
* php code.
*
*
* It will load any code from theme/mytheme/renderers.php and
* theme/parenttheme/renderers.php, if then exist. Then whenever you ask for
* a renderer for 'component', it will create a mytheme_component_renderer or a
@ -313,7 +290,7 @@ class theme_overridden_renderer_factory extends standard_renderer_factory {
* exists. Then, a call to $OUTPUT->greeting() will cause the template
* /theme/yourtheme/templates/core/greeting.php to be rendered, with the variable
* $name available. The greeting.php template might contain
*
*
* <pre>
* <h1>Hello <?php echo $name ?>!</h1>
* </pre>
@ -421,6 +398,9 @@ class moodle_renderer_base {
}
}
protected function output_attributes($attributes) {
if (empty($attributes)) {
$attributes = array();
}
$output = '';
foreach ($attributes as $name => $value) {
$output .= $this->output_attribute($name, $value);
@ -812,7 +792,7 @@ class moodle_core_renderer extends moodle_renderer_base {
$output .= ob_get_contents();
ob_end_clean();
$output .= $this->page->requires->get_head_code();
foreach ($this->page->alternateversions as $type => $alt) {
$output .= $this->output_empty_tag('link', array('rel' => 'alternate',
'type' => $type, 'title' => $alt->title, 'href' => $alt->url));
@ -1113,12 +1093,93 @@ class moodle_core_renderer extends moodle_renderer_base {
return $output . $footer;
}
/**
* Prints a nice side block with an optional header.
*
* The content is described
* by a {@link block_contents} object.
*
* @param block $content HTML for the content
* @return string the HTML to be output.
*/
function block($bc) {
$bc = clone($bc);
$bc->prepare();
$title = strip_tags($bc->title);
if (empty($title)) {
$output = '';
$skipdest = '';
} else {
$output = $this->output_tag('a', array('href' => '#sb-' . $bc->skipid, 'class' => 'skip-block'),
get_string('skipa', 'access', $title));
$skipdest = $this->output_tag('span', array('id' => 'sb-' . $bc->skipid, 'class' => 'skip-block-to'), '');
}
$bc->attributes['id'] = $bc->id;
$bc->attributes['class'] = $bc->get_classes_string();
$output .= $this->output_start_tag('div', $bc->attributes);
if ($bc->heading) {
// Some callers pass in complete html for the heading, which may include
// complicated things such as the 'hide block' button; some just pass in
// text. If they only pass in plain text i.e. it doesn't include a
// <div>, then we add in standard tags that make it look like a normal
// page block including the h2 for accessibility
if (strpos($bc->heading, '</div>') === false) {
$bc->heading = $this->output_tag('div', array('class' => 'title'),
$this->output_tag('h2', null, $bc->heading));
}
$output .= $this->output_tag('div', array('class' => 'header'), $bc->heading);
}
$output .= $this->output_start_tag('div', array('class' => 'content'));
if ($bc->content) {
$output .= $bc->content;
} else if ($bc->list) {
$row = 0;
$output .= $this->output_start_tag('ul', array('class' => 'list'));
$items = array();
foreach ($bc->list as $key => $string) {
$item = $this->output_start_tag('li', array('class' => 'r' . $row));
if ($bc->icons) {
$item .= $this->output_tag('div', array('class' => 'icon column c0'), $bc->icons[$key]);
}
$item .= $this->output_tag('div', array('class' => 'column c1'), $string);
$item .= $this->output_end_tag('li');
$items[] = $item;
$row = 1 - $row; // Flip even/odd.
}
$output .= $this->output_tag('ul', array('class' => 'list'), implode("\n", $items));
}
if ($bc->footer) {
$output .= $this->output_tag('div', array('class' => 'footer'), $bc->footer);
}
$output .= $this->output_end_tag('div');
$output .= $this->output_end_tag('div');
$output .= $skipdest;
if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
$strshow = addslashes_js(get_string('showblocka', 'access', $title));
$strhide = addslashes_js(get_string('hideblocka', 'access', $title));
$output .= $this->page->requires->js_function_call('elementCookieHide', array(
$bc->id, $strshow, $strhide))->asap();
}
return $output;
}
public function link_to_popup_window() {
}
public function button_to_popup_window() {
}
public function close_window_button($buttontext = null, $reloadopener = false) {
@ -1344,6 +1405,21 @@ class moodle_core_renderer extends moodle_renderer_base {
public function container_end() {
return $this->opencontainers->pop('container');
}
/**
* At the moment we frequently have a problem with $CFG->pixpath not being
* initialised when it is needed. Unfortunately, there is no nice way to handle
* this. I think we need to replace $CFG->pixpath with something like $OUTPUT->icon(...).
* However, until then, we need a way to force $CFG->pixpath to be initialised,
* to fix the error messages, and that is what this function if for.
*/
public function initialise_deprecated_cfg_pixpath() {
// Actually, we don't have to do anything here. Just calling any method
// of $OBJECT is enough. However, if the only reason you are calling
// an $OUTPUT method is to get $CFG->pixpath initialised, please use this
// method, so we can find them and clean them up later once we have
// found a better replacement for $CFG->pixpath.
}
}
@ -1376,7 +1452,7 @@ class moodle_html_component {
if (is_array($classes)) {
return $classes;
} else {
return explode(' '. trim($classes));
return explode(' ', trim($classes));
}
}
@ -1532,6 +1608,63 @@ class moodle_select_menu extends moodle_html_component {
}
/**
* This class hold all the information required to describe a Moodle block.
*
* That is, it holds all the different bits of HTML content that need to be put into the block.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class block_contents extends moodle_html_component {
protected static $idcounter = 1;
/**
* @param string $heading HTML for the heading. Can include full HTML or just
* plain text - plain text will automatically be enclosed in the appropriate
* heading tags.
*/
public $heading = '';
/**
* @param string $title Plain text title, as embedded in the $heading.
*/
public $title = '';
/**
* @param string $content HTML for the content
*/
public $content = '';
/**
* @param array $list an alternative to $content, it you want a list of things with optional icons.
*/
public $list = array();
/**
* @param array $icons optional icons for the things in $list.
*/
public $icons = array();
/**
* @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
*/
public $footer = '';
/**
* @param array $attributes an array of attribute => value pairs that are put on the
* outer div of this block. {@link $id} and {@link $classes} attributes should be set separately.
*/
public $attributes = array();
/**
* @param integer $skipid do not set this manually. It is set automatically be the {@link prepare()} method.
*/
public $skipid;
/* @see lib/moodle_html_component#prepare() */
public function prepare() {
$this->skipid = self::$idcounter;
self::$idcounter += 1;
$this->add_class('sideblock');
parent::prepare();
}
}
/**
* A renderer that generates output for commandlines scripts.
*
@ -1582,81 +1715,3 @@ class cli_core_renderer extends moodle_core_renderer {
}
}
/**
* A renderer for the custom corner theme, and other themes based on it.
*
* Generates the slightly different HTML that the custom corners theme wants.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class custom_corners_core_renderer extends moodle_core_renderer {
protected $wraplevel = 1;
protected function custom_corners_divs($classes = '', $idbase = '') {
if (strpos($classes, 'clearfix') !== false) {
$clearfix = ' clearfix';
$classes = trim(str_replace('clearfix', '', $classes));
} else {
$clearfix = '';
}
// Analise if we want ids for the custom corner elements
$id = '';
$idbt = '';
$idi1 = '';
$idi2 = '';
$idi3 = '';
$idbb = '';
if ($idbase) {
$id = $idbase;
$idbt = $idbase . '-bt';
$idi1 = $idbase . '-i1';
$idi2 = $idbase . '-i2';
$idi3 = $idbase . '-i3';
$idbb = $idbase . '-bb';
}
// Create start tags.
$start = $this->output_start_tag('div', array('id' => $id, 'class' => "wrap wraplevel{$this->wraplevel} $classes")) . "\n";
$start .= $this->output_tag('div', array('id' => $idbt, 'class' => 'bt'), '<div>&nbsp;</div>') . "\n";
$start .= $this->output_start_tag('div', array('id' => $idi1, 'class' => 'i1'));
$start .= $this->output_start_tag('div', array('id' => $idi2, 'class' => 'i2'));
$start .= $this->output_start_tag('div', array('id' => $idi3, 'class' => "i3$clearfix"));
// Create end tags.
$end = $this->output_end_tag('div');
$end .= $this->output_end_tag('div');
$end .= $this->output_end_tag('div');
$end .= $this->output_tag('div', array('id' => $idbb, 'class' => 'bb'), '<div>&nbsp;</div>') . "\n";
$end .= $this->output_end_tag('div');
return array($start, $end);
}
public function box_start($classes = 'generalbox', $id = '') {
list($start, $end) = $this->custom_corners_divs('ccbox box ' . moodle_renderer_base::prepare_classes($classes), $id);
$this->opencontainers->push('box', $end);
$this->wraplevel += 1;
return $start;
}
public function box_end() {
$this->wraplevel -= 1;
return parent::box_end();
}
public function container_start($classes = '', $id = '') {
list($start, $end) = $this->custom_corners_divs(moodle_renderer_base::prepare_classes($classes), $id);
$this->opencontainers->push('container', $end);
$this->wraplevel += 1;
return $start;
}
public function container_end() {
$this->wraplevel -= 1;
return parent::container_end();
}
}

View File

@ -3201,7 +3201,14 @@ function theme_setup($theme = '', $params=NULL) {
// Support legacy themes, by setting sensible defaults for some of the new
// properties that were introduced in Moodle 2.0.
if (empty($THEME->rendererfactory)) {
$THEME->rendererfactory = 'standard_renderer_factory';
if (!empty($THEME->customcorners)) {
// $THEME->customcorners is deprecated but we provide support for it via the
// custom_corners_renderer_factory class in lib/deprecatedlib.php
debugging('$THEME->customcorners is deprecated. Please use the new $THEME->rendererfactory to control HTML generation.', DEBUG_DEVELOPER);
$THEME->rendererfactory = 'custom_corners_renderer_factory';
} else {
$THEME->rendererfactory = 'standard_renderer_factory';
}
}
if (empty($THEME->blockregions)) {
$THEME->blockregions = array('side-pre', 'side-post');
@ -5906,191 +5913,6 @@ function rebuildnolinktag($text) {
return $text;
}
/**
* Prints a nice side block with an optional header. The content can either
* be a block of HTML or a list of text with optional icons.
*
* @todo Finish documenting this function. Show example of various attributes, etc.
*
* @static int $block_id Increments for each call to the function
* @param string $heading HTML for the heading. Can include full HTML or just
* plain text - plain text will automatically be enclosed in the appropriate
* heading tags.
* @param string $content HTML for the content
* @param array $list an alternative to $content, it you want a list of things with optional icons.
* @param array $icons optional icons for the things in $list.
* @param string $footer Extra HTML content that gets output at the end, inside a &lt;div class="footer">
* @param array $attributes an array of attribute => value pairs that are put on the
* outer div of this block. If there is a class attribute ' sideblock' gets appended to it. If there isn't
* already a class, class='sideblock' is used.
* @param string $title Plain text title, as embedded in the $heading.
* @return void Echo's output
*/
function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array(), $title='') {
//Accessibility: skip block link, with title-text (or $block_id) to differentiate links.
static $block_id = 0;
$block_id++;
$skip_text = get_string('skipa', 'access', strip_tags($title));
$skip_link = '<a href="#sb-'.$block_id.'" class="skip-block">'.$skip_text.'</a>';
$skip_dest = '<span id="sb-'.$block_id.'" class="skip-block-to"></span>';
$strip_title = strip_tags($title);
if (! empty($strip_title)) {
echo $skip_link;
}
//ELSE: a single link on a page "Skip block 4" is too confusing - ignore.
print_side_block_start($heading, $attributes);
// The content.
if ($content) {
echo $content;
} else {
if ($list) {
$row = 0;
//Accessibility: replaced unnecessary table with list, see themes/standard/styles_layout.css
echo "\n<ul class='list'>\n";
foreach ($list as $key => $string) {
echo '<li class="r'. $row .'">';
if ($icons) {
echo '<div class="icon column c0">'. $icons[$key] .'</div>';
}
echo '<div class="column c1">'. $string .'</div>';
echo "</li>\n";
$row = $row ? 0:1;
}
echo "</ul>\n";
}
}
// Footer, if any.
if ($footer) {
echo '<div class="footer">'. $footer .'</div>';
}
print_side_block_end($attributes, $title);
echo $skip_dest;
}
/**
* Starts a nice side block with an optional header.
*
* @todo Finish documenting this function
*
* @global object
* @global object
* @param string $heading HTML for the heading. Can include full HTML or just
* plain text - plain text will automatically be enclosed in the appropriate
* heading tags.
* @param array $attributes HTML attributes to apply if possible
* @return void Echo's output
*/
function print_side_block_start($heading='', $attributes = array()) {
global $CFG, $THEME;
// If there are no special attributes, give a default CSS class
if (empty($attributes) || !is_array($attributes)) {
$attributes = array('class' => 'sideblock');
} else if(!isset($attributes['class'])) {
$attributes['class'] = 'sideblock';
} else if(!strpos($attributes['class'], 'sideblock')) {
$attributes['class'] .= ' sideblock';
}
// OK, the class is surely there and in addition to anything
// else, it's tagged as a sideblock
/*
// IE misery: if I do it this way, blocks which start hidden cannot be "unhidden"
// If there is a cookie to hide this thing, start it hidden
if (!empty($attributes['id']) && isset($_COOKIE['hide:'.$attributes['id']])) {
$attributes['class'] = 'hidden '.$attributes['class'];
}
*/
$attrtext = '';
foreach ($attributes as $attr => $val) {
$attrtext .= ' '.$attr.'="'.$val.'"';
}
echo '<div '.$attrtext.'>';
if (!empty($THEME->customcorners)) {
echo '<div class="wrap">'."\n";
}
if ($heading) {
// Some callers pass in complete html for the heading, which may include
// complicated things such as the 'hide block' button; some just pass in
// text. If they only pass in plain text i.e. it doesn't include a
// <div>, then we add in standard tags that make it look like a normal
// page block including the h2 for accessibility
if(strpos($heading,'</div>')===false) {
$heading='<div class="title"><h2>'.$heading.'</h2></div>';
}
echo '<div class="header">';
if (!empty($THEME->customcorners)) {
echo '<div class="bt"><div>&nbsp;</div></div>';
echo '<div class="i1"><div class="i2">';
echo '<div class="i3">';
}
echo $heading;
if (!empty($THEME->customcorners)) {
echo '</div></div></div>';
}
echo '</div>';
} else {
if (!empty($THEME->customcorners)) {
echo '<div class="bt"><div>&nbsp;</div></div>';
}
}
if (!empty($THEME->customcorners)) {
echo '<div class="i1"><div class="i2">';
echo '<div class="i3">';
}
echo '<div class="content">';
}
/**
* Print table ending tags for a side block box.
*
* @global object
* @global object
* @param array $attributes HTML attributes to apply if possible [id]
* @param string $title
* @return void Echo's output
*/
function print_side_block_end($attributes = array(), $title='') {
global $CFG, $THEME;
echo '</div>';
if (!empty($THEME->customcorners)) {
echo '</div></div></div><div class="bb"><div>&nbsp;</div></div></div>';
}
echo '</div>';
$strshow = addslashes_js(get_string('showblocka', 'access', strip_tags($title)));
$strhide = addslashes_js(get_string('hideblocka', 'access', strip_tags($title)));
// IE workaround: if I do it THIS way, it works! WTF?
if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
echo '<script type="text/javascript">'."\n//<![CDATA[\n".'elementCookieHide("'.$attributes['id'].
'","'.$strshow.'","'.$strhide."\");\n//]]>\n".'</script>';
}
}
/**
* @todo Remove this deprecated function when no longer used
* @deprecated since Moodle 2.0 - use $PAGE->pagetype instead of the .
@ -6812,7 +6634,6 @@ abstract class moodle_progress_trace {
* Called when the processing is finished.
*/
public function finished() {
}
}

View File

@ -473,15 +473,9 @@ if ($quiz_qbanktool) {
$bankclass = 'collapsed';
$quizcontentsclass = 'quizwhenbankcollapsed';
}
print_side_block_start(get_string('questionbankcontents', 'quiz') .
' <a href="' . $thispageurl->out(false, array('qbanktool' => '1')) .
'" id="showbankcmd">[' . get_string('show').
']</a>
<a href="' . $thispageurl->out(false, array('qbanktool' => '0')) .
'" id="hidebankcmd">[' . get_string('hide').
']</a>
', array('class' => 'questionbankwindow ' . $bankclass));
// Nasty short-term hack, becuase I am getting rid of separate print_side_block_start/end functions.
ob_start();
echo '<span id="questionbank"></span>';
echo '<div class="container">';
echo '<div id="module" class="module">';
@ -495,7 +489,17 @@ $questionbank->display('editq',
echo '</div>';
echo '</div>';
echo '</div>';
print_side_block_end();
$qbhtml = ob_get_contents();
ob_end_clean();
print_side_block(get_string('questionbankcontents', 'quiz') .
' <a href="' . $thispageurl->out(false, array('qbanktool' => '1')) .
'" id="showbankcmd">[' . get_string('show').
']</a>
<a href="' . $thispageurl->out(false, array('qbanktool' => '0')) .
'" id="hidebankcmd">[' . get_string('hide').
']</a>
', $qbhtml, null, null, '', array('class' => 'questionbankwindow ' . $bankclass));
echo '<div class="quizcontents ' . $quizcontentsclass . '" id="quizcontentsblock">';
if ($quiz->shufflequestions) {

View File

@ -11,6 +11,9 @@
/// Let's know if we are using a customcorners theme. It implies new calculations
/// within the resizeiframe function.
// TODO this will no longer work. We have the more general mechanism using renderers/renderer_factories
// to determine what HTML is output. If this JavaScript is really still necessary, then we will have
// to find another way to handle this.
if (!empty($THEME->customcorners)) {
$customcorners = 'true';
} else {

View File

@ -148,7 +148,7 @@ class question_category_object {
* Gets necessary strings and sets relevant path information
*/
public function question_category_object($page, $pageurl, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
global $CFG, $COURSE;
global $CFG, $COURSE, $OUTPUT;
$this->tab = str_repeat('&nbsp;', $this->tabsize);
@ -173,6 +173,7 @@ class question_category_object {
$this->str->cancel = get_string('cancel');
$this->str->editcategories = get_string('editcategories', 'quiz');
$this->str->page = get_string('page');
$OUTPUT->initialise_deprecated_cfg_pixpath();
$this->pixpath = $CFG->pixpath;
$this->pageurl = $pageurl;

View File

@ -1,15 +1,15 @@
<h3>"Custom corners", the Moodle theme with graphics for transparent custom corners and borders.</h3>
<p>
This theme contains graphics for customising corners and borders. It makes use of a technique described by
This theme contains graphics for customising corners and borders. It makes use of a technique described by
Roger Johansson - see
"<a href="http://www.456bereastreet.com/archive/200506/customising_custom_corners_and_borders/">customising_custom_corners_and_borders</a>"
However, the custom corners theme doesn't use all the JavaScript mentioned by Roger Johansson.
Instead, divs are added when "$THEME->customcorners = true;" is set in config.php.
However, the custom corners theme doesn't use all the JavaScript mentioned by Roger Johansson.
Instead, divs are added when using the custom_corners_core_renderer (defined in renderers.php) instead of moodle_core renderer.
</p>
<p>
Note: Custom corners is included in Moodle 1.9 as an experimental feature.
Note: Custom corners is included in Moodle 1.9 as an experimental feature.
</p>
<p>

View File

@ -1,12 +1,12 @@
<?php // $Id$
////////////////////////////////////////////////////////////////////////////////
/// This file contains a few configuration variables that control
/// This file contains a few configuration variables that control
/// how Moodle uses this theme.
////////////////////////////////////////////////////////////////////////////////
$THEME->sheets = array('user_styles');
/// This variable is an array containing the names of all the
/// This variable is an array containing the names of all the
/// stylesheet files you want included in this theme, and in what order
////////////////////////////////////////////////////////////////////////////////
@ -14,67 +14,67 @@ $THEME->sheets = array('user_styles');
$THEME->standardsheets = array('styles_layout', 'styles_color');
/// This variable can be set to an array containing
/// filenames from the *STANDARD* theme. If the
/// array exists, it will be used to choose the
/// filenames from the *STANDARD* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->standardsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->parent = '';
$THEME->parent = '';
/// 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
/// This can make it easy to make modifications to another
/// theme without having to actually change the files
/// If this variable is empty or false then a parent theme
/// If this variable is empty or false then a parent theme
/// is not used.
////////////////////////////////////////////////////////////////////////////////
$THEME->parentsheets = false;
$THEME->parentsheets = false;
/// This variable can be set to an array containing
/// filenames from a chosen *PARENT* theme. If the
/// array exists, it will be used to choose the
/// filenames from a chosen *PARENT* theme. If the
/// array exists, it will be used to choose the
/// files to include in the standard style sheet.
/// When false, then no files are used.
/// When true or NON-EXISTENT, then ALL standard files are used.
/// This parameter can be used, for example, to prevent
/// This parameter can be used, for example, to prevent
/// having to override too many classes.
/// Note that the trailing .css should not be included
/// eg $THEME->parentsheets = array('styles_layout','styles_fonts','styles_color');
////////////////////////////////////////////////////////////////////////////////
$THEME->modsheets = true;
$THEME->modsheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Activity modules and
/// include them. This allows modules to provide some basic
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Activity modules and
/// include them. This allows modules to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->blocksheets = true;
$THEME->blocksheets = true;
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Block modules and
/// include them. This allows Blocks to provide some basic
/// When this is enabled, then this theme will search for
/// files named "styles.php" inside all Block modules and
/// include them. This allows Blocks to provide some basic
/// layouts so they work out of the box.
/// It is HIGHLY recommended to leave this enabled.
$THEME->langsheets = false;
/// By setting this to true, then this theme will search for
/// By setting this to true, then this theme will search for
/// a file named "styles.php" inside the current language
/// directory. This allows different languages to provide
/// directory. This allows different languages to provide
/// different styles.
@ -84,7 +84,7 @@ $THEME->block_r_min_width = 180;
$THEME->block_r_max_width = 210;
/// These values define the min and max width of the left and right
/// sieblocks in the course pages. If not set or false the standard
/// sieblocks in the course pages. If not set or false the standard
/// values are taken.
@ -98,37 +98,37 @@ $THEME->block_r_max_width = 210;
$THEME->courseformatsheets = true;
/// When this is enabled, this theme will search for files
/// named "styles.php" inside all course formats and
/// include them. This allows course formats to provide
/// When this is enabled, this theme will search for files
/// named "styles.php" inside all course formats and
/// include them. This allows course formats to provide
/// their own default styles.
$THEME->metainclude = true;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from this theme into the
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from this theme into the
/// <head></head> part of the page.
$THEME->standardmetainclude = true;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the standard theme into the
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the standard theme into the
/// <head></head> part of the page.
$THEME->parentmetainclude = false;
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the parent theme into the
/// When this is enabled (or not set!) then Moodle will try
/// to include a file meta.php from the parent theme into the
/// <head></head> part of the page.
$THEME->navmenuwidth = 50;
/// You can use this to control the cutoff point for strings
/// You can use this to control the cutoff point for strings
/// in the navmenus (list of activities in popup menu etc)
/// Default is 50 characters wide.
@ -137,38 +137,31 @@ $THEME->makenavmenulist = false;
/// By setting this to true, then you will have access to a
/// new variable in your header.html and footer.html called
/// $navmenulist ... this contains a simple XHTML menu of
/// all activities in the current course, mostly useful for
/// $navmenulist ... this contains a simple XHTML menu of
/// all activities in the current course, mostly useful for
/// creating popup navigation menus and so on.
// $THEME->layouttable = array('middle', 'left', 'right');
$THEME->customcorners = true;
/// By setting this to true, Moodle will generate extra divs in
/// all pages to enable graphical rich custom corners and borders.
/// Please have a look at the README with more details.
// $CFG->CSSEdit = true;
/// When this is enabled then Moodle will include all CSS files
/// seperately instead of writing all CSS code into one single
/// CSS file per theme. The single CSS files can then be edited
/// CSS file per theme. The single CSS files can then be edited
/// and saved with interactive CSS editors like CSSEdit.
$THEME->resource_mp3player_colors =
$THEME->resource_mp3player_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
/// With this you can control the colours of the "big" MP3 player
/// With this you can control the colours of the "big" MP3 player
/// that is used for MP3 resources.
$THEME->filter_mediaplugin_colors =
$THEME->filter_mediaplugin_colors =
'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
'waitForPlay=yes';
@ -178,15 +171,15 @@ $THEME->filter_mediaplugin_colors =
$THEME->custompix = false;
/// If true, then this theme must have a "pix"
/// subdirectory that contains copies of all
/// If true, then this theme must have a "pix"
/// subdirectory that contains copies of all
/// files from the moodle/pix directory, plus a
/// "pix/mod" directory containing all the icons
/// "pix/mod" directory containing all the icons
/// for all the activity modules.
////////////////////////////////////////////////////////////////////////////////
$THEME->rendererfactory = 'custom_corners_renderer_factory';
$THEME->rendererfactory = 'theme_overridden_renderer_factory';
/// This is an advanced features that lets you control the HTML that Moodle
/// generates. You need to specify a class that implements the renderer_factory
/// interface. As well as the default 'standard_renderer_factory', there is

View File

@ -0,0 +1,195 @@
<?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/>.
/**
* Functions for generating the HTML that Moodle should output.
*
* Please see http://docs.moodle.org/en/Developement:How_Moodle_outputs_HTML
* for an overview.
*
* @package moodlecore
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later (5)
*/
/**
* A renderer for the custom corner theme, and other themes based on it.
*
* Generates the slightly different HTML that the custom corners theme wants.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since Moodle 2.0
*/
class custom_corners_core_renderer extends moodle_core_renderer {
protected $wraplevel = 1;
protected function custom_corners_divs($classes = '', $idbase = '') {
if (strpos($classes, 'clearfix') !== false) {
$clearfix = ' clearfix';
$classes = trim(str_replace('clearfix', '', $classes));
} else {
$clearfix = '';
}
// Analise if we want ids for the custom corner elements
$id = '';
$idbt = '';
$idi1 = '';
$idi2 = '';
$idi3 = '';
$idbb = '';
if ($idbase) {
$id = $idbase;
$idbt = $idbase . '-bt';
$idi1 = $idbase . '-i1';
$idi2 = $idbase . '-i2';
$idi3 = $idbase . '-i3';
$idbb = $idbase . '-bb';
}
// Create start tags.
$start = $this->output_start_tag('div', array('id' => $id, 'class' => "wrap wraplevel{$this->wraplevel} $classes")) . "\n";
$start .= $this->output_tag('div', array('id' => $idbt, 'class' => 'bt'), '<div>&nbsp;</div>') . "\n";
$start .= $this->output_start_tag('div', array('id' => $idi1, 'class' => 'i1'));
$start .= $this->output_start_tag('div', array('id' => $idi2, 'class' => 'i2'));
$start .= $this->output_start_tag('div', array('id' => $idi3, 'class' => "i3$clearfix"));
// Create end tags.
$end = $this->output_end_tag('div');
$end .= $this->output_end_tag('div');
$end .= $this->output_end_tag('div');
$end .= $this->output_tag('div', array('id' => $idbb, 'class' => 'bb'), '<div>&nbsp;</div>') . "\n";
$end .= $this->output_end_tag('div');
return array($start, $end);
}
public function box_start($classes = 'generalbox', $id = '') {
list($start, $end) = $this->custom_corners_divs('ccbox box ' . moodle_renderer_base::prepare_classes($classes), $id);
$this->opencontainers->push('box', $end);
$this->wraplevel += 1;
return $start;
}
public function box_end() {
$this->wraplevel -= 1;
return parent::box_end();
}
public function container_start($classes = '', $id = '') {
list($start, $end) = $this->custom_corners_divs(moodle_renderer_base::prepare_classes($classes), $id);
$this->opencontainers->push('container', $end);
$this->wraplevel += 1;
return $start;
}
public function container_end() {
$this->wraplevel -= 1;
return parent::container_end();
}
/**
* Prints a nice side block with an optional header.
*
* The content is described
* by a {@link block_contents} object.
*
* @param block $content HTML for the content
* @return string the HTML to be output.
*/
function block($bc) {
$bc = clone($bc);
$bc->prepare();
$title = strip_tags($bc->title);
if (empty($title)) {
$output = '';
$skipdest = '';
} else {
$output = $this->output_tag('a', array('href' => '#sb-' . $bc->skipid, 'class' => 'skip-block'),
get_string('skipa', 'access', $title));
$skipdest = $this->output_tag('span', array('id' => 'sb-' . $bc->skipid, 'class' => 'skip-block-to'), '');
}
$bc->attributes['id'] = $bc->id;
$bc->attributes['class'] = $bc->get_classes_string();
$output .= $this->output_start_tag('div', $bc->attributes);
$output .= $this->output_start_tag('div', array('class' => 'wrap'));
if ($bc->heading) {
// Some callers pass in complete html for the heading, which may include
// complicated things such as the 'hide block' button; some just pass in
// text. If they only pass in plain text i.e. it doesn't include a
// <div>, then we add in standard tags that make it look like a normal
// page block including the h2 for accessibility
if (strpos($bc->heading, '</div>') === false) {
$bc->heading = $this->output_tag('div', array('class' => 'title'),
$this->output_tag('h2', null, $bc->heading));
}
$output .= '<div class="header"><div class="bt"><div>&nbsp;</div></div>';
$output .= '<div class="i1"><div class="i2"><div class="i3">';
$output .= $bc->heading;
$output .= '</div></div></div></div>';
} else {
$output .= '<div class="bt"><div>&nbsp;</div></div>';
}
$output .= '<div class="i1"><div class="i2"><div class="i3"><div class="content">';
if ($bc->content) {
$output .= $bc->content;
} else if ($bc->list) {
$row = 0;
$output .= $this->output_start_tag('ul', array('class' => 'list'));
$items = array();
foreach ($bc->list as $key => $string) {
$item = $this->output_start_tag('li', array('class' => 'r' . $row));
if ($bc->icons) {
$item .= $this->output_tag('div', array('class' => 'icon column c0'), $bc->icons[$key]);
}
$item .= $this->output_tag('div', array('class' => 'column c1'), $string);
$item .= $this->output_end_tag('li');
$items[] = $item;
$row = 1 - $row; // Flip even/odd.
}
$output .= $this->output_tag('ul', array('class' => 'list'), implode("\n", $items));
}
if ($bc->footer) {
$output .= $this->output_tag('div', array('class' => 'footer'), $bc->footer);
}
$output .= '</div></div></div></div><div class="bb"><div>&nbsp;</div></div></div></div>';
$output .= $skipdest;
if (!empty($CFG->allowuserblockhiding) && isset($attributes['id'])) {
$strshow = addslashes_js(get_string('showblocka', 'access', $title));
$strhide = addslashes_js(get_string('hideblocka', 'access', $title));
$output .= $this->page->requires->js_function_call('elementCookieHide', array(
$bc->id, $strshow, $strhide))->asap();
}
return $output;
}
}