Added stripos function and allow filters to work even when courseid

isn't set.
This commit is contained in:
moodler
2004-01-20 08:51:43 +00:00
parent 46d621261b
commit ce57cc79eb
+13 -8
View File
@@ -192,12 +192,12 @@ function stripslashes_safe($string) {
return $string;
}
if (!function_exists('str_ireplace')) {
if (!function_exists('str_ireplace')) { /// Only exists in PHP 5
function str_ireplace($find, $replace, $string) {
/// This does a search and replace, ignoring case
/// This function is only here versions of PHP older than version 5
/// may not have a native version of this function.
/// Taken from the PHP manual, by bradhuizenga@softhome.net
/// This function is only used for versions of PHP older than version 5
/// which do not have a native version of this function.
/// Taken from the PHP manual, by bradhuizenga @ softhome.net
if (!is_array($find)) {
$find = array($find);
@@ -230,6 +230,15 @@ if (!function_exists('str_ireplace')) {
}
}
if (!function_exists('stripos')) { /// Only exists in PHP 5
function stripos($haystack, $needle, $offset=0) {
/// This function is only used for versions of PHP older than version 5
/// which do not have a native version of this function.
/// Taken from the PHP manual, by dmarsh @ spscc.ctc.edu
return strpos(strtoupper($haystack), strtoupper($needle), $offset);
}
}
function read_template($filename, &$var) {
/// return 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
@@ -564,10 +573,6 @@ function filter_text($text, $courseid=NULL) {
global $CFG;
if (empty($courseid)) {
return $text;
}
for ($i=1; $i<=10; $i++) {
$variable = "textfilter$i";
if (empty($CFG->$variable)) { /// No more filters