From 8e1ec6be5843d24d5c76317af53ca6e12e3c5101 Mon Sep 17 00:00:00 2001 From: skodak Date: Sun, 16 Sep 2007 18:49:41 +0000 Subject: [PATCH] MDL-11298 use textlib_get_instance() instead of new textlib() --- grade/import/csv/index.php | 2 +- grade/import/grade_import_form.php | 2 +- grade/import/xml/index.php | 2 +- lib/moodlelib.php | 4 ++-- lib/textlib.class.php | 2 +- mod/data/view.php | 2 +- tag/lib.php | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/grade/import/csv/index.php b/grade/import/csv/index.php index 552193af3da..0616a7c2c23 100755 --- a/grade/import/csv/index.php +++ b/grade/import/csv/index.php @@ -333,7 +333,7 @@ if (($formdata = data_submitted()) && !empty($formdata->map)) { $text = my_file_get_contents($filename); // trim utf-8 bom - $textlib = new textlib(); + $textlib = textlib_get_instance(); /// normalize line endings and do the encoding conversion $text = $textlib->convert($text, $formdata->encoding); $text = $textlib->trim_utf8_bom($text); diff --git a/grade/import/grade_import_form.php b/grade/import/grade_import_form.php index e0018e1ad6d..df29572e631 100755 --- a/grade/import/grade_import_form.php +++ b/grade/import/grade_import_form.php @@ -13,7 +13,7 @@ class grade_import_form extends moodleform { $mform->addElement('file', 'userfile', get_string('file')); $mform->setType('userfile', PARAM_FILE); $mform->addRule('userfile', null, 'required'); - $textlib = new textlib(); + $textlib = textlib_get_instance(); $encodings = $textlib->get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); diff --git a/grade/import/xml/index.php b/grade/import/xml/index.php index ef7cb9a5e7f..73e081a49ac 100755 --- a/grade/import/xml/index.php +++ b/grade/import/xml/index.php @@ -49,7 +49,7 @@ if ( $formdata = $mform->get_data()) { $text = my_file_get_contents($filename); // trim utf-8 bom - $textlib = new textlib(); + $textlib = textlib_get_instance(); // converts to propert unicode $text = $textlib->convert($text, $formdata->encoding); $text = $textlib->trim_utf8_bom($text); diff --git a/lib/moodlelib.php b/lib/moodlelib.php index d29c2c9f552..71645640221 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -561,7 +561,7 @@ function clean_param($param, $type) { //cleanup the spaces $param = preg_replace('/ +/', ' ', $param); $param = trim($param); - $textlib = new textlib(); + $textlib = textlib_get_instance(); return $textlib->substr($param, 0, TAG_MAX_LENGTH); @@ -3081,7 +3081,7 @@ function check_password_policy($password, &$errmsg) { return true; } - $textlib = new textlib(); + $textlib = textlib_get_instance(); $errmsg = ''; if ($textlib->strlen($password) < $CFG->minpasswordlength) { $errmsg = get_string('errorminpasswordlength', 'auth', $CFG->minpasswordlength); diff --git a/lib/textlib.class.php b/lib/textlib.class.php index 08e5de3a4b2..d67c5d0e4d2 100644 --- a/lib/textlib.class.php +++ b/lib/textlib.class.php @@ -70,7 +70,7 @@ /// its capabilities so, don't forget to make the conversion /// from every wrapper function! -function textlib_get_instance () { +function textlib_get_instance() { static $instance; if (!is_object($instance)) { $instance = new textlib(); diff --git a/mod/data/view.php b/mod/data/view.php index 60602e3742e..e17e53b9ce4 100755 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -191,7 +191,7 @@ $paging = NULL; } - $textlib = new textlib(); + $textlib = textlib_get_instance(); if ($textlib->strlen($search) < 2) { $search = ''; } diff --git a/tag/lib.php b/tag/lib.php index b973ed0642e..e15f2061b08 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -220,7 +220,7 @@ function tag_display_name($tag_object){ if( empty($CFG->keeptagnamecase) ) { //this is the normalized tag name - $textlib = new textlib(); + $textlib = textlib_get_instance(); return $textlib->strtotitle($tag_object->name); } else {