* Renderers will normally want to subclass the moodle_renderer_base class.
* (However, if you really know what you are doing, you don't have to do that.)
*
- * There is no separate interface definintion for renderers. The default
+ * There is no separate interface definition for renderers. The default
* moodle_{plugin}_renderer implementation also serves to define the API for
* other implementations of the interface, whether or not they subclass it.
* For example, {@link custom_corners_core_renderer} does subclass
* of the {@link template_renderer} class, whatever type of renderer you ask
* for. This uses the fact that PHP is a dynamic language.
*
- * A particular plugin can defnie multiple renderers if it wishes, using the
+ * A particular plugin can define multiple renderers if it wishes, using the
* $subtype parameter. For example moodle_mod_workshop_renderer,
* moodle_mod_workshop_allocation_manual_renderer etc.
*
* (See {@link standard_icon_finder::__construct} for an example.)
*
* Note that we are planning to change the Moodle icon naming convention before
- * the Moodle 2.0 relase. Therefore, this API will probably change.
+ * the Moodle 2.0 release. Therefore, this API will probably change.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
interface icon_finder {
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->pixpath/i/course.gif";
* then old_icon_url('i/course'); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
+ * @param string $iconname the name of the icon.
* @return string the URL for that icon.
*/
public function old_icon_url($iconname);
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->modpixpath/$mod/icon.gif";
* then mod_icon_url('icon', $mod); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
- * @param $module the module the icon belongs to.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
* @return string the URL for that icon.
*/
public function mod_icon_url($iconname, $module);
*
* There are also some methods and protected variables that are part of the inner
* workings of Moodle's themes system. If you are just editing a theme's config.php
- * file, you cac just ingore those, and the following information for developers.
+ * file, you can just ignore those, and the following information for developers.
*
* Normally, to create an instance of this class, you should use the
* {@link theme_config::load()} factory method to load a themes config.php file.
- * However, normally you don't need to bother, becuase moodle_page (that is, $PAGE)
+ * However, normally you don't need to bother, because moodle_page (that is, $PAGE)
* will create one for you, accessible as $PAGE->theme.
*
* @copyright 2009 Tim Hunt
* @var boolean|array Whether and which stylesheets from the parent theme
* to use in this theme. (Ignored if parent is null)
*
- * Possbile values are:
+ * Possible values are:
* false - no parent theme CSS.
* true - include all the normal parent theme CSS. Currently this means
* array('styles_layout', 'styles_fonts', 'styles_color').
* the changes in the code. Therefore, your theme is less likely to break
* when you upgrade Moodle.
*
- * Possbile values are:
+ * Possible values are:
* false - no standard theme CSS.
* true - include all the main standard theme CSS. Currently this means
* array('styles_layout', 'styles_fonts', 'styles_color').
* This is not necessarily the best choice.
*
* The plugin CSS is included first, before any theme CSS. To be precise,
- * if $standardsheets is true, the the plugin CSS is included with the
+ * if $standardsheets is true, the plugin CSS is included with the
* standard theme's CSS, otherwise if $parentsheets is true, the plugin CSS
* will be included with the parent theme's CSS, otherwise the plugin CSS
* will be include with this theme's CSS.
* {@link http://cvs.moodle.org/moodle/theme/standard/config.php?view=markup the standard theme config.php file}.
* That file also has a good example of how to set this setting.
*
- * If Moodle encouters a general type of page that is not listed in your theme,
+ * If Moodle encounters a general type of page that is not listed in your theme,
* then it will use the first layout. Therefore, should probably put 'normal'
* first in this array.
*
* <li><b>standard:filename</b> for example 'standard:layout-popup.php'. Use
* the specified file from the standard theme.</li>
* </ol>
- * To promote conisitency, you are encouraged to call your layout files
+ * To promote consistency, you are encouraged to call your layout files
* layout.php or layout-something.php.
*
* 'regions' This lists the regions on the page where blocks may appear. For
* 'defaultregion' If the list of regions is non-empty, then you must pick
* one of the one of them as 'default'. This has two meanings. First, this is
* where new blocks are added. Second, if there are any blocks associated with
- * the page, but in non-existant regions, they appear here. (Imaging, for example,
+ * the page, but in non-existent regions, they appear here. (Imaging, for example,
* that someone added blocks using a different theme that used different region
* names, and then switched to this theme.)
*
* CSS before it is output (for example, to replace certain variable names
* with particular values) you can give the name of a function here.
*
- * There are two functions avaiable that you may wish to use (defined in lib/outputlib.php):
+ * There are two functions available that you may wish to use (defined in lib/outputlib.php):
* <ul>
* <li>{@link output_css_replacing_constants}</li>
* <li>{@link output_css_for_css_edit}</li>
public static function load($themename) {
global $CFG;
- // We have to use the variable name $THEME (upper case) becuase that
+ // We have to use the variable name $THEME (upper case) because that
// is what is used in theme config.php files.
// Set some other standard properties of the theme.
* Get the renderer for a part of Moodle for this theme.
* @param string $module the name of part of moodle. E.g. 'core', 'quiz', 'qtype_multichoice'.
* @param moodle_page $page the page we are rendering
- * @return moodle_renderer_base the requested renderer.
* @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news'
+ * @return moodle_renderer_base the requested renderer.
*/
public function get_renderer($module, $page, $subtype=null) {
if (is_null($this->rf)) {
}
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->pixpath/i/course.gif";
* then old_icon_url('i/course'); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
+ * @param string $iconname the name of the icon.
* @return string the URL for that icon.
*/
public function old_icon_url($iconname) {
}
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->modpixpath/$mod/icon.gif";
* then mod_icon_url('icon', $mod); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
- * @param $module the module the icon belongs to.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
* @return string the URL for that icon.
*/
public function mod_icon_url($iconname, $module) {
/**
* Get the meta tags from one theme to got in the <head> of the HTML.
- * @param $themename the name of the theme to get meta tags from.
- * @param $page that page whose <head> is being output.
+ * @param string $themename the name of the theme to get meta tags from.
+ * @param string $page that page whose <head> is being output.
* @return string HTML code.
*/
protected function get_theme_meta_tags($themename, $page) {
* Get all the meta tags (from this theme, standard, parent) that this theme
* wants in the <head> of the HTML.
*
- * @param $page that page whose <head> is being output.
+ * @param string $page that page whose <head> is being output.
* @return string HTML code.
*/
public function get_meta_tags($page) {
$templatepath = $this->dir . '/' . $templatefile;
}
- // Check the the template exists.
+ // Check the template exists.
if (!is_readable($templatepath)) {
throw new coding_exception('The template ' . $templatefile . ' (' . $templatepath .
') for page type ' . $generaltype . ' cannot be found in this theme (' .
* type of page.
* @param string $generaltype the general type of the page.
* @param block_manager $blockmanager the block_manger to set up.
+ * @return void
*/
public function setup_blocks($generaltype, $blockmanager) {
// Legacy fallback.
/**
* Helper method used by {@link update_legacy_information()}. Update one entry
* in the $this->pluginsheets array, based on the legacy $property propery.
- * @param $plugintype e.g. 'mod'.
- * @param $property e.g. 'modsheets'.
+ * @param string $plugintype e.g. 'mod'.
+ * @param string $property e.g. 'modsheets'.
+ * @return void
*/
protected function update_legacy_plugin_sheets($plugintype, $property) {
// In Moodle 1.9, modsheets etc. were ignored if standardsheets was false.
* This method looks a the settings that have been loaded, to see whether
* any legacy things are being used, and outputs warning and tries to update
* things to use equivalent newer settings.
+ * @return void
*/
protected function update_legacy_information() {
global $CFG;
* Set the variable $CFG->pixpath and $CFG->modpixpath to be the right
* ones for this theme. These should no longer be used, but legacy code
* might still rely on them.
+ * @return void
*/
public function setup_legacy_pix_paths() {
global $CFG;
public function __construct($theme) {
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @return string the URL for that icon.
+ */
public function old_icon_url($iconname) {
global $CFG;
if (file_exists($CFG->dirroot . '/pix/' . $iconname . '.png')) {
}
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
+ * @return string the URL for that icon.
+ */
public function mod_icon_url($iconname, $module) {
global $CFG;
if (file_exists($CFG->dirroot . '/mod/' . $module . '/' . $iconname . '.png')) {
$this->themename = $theme->name;
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @return string the URL for that icon.
+ */
public function old_icon_url($iconname) {
global $CFG;
if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/' . $iconname . '.png')) {
}
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
+ * @return string the URL for that icon.
+ */
public function mod_icon_url($iconname, $module) {
global $CFG;
if (file_exists($CFG->themedir . '/' . $this->themename . '/pix/mod/' . $module . '/' . $iconname . '.png')) {
}
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @return string the URL for that icon.
+ */
public function old_icon_url($iconname) {
foreach ($this->places as $dirroot => $urlroot) {
if (file_exists($dirroot . $iconname . '.png')) {
return parent::old_icon_url($iconname);
}
- /* Implement interface method. */
+ /**
+ * Implement interface method.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
+ * @return string the URL for that icon.
+ */
public function mod_icon_url($iconname, $module) {
foreach ($this->places as $dirroot => $urlroot) {
if (file_exists($dirroot . 'mod/' . $iconname . '.png')) {
* @since Moodle 2.0
*/
class standard_renderer_factory extends renderer_factory_base {
- /* Implement the subclass method. */
+ /**
+ * Implement the subclass method
+ * @param string $module name such as 'core', 'mod_forum' or 'qtype_multichoice'.
+ * @param moodle_page $page the page the renderer is outputting content for.
+ * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news'
+ * @return object an object implementing the requested renderer interface.
+ */
public function get_renderer($module, $page, $subtype=null) {
if ($module == 'core') {
return new moodle_core_renderer($page);
* @since Moodle 2.0
*/
class cli_renderer_factory extends standard_renderer_factory {
- /* Implement the subclass method. */
+ /**
+ * Implement the subclass method
+ * @param string $module name such as 'core', 'mod_forum' or 'qtype_multichoice'.
+ * @param moodle_page $page the page the renderer is outputting content for.
+ * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news'
+ * @return object an object implementing the requested renderer interface.
+ */
public function get_renderer($module, $page, $subtype=null) {
if ($module == 'core') {
return new cli_core_renderer($page);
/**
* 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) {
global $CFG;
}
}
- /* Implement the interface method. */
+ /**
+ * Implement the subclass method
+ * @param string $module name such as 'core', 'mod_forum' or 'qtype_multichoice'.
+ * @param moodle_page $page the page the renderer is outputting content for.
+ * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news'
+ * @return object an object implementing the requested renderer interface.
+ */
public function get_renderer($module, $page, $subtype=null) {
foreach ($this->prefixes as $prefix) {
if (is_null($subtype)) {
/**
* 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) {
global $CFG;
$this->searchpaths[] = $CFG->themedir .'/standardtemplate/templates';
}
- /* Implement the subclass method. */
+ /**
+ * Implement the subclass method
+ * @param string $module name such as 'core', 'mod_forum' or 'qtype_multichoice'.
+ * @param moodle_page $page the page the renderer is outputting content for.
+ * @param string $subtype optional subtype such as 'news' resulting to 'mod_forum_news'
+ * @return object an object implementing the requested renderer interface.
+ */
public function get_renderer($module, $page, $subtype=null) {
// Refine the list of search paths for this module.
$searchpaths = array();
/**
* Constructor
- * @param $opencontainers the xhtml_container_stack to use.
* @param moodle_page $page the page we are doing output for.
*/
public function __construct($page) {
return $this->page->state >= moodle_page::STATE_IN_BODY;
}
+ /**
+ * Outputs a tag with attributes and contents
+ * @param string $tagname The name of tag ('a', 'img', 'span' etc.)
+ * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
+ * @param string $contents What goes between the opening and closing tags
+ * @return string HTML fragment
+ */
protected function output_tag($tagname, $attributes, $contents) {
return $this->output_start_tag($tagname, $attributes) . $contents .
$this->output_end_tag($tagname);
}
+
+ /**
+ * Outputs an opening tag with attributes
+ * @param string $tagname The name of tag ('a', 'img', 'span' etc.)
+ * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
+ * @return string HTML fragment
+ */
protected function output_start_tag($tagname, $attributes) {
return '<' . $tagname . $this->output_attributes($attributes) . '>';
}
+
+ /**
+ * Outputs a closing tag
+ * @param string $tagname The name of tag ('a', 'img', 'span' etc.)
+ * @return string HTML fragment
+ */
protected function output_end_tag($tagname) {
return '</' . $tagname . '>';
}
+
+ /**
+ * Outputs an empty tag with attributes
+ * @param string $tagname The name of tag ('input', 'img', 'br' etc.)
+ * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
+ * @return string HTML fragment
+ */
protected function output_empty_tag($tagname, $attributes) {
return '<' . $tagname . $this->output_attributes($attributes) . ' />';
}
+ /**
+ * Outputs a HTML attribute and value
+ * @param string $name The name of the attribute ('src', 'href', 'class' etc.)
+ * @param string $value The value of the attribute
+ * @return string HTML fragment
+ */
protected function output_attribute($name, $value) {
$value = trim($value);
if ($value || is_numeric($value)) { // We want 0 to be output.
return ' ' . $name . '="' . $value . '"';
}
}
+
+ /**
+ * Outputs a list of HTML attributes and values
+ * @param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
+ * @return string HTML fragment
+ */
protected function output_attributes($attributes) {
if (empty($attributes)) {
$attributes = array();
}
return $output;
}
+
+ /**
+ * Given an array or space-separated list of classes, prepares and returns the HTML class attribute value
+ * @param mixed $classes Space-separated string or array of classes
+ * @return string HTML class attribute value
+ */
public static function prepare_classes($classes) {
if (is_array($classes)) {
return implode(' ', array_unique($classes));
}
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->pixpath/i/course.gif";
* then old_icon_url('i/course'); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
+ * @param string $iconname the name of the icon.
* @return string the URL for that icon.
*/
public function old_icon_url($iconname) {
}
/**
- * Return the URL for an icon indentifed as in pre-Moodle 2.0 code.
+ * Return the URL for an icon identified as in pre-Moodle 2.0 code.
*
* Suppose you have old code like $url = "$CFG->modpixpath/$mod/icon.gif";
* then mod_icon_url('icon', $mod); will return the equivalent URL that is correct now.
*
- * @param $iconname the name of the icon.
- * @param $module the module the icon belongs to.
+ * @param string $iconname the name of the icon.
+ * @param string $module the module the icon belongs to.
* @return string the URL for that icon.
*/
public function mod_icon_url($iconname, $module) {
* Magic word used when breaking apart container templates to implement
* _start and _end methods.
*/
- const contentstoken = '-@#-Contents-go-here-#@-';
+ const CONTENTSTOKEN = '-@#-Contents-go-here-#@-';
/**
* Constructor
* @param string $copiedclass the name of a class whose API we should be copying.
- * @param $searchpaths a list of folders to search for templates in.
- * @param $opencontainers the xhtml_container_stack to use.
+ * @param array $searchpaths a list of folders to search for templates in.
* @param moodle_page $page the page we are doing output for.
*/
public function __construct($copiedclass, $searchpaths, $page) {
$this->searchpaths = $searchpaths;
}
- /* PHP magic method implementation. */
+ /**
+ * PHP magic method implementation. Do not use this method directly.
+ * @param string $method The method to call
+ * @param array $arguments The arguments to pass to the method
+ * @return mixed The return value of the called method
+ */
public function __call($method, $arguments) {
if (substr($method, -6) == '_start') {
return $this->process_start(substr($method, 0, -6), $arguments);
/**
* Actually do the work of rendering the template.
- * @param $_template the full path to the template file.
- * @param $_namedarguments an array variable name => value, the variables
+ * @param string $_template the full path to the template file.
+ * @param array $_namedarguments an array variable name => value, the variables
* that should be available to the template.
* @return string the HTML to be output.
*/
global $CFG, $SITE, $THEME, $USER;
// The next lines are a bit tricky. The point is, here we are in a method
- // of a renderer class, and this object may, or may not, be the the same as
+ // of a renderer class, and this object may, or may not, be the same as
// the global $OUTPUT object. When rendering the template, we want to use
// this object. However, people writing Moodle code expect the current
- // rederer to be called $OUTPUT, not $this, so define a variable called
+ // renderer to be called $OUTPUT, not $this, so define a variable called
// $OUTPUT pointing at $this. The same comment applies to $PAGE and $COURSE.
$OUTPUT = $this;
$PAGE = $this->page;
/**
* Handle methods like print_box_start by using the print_box template,
- * splitting the result, pusing the end onto the stack, then returning the start.
+ * splitting the result, pushing the end onto the stack, then returning the start.
* @param string $method the method that was called, with _start stripped off.
* @param array $arguments the arguments that were passed to it.
* @return string the HTML to be output.
*/
- protected function process_start($template, $arguments) {
- array_unshift($arguments, self::contentstoken);
- $html = $this->process_template($template, $arguments);
- list($start, $end) = explode(self::contentstoken, $html, 2);
- $this->opencontainers->push($template, $end);
+ protected function process_start($method, $arguments) {
+ array_unshift($arguments, self::CONTENTSTOKEN);
+ $html = $this->process_template($method, $arguments);
+ list($start, $end) = explode(self::CONTENTSTOKEN, $html, 2);
+ $this->opencontainers->push($method, $end);
return $start;
}
* @param array $arguments not used. Assumed to be irrelevant.
* @return string the HTML to be output.
*/
- protected function process_end($template, $arguments) {
- return $this->opencontainers->pop($template);
+ protected function process_end($method, $arguments) {
+ return $this->opencontainers->pop($method);
}
/**
*
* This makes it much easier to always generate well formed XHTML output, even
* if execution terminates abruptly. Any time you output some opening HTML
- * without the matching closing HTML, you should push the neccessary close tags
+ * without the matching closing HTML, you should push the necessary close tags
* onto the stack.
*
* @copyright 2009 Tim Hunt
* @param string $type The type of container. This is checked when {@link pop()}
* is called and must match, otherwise a developer debug warning is output.
* @param string $closehtml The HTML required to close the container.
+ * @return void
*/
public function push($type, $closehtml) {
$container = new stdClass;
* must match the type passed when the container was opened, otherwise a
* warning will be output.
* @param string $type The type of container.
- * @return string the HTML requried to close the container.
+ * @return string the HTML required to close the container.
*/
public function pop($type) {
if (empty($this->opencontainers)) {
* Close all but the last open container. This is useful in places like error
* handling, where you want to close all the open containers (apart from <body>)
* before outputting the error message.
- * @param $shouldbenone assert that the stack shold be empty now - causes a
+ * @param bool $shouldbenone assert that the stack should be empty now - causes a
* developer debug warning if it isn't.
- * @return string the HTML requried to close any open containers inside <body>.
+ * @return string the HTML required to close any open containers inside <body>.
*/
public function pop_all_but_last($shouldbenone = false) {
if ($shouldbenone && count($this->opencontainers) != 1) {
* class without properly emptying the stack (for example, in a unit test).
* Calling this method stops the destruct method from outputting a developer
* debug warning. After calling this method, the instance can no longer be used.
+ * @return void
*/
public function discard() {
$this->opencontainers = null;
/**
* Emergency fallback. If we get to the end of processing and not all
* containers have been closed, output the rest with a developer debug warning.
+ * @return void
*/
public function __destruct() {
if (empty($this->opencontainers)) {
$container = array_pop($this->opencontainers);
echo $container->closehtml;
}
-
+
+ /**
+ * Adds an entry to the log.
+ * @param string $action The name of the action
+ * @param string $type The type of action
+ * @return void
+ */
protected function log($action, $type) {
$this->log[] = '<li>' . $action . ' ' . $type . ' at:' .
format_backtrace(debug_backtrace()) . '</li>';
}
-
+
+ /**
+ * Outputs the log's contents as a HTML list.
+ * @return string HTML list of the log
+ */
protected function output_log() {
return '<ul>' . implode("\n", $this->log) . '</ul>';
}
$focus = $this->page->focuscontrol;
if (!empty($focus)) {
- if(preg_match("#forms\['([a-zA-Z0-9]+)'\].elements\['([a-zA-Z0-9]+)'\]#", $focus, $matches)) {
+ if (preg_match("#forms\['([a-zA-Z0-9]+)'\].elements\['([a-zA-Z0-9]+)'\]#", $focus, $matches)) {
// This is a horrifically bad way to handle focus but it is passed in
// through messy formslib::moodleform
$this->page->requires->js_function_call('old_onload_focus', Array($matches[1], $matches[2]));
/**
* The standard tags (typically performance information and validation links,
- * if we are indevelope debug mode) that should be output in the footer area
+ * if we are in developer debug mode) that should be output in the footer area
* of the page. Designed to be called in theme layout.php files.
* @return string HTML fragment.
*/
* @param string $message The message to display to the user if any
* @param int $delay The delay before redirecting a user, if $message has been
* set this is a requirement and defaults to 3, set to 0 no delay
- * @param string $messageclass The css class to put on the message that is
- * being displayed to the user
* @param boolean $debugdisableredirect this redirect has been disabled for
* debugging purposes. Display a message that explains, and don't
* trigger the redirect.
switch ($this->page->state) {
case moodle_page::STATE_BEFORE_HEADER :
- // No output yet it is safe to delivery the full arsenol of redirect methods
+ // No output yet it is safe to delivery the full arsenal of redirect methods
if (!$debugdisableredirect) {
// Don't use exactly the same time here, it can cause problems when both redirects fire at the same time.
$this->metarefreshtag = '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />'."\n";
* Start output by sending the HTTP headers, and printing the HTML <head>
* and the start of the <body>.
*
- * To control what is printed, you should set properies on $PAGE. If you
+ * To control what is printed, you should set properties on $PAGE. If you
* are familiar with the old {@link print_header()} function from Moodle 1.9
* you will find that there are properties on $PAGE that correspond to most
- * of the old paramters to could be passed to print_header.
+ * of the old parameters to could be passed to print_header.
*
- * Not that, in due course, the remaining $navigation, $menu paramters here
+ * Not that, in due course, the remaining $navigation, $menu parameters here
* will be replaced by more properties of $PAGE, but that is still to do.
*
- * @param $navigation legacy, like the old paramter to print_header. Will be
+ * @param string $navigation legacy, like the old parameter to print_header. Will be
* removed when there is a $PAGE->... replacement.
- * @param $menu legacy, like the old paramter to print_header. Will be
+ * @param string $menu legacy, like the old parameter to print_header. Will be
* removed when there is a $PAGE->... replacement.
* @return string HTML that you must output this, preferably immediately.
*/
public function header($navigation = '', $menu='') {
- // TODO remove $navigation and $menu arguments - replace with $PAGE->navigation
+ // TODO remove $navigation and $menu arguments - replace with $PAGE->navigation
global $USER, $CFG;
$this->page->set_state(moodle_page::STATE_PRINTING_HEADER);
$this->page->set_state(moodle_page::STATE_IN_BODY);
return $header . $this->skip_link_target();
}
-
+
+ /**
+ * Renders and outputs the page template.
+ * @param string $templatefile The name of the template's file
+ * @param array $menu The menu that will be used in the included file
+ * @param array $navigation The navigation that will be used in the included file
+ * @return string HTML code
+ */
protected function render_page_template($templatefile, $menu, $navigation) {
global $CFG, $SITE, $THEME, $USER;
// The next lines are a bit tricky. The point is, here we are in a method
- // of a renderer class, and this object may, or may not, be the the same as
+ // of a renderer class, and this object may, or may not, be the same as
// the global $OUTPUT object. When rendering the template, we want to use
// this object. However, people writing Moodle code expect the current
- // rederer to be called $OUTPUT, not $this, so define a variable called
+ // renderer to be called $OUTPUT, not $this, so define a variable called
// $OUTPUT pointing at $this. The same comment applies to $PAGE and $COURSE.
$OUTPUT = $this;
$PAGE = $this->page;
return $template;
}
+ /**
+ * Renders and outputs a legacy template.
+ * @param array $navigation The navigation that will be used in the included file
+ * @param array $menu The menu that will be used in the included file
+ * @return string HTML code
+ */
protected function handle_legacy_theme($navigation, $menu) {
global $CFG, $SITE, $USER;
// Set a pretend global from the properties of this class.
return $output;
}
-
+
+ /**
+ * Outputs the page's footer
+ * @return string HTML fragment
+ */
public function footer() {
$output = $this->opencontainers->pop_all_but_last(true);
/**
* Output the row of editing icons for a block, as defined by the controls array.
- * @param $controls an array like {@link block_contents::$controls}.
+ * @param array $controls an array like {@link block_contents::$controls}.
* @return HTML fragment.
*/
public function block_controls($controls) {
$this->init_block_hider_js($bc);
return $output;
}
-
+
+ /**
+ * Calls the JS require function to hide a block.
+ * @param block_contents $bc A block_contents object
+ * @return void
+ */
protected function init_block_hider_js($bc) {
if ($bc->collapsible != block_contents::NOT_HIDEABLE) {
$userpref = 'block' . $bc->blockinstanceid . 'hidden';
/**
* Output all the blocks in a particular region.
- * @param $region the name of a region on this page.
+ * @param string $region the name of a region on this page.
* @return string the HTML to be output.
*/
public function blocks_for_region($region) {
$html = $this->output_start_tag('select', $attributes) . "\n";
foreach ($selectmenu->options as $value => $label) {
$attributes = array('value' => $value);
- if ((string)$value == (string)$selectmenu->selectedvalue ||
+ if ((string) $value == (string) $selectmenu->selectedvalue ||
(is_array($selectmenu->selectedvalue) && in_array($value, $selectmenu->selectedvalue))) {
$attributes['selected'] = 'selected';
}
/**
* Output an error message. By default wraps the error message in <span class="error">.
* If the error message is blank, nothing is output.
- * @param $message the error message.
+ * @param string $message the error message.
* @return string the HTML to output.
*/
public function error_text($message) {
*
* To terminate the current script with a fatal error, call the {@link print_error}
* function, or throw an exception. Doing either of those things will then call this
- * funciton to display the error, before terminating the exection.
- *
- * @param string $message
- * @param string $moreinfourl
- * @param string $link
- * @param array $backtrace
- * @param string $debuginfo
- * @param bool $showerrordebugwarning
+ * function to display the error, before terminating the execution.
+ *
+ * @param string $message The message to output
+ * @param string $moreinfourl URL where more info can be found about the error
+ * @param string $link Link for the Continue button
+ * @param array $backtrace The execution backtrace
+ * @param string $debuginfo Debugging information
+ * @param bool $showerrordebugwarning Whether or not to show a debugging warning
* @return string the HTML to output.
*/
public function fatal_error($message, $moreinfourl, $link, $backtrace,
/**
* Output the place a skip link goes to.
- * @param $id The target name from the corresponding $PAGE->requires->skip_link_to($target) call.
+ * @param string $id The target name from the corresponding $PAGE->requires->skip_link_to($target) call.
* @return string the HTML to output.
*/
public function skip_link_target($id = '') {
return $this->output_tag('span', array('id' => $id), '');
}
+ /**
+ * Outputs a heading
+ * @param string $text The text of the heading
+ * @param int $level The level of importance of the heading
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string the HTML to output.
+ */
public function heading($text, $level, $classes = 'main', $id = '') {
$level = (integer) $level;
if ($level < 1 or $level > 6) {
array('id' => $id, 'class' => moodle_renderer_base::prepare_classes($classes)), $text);
}
+ /**
+ * Outputs a box.
+ * @param string $contents The contents of the box
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string the HTML to output.
+ */
public function box($contents, $classes = 'generalbox', $id = '') {
return $this->box_start($classes, $id) . $contents . $this->box_end();
}
+ /**
+ * Outputs the opening section of a box.
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string the HTML to output.
+ */
public function box_start($classes = 'generalbox', $id = '') {
$this->opencontainers->push('box', $this->output_end_tag('div'));
return $this->output_start_tag('div', array('id' => $id,
'class' => 'box ' . moodle_renderer_base::prepare_classes($classes)));
}
+ /**
+ * Outputs the closing section of a box.
+ * @return string the HTML to output.
+ */
public function box_end() {
return $this->opencontainers->pop('box');
}
+ /**
+ * Outputs a container.
+ * @param string $contents The contents of the box
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string the HTML to output.
+ */
public function container($contents, $classes = '', $id = '') {
return $this->container_start($classes, $id) . $contents . $this->container_end();
}
+ /**
+ * Outputs the opening section of a container.
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string the HTML to output.
+ */
public function container_start($classes = '', $id = '') {
$this->opencontainers->push('container', $this->output_end_tag('div'));
return $this->output_start_tag('div', array('id' => $id,
'class' => moodle_renderer_base::prepare_classes($classes)));
}
+ /**
+ * Outputs the closing section of a container.
+ * @return string the HTML to output.
+ */
public function container_end() {
return $this->opencontainers->pop('container');
}
/**
* Base class for classes representing HTML elements, like moodle_select_menu.
*
- * Handles the id and class attribues.
+ * Handles the id and class attributes.
*
* @copyright 2009 Tim Hunt
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* Set the class name array.
* @param mixed $classes either an array of class names or a space-separated
* string containing class names.
+ * @return void
*/
public function set_classes($classes) {
$this->classes = self::clean_classes($classes);
/**
* Add a class name to the class names array.
* @param string $class the new class name to add.
+ * @return void
*/
public function add_class($class) {
$this->classes[] = $class;
* Add a whole lot of class names to the class names array.
* @param mixed $classes either an array of class names or a space-separated
* string containing class names.
+ * @return void
*/
public function add_classes($classes) {
$this->classes += self::clean_classes($classes);
/**
* Perform any cleanup or final processing that should be done before an
* instance of this class is output.
+ * @return void
*/
public function prepare() {
$this->classes = array_unique(self::clean_classes($this->classes));
/**
* This checks developer do not try to assign a property directly
* if we have a setter for it. Otherwise, the property is set as expected.
+ * @param string $name The name of the variable to set
+ * @param mixed $value The value to assign to the variable
+ * @return void
*/
public function __set($name, $value) {
if ($name == 'class') {
public $options;
/**
* @var string the name of this form control. That is, the name of the GET/POST
- * variable that will be set if this select is submmitted as part of a form.
+ * variable that will be set if this select is submitted as part of a form.
*/
public $name;
/**
*/
public $script = '';
- /* @see lib/moodle_html_component#prepare() */
+ /**
+ * @see moodle_html_component::prepare()
+ * @return void
+ */
public function prepare() {
if (empty($this->id)) {
$this->id = 'menu' . str_replace(array('[', ']'), '', $this->name);
*/
public $controls = array();
- /* @see lib/moodle_html_component#prepare() */
+ /**
+ * @see moodle_html_component::prepare()
+ * @return void
+ */
public function prepare() {
$this->skipid = self::$idcounter;
self::$idcounter += 1;
*/
public $data;
/**
- * @var string width of the table, percentage of the page prefered. Defaults to 80% of the page width.
+ * @var string width of the table, percentage of the page preferred. Defaults to 80% of the page width.
* @deprecated since Moodle 2.0. Styling should be in the CSS.
*/
public $width = null;
*/
public $rowclasses;
/**
- * @var array classes to add to every cell in a particular colummn,
+ * @var array classes to add to every cell in a particular column,
* space-separated string. Class 'cell' is added automatically by the renderer.
* Classes 'c0' or 'c1' are added automatically for every odd or even column,
* respectively. Class 'lastcol' is added automatically for all last cells
/**
* @see moodle_html_component::prepare()
+ * @return void
*/
public function prepare() {
if (!empty($this->align)) {
}
parent::prepare();
}
-
+ /**
+ * @param string $name The name of the variable to set
+ * @param mixed $value The value to assign to the variable
+ * @return void
+ */
public function __set($name, $value) {
if ($name == 'rowclass') {
debugging('rowclass[] has been deprecated for html_table ' .
/**
- * A renderer that generates output for commandlines scripts.
+ * A renderer that generates output for command-line scripts.
*
* The implementation of this renderer is probably incomplete.
*
* @since Moodle 2.0
*/
class cli_core_renderer extends moodle_core_renderer {
+ /**
+ * Returns the page header.
+ * @return string HTML fragment
+ */
public function header() {
output_starting_hook();
return $this->page->heading . "\n";
}
-
+
+ /**
+ * Returns a template fragment representing a Heading.
+ * @param string $text The text of the heading
+ * @param int $level The level of importance of the heading
+ * @param string $classes A space-separated list of CSS classes
+ * @param string $id An optional ID
+ * @return string A template fragment for a heading
+ */
public function heading($text, $level, $classes = 'main', $id = '') {
$text .= "\n";
switch ($level) {
}
}
+ /**
+ * Returns a template fragment representing a fatal error.
+ * @param string $message The message to output
+ * @param string $moreinfourl URL where more info can be found about the error
+ * @param string $link Link for the Continue button
+ * @param array $backtrace The execution backtrace
+ * @param string $debuginfo Debugging information
+ * @param bool $showerrordebugwarning Whether or not to show a debugging warning
+ * @return string A template fragment for a fatal error
+ */
public function fatal_error($message, $moreinfourl, $link, $backtrace,
$debuginfo = null, $showerrordebugwarning = false) {
$output = "!!! $message !!!\n";
}
}
}
-
+
+ /**
+ * Returns a template fragment representing a notification.
+ * @param string $message The message to include
+ * @param string $classes A space-separated list of CSS classes
+ * @return string A template fragment for a notification
+ */
public function notification($message, $classes = 'notifyproblem') {
$message = clean_text($message);
if ($classes === 'notifysuccess') {
* }
* </code>
*
- * @param array $files an arry of the CSS fiels that need to be output.
+ * @param array $files an array of the CSS fields that need to be output.
* @param array $toreplace for convenience. If you are going to output the names
* of the css files, for debugging purposes, then you should output
- * str_replace($toreplace, '', $file); becuase it looks prettier.
+ * str_replace($toreplace, '', $file); because it looks prettier.
+ * @return void
*/
function output_css_replacing_constants($files, $toreplace) {
// Get all the CSS.
* CSS editors like CSSEdit. Any files that have a .php extension are still included
* inline.
*
- * @param array $files an arry of the CSS fiels that need to be output.
+ * @param array $files an array of the CSS fields that need to be output.
* @param array $toreplace for convenience. If you are going to output the names
* of the css files, for debugging purposes, then you should output
- * str_replace($toreplace, '', $file); becuase it looks prettier.
+ * str_replace($toreplace, '', $file); because it looks prettier.
+ * @return void
*/
function output_css_for_css_edit($files, $toreplace) {
foreach ($files as $file) {