From ed5dd29fc89b3cd0cbc861a0e9bb6abf41a765da Mon Sep 17 00:00:00 2001 From: skodak Date: Sat, 20 Jan 2007 13:32:15 +0000 Subject: [PATCH] moved obsoleted functions from weblib.php to deprecatedlib.php --- lib/deprecatedlib.php | 101 ++++++++++++++++++++++++++++ lib/editor/htmlarea/coursefiles.php | 2 +- lib/weblib.php | 90 ------------------------- 3 files changed, 102 insertions(+), 91 deletions(-) diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index c0841158475..d4135882016 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -879,6 +879,107 @@ function print_simple_box_end($return=false) { } } +/** + * deprecated - use clean_param($string, PARAM_FILE); instead + * Check for bad characters ? + * + * @param string $string ? + * @param int $allowdots ? + * @todo Finish documenting this function - more detail needed in description as well as details on arguments + */ +function detect_munged_arguments($string, $allowdots=1) { + if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references + return true; + } + if (ereg('[\|\`]', $string)) { // check for other bad characters + return true; + } + if (empty($string) or $string == '/') { + return true; + } + + return false; +} + +///////////////////////////////////////////////////////////// +/// Old functions not used anymore - candidates for removal +///////////////////////////////////////////////////////////// + +/** + * Load a template from file - this function dates back to Moodle 1 :-) not used anymore + * + * Returns a (big) string containing the contents of a template file with all + * the variables interpolated. all the variables must be in the $var[] array or + * object (whatever you decide to use). + * + * WARNING: do not use this on big files!! + * + * @param string $filename Location on the server's filesystem where template can be found. + * @param mixed $var Passed in by reference. An array or object which will be loaded with data from the template file. + * + */ +function read_template($filename, &$var) { + + $temp = str_replace("\\", "\\\\", implode(file($filename), '')); + $temp = str_replace('"', '\"', $temp); + eval("\$template = \"$temp\";"); + return $template; +} + + +/** + * deprecated - relies on register globals; use new formslib instead + * + * 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 + * unset_value. used to handle checkboxes when you are expecting them from + * a form + * + * @param mixed $var Passed in by reference. The variable to check. + * @param mixed $set_value The value to set $var to if $var already has a value. + * @param mixed $unset_value The value to set $var to if $var does not already have a value. + */ +function checked(&$var, $set_value = 1, $unset_value = 0) { + + if (empty($var)) { + $var = $unset_value; + } else { + $var = $set_value; + } +} + +/** + * deprecated - use new formslib instead + * + * Prints the word "checked" if a variable is true, otherwise prints nothing, + * used for printing the word "checked" in a checkbox form element. + * + * @param boolean $var Variable to be checked for true value + * @param string $true_value Value to be printed if $var is true + * @param string $false_value Value to be printed if $var is false + */ +function frmchecked(&$var, $true_value = 'checked', $false_value = '') { + + if ($var) { + echo $true_value; + } else { + echo $false_value; + } +} + +/** + * Legacy function, provided for backward compatability. + * This method now simply calls {@link use_html_editor()} + * + * @deprecated Use {@link use_html_editor()} instead. + * @param string $name Form element to replace with HTMl editor by name + * @todo Finish documenting this function + */ +function print_richedit_javascript($form, $name, $source='no') { + use_html_editor($name); +} + ?> diff --git a/lib/editor/htmlarea/coursefiles.php b/lib/editor/htmlarea/coursefiles.php index f714f7dfdea..843cfd432f6 100644 --- a/lib/editor/htmlarea/coursefiles.php +++ b/lib/editor/htmlarea/coursefiles.php @@ -427,7 +427,7 @@ echo "\n"; if ($usehtmleditor) { - print_richedit_javascript("form", "text", "yes"); + use_html_editor("text"); } diff --git a/lib/weblib.php b/lib/weblib.php index 853c34eb3e3..3e9cbb2e6d6 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -474,63 +474,6 @@ if (!function_exists('stripos')) { /// Only exists in PHP 5 } } -/** - * Load a template from file - * - * Returns a (big) string containing the contents of a template file with all - * the variables interpolated. all the variables must be in the $var[] array or - * object (whatever you decide to use). - * - * WARNING: do not use this on big files!! - * - * @param string $filename Location on the server's filesystem where template can be found. - * @param mixed $var Passed in by reference. An array or object which will be loaded with data from the template file. - */ -function read_template($filename, &$var) { - - $temp = str_replace("\\", "\\\\", implode(file($filename), '')); - $temp = str_replace('"', '\"', $temp); - eval("\$template = \"$temp\";"); - return $template; -} - -/** - * 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 - * unset_value. used to handle checkboxes when you are expecting them from - * a form - * - * @param mixed $var Passed in by reference. The variable to check. - * @param mixed $set_value The value to set $var to if $var already has a value. - * @param mixed $unset_value The value to set $var to if $var does not already have a value. - */ -function checked(&$var, $set_value = 1, $unset_value = 0) { - - if (empty($var)) { - $var = $unset_value; - } else { - $var = $set_value; - } -} - -/** - * Prints the word "checked" if a variable is true, otherwise prints nothing, - * used for printing the word "checked" in a checkbox form element. - * - * @param boolean $var Variable to be checked for true value - * @param string $true_value Value to be printed if $var is true - * @param string $false_value Value to be printed if $var is false - */ -function frmchecked(&$var, $true_value = 'checked', $false_value = '') { - - if ($var) { - echo $true_value; - } else { - echo $false_value; - } -} - /** * This function will create a HTML link that will work on both * Javascript and non-javascript browsers. @@ -1137,27 +1080,6 @@ function get_file_argument($scriptname) { return $relativepath; } -/** - * Check for bad characters ? - * - * @param string $string ? - * @param int $allowdots ? - * @todo Finish documenting this function - more detail needed in description as well as details on arguments - */ -function detect_munged_arguments($string, $allowdots=1) { - if (substr_count($string, '..') > $allowdots) { // Sometimes we allow dots in references - return true; - } - if (ereg('[\|\`]', $string)) { // check for other bad characters - return true; - } - if (empty($string) or $string == '/') { - return true; - } - - return false; -} - /** * Searches the current environment variables for some slash arguments * @@ -3715,18 +3637,6 @@ function print_textarea($usehtmleditor, $rows, $cols, $width, $height, $name, $v echo $str; } -/** - * Legacy function, provided for backward compatability. - * This method now simply calls {@link use_html_editor()} - * - * @deprecated Use {@link use_html_editor()} instead. - * @param string $name Form element to replace with HTMl editor by name - * @todo Finish documenting this function - */ -function print_richedit_javascript($form, $name, $source='no') { - use_html_editor($name); -} - /** * Sets up the HTML editor on textareas in the current page. * If a field name is provided, then it will only be