* @license http://www.gnu.org/copyleft/gpl.html GNU Public License
* @package moodlecore
*/
-
+
/// Constants
/// Define text formatting types ... eventually we can add Wiki, BBcode etc
/**
* Ensure that a variable is set
*
- * Return $var if it is defined, otherwise return $default,
+ * Return $var if it is defined, otherwise return $default,
* This function is very similar to {@link optional_variable()}
*
* @param mixed $var the variable which may be unset
* Returns the data as an object, if it's found.
* This object can be used in foreach loops without
* casting because it's cast to (array) automatically
- *
+ *
* Checks that submitted POST data exists, and also
* checks the referer against the given url (it uses
* the current page if none was specified.
/**
* Moodle replacement for php stripslashes() function
*
- * The standard php stripslashes() removes ALL backslashes
+ * The standard php stripslashes() removes ALL backslashes
* even from strings - so C:\temp becomes C:temp - this isn't good.
* This function should work as a fairly safe replacement
* to be called on quoted AND unquoted strings (to be sure)
/**
* Set a variable's value depending on whether or not it already has a value.
*
- * If variable is set, set it to the set_value otherwise set it to the
+ * If variable is set, set it to the set_value otherwise set it to the
* unset_value. used to handle checkboxes when you are expecting them from
* a form
*
* @param string $helptext The name of the label for the help button
* @param boolean $return Indicates whether the function should return the text
* as a string or echo it directly to the page being rendered
- * @param string $targetwindow The name of the target page to open the linked page in.
+ * @param string $targetwindow The name of the target page to open the linked page in.
* @return string If $return is true then the entire form is returned as a string.
* @todo Finish documenting this function<br>
*/
function popup_form($common, $options, $formname, $selected='', $nothing='choose', $help='', $helptext='', $return=false, $targetwindow='self') {
- global $CFG;
+ global $CFG;
static $go, $choose; /// Locally cached, in case there's lots on a page
if (empty($options)) {
$inoptgroup = false;
foreach ($options as $value => $label) {
-
+
if (substr($label,0,2) == '--') { /// we are starting a new optgroup
-
+
/// Check to see if we already have a valid open optgroup
/// XHTML demands that there be at least 1 option within an optgroup
if ($inoptgroup and (count($optgr) > 1) ) {
$optgr = array();
$optgr[] = ' <optgroup label="'. substr($label,2) .'">'; // Plain labels
-
+
$inoptgroup = true; /// everything following will be in an optgroup
continue;
-
+
} else {
$optstr = ' <option value="' . $common . $value . '"';
-
+
if ($value == $selected) {
$optstr .= ' selected="selected"';
}
-
+
if ($label) {
$optstr .= '>'. $label .'</option>' . "\n";
} else {
$optstr .= '>'. $value .'</option>' . "\n";
}
-
+
if ($inoptgroup) {
$optgr[] = $optstr;
} else {
$output .= $optstr;
}
}
-
+
}
/// catch the final group if not closed
/**
* Given text in a variety of format codings, this function returns
- * the text as safe HTML.
+ * the text as safe HTML.
*
* @uses $CFG
* @uses FORMAT_MOODLE
* @uses FORMAT_WIKI
* @uses FORMAT_MARKDOWN
* @param string $text The text to be formatted. This is raw text originally from user input.
- * @param int $format Identifier of the text format to be used
+ * @param int $format Identifier of the text format to be used
* (FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN)
* @param array $options ?
* @param int $courseid ?
* @uses FORMAT_WIKI
* @uses FORMAT_MARKDOWN
* @param string $text The text to be formatted. This is raw text originally from user input.
- * @param int $format Identifier of the text format to be used
+ * @param int $format Identifier of the text format to be used
* (FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN)
* @return string
*/
* @uses FORMAT_PLAIN
* @uses ALLOWED_TAGS
* @param string $text The text to be cleaned
- * @param int $format Identifier of the text format to be used
+ * @param int $format Identifier of the text format to be used
* (FORMAT_MOODLE, FORMAT_HTML, FORMAT_PLAIN, FORMAT_WIKI, FORMAT_MARKDOWN)
* @return string The cleaned up text
*/
* @return string
*/
function replace_smilies(&$text) {
-///
+///
global $CFG;
/// this builds the mapping array only once
*/
function text_to_html($text, $smiley=true, $para=true, $newlines=true) {
-///
+///
global $CFG;
if ($cache) { // Allow caching on "back" (but not on normal clicks)
@header('Cache-Control: private, pre-check=0, post-check=0, max-age=0');
@header('Pragma: no-cache');
- @header('Expires: ');
+ @header('Expires: ');
} else { // Do everything we can to always prevent clients and proxies caching
@header('Cache-Control: no-store, no-cache, must-revalidate');
@header('Cache-Control: post-check=0, pre-check=0', false);
}
$bodytags .= ' class="'.$pageclass.'" id="'.$pageid.'"';
-
+
include ($CFG->dirroot .'/theme/'. $CFG->theme .'/header.html');
echo message_popup_window();
}
/**
- * Legacy function, provided for backward compatability.
+ * Legacy function, provided for backward compatability.
* This method now simply calls {@link use_html_editor()}
*
* @deprecated Use {@link use_html_editor()} instead.
* @return string
*/
function update_course_icon($courseid) {
-
+
global $CFG, $USER;
if (isteacheredit($courseid)) {
* @param boolean $includenograde ?
* @todo Finish documenting this function
*/
-function print_grade_menu($courseid, $name, $current, $includenograde=true) {
+function print_grade_menu($courseid, $name, $current, $includenograde=true) {
global $CFG;
}
$linkobject .= $imagetext;
-
+
} else {
$linkobject .= $title;
}
$linkobject .= '</span>';
-
+
if ($text) {
$url = '/help.php?module='. $module .'&text='. htmlentities(urlencode($text));
} else {
$url = clean_text($url);
$message = clean_text($message);
-
+
$url = html_entity_decode($url); // for php < 4.3.0 this is defined in moodlelib.php
$encodedurl = htmlentities($url);
* @return string
*/
function obfuscate_text($plaintext) {
-
+
$i=0;
$length = strlen($plaintext);
$obfuscated='';
* @param array $attributes ?
* @todo Finish documenting this function. Show example of various attributes, etc.
*/
-function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array()) {
+function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $footer='', $attributes = array()) {
print_side_block_start($heading, $attributes);
* Print table ending tags for a side block box.
*/
function print_side_block_end() {
- echo '</td></tr></tbody></table><br />';
+ echo '</td></tr></tbody></table>';
echo "\n";
}
* @param boolean $usehtmleditor ?
* @todo Finish documenting this function
*/
-function print_speller_code ($usehtmleditor=false) {
+function print_speller_code ($usehtmleditor=false) {
global $CFG;
if(!$usehtmleditor) {