MDL-11298 use textlib_get_instance() instead of new textlib()

This commit is contained in:
skodak 2007-09-16 18:49:41 +00:00
parent 4eb718d801
commit 8e1ec6be58
7 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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();

View File

@ -191,7 +191,7 @@
$paging = NULL;
}
$textlib = new textlib();
$textlib = textlib_get_instance();
if ($textlib->strlen($search) < 2) {
$search = '';
}

View File

@ -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 {