diff --git a/admin/blocks.php b/admin/blocks.php index 2ad0a0eced4d1..6a2d31efd6e03 100644 --- a/admin/blocks.php +++ b/admin/blocks.php @@ -115,7 +115,7 @@ $blocknames[$blockid] = $blockname; } } - collatorlib::asort($blocknames); + core_collator::asort($blocknames); foreach ($blocknames as $blockid=>$strblockname) { $block = $blocks[$blockid]; diff --git a/admin/localplugins.php b/admin/localplugins.php index 145f65ae20ec7..be09151a5a342 100644 --- a/admin/localplugins.php +++ b/admin/localplugins.php @@ -55,7 +55,7 @@ } $plugins[$plugin] = $strpluginname; } -collatorlib::asort($plugins); +core_collator::asort($plugins); foreach ($plugins as $plugin => $name) { $uninstall = ''; diff --git a/admin/mnet/access_control.php b/admin/mnet/access_control.php index 1c0470e18f713..79c744c9c6d53 100644 --- a/admin/mnet/access_control.php +++ b/admin/mnet/access_control.php @@ -103,7 +103,7 @@ $usernames = explode(',', $form->username); foreach ($usernames as $username) { - $username = trim(textlib::strtolower($username)); + $username = trim(core_text::strtolower($username)); if (!empty($username)) { if (mnet_update_sso_access_control($username, $form->mnet_host_id, $form->accessctrl)) { if ($form->accessctrl == 'allow') { diff --git a/admin/registration/forms.php b/admin/registration/forms.php index 1f868d00e4e8d..8eff8411bb428 100644 --- a/admin/registration/forms.php +++ b/admin/registration/forms.php @@ -137,8 +137,8 @@ public function definition() { $options = array(); foreach ($hubs as $hub) { //to not display a name longer than 100 character (too big) - if (textlib::strlen($hub['name']) > 100) { - $hubname = textlib::substr($hub['name'], 0, 100); + if (core_text::strlen($hub['name']) > 100) { + $hubname = core_text::substr($hub['name'], 0, 100); $hubname = $hubname . "..."; } else { $hubname = $hub['name']; @@ -287,7 +287,7 @@ public function definition() { $mform->addHelpButton('description', 'sitedesc', 'hub'); $languages = get_string_manager()->get_list_of_languages(); - collatorlib::asort($languages); + core_collator::asort($languages); $mform->addElement('select', 'language', get_string('sitelang', 'hub'), $languages); $mform->setType('language', PARAM_ALPHANUMEXT); diff --git a/admin/reports.php b/admin/reports.php index 70ec9525d84a3..0a73d226db9ba 100644 --- a/admin/reports.php +++ b/admin/reports.php @@ -57,7 +57,7 @@ } $plugins[$plugin] = $strpluginname; } -collatorlib::asort($plugins); +core_collator::asort($plugins); $like = $DB->sql_like('plugin', '?', true, true, false, '|'); $params = array('report|_%'); diff --git a/admin/roles/classes/define_role_table_advanced.php b/admin/roles/classes/define_role_table_advanced.php index 496df3ed57c9a..cd7741cc6148c 100644 --- a/admin/roles/classes/define_role_table_advanced.php +++ b/admin/roles/classes/define_role_table_advanced.php @@ -99,8 +99,8 @@ public function read_submitted_permissions() { $shortname = optional_param('shortname', null, PARAM_RAW); if (!is_null($shortname)) { $this->role->shortname = $shortname; - $this->role->shortname = textlib::specialtoascii($this->role->shortname); - $this->role->shortname = textlib::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT)); + $this->role->shortname = core_text::specialtoascii($this->role->shortname); + $this->role->shortname = core_text::strtolower(clean_param($this->role->shortname, PARAM_ALPHANUMEXT)); if (empty($this->role->shortname)) { $this->errors['shortname'] = get_string('errorbadroleshortname', 'core_role'); } diff --git a/admin/tool/uploadcourse/classes/helper.php b/admin/tool/uploadcourse/classes/helper.php index 11ff373f5d7cb..ebd0b75b5f66b 100644 --- a/admin/tool/uploadcourse/classes/helper.php +++ b/admin/tool/uploadcourse/classes/helper.php @@ -117,18 +117,18 @@ public static function generate_shortname_callback($fullname, $idnumber, $block) switch ($block[1]) { case '+': - $repl = textlib::strtoupper($repl); + $repl = core_text::strtoupper($repl); break; case '-': - $repl = textlib::strtolower($repl); + $repl = core_text::strtolower($repl); break; case '~': - $repl = textlib::strtotitle($repl); + $repl = core_text::strtotitle($repl); break; } if (!empty($block[2])) { - $repl = textlib::substr($repl, 0, $block[2]); + $repl = core_text::substr($repl, 0, $block[2]); } return $repl; diff --git a/admin/tool/uploadcourse/classes/step1_form.php b/admin/tool/uploadcourse/classes/step1_form.php index cd0abc0b6c805..189ff9eb68f63 100644 --- a/admin/tool/uploadcourse/classes/step1_form.php +++ b/admin/tool/uploadcourse/classes/step1_form.php @@ -57,7 +57,7 @@ public function definition () { $mform->setDefault('delimiter_name', 'comma'); } - $choices = textlib::get_encodings(); + $choices = core_text::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploadcourse'), $choices); $mform->setDefault('encoding', 'UTF-8'); diff --git a/admin/tool/uploadcourse/cli/uploadcourse.php b/admin/tool/uploadcourse/cli/uploadcourse.php index 1aa4613503569..511d6029828a6 100644 --- a/admin/tool/uploadcourse/cli/uploadcourse.php +++ b/admin/tool/uploadcourse/cli/uploadcourse.php @@ -145,7 +145,7 @@ } // Encoding. -$encodings = textlib::get_encodings(); +$encodings = core_text::get_encodings(); if (!isset($encodings[$options['encoding']])) { echo get_string('invalidencoding', 'tool_uploadcourse')."\n"; echo $help; diff --git a/admin/tool/uploaduser/locallib.php b/admin/tool/uploaduser/locallib.php index a050e803c612e..01863f9858c21 100644 --- a/admin/tool/uploaduser/locallib.php +++ b/admin/tool/uploaduser/locallib.php @@ -183,7 +183,7 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $pr $processed = array(); foreach ($columns as $key=>$unused) { $field = $columns[$key]; - $lcfield = textlib::strtolower($field); + $lcfield = core_text::strtolower($field); if (in_array($field, $stdfields) or in_array($lcfield, $stdfields)) { // standard fields are only lowercase $newfield = $lcfield; @@ -295,18 +295,18 @@ function uu_process_template_callback($username, $firstname, $lastname, $block) switch ($block[1]) { case '+': - $repl = textlib::strtoupper($repl); + $repl = core_text::strtoupper($repl); break; case '-': - $repl = textlib::strtolower($repl); + $repl = core_text::strtolower($repl); break; case '~': - $repl = textlib::strtotitle($repl); + $repl = core_text::strtotitle($repl); break; } if (!empty($block[2])) { - $repl = textlib::substr($repl, 0 , $block[2]); + $repl = core_text::substr($repl, 0 , $block[2]); } return $repl; diff --git a/admin/tool/uploaduser/user_form.php b/admin/tool/uploaduser/user_form.php index b377a9b256884..ce32ea260d59c 100644 --- a/admin/tool/uploaduser/user_form.php +++ b/admin/tool/uploaduser/user_form.php @@ -53,7 +53,7 @@ function definition () { $mform->setDefault('delimiter_name', 'comma'); } - $choices = textlib::get_encodings(); + $choices = core_text::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'tool_uploaduser'), $choices); $mform->setDefault('encoding', 'UTF-8'); diff --git a/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php b/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php index 80416727a51cc..f2128b11acc34 100644 --- a/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php +++ b/admin/tool/xmldb/actions/check_oracle_semantics/check_oracle_semantics.class.php @@ -75,8 +75,8 @@ protected function check_table(xmldb_table $xmldb_table, array $metacolumns) { // Get current semantic from dictionary, we only will process B (BYTE) ones // suplying the SQL code to change them to C (CHAR) semantic $params = array( - 'table_name' => textlib::strtoupper($DB->get_prefix() . $xmldb_table->getName()), - 'column_name' => textlib::strtoupper($xmldb_field->getName()), + 'table_name' => core_text::strtoupper($DB->get_prefix() . $xmldb_table->getName()), + 'column_name' => core_text::strtoupper($xmldb_field->getName()), 'data_type' => 'VARCHAR2'); $currentsemantic = $DB->get_field_sql(' SELECT char_used diff --git a/admin/tools.php b/admin/tools.php index 491e4511cc161..5f6a4686f49e9 100644 --- a/admin/tools.php +++ b/admin/tools.php @@ -57,7 +57,7 @@ } $plugins[$plugin] = $strpluginname; } -collatorlib::asort($plugins); +core_collator::asort($plugins); $like = $DB->sql_like('plugin', '?', true, true, false, '|'); $params = array('tool|_%'); diff --git a/auth/cas/auth.php b/auth/cas/auth.php index 95ab72523d92b..6d1d5820ed13d 100644 --- a/auth/cas/auth.php +++ b/auth/cas/auth.php @@ -61,7 +61,7 @@ function prevent_local_passwords() { */ function user_login ($username, $password) { $this->connectCAS(); - return phpCAS::isAuthenticated() && (trim(textlib::strtolower(phpCAS::getUser())) == $username); + return phpCAS::isAuthenticated() && (trim(core_text::strtolower(phpCAS::getUser())) == $username); } /** @@ -381,15 +381,15 @@ function process_config($config) { set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig); set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig); set_config('contexts', trim($config->contexts), $this->pluginconfig); - set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig); - set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig); + set_config('user_type', core_text::strtolower(trim($config->user_type)), $this->pluginconfig); + set_config('user_attribute', core_text::strtolower(trim($config->user_attribute)), $this->pluginconfig); set_config('search_sub', $config->search_sub, $this->pluginconfig); set_config('opt_deref', $config->opt_deref, $this->pluginconfig); set_config('bind_dn', trim($config->bind_dn), $this->pluginconfig); set_config('bind_pw', $config->bind_pw, $this->pluginconfig); set_config('ldap_version', $config->ldap_version, $this->pluginconfig); set_config('objectclass', trim($config->objectclass), $this->pluginconfig); - set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig); + set_config('memberattribute', core_text::strtolower(trim($config->memberattribute)), $this->pluginconfig); set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig); set_config('attrcreators', trim($config->attrcreators), $this->pluginconfig); set_config('groupecreators', trim($config->groupecreators), $this->pluginconfig); @@ -409,7 +409,7 @@ function iscreator($username) { return false; } - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); // Test for group creator if (!empty($this->config->groupecreators)) { diff --git a/auth/db/auth.php b/auth/db/auth.php index f245d60febbba..de5061da32a8f 100644 --- a/auth/db/auth.php +++ b/auth/db/auth.php @@ -58,8 +58,8 @@ function __construct() { function user_login($username, $password) { global $CFG, $DB; - $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding); - $extpassword = textlib::convert($password, 'utf-8', $this->config->extencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding); + $extpassword = core_text::convert($password, 'utf-8', $this->config->extencoding); if ($this->is_internal()) { // Lookup username externally, but resolve @@ -176,7 +176,7 @@ function db_attributes() { function get_userinfo($username) { global $CFG; - $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding); $authdb = $this->db_init(); @@ -199,7 +199,7 @@ function get_userinfo($username) { $fields_obj = $rs->FetchObj(); $fields_obj = (object)array_change_key_case((array)$fields_obj , CASE_LOWER); foreach ($selectfields as $localname=>$externalname) { - $result[$localname] = textlib::convert($fields_obj->{$localname}, $this->config->extencoding, 'utf-8'); + $result[$localname] = core_text::convert($fields_obj->{$localname}, $this->config->extencoding, 'utf-8'); } } $rs->Close(); @@ -426,7 +426,7 @@ function user_exists($username) { // Init result value. $result = false; - $extusername = textlib::convert($username, 'utf-8', $this->config->extencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->extencoding); $authdb = $this->db_init(); @@ -501,7 +501,7 @@ function update_user_record($username, $updatekeys=false) { global $CFG, $DB; //just in case check text case - $username = trim(textlib::strtolower($username)); + $username = trim(core_text::strtolower($username)); // get the current user record $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id)); @@ -569,7 +569,7 @@ function user_update($olduser, $newuser) { return false; } - $extusername = textlib::convert($olduser->username, 'utf-8', $this->config->extencoding); + $extusername = core_text::convert($olduser->username, 'utf-8', $this->config->extencoding); $authdb = $this->db_init(); @@ -586,7 +586,7 @@ function user_update($olduser, $newuser) { } $nuvalue = $newuser->$key; if ($nuvalue != $value) { - $update[] = $this->config->{"field_map_$key"}."='".$this->ext_addslashes(textlib::convert($nuvalue, 'utf-8', $this->config->extencoding))."'"; + $update[] = $this->config->{"field_map_$key"}."='".$this->ext_addslashes(core_text::convert($nuvalue, 'utf-8', $this->config->extencoding))."'"; } } if (!empty($update)) { diff --git a/auth/ldap/auth.php b/auth/ldap/auth.php index dae99230a6651..a1a964514753b 100644 --- a/auth/ldap/auth.php +++ b/auth/ldap/auth.php @@ -168,8 +168,8 @@ function user_login($username, $password) { return false; } - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); - $extpassword = textlib::convert($password, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); + $extpassword = core_text::convert($password, 'utf-8', $this->config->ldapencoding); // Before we connect to LDAP, check if this is an AD SSO login // if we succeed in this block, we'll return success early. @@ -250,7 +250,7 @@ function user_login($username, $password) { * @return mixed array with no magic quotes or false on error */ function get_userinfo($username) { - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); if(!($user_dn = $this->ldap_find_userdn($ldapconnection, $extusername))) { @@ -298,9 +298,9 @@ function get_userinfo($username) { continue; // wrong data mapping! } if (is_array($entry[$value])) { - $newval = textlib::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8'); + $newval = core_text::convert($entry[$value][0], $this->config->ldapencoding, 'utf-8'); } else { - $newval = textlib::convert($entry[$value], $this->config->ldapencoding, 'utf-8'); + $newval = core_text::convert($entry[$value], $this->config->ldapencoding, 'utf-8'); } if (!empty($newval)) { // favour ldap entries that are set $ldapval = $newval; @@ -351,7 +351,7 @@ function get_userlist() { * @param string $username */ function user_exists($username) { - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); // Returns true if given username exists on ldap $users = $this->ldap_get_userlist('('.$this->config->user_attribute.'='.ldap_filter_addslashes($extusername).')'); @@ -367,8 +367,8 @@ function user_exists($username) { * @param mixed $plainpass Plaintext password */ function user_create($userobject, $plainpass) { - $extusername = textlib::convert($userobject->username, 'utf-8', $this->config->ldapencoding); - $extpassword = textlib::convert($plainpass, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($userobject->username, 'utf-8', $this->config->ldapencoding); + $extpassword = core_text::convert($plainpass, 'utf-8', $this->config->ldapencoding); switch ($this->config->passtype) { case 'md5': @@ -393,7 +393,7 @@ function user_create($userobject, $plainpass) { } foreach ($values as $value) { if (!empty($userobject->$key) ) { - $newuser[$value] = textlib::convert($userobject->$key, 'utf-8', $this->config->ldapencoding); + $newuser[$value] = core_text::convert($userobject->$key, 'utf-8', $this->config->ldapencoding); } } } @@ -637,7 +637,7 @@ function user_confirm($username, $confirmsecret) { function password_expire($username) { $result = 0; - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); $user_dn = $this->ldap_find_userdn($ldapconnection, $extusername); @@ -735,7 +735,7 @@ function sync_users($do_updates=true) { if ($entry = @ldap_first_entry($ldapconnection, $ldap_result)) { do { $value = ldap_get_values_len($ldapconnection, $entry, $this->config->user_attribute); - $value = textlib::convert($value[0], $this->config->ldapencoding, 'utf-8'); + $value = core_text::convert($value[0], $this->config->ldapencoding, 'utf-8'); $this->ldap_bulk_insert($value); } while ($entry = ldap_next_entry($ldapconnection, $entry)); } @@ -945,7 +945,7 @@ function sync_users($do_updates=true) { $user->mnethostid = $CFG->mnet_localhost_id; // get_userinfo_asobj() might have replaced $user->username with the value // from the LDAP server (which can be mixed-case). Make sure it's lowercase - $user->username = trim(textlib::strtolower($user->username)); + $user->username = trim(core_text::strtolower($user->username)); if (empty($user->lang)) { $user->lang = $CFG->lang; } @@ -991,7 +991,7 @@ function update_user_record($username, $updatekeys = false) { global $CFG, $DB; // Just in case check text case - $username = trim(textlib::strtolower($username)); + $username = trim(core_text::strtolower($username)); // Get the current user record $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id)); @@ -1040,7 +1040,7 @@ function update_user_record($username, $updatekeys = false) { function ldap_bulk_insert($username) { global $DB, $CFG; - $username = textlib::strtolower($username); // usernames are __always__ lowercase. + $username = core_text::strtolower($username); // usernames are __always__ lowercase. $DB->insert_record_raw('tmp_extuser', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id), false, true); echo '.'; @@ -1053,7 +1053,7 @@ function ldap_bulk_insert($username) { * @return boolean result */ function user_activate($username) { - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); @@ -1103,7 +1103,7 @@ function iscreator($username) { return null; } - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); @@ -1161,7 +1161,7 @@ function user_update($olduser, $newuser) { return true; } - $extoldusername = textlib::convert($olduser->username, 'utf-8', $this->config->ldapencoding); + $extoldusername = core_text::convert($olduser->username, 'utf-8', $this->config->ldapencoding); $ldapconnection = $this->ldap_connect(); @@ -1223,9 +1223,9 @@ function user_update($olduser, $newuser) { $ambiguous = false; } - $nuvalue = textlib::convert($newuser->$profilefield, 'utf-8', $this->config->ldapencoding); + $nuvalue = core_text::convert($newuser->$profilefield, 'utf-8', $this->config->ldapencoding); empty($nuvalue) ? $nuvalue = array() : $nuvalue; - $ouvalue = textlib::convert($olduser->$profilefield, 'utf-8', $this->config->ldapencoding); + $ouvalue = core_text::convert($olduser->$profilefield, 'utf-8', $this->config->ldapencoding); foreach ($ldapkeys as $ldapkey) { $ldapkey = $ldapkey; @@ -1321,8 +1321,8 @@ function user_update_password($user, $newpassword) { $result = false; $username = $user->username; - $extusername = textlib::convert($username, 'utf-8', $this->config->ldapencoding); - $extpassword = textlib::convert($newpassword, 'utf-8', $this->config->ldapencoding); + $extusername = core_text::convert($username, 'utf-8', $this->config->ldapencoding); + $extpassword = core_text::convert($newpassword, 'utf-8', $this->config->ldapencoding); switch ($this->config->passtype) { case 'md5': @@ -1498,13 +1498,13 @@ function ldap_attributes () { foreach ($userfields as $field) { if (!empty($this->config->{"field_map_$field"})) { - $moodleattributes[$field] = textlib::strtolower(trim($this->config->{"field_map_$field"})); + $moodleattributes[$field] = core_text::strtolower(trim($this->config->{"field_map_$field"})); if (preg_match('/,/', $moodleattributes[$field])) { $moodleattributes[$field] = explode(',', $moodleattributes[$field]); // split ? } } } - $moodleattributes['username'] = textlib::strtolower(trim($this->config->user_attribute)); + $moodleattributes['username'] = core_text::strtolower(trim($this->config->user_attribute)); return $moodleattributes; } @@ -1555,7 +1555,7 @@ function ldap_get_userlist($filter='*') { $users = ldap_get_entries_moodle($ldapconnection, $ldap_result); // Add found users to list. for ($i = 0; $i < count($users); $i++) { - $extuser = textlib::convert($users[$i][$this->config->user_attribute][0], + $extuser = core_text::convert($users[$i][$this->config->user_attribute][0], $this->config->ldapencoding, 'utf-8'); array_push($fresult, $extuser); } @@ -1696,7 +1696,7 @@ function ntlmsso_magic($sesskey) { // (according to my reading of RFC-1945, RFC-2616 and RFC-2617 and // my local tests), so we need to convert the REMOTE_USER value // (i.e., what we got from the HTTP WWW-Authenticate header) into UTF-8 - $username = textlib::convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8'); + $username = core_text::convert($_SERVER['REMOTE_USER'], 'iso-8859-1', 'utf-8'); switch ($this->config->ntlmsso_type) { case 'ntlm': @@ -1715,7 +1715,7 @@ function ntlmsso_magic($sesskey) { return false; // Should never happen! } - $username = textlib::strtolower($username); // Compatibility hack + $username = core_text::strtolower($username); // Compatibility hack set_cache_flag($this->pluginconfig.'/ntlmsess', $sesskey, $username, AUTH_NTLMTIMEOUT); return true; } @@ -1924,7 +1924,7 @@ function process_config($config) { // Try to remove duplicates before storing the contexts (to avoid problems in sync_users()). $config->contexts = explode(';', $config->contexts); - $config->contexts = array_map(create_function('$x', 'return textlib::strtolower(trim($x));'), + $config->contexts = array_map(create_function('$x', 'return core_text::strtolower(trim($x));'), $config->contexts); $config->contexts = implode(';', array_unique($config->contexts)); @@ -1934,8 +1934,8 @@ function process_config($config) { set_config('ldapencoding', trim($config->ldapencoding), $this->pluginconfig); set_config('pagesize', (int)trim($config->pagesize), $this->pluginconfig); set_config('contexts', $config->contexts, $this->pluginconfig); - set_config('user_type', textlib::strtolower(trim($config->user_type)), $this->pluginconfig); - set_config('user_attribute', textlib::strtolower(trim($config->user_attribute)), $this->pluginconfig); + set_config('user_type', core_text::strtolower(trim($config->user_type)), $this->pluginconfig); + set_config('user_attribute', core_text::strtolower(trim($config->user_attribute)), $this->pluginconfig); set_config('search_sub', $config->search_sub, $this->pluginconfig); set_config('opt_deref', $config->opt_deref, $this->pluginconfig); set_config('preventpassindb', $config->preventpassindb, $this->pluginconfig); @@ -1943,15 +1943,15 @@ function process_config($config) { set_config('bind_pw', $config->bind_pw, $this->pluginconfig); set_config('ldap_version', $config->ldap_version, $this->pluginconfig); set_config('objectclass', trim($config->objectclass), $this->pluginconfig); - set_config('memberattribute', textlib::strtolower(trim($config->memberattribute)), $this->pluginconfig); + set_config('memberattribute', core_text::strtolower(trim($config->memberattribute)), $this->pluginconfig); set_config('memberattribute_isdn', $config->memberattribute_isdn, $this->pluginconfig); set_config('creators', trim($config->creators), $this->pluginconfig); set_config('create_context', trim($config->create_context), $this->pluginconfig); set_config('expiration', $config->expiration, $this->pluginconfig); set_config('expiration_warning', trim($config->expiration_warning), $this->pluginconfig); - set_config('expireattr', textlib::strtolower(trim($config->expireattr)), $this->pluginconfig); + set_config('expireattr', core_text::strtolower(trim($config->expireattr)), $this->pluginconfig); set_config('gracelogins', $config->gracelogins, $this->pluginconfig); - set_config('graceattr', textlib::strtolower(trim($config->graceattr)), $this->pluginconfig); + set_config('graceattr', core_text::strtolower(trim($config->graceattr)), $this->pluginconfig); set_config('auth_user_create', $config->auth_user_create, $this->pluginconfig); set_config('forcechangepassword', $config->forcechangepassword, $this->pluginconfig); set_config('stdchangepassword', $config->stdchangepassword, $this->pluginconfig); diff --git a/backup/converter/moodle1/handlerlib.php b/backup/converter/moodle1/handlerlib.php index 539d804974f52..c3df06bec7d59 100644 --- a/backup/converter/moodle1/handlerlib.php +++ b/backup/converter/moodle1/handlerlib.php @@ -1222,7 +1222,7 @@ public function process_question(array $data, array $raw) { // replay the upgrade step 2010080901 - updating question image if (!empty($data['image'])) { - if (textlib::substr(textlib::strtolower($data['image']), 0, 7) == 'http://') { + if (core_text::substr(core_text::strtolower($data['image']), 0, 7) == 'http://') { // it is a link, appending to existing question text $data['questiontext'] .= ' '; diff --git a/backup/converter/moodle1/lib.php b/backup/converter/moodle1/lib.php index 8f7ec304f608b..fb9b9e14622a5 100644 --- a/backup/converter/moodle1/lib.php +++ b/backup/converter/moodle1/lib.php @@ -1233,7 +1233,7 @@ public function migrate_file($sourcepath, $filepath = '/', $filename = null, $so } $filepath = clean_param($filepath, PARAM_PATH); - if (textlib::strlen($filepath) > 255) { + if (core_text::strlen($filepath) > 255) { throw new moodle1_convert_exception('file_path_longer_than_255_chars'); } diff --git a/backup/util/dbops/backup_plan_dbops.class.php b/backup/util/dbops/backup_plan_dbops.class.php index 2e2faaeb05e4e..530763752be58 100644 --- a/backup/util/dbops/backup_plan_dbops.class.php +++ b/backup/util/dbops/backup_plan_dbops.class.php @@ -204,7 +204,7 @@ public static function get_default_backup_filename($format, $type, $id, $users, global $DB; // Calculate backup word - $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename'))); + $backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename'))); $backupword = trim(clean_filename($backupword), '_'); // Not $useidonly, lets fetch the name @@ -228,7 +228,7 @@ public static function get_default_backup_filename($format, $type, $id, $users, break; } $shortname = str_replace(' ', '_', $shortname); - $shortname = textlib::strtolower(trim(clean_filename($shortname), '_')); + $shortname = core_text::strtolower(trim(clean_filename($shortname), '_')); } // The name will always contain the ID, but we append the course short name if requested. @@ -240,7 +240,7 @@ public static function get_default_backup_filename($format, $type, $id, $users, // Calculate date $backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig')); $date = userdate(time(), $backupdateformat, 99, false); - $date = textlib::strtolower(trim(clean_filename($date), '_')); + $date = core_text::strtolower(trim(clean_filename($date), '_')); // Calculate info $info = ''; diff --git a/backup/util/helper/backup_cron_helper.class.php b/backup/util/helper/backup_cron_helper.class.php index e90125d1bcc38..5913324601859 100644 --- a/backup/util/helper/backup_cron_helper.class.php +++ b/backup/util/helper/backup_cron_helper.class.php @@ -554,7 +554,7 @@ public static function remove_excess_backups($course) { return true; } - $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename'))); + $backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename'))); $backupword = trim(clean_filename($backupword), '_'); if (!file_exists($dir) || !is_dir($dir) || !is_writable($dir)) { diff --git a/blocks/activity_modules/block_activity_modules.php b/blocks/activity_modules/block_activity_modules.php index 7383658d7baa6..6dc2f9b1055ba 100644 --- a/blocks/activity_modules/block_activity_modules.php +++ b/blocks/activity_modules/block_activity_modules.php @@ -49,7 +49,7 @@ function get_content() { } } - collatorlib::asort($modfullnames); + core_collator::asort($modfullnames); foreach ($modfullnames as $modname => $modfullname) { if ($modname === 'resources') { diff --git a/blocks/community/forms.php b/blocks/community/forms.php index cb8d7d3e1887e..3a01716737093 100644 --- a/blocks/community/forms.php +++ b/blocks/community/forms.php @@ -272,7 +272,7 @@ public function definition() { $mform->setDefault('licence', $licence); $languages = get_string_manager()->get_list_of_languages(); - collatorlib::asort($languages); + core_collator::asort($languages); $languages = array_merge(array('all' => get_string('any')), $languages); $mform->addElement('select', 'language', get_string('language'), $languages); diff --git a/blocks/completionstatus/details.php b/blocks/completionstatus/details.php index b842fb4bc4cbf..be4cd2fd4c093 100644 --- a/blocks/completionstatus/details.php +++ b/blocks/completionstatus/details.php @@ -210,12 +210,12 @@ $agg = $info->get_aggregation_method($row['type']); echo '('. html_writer::start_tag('i'); if ($agg == COMPLETION_AGGREGATION_ALL) { - echo textlib::strtolower(get_string('all', 'completion')); + echo core_text::strtolower(get_string('all', 'completion')); } else { - echo textlib::strtolower(get_string('any', 'completion')); + echo core_text::strtolower(get_string('any', 'completion')); } - echo html_writer::end_tag('i') .textlib::strtolower(get_string('required')).')'; + echo html_writer::end_tag('i') .core_text::strtolower(get_string('required')).')'; $agg_type = false; } } diff --git a/blocks/navigation/block_navigation.php b/blocks/navigation/block_navigation.php index 2252e85a45bee..9b2613baeeb69 100644 --- a/blocks/navigation/block_navigation.php +++ b/blocks/navigation/block_navigation.php @@ -255,31 +255,31 @@ public function html_attributes() { public function trim(navigation_node $node, $mode=1, $long=50, $short=25, $recurse=true) { switch ($mode) { case self::TRIM_RIGHT : - if (textlib::strlen($node->text)>($long+3)) { + if (core_text::strlen($node->text)>($long+3)) { // Truncate the text to $long characters $node->text = $this->trim_right($node->text, $long); } - if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) { + if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) { // Truncate the shorttext $node->shorttext = $this->trim_right($node->shorttext, $short); } break; case self::TRIM_LEFT : - if (textlib::strlen($node->text)>($long+3)) { + if (core_text::strlen($node->text)>($long+3)) { // Truncate the text to $long characters $node->text = $this->trim_left($node->text, $long); } - if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) { + if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) { // Truncate the shorttext $node->shorttext = $this->trim_left($node->shorttext, $short); } break; case self::TRIM_CENTER : - if (textlib::strlen($node->text)>($long+3)) { + if (core_text::strlen($node->text)>($long+3)) { // Truncate the text to $long characters $node->text = $this->trim_center($node->text, $long); } - if (is_string($node->shorttext) && textlib::strlen($node->shorttext)>($short+3)) { + if (is_string($node->shorttext) && core_text::strlen($node->shorttext)>($short+3)) { // Truncate the shorttext $node->shorttext = $this->trim_center($node->shorttext, $short); } @@ -298,7 +298,7 @@ public function trim(navigation_node $node, $mode=1, $long=50, $short=25, $recur * @return string The truncated string */ protected function trim_left($string, $length) { - return '...'.textlib::substr($string, textlib::strlen($string)-$length, $length); + return '...'.core_text::substr($string, core_text::strlen($string)-$length, $length); } /** * Truncate a string from the right @@ -307,7 +307,7 @@ protected function trim_left($string, $length) { * @return string The truncated string */ protected function trim_right($string, $length) { - return textlib::substr($string, 0, $length).'...'; + return core_text::substr($string, 0, $length).'...'; } /** * Truncate a string in the center @@ -317,8 +317,8 @@ protected function trim_right($string, $length) { */ protected function trim_center($string, $length) { $trimlength = ceil($length/2); - $start = textlib::substr($string, 0, $trimlength); - $end = textlib::substr($string, textlib::strlen($string)-$trimlength); + $start = core_text::substr($string, 0, $trimlength); + $end = core_text::substr($string, core_text::strlen($string)-$trimlength); $string = $start.'...'.$end; return $string; } diff --git a/blocks/rss_client/block_rss_client.php b/blocks/rss_client/block_rss_client.php index 4b861a8492418..e2ab922083b57 100644 --- a/blocks/rss_client/block_rss_client.php +++ b/blocks/rss_client/block_rss_client.php @@ -223,7 +223,7 @@ function get_item_html($item){ if(empty($title)){ // no title present, use portion of description - $title = textlib::substr(strip_tags($description), 0, 20) . '...'; + $title = core_text::substr(strip_tags($description), 0, 20) . '...'; }else{ $title = break_up_long_words($title, 30); } @@ -272,10 +272,10 @@ function get_item_html($item){ */ function format_title($title,$max=64) { - if (textlib::strlen($title) <= $max) { + if (core_text::strlen($title) <= $max) { return s($title); } else { - return s(textlib::substr($title,0,$max-3).'...'); + return s(core_text::substr($title,0,$max-3).'...'); } } diff --git a/blog/lib.php b/blog/lib.php index cfe8771afeb27..c7ee5bd9a2ed5 100644 --- a/blog/lib.php +++ b/blog/lib.php @@ -205,8 +205,8 @@ function blog_sync_external_entries($externalblog) { $newentry->subject = clean_param($entry->get_title(), PARAM_TEXT); // Observe 128 max chars in DB // TODO: +1 to raise this to 255 - if (textlib::strlen($newentry->subject) > 128) { - $newentry->subject = textlib::substr($newentry->subject, 0, 125) . '...'; + if (core_text::strlen($newentry->subject) > 128) { + $newentry->subject = core_text::substr($newentry->subject, 0, 125) . '...'; } $newentry->summary = $entry->get_description(); @@ -241,7 +241,7 @@ function blog_sync_external_entries($externalblog) { $oldesttimestamp = $timestamp; } - if (textlib::strlen($newentry->uniquehash) > 255) { + if (core_text::strlen($newentry->uniquehash) > 255) { // The URL for this item is too long for the field. Rather than add // the entry without the link we will skip straight over it. // RSS spec says recommended length 500, we use 255. diff --git a/course/dnduploadlib.php b/course/dnduploadlib.php index fee7ec0a645c9..917d67051f62d 100644 --- a/course/dnduploadlib.php +++ b/course/dnduploadlib.php @@ -588,9 +588,9 @@ protected function handle_other_upload($content) { * @return string the display name to use */ protected function display_name_from_file($filename) { - $pos = textlib::strrpos($filename, '.'); + $pos = core_text::strrpos($filename, '.'); if ($pos) { // Want to skip if $pos === 0 OR $pos === false. - $filename = textlib::substr($filename, 0, $pos); + $filename = core_text::substr($filename, 0, $pos); } return str_replace('_', ' ', $filename); } diff --git a/course/lib.php b/course/lib.php index 670e6d2aea750..609235060aefd 100644 --- a/course/lib.php +++ b/course/lib.php @@ -405,7 +405,7 @@ function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0, $per // If $log->url has been trimmed short by the db size restriction // code in add_to_log, keep a note so we don't add a link to a broken url - $brokenurl=(textlib::strlen($log->url)==100 && textlib::substr($log->url,97)=='...'); + $brokenurl=(core_text::strlen($log->url)==100 && core_text::substr($log->url,97)=='...'); $row = array(); if ($course->id == SITEID) { @@ -1039,8 +1039,8 @@ function get_module_types_names($plural = false) { $modnames[1][$mod->name] = get_string("modulenameplural", "$mod->name"); } } - collatorlib::asort($modnames[0]); - collatorlib::asort($modnames[1]); + core_collator::asort($modnames[0]); + core_collator::asort($modnames[1]); } } return $modnames[(int)$plural]; @@ -1966,11 +1966,11 @@ function course_format_name ($course,$max=100) { $shortname = format_string($course->shortname, true, array('context' => $context)); $fullname = format_string($course->fullname, true, array('context' => context_course::instance($course->id))); $str = $shortname.': '. $fullname; - if (textlib::strlen($str) <= $max) { + if (core_text::strlen($str) <= $max) { return $str; } else { - return textlib::substr($str,0,$max-3).'...'; + return core_text::substr($str,0,$max-3).'...'; } } diff --git a/course/manage.php b/course/manage.php index df8c5f473efc2..d4a905455cd27 100644 --- a/course/manage.php +++ b/course/manage.php @@ -194,7 +194,7 @@ if ($coursecat->id && $canmanage && $resort && confirm_sesskey()) { // Resort the category. if ($courses = get_courses($coursecat->id, '', 'c.id,c.fullname,c.sortorder')) { - collatorlib::asort_objects_by_property($courses, 'fullname', collatorlib::SORT_NATURAL); + core_collator::asort_objects_by_property($courses, 'fullname', core_collator::SORT_NATURAL); $i = 1; foreach ($courses as $course) { $DB->set_field('course', 'sortorder', $coursecat->sortorder + $i, array('id' => $course->id)); diff --git a/course/publish/forms.php b/course/publish/forms.php index ceb6b10b2b959..898c5ac459887 100644 --- a/course/publish/forms.php +++ b/course/publish/forms.php @@ -248,7 +248,7 @@ public function definition() { $mform->addHelpButton('description', 'description', 'hub'); $languages = get_string_manager()->get_list_of_languages(); - collatorlib::asort($languages); + core_collator::asort($languages); $mform->addElement('select', 'language', get_string('language'), $languages); $mform->setDefault('language', $defaultlanguage); $mform->addHelpButton('language', 'language', 'hub'); diff --git a/course/renderer.php b/course/renderer.php index 608ba6982868f..8096fd60385d5 100644 --- a/course/renderer.php +++ b/course/renderer.php @@ -708,8 +708,8 @@ public function course_section_cm_name(cm_info $mod, $displayoptions = array()) // Avoid unnecessary duplication: if e.g. a forum name already // includes the word forum (or Forum, etc) then it is unhelpful // to include that in the accessible description that is added. - if (false !== strpos(textlib::strtolower($instancename), - textlib::strtolower($altname))) { + if (false !== strpos(core_text::strtolower($instancename), + core_text::strtolower($altname))) { $altname = ''; } // File type after name, for alphabetic lists (screen reader). diff --git a/enrol/database/lib.php b/enrol/database/lib.php index fc57b58358c8c..052458a1e0517 100644 --- a/enrol/database/lib.php +++ b/enrol/database/lib.php @@ -855,7 +855,7 @@ protected function db_encode($text) { } return $text; } else { - return textlib::convert($text, 'utf-8', $dbenc); + return core_text::convert($text, 'utf-8', $dbenc); } } @@ -870,7 +870,7 @@ protected function db_decode($text) { } return $text; } else { - return textlib::convert($text, $dbenc, 'utf-8'); + return core_text::convert($text, $dbenc, 'utf-8'); } } diff --git a/enrol/flatfile/lib.php b/enrol/flatfile/lib.php index f3a0908a7a83b..4add14e4b253a 100644 --- a/enrol/flatfile/lib.php +++ b/enrol/flatfile/lib.php @@ -252,7 +252,7 @@ protected function process_file(progress_trace $trace) { $rolemap = $this->get_role_map($trace); - $content = textlib::convert($content, $this->get_config('encoding', 'utf-8'), 'utf-8'); + $content = core_text::convert($content, $this->get_config('encoding', 'utf-8'), 'utf-8'); $content = str_replace("\r", '', $content); $content = explode("\n", $content); @@ -278,8 +278,8 @@ protected function process_file(progress_trace $trace) { continue; } - $fields[0] = trim(textlib::strtolower($fields[0])); - $fields[1] = trim(textlib::strtolower($fields[1])); + $fields[0] = trim(core_text::strtolower($fields[0])); + $fields[1] = trim(core_text::strtolower($fields[1])); $fields[2] = trim($fields[2]); $fields[3] = trim($fields[3]); $fields[4] = isset($fields[4]) ? (int)trim($fields[4]) : 0; @@ -664,7 +664,7 @@ protected function get_role_map(progress_trace $trace) { $roles = $DB->get_records('role', null, '', 'id, name, shortname'); foreach ($roles as $id=>$role) { $alias = $this->get_config('map_'.$id, $role->shortname, ''); - $alias = trim(textlib::strtolower($alias)); + $alias = trim(core_text::strtolower($alias)); if ($alias === '') { // Either not configured yet or somebody wants to skip these intentionally. continue; diff --git a/enrol/flatfile/settings.php b/enrol/flatfile/settings.php index 379568e5dd780..5b7d345a75775 100644 --- a/enrol/flatfile/settings.php +++ b/enrol/flatfile/settings.php @@ -34,7 +34,7 @@ $settings->add(new admin_setting_configfile('enrol_flatfile/location', get_string('location', 'enrol_flatfile'), get_string('location_desc', 'enrol_flatfile'), '')); - $options = textlib::get_encodings(); + $options = core_text::get_encodings(); $settings->add(new admin_setting_configselect('enrol_flatfile/encoding', get_string('encoding', 'enrol_flatfile'), '', 'UTF-8', $options)); $settings->add(new admin_setting_configcheckbox('enrol_flatfile/mailstudents', get_string('notifyenrolled', 'enrol_flatfile'), '', 0)); diff --git a/enrol/flatfile/tests/flatfile_test.php b/enrol/flatfile/tests/flatfile_test.php index 976d109d466d6..93ed0ef784528 100644 --- a/enrol/flatfile/tests/flatfile_test.php +++ b/enrol/flatfile/tests/flatfile_test.php @@ -167,7 +167,7 @@ public function test_sync() { // Test encoding. $data = "add;student;čtvrtý;c3"; - $data = textlib::convert($data, 'utf-8', 'iso-8859-2'); + $data = core_text::convert($data, 'utf-8', 'iso-8859-2'); file_put_contents($file, $data); $flatfileplugin->set_config('encoding', 'iso-8859-2'); diff --git a/enrol/guest/locallib.php b/enrol/guest/locallib.php index 14e13a92fb485..2fecf89ab67d1 100644 --- a/enrol/guest/locallib.php +++ b/enrol/guest/locallib.php @@ -61,7 +61,7 @@ public function validation($data, $files) { if ($data['guestpassword'] !== $instance->password) { $plugin = enrol_get_plugin('guest'); if ($plugin->get_config('showhint')) { - $hint = textlib::substr($instance->password, 0, 1); + $hint = core_text::substr($instance->password, 0, 1); $errors['guestpassword'] = get_string('passwordinvalidhint', 'enrol_guest', $hint); } else { $errors['guestpassword'] = get_string('passwordinvalid', 'enrol_guest'); diff --git a/enrol/ldap/lib.php b/enrol/ldap/lib.php index a4448c7654475..9ebacb8be2416 100644 --- a/enrol/ldap/lib.php +++ b/enrol/ldap/lib.php @@ -327,7 +327,7 @@ public function sync_enrolments(progress_trace $trace, $onecourse = null) { $trace->finished(); return; } - $oneidnumber = ldap_filter_addslashes(textlib::convert($course->idnumber, 'utf-8', $this->get_config('ldapencoding'))); + $oneidnumber = ldap_filter_addslashes(core_text::convert($course->idnumber, 'utf-8', $this->get_config('ldapencoding'))); } // Get enrolments for each type of role. @@ -689,7 +689,7 @@ protected function find_ext_enrolments($memberuid, $role) { return array(); } - $extmemberuid = textlib::convert($memberuid, 'utf-8', $this->get_config('ldapencoding')); + $extmemberuid = core_text::convert($memberuid, 'utf-8', $this->get_config('ldapencoding')); if($this->get_config('memberattribute_isdn')) { if (!($extmemberuid = $this->ldap_find_userdn($extmemberuid))) { diff --git a/enrol/ldap/settingslib.php b/enrol/ldap/settingslib.php index c090c2c8d53d0..7b943ab94770a 100644 --- a/enrol/ldap/settingslib.php +++ b/enrol/ldap/settingslib.php @@ -63,7 +63,7 @@ public function write_setting($data) { return $validated; } if ($this->lowercase) { - $data = textlib::strtolower($data); + $data = core_text::strtolower($data); } if (!$this->enabled) { return ''; @@ -134,7 +134,7 @@ public function write_setting($data) { if (!$this->config_write('contexts_role'.$roleid, trim($data['contexts']))) { $return = get_string('errorsetting', 'admin'); } - if (!$this->config_write('memberattribute_role'.$roleid, textlib::strtolower(trim($data['memberattribute'])))) { + if (!$this->config_write('memberattribute_role'.$roleid, core_text::strtolower(trim($data['memberattribute'])))) { $return = get_string('errorsetting', 'admin'); } } diff --git a/enrol/paypal/ipn.php b/enrol/paypal/ipn.php index 4a09dc54baff5..32c67ca0409a8 100644 --- a/enrol/paypal/ipn.php +++ b/enrol/paypal/ipn.php @@ -171,7 +171,7 @@ } - if (textlib::strtolower($data->business) !== textlib::strtolower($plugin->get_config('paypalbusiness'))) { // Check that the email is the one we want it to be + if (core_text::strtolower($data->business) !== core_text::strtolower($plugin->get_config('paypalbusiness'))) { // Check that the email is the one we want it to be message_paypal_error_to_admin("Business email is {$data->business} (not ". $plugin->get_config('paypalbusiness').")", $data); die; diff --git a/enrol/self/locallib.php b/enrol/self/locallib.php index 7d6a917a63279..cd010eb3fd5b2 100644 --- a/enrol/self/locallib.php +++ b/enrol/self/locallib.php @@ -101,7 +101,7 @@ public function validation($data, $files) { } else { $plugin = enrol_get_plugin('self'); if ($plugin->get_config('showhint')) { - $hint = textlib::substr($instance->password, 0, 1); + $hint = core_text::substr($instance->password, 0, 1); $errors['enrolpassword'] = get_string('passwordinvalidhint', 'enrol_self', $hint); } else { $errors['enrolpassword'] = get_string('passwordinvalid', 'enrol_self'); diff --git a/grade/edit/scale/edit_form.php b/grade/edit/scale/edit_form.php index 8cd7d0ddad25a..848cc4b3b0d26 100644 --- a/grade/edit/scale/edit_form.php +++ b/grade/edit/scale/edit_form.php @@ -141,7 +141,7 @@ function validation($data, $files) { $thescale = implode(',',$scalearray); //this check strips out whitespace from the scale we're validating but not from those already in the DB - $count = $DB->count_records_select('scale', "courseid=:courseid AND ".$DB->sql_compare_text('scale', textlib::strlen($thescale)).'=:scale', + $count = $DB->count_records_select('scale', "courseid=:courseid AND ".$DB->sql_compare_text('scale', core_text::strlen($thescale)).'=:scale', array('courseid'=>$courseid, 'scale'=>$thescale)); if ($count) { diff --git a/grade/import/grade_import_form.php b/grade/import/grade_import_form.php index 9f86e483e3b3f..73ff6803d7e91 100644 --- a/grade/import/grade_import_form.php +++ b/grade/import/grade_import_form.php @@ -41,7 +41,7 @@ function definition (){ // file upload $mform->addElement('filepicker', 'userfile', get_string('file')); $mform->addRule('userfile', null, 'required'); - $encodings = textlib::get_encodings(); + $encodings = core_text::get_encodings(); $mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings); if (!empty($features['includeseparator'])) { diff --git a/group/group_form.php b/group/group_form.php index 46f01377a1d6a..6818ca2b1e8cc 100644 --- a/group/group_form.php +++ b/group/group_form.php @@ -101,7 +101,7 @@ function validation($data, $files) { $idnumber = ''; } if ($data['id'] and $group = $DB->get_record('groups', array('id'=>$data['id']))) { - if (textlib::strtolower($group->name) != textlib::strtolower($name)) { + if (core_text::strtolower($group->name) != core_text::strtolower($name)) { if (groups_get_group_by_name($COURSE->id, $name)) { $errors['name'] = get_string('groupnameexists', 'group', $name); } diff --git a/group/grouping_form.php b/group/grouping_form.php index 1f15bc78b5fc3..d44444be2dbde 100644 --- a/group/grouping_form.php +++ b/group/grouping_form.php @@ -93,7 +93,7 @@ function validation($data, $files) { $idnumber = ''; } if ($data['id'] and $grouping = $DB->get_record('groupings', array('id'=>$data['id']))) { - if (textlib::strtolower($grouping->name) != textlib::strtolower($name)) { + if (core_text::strtolower($grouping->name) != core_text::strtolower($name)) { if (groups_get_grouping_by_name($COURSE->id, $name)) { $errors['name'] = get_string('groupingnameexists', 'group', $name); } diff --git a/index.php b/index.php index b5dc3218dd4c0..54defb495e951 100644 --- a/index.php +++ b/index.php @@ -176,7 +176,7 @@ $newsforumcontext = context_module::instance($newsforumcm->id, MUST_EXIST); $forumname = format_string($newsforum->name, true, array('context' => $newsforumcontext)); - echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block')); + echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(strip_tags($forumname))), array('href'=>'#skipsitenews', 'class'=>'skip-block')); // wraps site news forum in div container. echo html_writer::start_tag('div', array('id'=>'site-news-forum')); @@ -210,7 +210,7 @@ case FRONTPAGEENROLLEDCOURSELIST: $mycourseshtml = $courserenderer->frontpage_my_courses(); if (!empty($mycourseshtml)) { - echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block')); + echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('mycourses'))), array('href'=>'#skipmycourses', 'class'=>'skip-block')); //wrap frontpage course list in div container echo html_writer::start_tag('div', array('id'=>'frontpage-course-list')); @@ -229,7 +229,7 @@ case FRONTPAGEALLCOURSELIST: $availablecourseshtml = $courserenderer->frontpage_available_courses(); if (!empty($availablecourseshtml)) { - echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block')); + echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('availablecourses'))), array('href'=>'#skipavailablecourses', 'class'=>'skip-block')); //wrap frontpage course list in div container echo html_writer::start_tag('div', array('id'=>'frontpage-course-list')); @@ -245,7 +245,7 @@ break; case FRONTPAGECATEGORYNAMES: - echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block')); + echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('categories'))), array('href'=>'#skipcategories', 'class'=>'skip-block')); //wrap frontpage category names in div container echo html_writer::start_tag('div', array('id'=>'frontpage-category-names')); @@ -260,7 +260,7 @@ break; case FRONTPAGECATEGORYCOMBO: - echo html_writer::tag('a', get_string('skipa', 'access', textlib::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block')); + echo html_writer::tag('a', get_string('skipa', 'access', core_text::strtolower(get_string('courses'))), array('href'=>'#skipcourses', 'class'=>'skip-block')); //wrap frontpage category combo in div container echo html_writer::start_tag('div', array('id'=>'frontpage-category-combo')); diff --git a/iplookup/lib.php b/iplookup/lib.php index 5ca07d2dde5a6..da07be6ffdf0a 100644 --- a/iplookup/lib.php +++ b/iplookup/lib.php @@ -48,7 +48,7 @@ function iplookup_find_location($ip) { return $info; } if (!empty($location->city)) { - $info['city'] = textlib::convert($location->city, 'iso-8859-1', 'utf-8'); + $info['city'] = core_text::convert($location->city, 'iso-8859-1', 'utf-8'); $info['title'][] = $info['city']; } diff --git a/lib/adminlib.php b/lib/adminlib.php index 3b37521e03d17..25ae3d0cae101 100644 --- a/lib/adminlib.php +++ b/lib/adminlib.php @@ -1235,7 +1235,7 @@ public function search($query) { $found = false; if (strpos(strtolower($this->name), $query) !== false) { $found = true; - } else if (strpos(textlib::strtolower($this->visiblename), $query) !== false) { + } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) { $found = true; } if ($found) { @@ -1382,7 +1382,7 @@ public function search($query) { $found = false; if (strpos(strtolower($this->name), $query) !== false) { $found = true; - } else if (strpos(textlib::strtolower($this->visiblename), $query) !== false) { + } else if (strpos(core_text::strtolower($this->visiblename), $query) !== false) { $found = true; } if ($found) { @@ -1827,16 +1827,16 @@ public function is_related($query) { if (strpos(strtolower($this->name), $query) !== false) { return true; } - if (strpos(textlib::strtolower($this->visiblename), $query) !== false) { + if (strpos(core_text::strtolower($this->visiblename), $query) !== false) { return true; } - if (strpos(textlib::strtolower($this->description), $query) !== false) { + if (strpos(core_text::strtolower($this->description), $query) !== false) { return true; } $current = $this->get_setting(); if (!is_null($current)) { if (is_string($current)) { - if (strpos(textlib::strtolower($current), $query) !== false) { + if (strpos(core_text::strtolower($current), $query) !== false) { return true; } } @@ -1844,7 +1844,7 @@ public function is_related($query) { $default = $this->get_defaultsetting(); if (!is_null($default)) { if (is_string($default)) { - if (strpos(textlib::strtolower($default), $query) !== false) { + if (strpos(core_text::strtolower($default), $query) !== false) { return true; } } @@ -2602,7 +2602,7 @@ public function is_related($query) { } foreach ($this->choices as $desc) { - if (strpos(textlib::strtolower($desc), $query) !== false) { + if (strpos(core_text::strtolower($desc), $query) !== false) { return true; } } @@ -2831,10 +2831,10 @@ public function is_related($query) { return false; } foreach ($this->choices as $key=>$value) { - if (strpos(textlib::strtolower($key), $query) !== false) { + if (strpos(core_text::strtolower($key), $query) !== false) { return true; } - if (strpos(textlib::strtolower($value), $query) !== false) { + if (strpos(core_text::strtolower($value), $query) !== false) { return true; } } @@ -3014,7 +3014,7 @@ public function is_related($query) { } foreach ($this->choices as $desc) { - if (strpos(textlib::strtolower($desc), $query) !== false) { + if (strpos(core_text::strtolower($desc), $query) !== false) { return true; } } @@ -5027,7 +5027,7 @@ public function search($query) { break; } $strmodulename = get_string('modulename', $module->name); - if (strpos(textlib::strtolower($strmodulename), $query) !== false) { + if (strpos(core_text::strtolower($strmodulename), $query) !== false) { $found = true; break; } @@ -5099,14 +5099,14 @@ public function is_related($query) { return true; } - $query = textlib::strtolower($query); + $query = core_text::strtolower($query); $enrols = enrol_get_plugins(false); foreach ($enrols as $name=>$enrol) { $localised = get_string('pluginname', 'enrol_'.$name); - if (strpos(textlib::strtolower($name), $query) !== false) { + if (strpos(core_text::strtolower($name), $query) !== false) { return true; } - if (strpos(textlib::strtolower($localised), $query) !== false) { + if (strpos(core_text::strtolower($localised), $query) !== false) { return true; } } @@ -5295,7 +5295,7 @@ public function search($query) { break; } $strblockname = get_string('pluginname', 'block_'.$block->name); - if (strpos(textlib::strtolower($strblockname), $query) !== false) { + if (strpos(core_text::strtolower($strblockname), $query) !== false) { $found = true; break; } @@ -5349,7 +5349,7 @@ public function search($query) { break; } $strprocessorname = get_string('pluginname', 'message_'.$processor->name); - if (strpos(textlib::strtolower($strprocessorname), $query) !== false) { + if (strpos(core_text::strtolower($strprocessorname), $query) !== false) { $found = true; break; } @@ -5413,7 +5413,7 @@ public function search($query) { $found = false; require_once($CFG->dirroot . '/question/engine/lib.php'); foreach (core_component::get_plugin_list('qbehaviour') as $behaviour => $notused) { - if (strpos(textlib::strtolower(question_engine::get_behaviour_name($behaviour)), + if (strpos(core_text::strtolower(question_engine::get_behaviour_name($behaviour)), $query) !== false) { $found = true; break; @@ -5461,7 +5461,7 @@ public function search($query) { $found = false; require_once($CFG->dirroot . '/question/engine/bank.php'); foreach (question_bank::get_all_qtypes() as $qtype) { - if (strpos(textlib::strtolower($qtype->local_name()), $query) !== false) { + if (strpos(core_text::strtolower($qtype->local_name()), $query) !== false) { $found = true; break; } @@ -5510,7 +5510,7 @@ public function search($query) { if (!$found) { foreach (portfolio_instances(false, false) as $instance) { $title = $instance->get('name'); - if (strpos(textlib::strtolower($title), $query) !== false) { + if (strpos(core_text::strtolower($title), $query) !== false) { $found = true; break; } @@ -5561,7 +5561,7 @@ public function search($query) { if (!$found) { foreach (repository::get_types() as $instance) { $title = $instance->get_typename(); - if (strpos(textlib::strtolower($title), $query) !== false) { + if (strpos(core_text::strtolower($title), $query) !== false) { $found = true; break; } @@ -5640,7 +5640,7 @@ public function is_related($query) { } $authplugin = get_auth_plugin($auth); $authtitle = $authplugin->get_title(); - if (strpos(textlib::strtolower($authtitle), $query) !== false) { + if (strpos(core_text::strtolower($authtitle), $query) !== false) { return true; } } @@ -5841,7 +5841,7 @@ public function is_related($query) { if (strpos($editor, $query) !== false) { return true; } - if (strpos(textlib::strtolower($editorstr), $query) !== false) { + if (strpos(core_text::strtolower($editorstr), $query) !== false) { return true; } } @@ -6107,7 +6107,7 @@ public function is_related($query) { $formats = plugin_manager::instance()->get_plugins_of_type('format'); foreach ($formats as $format) { if (strpos($format->component, $query) !== false || - strpos(textlib::strtolower($format->displayname), $query) !== false) { + strpos(core_text::strtolower($format->displayname), $query) !== false) { return true; } } @@ -6222,7 +6222,7 @@ public function search($query) { $found = false; $filternames = filter_get_all_installed(); foreach ($filternames as $path => $strfiltername) { - if (strpos(textlib::strtolower($strfiltername), $query) !== false) { + if (strpos(core_text::strtolower($strfiltername), $query) !== false) { $found = true; break; } @@ -6536,10 +6536,10 @@ function admin_find_write_settings($node, $data) { function admin_search_settings_html($query) { global $CFG, $OUTPUT; - if (textlib::strlen($query) < 2) { + if (core_text::strlen($query) < 2) { return ''; } - $query = textlib::strtolower($query); + $query = core_text::strtolower($query); $adminroot = admin_get_root(); $findings = $adminroot->search($query); @@ -6884,7 +6884,7 @@ public function is_related($query) { } foreach (repository::get_types() as $instance) { $title = $instance->get_typename(); - if (strpos(textlib::strtolower($title), $query) !== false) { + if (strpos(core_text::strtolower($title), $query) !== false) { return true; } } @@ -7319,7 +7319,7 @@ public function is_related($query) { $services = $DB->get_records('external_services', array(), 'id, name'); foreach ($services as $service) { - if (strpos(textlib::strtolower($service->name), $query) !== false) { + if (strpos(core_text::strtolower($service->name), $query) !== false) { return true; } } @@ -7791,7 +7791,7 @@ public function is_related($query) { return true; } $protocolstr = get_string('pluginname', 'webservice_'.$protocol); - if (strpos(textlib::strtolower($protocolstr), $query) !== false) { + if (strpos(core_text::strtolower($protocolstr), $query) !== false) { return true; } } diff --git a/lib/bennu/iCalendar_rfc2445.php b/lib/bennu/iCalendar_rfc2445.php index a84f370a5c222..d221217c61013 100644 --- a/lib/bennu/iCalendar_rfc2445.php +++ b/lib/bennu/iCalendar_rfc2445.php @@ -56,7 +56,7 @@ function rfc2445_fold($string) { - if(textlib::strlen($string, 'utf-8') <= RFC2445_FOLDED_LINE_LENGTH) { + if(core_text::strlen($string, 'utf-8') <= RFC2445_FOLDED_LINE_LENGTH) { return $string; } @@ -66,15 +66,15 @@ function rfc2445_fold($string) { $len_count=0; //multi-byte string, get the correct length - $section_len = textlib::strlen($string, 'utf-8'); + $section_len = core_text::strlen($string, 'utf-8'); while($len_count<$section_len) { //get the current portion of the line - $section = textlib::substr($string, ($i * RFC2445_FOLDED_LINE_LENGTH), (RFC2445_FOLDED_LINE_LENGTH), 'utf-8'); + $section = core_text::substr($string, ($i * RFC2445_FOLDED_LINE_LENGTH), (RFC2445_FOLDED_LINE_LENGTH), 'utf-8'); //increment the length we've processed by the length of the new portion - $len_count += textlib::strlen($section, 'utf-8'); + $len_count += core_text::strlen($section, 'utf-8'); /* Add the portion to the return value, terminating with CRLF.HTAB As per RFC 2445, CRLF.HTAB will be replaced by the processor of the diff --git a/lib/bennu/readme_moodle.txt b/lib/bennu/readme_moodle.txt index 582b265fde72c..ce650557c2676 100644 --- a/lib/bennu/readme_moodle.txt +++ b/lib/bennu/readme_moodle.txt @@ -2,5 +2,5 @@ Description of Bennu library import - customised library by author, this version modifications: 1/ removed ereg functions deprecated as of php 5.3 (18 Nov 2009) -2/ replaced mbstring functions with moodle textlib (28 Nov 2011) +2/ replaced mbstring functions with moodle core_text (28 Nov 2011) 3/ replaced explode in iCalendar_component::unserialize() with preg_split to support various line breaks (20 Nov 2012) \ No newline at end of file diff --git a/lib/blocklib.php b/lib/blocklib.php index 8d687b2f9ffc0..f14b8926f271a 100644 --- a/lib/blocklib.php +++ b/lib/blocklib.php @@ -1902,7 +1902,7 @@ function block_add_block_ui($page, $output) { $menu[$block->name] = $blockobject->get_title(); } } - collatorlib::asort($menu); + core_collator::asort($menu); $actionurl = new moodle_url($page->url, array('sesskey'=>sesskey())); $select = new single_select($actionurl, 'bui_addblock', $menu, null, array(''=>get_string('adddots')), 'add_block'); diff --git a/lib/classes/collator.php b/lib/classes/collator.php index b3341b4418e76..fa1931ce1dd27 100644 --- a/lib/classes/collator.php +++ b/lib/classes/collator.php @@ -141,7 +141,7 @@ protected static function restore_array(array &$arr, array &$original) { * @return string string with normalised numbers */ protected static function naturalise($string) { - return preg_replace_callback('/[0-9]+/', array('collatorlib', 'callback_naturalise'), $string); + return preg_replace_callback('/[0-9]+/', array('core_collator', 'callback_naturalise'), $string); } /** @@ -158,11 +158,11 @@ public static function callback_naturalise($matches) { * Locale aware sorting, the key associations are kept, values are sorted alphabetically. * * @param array $arr array to be sorted (reference) - * @param int $sortflag One of collatorlib::SORT_NUMERIC, collatorlib::SORT_STRING, collatorlib::SORT_NATURAL, collatorlib::SORT_REGULAR - * optionally "|" collatorlib::CASE_SENSITIVE + * @param int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR + * optionally "|" core_collator::CASE_SENSITIVE * @return bool True on success */ - public static function asort(array &$arr, $sortflag = collatorlib::SORT_STRING) { + public static function asort(array &$arr, $sortflag = core_collator::SORT_STRING) { if (empty($arr)) { // nothing to do return true; @@ -170,26 +170,26 @@ public static function asort(array &$arr, $sortflag = collatorlib::SORT_STRING) $original = null; - $casesensitive = (bool)($sortflag & collatorlib::CASE_SENSITIVE); - $sortflag = ($sortflag & ~collatorlib::CASE_SENSITIVE); - if ($sortflag != collatorlib::SORT_NATURAL and $sortflag != collatorlib::SORT_STRING) { + $casesensitive = (bool)($sortflag & core_collator::CASE_SENSITIVE); + $sortflag = ($sortflag & ~core_collator::CASE_SENSITIVE); + if ($sortflag != core_collator::SORT_NATURAL and $sortflag != core_collator::SORT_STRING) { $casesensitive = false; } if (self::ensure_collator_available()) { - if ($sortflag == collatorlib::SORT_NUMERIC) { + if ($sortflag == core_collator::SORT_NUMERIC) { $flag = Collator::SORT_NUMERIC; - } else if ($sortflag == collatorlib::SORT_REGULAR) { + } else if ($sortflag == core_collator::SORT_REGULAR) { $flag = Collator::SORT_REGULAR; } else { $flag = Collator::SORT_STRING; } - if ($sortflag == collatorlib::SORT_NATURAL) { + if ($sortflag == core_collator::SORT_NATURAL) { $original = $arr; - if ($sortflag == collatorlib::SORT_NATURAL) { + if ($sortflag == core_collator::SORT_NATURAL) { foreach ($arr as $key => $value) { $arr[$key] = self::naturalise((string)$value); } @@ -209,21 +209,21 @@ public static function asort(array &$arr, $sortflag = collatorlib::SORT_STRING) // try some fallback that works at least for English - if ($sortflag == collatorlib::SORT_NUMERIC) { + if ($sortflag == core_collator::SORT_NUMERIC) { return asort($arr, SORT_NUMERIC); - } else if ($sortflag == collatorlib::SORT_REGULAR) { + } else if ($sortflag == core_collator::SORT_REGULAR) { return asort($arr, SORT_REGULAR); } if (!$casesensitive) { $original = $arr; foreach ($arr as $key => $value) { - $arr[$key] = textlib::strtolower($value); + $arr[$key] = core_text::strtolower($value); } } - if ($sortflag == collatorlib::SORT_NATURAL) { + if ($sortflag == core_collator::SORT_NATURAL) { $result = natsort($arr); } else { @@ -242,11 +242,11 @@ public static function asort(array &$arr, $sortflag = collatorlib::SORT_STRING) * * @param array $objects An array of objects to sort (handled by reference) * @param string $property The property to use for comparison - * @param int $sortflag One of collatorlib::SORT_NUMERIC, collatorlib::SORT_STRING, collatorlib::SORT_NATURAL, collatorlib::SORT_REGULAR - * optionally "|" collatorlib::CASE_SENSITIVE + * @param int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR + * optionally "|" core_collator::CASE_SENSITIVE * @return bool True on success */ - public static function asort_objects_by_property(array &$objects, $property, $sortflag = collatorlib::SORT_STRING) { + public static function asort_objects_by_property(array &$objects, $property, $sortflag = core_collator::SORT_STRING) { $original = $objects; foreach ($objects as $key => $object) { $objects[$key] = $object->$property; @@ -261,11 +261,11 @@ public static function asort_objects_by_property(array &$objects, $property, $so * * @param array $objects An array of objects to sort (handled by reference) * @param string $method The method to call to generate a value for comparison - * @param int $sortflag One of collatorlib::SORT_NUMERIC, collatorlib::SORT_STRING, collatorlib::SORT_NATURAL, collatorlib::SORT_REGULAR - * optionally "|" collatorlib::CASE_SENSITIVE + * @param int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR + * optionally "|" core_collator::CASE_SENSITIVE * @return bool True on success */ - public static function asort_objects_by_method(array &$objects, $method, $sortflag = collatorlib::SORT_STRING) { + public static function asort_objects_by_method(array &$objects, $method, $sortflag = core_collator::SORT_STRING) { $original = $objects; foreach ($objects as $key => $object) { $objects[$key] = $object->{$method}(); @@ -279,11 +279,11 @@ public static function asort_objects_by_method(array &$objects, $method, $sortfl * Locale aware sorting, the key associations are kept, keys are sorted alphabetically. * * @param array $arr array to be sorted (reference) - * @param int $sortflag One of collatorlib::SORT_NUMERIC, collatorlib::SORT_STRING, collatorlib::SORT_NATURAL, collatorlib::SORT_REGULAR - * optionally "|" collatorlib::CASE_SENSITIVE + * @param int $sortflag One of core_collator::SORT_NUMERIC, core_collator::SORT_STRING, core_collator::SORT_NATURAL, core_collator::SORT_REGULAR + * optionally "|" core_collator::CASE_SENSITIVE * @return bool True on success */ - public static function ksort(array &$arr, $sortflag = collatorlib::SORT_STRING) { + public static function ksort(array &$arr, $sortflag = core_collator::SORT_STRING) { $keys = array_keys($arr); if (!self::asort($keys, $sortflag)) { return false; diff --git a/lib/coursecatlib.php b/lib/coursecatlib.php index 05bbc6ba59285..b33cc90cd051f 100644 --- a/lib/coursecatlib.php +++ b/lib/coursecatlib.php @@ -310,14 +310,14 @@ public static function create($data, $editoroptions = null) { if (empty($data->name)) { throw new moodle_exception('categorynamerequired'); } - if (textlib::strlen($data->name) > 255) { + if (core_text::strlen($data->name) > 255) { throw new moodle_exception('categorytoolong'); } $newcategory->name = $data->name; // validate and set idnumber if (!empty($data->idnumber)) { - if (textlib::strlen($data->idnumber) > 100) { + if (core_text::strlen($data->idnumber) > 100) { throw new moodle_exception('idnumbertoolong'); } if ($DB->record_exists('course_categories', array('idnumber' => $data->idnumber))) { @@ -427,14 +427,14 @@ public function update($data, $editoroptions = null) { } if (!empty($data->name) && $data->name !== $this->name) { - if (textlib::strlen($data->name) > 255) { + if (core_text::strlen($data->name) > 255) { throw new moodle_exception('categorytoolong'); } $newcategory->name = $data->name; } if (isset($data->idnumber) && $data->idnumber != $this->idnumber) { - if (textlib::strlen($data->idnumber) > 100) { + if (core_text::strlen($data->idnumber) > 100) { throw new moodle_exception('idnumbertoolong'); } if ($DB->record_exists('course_categories', array('idnumber' => $data->idnumber))) { @@ -921,17 +921,17 @@ protected static function sort_records(&$records, $sortfields) { } } } - // sorting by one field - use collatorlib + // sorting by one field - use core_collator if (count($sortfields) == 1) { $property = key($sortfields); if (in_array($property, array('sortorder', 'id', 'visible', 'parent', 'depth'))) { - $sortflag = collatorlib::SORT_NUMERIC; + $sortflag = core_collator::SORT_NUMERIC; } else if (in_array($property, array('idnumber', 'displayname', 'name', 'shortname', 'fullname'))) { - $sortflag = collatorlib::SORT_STRING; + $sortflag = core_collator::SORT_STRING; } else { - $sortflag = collatorlib::SORT_REGULAR; + $sortflag = core_collator::SORT_REGULAR; } - collatorlib::asort_objects_by_property($records, $property, $sortflag); + core_collator::asort_objects_by_property($records, $property, $sortflag); if ($sortfields[$property] < 0) { $records = array_reverse($records, true); } diff --git a/lib/csvlib.class.php b/lib/csvlib.class.php index 25bcdcc90528a..1df60c4014f36 100644 --- a/lib/csvlib.class.php +++ b/lib/csvlib.class.php @@ -85,9 +85,9 @@ function load_csv_content(&$content, $encoding, $delimiter_name, $column_validat $this->close(); $this->_error = null; - $content = textlib::convert($content, $encoding, 'utf-8'); + $content = core_text::convert($content, $encoding, 'utf-8'); // remove Unicode BOM from first line - $content = textlib::trim_utf8_bom($content); + $content = core_text::trim_utf8_bom($content); // Fix mac/dos newlines $content = preg_replace('!\r\n?!', "\n", $content); // Remove any spaces or new lines at the end of the file. diff --git a/lib/datalib.php b/lib/datalib.php index fada22966d0c4..c7ef03ca556b1 100644 --- a/lib/datalib.php +++ b/lib/datalib.php @@ -1642,14 +1642,14 @@ function add_to_log($courseid, $module, $action, $url='', $info='', $cm=0, $user // database so that it doesn't cause a DB error. Log a warning so that // developers can avoid doing things which are likely to cause this on a // routine basis. - if(!empty($info) && textlib::strlen($info)>255) { - $info = textlib::substr($info,0,252).'...'; + if(!empty($info) && core_text::strlen($info)>255) { + $info = core_text::substr($info,0,252).'...'; debugging('Warning: logged very long info',DEBUG_DEVELOPER); } // If the 100 field size is changed, also need to alter print_log in course/lib.php - if(!empty($url) && textlib::strlen($url)>100) { - $url = textlib::substr($url,0,97).'...'; + if(!empty($url) && core_text::strlen($url)>100) { + $url = core_text::substr($url,0,97).'...'; debugging('Warning: logged very long URL',DEBUG_DEVELOPER); } diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index 33a9c0a9b75c4..796efaf69a9fe 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -2028,23 +2028,23 @@ function show_event($event) { } /** - * @deprecated Use textlib::strtolower($text) instead. + * @deprecated Use core_text::strtolower($text) instead. */ function moodle_strtolower($string, $encoding='') { - throw new coding_exception('moodle_strtolower() cannot be used any more. Please use textlib::strtolower() instead.'); + throw new coding_exception('moodle_strtolower() cannot be used any more. Please use core_text::strtolower() instead.'); } /** * Original singleton helper function, please use static methods instead, - * ex: textlib::convert() + * ex: core_text::convert() * - * @deprecated since Moodle 2.2 use textlib::xxxx() instead + * @deprecated since Moodle 2.2 use core_text::xxxx() instead * @see textlib * @return textlib instance */ function textlib_get_instance() { - debugging('textlib_get_instance() is deprecated. Please use static calling textlib::functioname() instead.', DEBUG_DEVELOPER); + debugging('textlib_get_instance() is deprecated. Please use static calling core_text::functioname() instead.', DEBUG_DEVELOPER); return new textlib(); } diff --git a/lib/editor/tinymce/adminlib.php b/lib/editor/tinymce/adminlib.php index 882e387f39071..d30f3bf56890a 100644 --- a/lib/editor/tinymce/adminlib.php +++ b/lib/editor/tinymce/adminlib.php @@ -142,7 +142,7 @@ public function is_related($query) { } $namestr = get_string('pluginname', 'tinymce_'.$name); - if (strpos(textlib::strtolower($namestr), textlib::strtolower($query)) !== false) { + if (strpos(core_text::strtolower($namestr), core_text::strtolower($query)) !== false) { return true; } } diff --git a/lib/editor/tinymce/plugins/spellchecker/classes/GoogleSpell.php b/lib/editor/tinymce/plugins/spellchecker/classes/GoogleSpell.php index 5edf76a105938..6665d69b8546a 100644 --- a/lib/editor/tinymce/plugins/spellchecker/classes/GoogleSpell.php +++ b/lib/editor/tinymce/plugins/spellchecker/classes/GoogleSpell.php @@ -4,7 +4,7 @@ * * @package MCManager.includes * @author Moxiecode - * @copyright Copyright 2004-2007, Moxiecode Systems AB, All rights reserved. + * @copyright Copyright � 2004-2007, Moxiecode Systems AB, All rights reserved. */ class GoogleSpell extends SpellChecker { @@ -128,7 +128,7 @@ function &_getMatches($lang, $str) { } function _unhtmlentities($string) { - return textlib::entities_to_utf8($string); // Moodle hack + return core_text::entities_to_utf8($string); // Moodle hack $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string); diff --git a/lib/excellib.class.php b/lib/excellib.class.php index 3103885bd9339..1e1355db0c21b 100644 --- a/lib/excellib.class.php +++ b/lib/excellib.class.php @@ -166,7 +166,7 @@ public function __construct($name, PHPExcel $workbook) { // Replace any characters in the name that Excel cannot cope with. $name = strtr($name, '[]*/\?:', ' '); // Shorten the title if necessary. - $name = textlib::substr($name, 0, 31); + $name = core_text::substr($name, 0, 31); if ($name === '') { // Name is required! diff --git a/lib/filebrowser/file_info.php b/lib/filebrowser/file_info.php index a6af3f78b4789..b7dcc46b47cae 100644 --- a/lib/filebrowser/file_info.php +++ b/lib/filebrowser/file_info.php @@ -143,7 +143,7 @@ public function get_non_empty_children($extensions = '*') { $nonemptylist[] = $fileinfo; } else { $filename = $fileinfo->get_visible_name(); - $extension = textlib::strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + $extension = core_text::strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (!empty($extension) && in_array('.' . $extension, $extensions)) { $nonemptylist[] = $fileinfo; } @@ -177,7 +177,7 @@ public function count_non_empty_children($extensions = '*', $limit = 1) { if (!$fileinfo->is_directory()) { if ($extensions !== '*') { $filename = $fileinfo->get_visible_name(); - $extension = textlib::strtolower(pathinfo($filename, PATHINFO_EXTENSION)); + $extension = core_text::strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (empty($extension) || !in_array('.' . $extension, $extensions)) { continue; } diff --git a/lib/filebrowser/file_info_context_course.php b/lib/filebrowser/file_info_context_course.php index 84fd4e6da9911..cd636e7c60410 100644 --- a/lib/filebrowser/file_info_context_course.php +++ b/lib/filebrowser/file_info_context_course.php @@ -566,7 +566,7 @@ public function get_non_empty_children($extensions = '*') { $storedfiles = $fs->get_directory_files($this->context->id, 'course', 'legacy', 0, $this->lf->get_filepath(), false, true, "filepath, filename"); foreach ($storedfiles as $file) { - $extension = textlib::strtolower(pathinfo($file->get_filename(), PATHINFO_EXTENSION)); + $extension = core_text::strtolower(pathinfo($file->get_filename(), PATHINFO_EXTENSION)); if ($file->is_directory() || $extensions === '*' || (!empty($extension) && in_array('.'.$extension, $extensions))) { $fileinfo = new file_info_area_course_legacy($this->browser, $this->context, $file, $this->urlbase, $this->topvisiblename, $this->itemidused, $this->readaccess, $this->writeaccess, false); diff --git a/lib/filebrowser/file_info_stored.php b/lib/filebrowser/file_info_stored.php index e9caf4cab0313..8c1069b65e02d 100644 --- a/lib/filebrowser/file_info_stored.php +++ b/lib/filebrowser/file_info_stored.php @@ -368,7 +368,7 @@ public function get_non_empty_children($extensions = '*') { $storedfiles = $fs->get_directory_files($this->context->id, $this->lf->get_component(), $this->lf->get_filearea(), $this->lf->get_itemid(), $this->lf->get_filepath(), false, true, "filepath, filename"); foreach ($storedfiles as $file) { - $extension = textlib::strtolower(pathinfo($file->get_filename(), PATHINFO_EXTENSION)); + $extension = core_text::strtolower(pathinfo($file->get_filename(), PATHINFO_EXTENSION)); if ($file->is_directory() || $extensions === '*' || (!empty($extension) && in_array('.'.$extension, $extensions))) { $fileinfo = new file_info_stored($this->browser, $this->context, $file, $this->urlbase, $this->topvisiblename, $this->itemidused, $this->readaccess, $this->writeaccess, false); @@ -396,7 +396,7 @@ public function count_non_empty_children($extensions = '*', $limit = 1) { } $filepath = $this->lf->get_filepath(); - $length = textlib::strlen($filepath); + $length = core_text::strlen($filepath); $sql = "SELECT filepath, filename FROM {files} f WHERE f.contextid = :contextid AND f.component = :component AND f.filearea = :filearea AND f.itemid = :itemid @@ -415,7 +415,7 @@ public function count_non_empty_children($extensions = '*', $limit = 1) { if ($record->filepath === $filepath) { $children[] = $record->filename; } else { - $path = explode('/', textlib::substr($record->filepath, $length)); + $path = explode('/', core_text::substr($record->filepath, $length)); if (!in_array($path[0], $children)) { $children[] = $path[0]; } diff --git a/lib/filestorage/file_archive.php b/lib/filestorage/file_archive.php index 1aa688d6f0eca..8d9ab818c89f3 100644 --- a/lib/filestorage/file_archive.php +++ b/lib/filestorage/file_archive.php @@ -131,17 +131,17 @@ protected function mangle_pathname($localname) { return $localname; } - $converted = textlib::convert($localname, 'utf-8', $this->encoding); - $original = textlib::convert($converted, $this->encoding, 'utf-8'); + $converted = core_text::convert($localname, 'utf-8', $this->encoding); + $original = core_text::convert($converted, $this->encoding, 'utf-8'); if ($original === $localname) { $result = $converted; } else { // try ascii conversion - $converted2 = textlib::specialtoascii($localname); - $converted2 = textlib::convert($converted2, 'utf-8', $this->encoding); - $original2 = textlib::convert($converted, $this->encoding, 'utf-8'); + $converted2 = core_text::specialtoascii($localname); + $converted2 = core_text::convert($converted2, 'utf-8', $this->encoding); + $original2 = core_text::convert($converted, $this->encoding, 'utf-8'); if ($original2 === $localname) { //this looks much better @@ -175,7 +175,7 @@ protected function unmangle_pathname($localname) { $result = ltrim($result, '/'); // no leading / if ($this->encoding !== 'utf-8') { - $result = textlib::convert($result, $this->encoding, 'utf-8'); + $result = core_text::convert($result, $this->encoding, 'utf-8'); } return clean_param($result, PARAM_PATH); diff --git a/lib/filestorage/file_storage.php b/lib/filestorage/file_storage.php index 31fd1fbf93c2f..3012ec5a3d009 100644 --- a/lib/filestorage/file_storage.php +++ b/lib/filestorage/file_storage.php @@ -648,9 +648,9 @@ protected function sort_area_tree($tree) { foreach ($tree as $key => &$value) { if ($key == 'subdirs') { $value = $this->sort_area_tree($value); - collatorlib::ksort($value, collatorlib::SORT_NATURAL); + core_collator::ksort($value, core_collator::SORT_NATURAL); } else if ($key == 'files') { - collatorlib::ksort($value, collatorlib::SORT_NATURAL); + core_collator::ksort($value, core_collator::SORT_NATURAL); } } return $tree; @@ -681,7 +681,7 @@ public function get_directory_files($contextid, $component, $filearea, $itemid, if ($recursive) { $dirs = $includedirs ? "" : "AND filename <> '.'"; - $length = textlib::strlen($filepath); + $length = core_text::strlen($filepath); $sql = "SELECT ".self::instance_sql_fields('f', 'r')." FROM {files} f @@ -710,7 +710,7 @@ public function get_directory_files($contextid, $component, $filearea, $itemid, $result = array(); $params = array('contextid'=>$contextid, 'component'=>$component, 'filearea'=>$filearea, 'itemid'=>$itemid, 'filepath'=>$filepath, 'dirid'=>$directory->get_id()); - $length = textlib::strlen($filepath); + $length = core_text::strlen($filepath); if ($includedirs) { $sql = "SELECT ".self::instance_sql_fields('f', 'r')." diff --git a/lib/filestorage/zip_archive.php b/lib/filestorage/zip_archive.php index 4304c6ea618d1..1ef485e1b802f 100644 --- a/lib/filestorage/zip_archive.php +++ b/lib/filestorage/zip_archive.php @@ -170,7 +170,7 @@ protected function unmangle_pathname($localname) { $name = $localname; // This should not happen. if (!empty($this->encoding) and $this->encoding !== 'utf-8') { - $name = @textlib::convert($name, $this->encoding, 'utf-8'); + $name = @core_text::convert($name, $this->encoding, 'utf-8'); } $name = str_replace('\\', '/', $name); // no MS \ separators $name = clean_param($name, PARAM_PATH); // only safe chars @@ -596,8 +596,8 @@ protected function init_namelookup() { } if (!$found and !empty($this->encoding) and $this->encoding !== 'utf-8') { // Try the encoding from open(). - $newname = @textlib::convert($name, $this->encoding, 'utf-8'); - $original = textlib::convert($newname, 'utf-8', $this->encoding); + $newname = @core_text::convert($name, $this->encoding, 'utf-8'); + $original = core_text::convert($newname, 'utf-8', $this->encoding); if ($original === $name) { $found = true; $name = $newname; @@ -649,8 +649,8 @@ protected function init_namelookup() { break; } } - $newname = @textlib::convert($name, $encoding, 'utf-8'); - $original = textlib::convert($newname, 'utf-8', $encoding); + $newname = @core_text::convert($name, $encoding, 'utf-8'); + $original = core_text::convert($newname, 'utf-8', $encoding); if ($original === $name) { $name = $newname; diff --git a/lib/filterlib.php b/lib/filterlib.php index fb674fffc9185..0438c21978b89 100644 --- a/lib/filterlib.php +++ b/lib/filterlib.php @@ -518,7 +518,7 @@ function filter_get_all_installed() { $filternames[$filter] = filter_get_name($filter); } } - collatorlib::asort($filternames); + core_collator::asort($filternames); return $filternames; } @@ -636,11 +636,11 @@ function filter_set_global_state($filtername, $state, $move = 0) { } } - collatorlib::asort_objects_by_property($on, 'newsortorder', collatorlib::SORT_NUMERIC); + core_collator::asort_objects_by_property($on, 'newsortorder', core_collator::SORT_NUMERIC); } // Inactive are sorted by filter name. - collatorlib::asort_objects_by_property($off, 'filter', collatorlib::SORT_NATURAL); + core_collator::asort_objects_by_property($off, 'filter', core_collator::SORT_NATURAL); // Update records if necessary. $i = 1; @@ -1379,13 +1379,13 @@ function filter_remove_duplicates($linkarray) { if ($filterobject->casesensitive) { $exists = in_array($filterobject->phrase, $concepts); } else { - $exists = in_array(textlib::strtolower($filterobject->phrase), $lconcepts); + $exists = in_array(core_text::strtolower($filterobject->phrase), $lconcepts); } if (!$exists) { $cleanlinks[] = $filterobject; $concepts[] = $filterobject->phrase; - $lconcepts[] = textlib::strtolower($filterobject->phrase); + $lconcepts[] = core_text::strtolower($filterobject->phrase); } } diff --git a/lib/gradelib.php b/lib/gradelib.php index fc026170614b0..28bb4a70a1ed8 100644 --- a/lib/gradelib.php +++ b/lib/gradelib.php @@ -808,7 +808,7 @@ function grade_get_categories_menu($courseid, $includenew=false) { foreach ($categories as $category) { $cats[$category->id] = $category->get_name(); } - collatorlib::asort($cats); + core_collator::asort($cats); return ($result+$cats); } diff --git a/lib/graphlib.php b/lib/graphlib.php index c712fad514b5a..0fa5eef9593e7 100644 --- a/lib/graphlib.php +++ b/lib/graphlib.php @@ -1247,7 +1247,7 @@ function print_TTF($message) { break; } // start of Moodle addition - $text = textlib::utf8_to_entities($text, true, true); //does not work with hex entities! + $text = core_text::utf8_to_entities($text, true, true); //does not work with hex entities! // end of Moodle addition ImageTTFText($this->image, $points, $angle, $x, $y, $colour, $font, $text); } @@ -1352,7 +1352,7 @@ function get_boundaryBox($message) { // get boundary box and offsets for printing at an angle // start of Moodle addition - $text = textlib::utf8_to_entities($text, true, true); //gd does not work with hex entities! + $text = core_text::utf8_to_entities($text, true, true); //gd does not work with hex entities! // end of Moodle addition $bounds = ImageTTFBBox($points, $angle, $font, $text); diff --git a/lib/html2text.php b/lib/html2text.php index b78b0ae1b9b27..f01ce8f8dd9dd 100644 --- a/lib/html2text.php +++ b/lib/html2text.php @@ -731,8 +731,8 @@ private function _strtoupper($str) { $str = html_entity_decode($str, ENT_COMPAT, RCMAIL_CHARSET); - if (class_exists('textlib')) - $str = textlib::strtoupper($str); + if (class_exists('core_text')) + $str = core_text::strtoupper($str); else if (function_exists('mb_strtoupper')) $str = mb_strtoupper($str); else diff --git a/lib/html2text_readme.txt b/lib/html2text_readme.txt index c92fe84b0b33c..2cdc2aaf6643b 100644 --- a/lib/html2text_readme.txt +++ b/lib/html2text_readme.txt @@ -9,7 +9,7 @@ Modifications 1. Don't just strip images, replace them with their alt text. (Tim Hunt 2010-08-04) 2. No strip slashes, we do not use magic quotes any more in Moodle 2.0 or later -3. Use textlib, not crappy functions that break UTF-8, in the _strtoupper method. (Tim Hunt 2010-11-02) +3. Use core_text, not crappy functions that break UTF-8, in the _strtoupper method. (Tim Hunt 2010-11-02) 4. Make sure html2text does not destroy '0'. (Tim Hunt 2011-09-21) 5. define missing mail charset 6. Fixed the links list enumeration (MDL-35206). diff --git a/lib/medialib.php b/lib/medialib.php index e75e07743be54..2dff8f2976301 100644 --- a/lib/medialib.php +++ b/lib/medialib.php @@ -156,7 +156,7 @@ public static function split_alternatives($combinedurl, &$width, &$height) { * @param moodle_url $url URL */ public static function get_extension(moodle_url $url) { - // Note: Does not use textlib (. is UTF8-safe). + // Note: Does not use core_text (. is UTF8-safe). $filename = self::get_filename($url); $dot = strrpos($filename, '.'); if ($dot === false) { diff --git a/lib/modinfolib.php b/lib/modinfolib.php index a163d38179a75..990fc6a45f9d5 100644 --- a/lib/modinfolib.php +++ b/lib/modinfolib.php @@ -172,7 +172,7 @@ public function get_used_module_names($plural = false) { $modnamesused[$mod->modname] = $modnames[$mod->modname]; } } - collatorlib::asort($modnamesused); + core_collator::asort($modnamesused); return $modnamesused; } diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 5b43636b9f8de..9c1bae11665ed 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -1094,7 +1094,7 @@ function clean_param($param, $type) { $param = preg_replace('~[[:cntrl:]]|[<>`]~u', '', $param); // Convert many whitespace chars into one. $param = preg_replace('/\s+/', ' ', $param); - $param = textlib::substr(trim($param), 0, TAG_MAX_LENGTH); + $param = core_text::substr(trim($param), 0, TAG_MAX_LENGTH); return $param; case PARAM_TAGLIST: @@ -1164,7 +1164,7 @@ function clean_param($param, $type) { $param = fix_utf8($param); $param = str_replace(" " , "", $param); // Convert uppercase to lowercase MDL-16919. - $param = textlib::strtolower($param); + $param = core_text::strtolower($param); if (empty($CFG->extendedusernamechars)) { // Regular expression, eliminate all chars EXCEPT: // alphanum, dash (-), underscore (_), at sign (@) and period (.) characters. @@ -1586,7 +1586,7 @@ function purge_all_caches() { js_reset_all_caches(); theme_reset_all_caches(); get_string_manager()->reset_caches(); - textlib::reset_caches(); + core_text::reset_caches(); cache_helper::purge_all(); @@ -1825,7 +1825,7 @@ function set_user_preference($name, $value, $user = null) { } // Value column maximum length is 1333 characters. $value = (string)$value; - if (textlib::strlen($value) > 1333) { + if (core_text::strlen($value) > 1333) { throw new coding_exception('Invalid value in set_user_preference() call, value is is too long for the value column'); } @@ -2243,17 +2243,17 @@ function date_format_string($date, $format, $tz = 99) { global $CFG; if (abs($tz) > 13) { if ($CFG->ostype == 'WINDOWS' and $localewincharset = get_string('localewincharset', 'langconfig')) { - $format = textlib::convert($format, 'utf-8', $localewincharset); + $format = core_text::convert($format, 'utf-8', $localewincharset); $datestring = strftime($format, $date); - $datestring = textlib::convert($datestring, $localewincharset, 'utf-8'); + $datestring = core_text::convert($datestring, $localewincharset, 'utf-8'); } else { $datestring = strftime($format, $date); } } else { if ($CFG->ostype == 'WINDOWS' and $localewincharset = get_string('localewincharset', 'langconfig')) { - $format = textlib::convert($format, 'utf-8', $localewincharset); + $format = core_text::convert($format, 'utf-8', $localewincharset); $datestring = gmstrftime($format, $date); - $datestring = textlib::convert($datestring, $localewincharset, 'utf-8'); + $datestring = core_text::convert($datestring, $localewincharset, 'utf-8'); } else { $datestring = gmstrftime($format, $date); } @@ -3967,7 +3967,7 @@ function create_user_record($username, $password, $auth = 'manual') { global $CFG, $DB; require_once($CFG->dirroot."/user/profile/lib.php"); // Just in case check text case. - $username = trim(textlib::strtolower($username)); + $username = trim(core_text::strtolower($username)); $authplugin = get_auth_plugin($auth); $customfields = $authplugin->get_custom_user_profile_fields(); @@ -4035,7 +4035,7 @@ function update_user_record($username) { global $DB, $CFG; require_once($CFG->dirroot."/user/profile/lib.php"); // Just in case check text case. - $username = trim(textlib::strtolower($username)); + $username = trim(core_text::strtolower($username)); $oldinfo = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id), '*', MUST_EXIST); $newuser = array(); @@ -4118,7 +4118,7 @@ function truncate_userinfo(array $info) { // Apply where needed. foreach (array_keys($info) as $key) { if (!empty($limit[$key])) { - $info[$key] = trim(textlib::substr($info[$key], 0, $limit[$key])); + $info[$key] = trim(core_text::substr($info[$key], 0, $limit[$key])); } } @@ -4775,7 +4775,7 @@ function check_password_policy($password, &$errmsg) { } $errmsg = ''; - if (textlib::strlen($password) < $CFG->minpasswordlength) { + if (core_text::strlen($password) < $CFG->minpasswordlength) { $errmsg .= '
'. get_string('errorminpasswordlength', 'auth', $CFG->minpasswordlength) .'
'; } @@ -5779,16 +5779,16 @@ function email_to_user($user, $from, $subject, $messagetext, $messagehtml = '', unset($charsets['UTF-8']); if (in_array($charset, $charsets)) { $mail->CharSet = $charset; - $mail->FromName = textlib::convert($mail->FromName, 'utf-8', strtolower($charset)); - $mail->Subject = textlib::convert($mail->Subject, 'utf-8', strtolower($charset)); - $mail->Body = textlib::convert($mail->Body, 'utf-8', strtolower($charset)); - $mail->AltBody = textlib::convert($mail->AltBody, 'utf-8', strtolower($charset)); + $mail->FromName = core_text::convert($mail->FromName, 'utf-8', strtolower($charset)); + $mail->Subject = core_text::convert($mail->Subject, 'utf-8', strtolower($charset)); + $mail->Body = core_text::convert($mail->Body, 'utf-8', strtolower($charset)); + $mail->AltBody = core_text::convert($mail->AltBody, 'utf-8', strtolower($charset)); foreach ($temprecipients as $key => $values) { - $temprecipients[$key][1] = textlib::convert($values[1], 'utf-8', strtolower($charset)); + $temprecipients[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset)); } foreach ($tempreplyto as $key => $values) { - $tempreplyto[$key][1] = textlib::convert($values[1], 'utf-8', strtolower($charset)); + $tempreplyto[$key][1] = core_text::convert($values[1], 'utf-8', strtolower($charset)); } } } @@ -7091,7 +7091,7 @@ public function get_list_of_countries($returnall = false, $lang = null) { } $countries = $this->load_component_strings('core_countries', $lang); - collatorlib::asort($countries); + core_collator::asort($countries); if (!$returnall and !empty($CFG->allcountrycodes)) { $enabled = explode(',', $CFG->allcountrycodes); $return = array(); @@ -7263,14 +7263,14 @@ public function get_list_of_translations($returnall = false) { if (!empty($CFG->langcache) and !empty($this->menucache)) { // Cache the list so that it can be used next time. - collatorlib::asort($languages); + core_collator::asort($languages); check_dir_exists(dirname($this->menucache), true, true); file_put_contents($this->menucache, json_encode($languages)); @chmod($this->menucache, $CFG->filepermissions); } } - collatorlib::asort($languages); + core_collator::asort($languages); return $languages; } @@ -7821,7 +7821,7 @@ function get_list_of_themes() { $themes[$themename] = $theme; } - collatorlib::asort_objects_by_method($themes, 'get_theme_name'); + core_collator::asort_objects_by_method($themes, 'get_theme_name'); return $themes; } @@ -9092,11 +9092,10 @@ function count_words($string) { * @return int The count of letters in the specified text. */ function count_letters($string) { - // Loading the textlib singleton instance. We are going to need it. $string = strip_tags($string); // Tags are out now. $string = preg_replace('/[[:space:]]*/', '', $string); // Whitespace are out now. - return textlib::strlen($string); + return core_text::strlen($string); } /** @@ -9155,7 +9154,7 @@ function complex_random_string($length=null) { */ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { // If the plain text is shorter than the maximum length, return the whole text. - if (textlib::strlen(preg_replace('/<.*?>/', '', $text)) <= $ideal) { + if (core_text::strlen(preg_replace('/<.*?>/', '', $text)) <= $ideal) { return $text; } @@ -9163,7 +9162,7 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { // and only tag in its 'line'. preg_match_all('/(<.+?>)?([^<>]*)/s', $text, $lines, PREG_SET_ORDER); - $totallength = textlib::strlen($ending); + $totallength = core_text::strlen($ending); $truncate = ''; // This array stores information about open and close tags and their position @@ -9181,16 +9180,16 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { // Record closing tag. $tagdetails[] = (object) array( 'open' => false, - 'tag' => textlib::strtolower($tagmatchings[1]), - 'pos' => textlib::strlen($truncate), + 'tag' => core_text::strtolower($tagmatchings[1]), + 'pos' => core_text::strlen($truncate), ); } else if (preg_match('/^<\s*([^\s>!]+).*?>$/s', $linematchings[1], $tagmatchings)) { // Record opening tag. $tagdetails[] = (object) array( 'open' => true, - 'tag' => textlib::strtolower($tagmatchings[1]), - 'pos' => textlib::strlen($truncate), + 'tag' => core_text::strtolower($tagmatchings[1]), + 'pos' => core_text::strlen($truncate), ); } } @@ -9199,7 +9198,7 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { } // Calculate the length of the plain text part of the line; handle entities as one character. - $contentlength = textlib::strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $linematchings[2])); + $contentlength = core_text::strlen(preg_replace('/&[0-9a-z]{2,8};|&#[0-9]{1,7};|&#x[0-9a-f]{1,6};/i', ' ', $linematchings[2])); if ($totallength + $contentlength > $ideal) { // The number of characters which are left. $left = $ideal - $totallength; @@ -9210,7 +9209,7 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { foreach ($entities[0] as $entity) { if ($entity[1]+1-$entitieslength <= $left) { $left--; - $entitieslength += textlib::strlen($entity[0]); + $entitieslength += core_text::strlen($entity[0]); } else { // No more characters left. break; @@ -9223,7 +9222,7 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { if (!$exact) { // Search the last occurence of a space. for (; $breakpos > 0; $breakpos--) { - if ($char = textlib::substr($linematchings[2], $breakpos, 1)) { + if ($char = core_text::substr($linematchings[2], $breakpos, 1)) { if ($char === '.' or $char === ' ') { $breakpos += 1; break; @@ -9243,7 +9242,7 @@ function shorten_text($text, $ideal=30, $exact = false, $ending='...') { $breakpos = $left + $entitieslength; } - $truncate .= textlib::substr($linematchings[2], 0, $breakpos); + $truncate .= core_text::substr($linematchings[2], 0, $breakpos); // Maximum length is reached, so get off the loop. break; } else { @@ -10212,8 +10211,8 @@ function message_popup_window() { if (!empty($messageusers->smallmessage)) { // Display the first 200 chars of the message in the popup. $smallmessage = null; - if (textlib::strlen($messageusers->smallmessage) > 200) { - $smallmessage = textlib::substr($messageusers->smallmessage, 0, 200).'...'; + if (core_text::strlen($messageusers->smallmessage) > 200) { + $smallmessage = core_text::substr($messageusers->smallmessage, 0, 200).'...'; } else { $smallmessage = $messageusers->smallmessage; } diff --git a/lib/phpmailer/moodle_phpmailer.php b/lib/phpmailer/moodle_phpmailer.php index 03d88eeb46c1a..cf2563a759cea 100644 --- a/lib/phpmailer/moodle_phpmailer.php +++ b/lib/phpmailer/moodle_phpmailer.php @@ -69,11 +69,11 @@ public function AddCustomHeader($custom_header) { } /** - * Use internal moodles own textlib to encode mimeheaders. + * Use internal moodles own core_text to encode mimeheaders. * Fall back to phpmailers inbuilt functions if not */ public function EncodeHeader($str, $position = 'text') { - $encoded = textlib::encode_mimeheader($str, $this->CharSet); + $encoded = core_text::encode_mimeheader($str, $this->CharSet); if ($encoded !== false) { $encoded = str_replace("\n", $this->LE, $encoded); if ($position == 'phrase') { diff --git a/lib/phpunit/classes/util.php b/lib/phpunit/classes/util.php index 09a4f827a6f22..e5e130a3adc88 100644 --- a/lib/phpunit/classes/util.php +++ b/lib/phpunit/classes/util.php @@ -193,7 +193,7 @@ public static function reset_all_data($detectchanges = false) { get_string_manager()->reset_caches(true); reset_text_filters_cache(true); events_get_handlers('reset'); - textlib::reset_caches(); + core_text::reset_caches(); if (class_exists('repository')) { repository::reset_caches(); } diff --git a/lib/questionlib.php b/lib/questionlib.php index f944c9b7bc33b..9984b71cd592b 100644 --- a/lib/questionlib.php +++ b/lib/questionlib.php @@ -1250,7 +1250,7 @@ function get_import_export_formats($type) { } } - collatorlib::asort($fileformatnames); + core_collator::asort($fileformatnames); return $fileformatnames; } diff --git a/lib/simplepie/moodle_simplepie.php b/lib/simplepie/moodle_simplepie.php index 31c5025d60f1e..98fcca04b1a40 100644 --- a/lib/simplepie/moodle_simplepie.php +++ b/lib/simplepie/moodle_simplepie.php @@ -214,7 +214,7 @@ public function sanitize($data, $type, $base = '') { } if ($this->output_encoding !== 'UTF-8') { - textlib::convert($data, 'UTF-8', $this->output_encoding); + core_text::convert($data, 'UTF-8', $this->output_encoding); } return $data; diff --git a/lib/tests/html2text_test.php b/lib/tests/html2text_test.php index 1fb06011d1eea..a3f75c28b5d3c 100644 --- a/lib/tests/html2text_test.php +++ b/lib/tests/html2text_test.php @@ -54,9 +54,9 @@ public function test_no_strip_slashes() { } /** - * Textlib integration. + * core_text integration. */ - public function test_textlib() { + public function test_core_text() { $text = 'Žluťoučký koníček'; $result = html_to_text($text, null, false, false); $this->assertSame($result, 'ŽLUŤOUČKÝ KONÍČEK'); diff --git a/lib/tests/moodlelib_test.php b/lib/tests/moodlelib_test.php index 405958d1295d8..60c3ed8d87965 100644 --- a/lib/tests/moodlelib_test.php +++ b/lib/tests/moodlelib_test.php @@ -1679,8 +1679,8 @@ public function test_userdate() { $actualoutput = userdate($vals['time'], '%A, %d %B %Y, %I:%M %p', $vals['timezone']); // On different systems case of AM PM changes so compare case insensitive. - $vals['expectedoutput'] = textlib::strtolower($vals['expectedoutput']); - $actualoutput = textlib::strtolower($actualoutput); + $vals['expectedoutput'] = core_text::strtolower($vals['expectedoutput']); + $actualoutput = core_text::strtolower($actualoutput); $this->assertSame($vals['expectedoutput'], $actualoutput, "Expected: {$vals['expectedoutput']} => Actual: {$actualoutput}, @@ -1864,8 +1864,8 @@ public function test_make_timestamp() { ); // On different systems case of AM PM changes so compare case insensitive. - $vals['expectedoutput'] = textlib::strtolower($vals['expectedoutput']); - $actualoutput = textlib::strtolower($actualoutput); + $vals['expectedoutput'] = core_text::strtolower($vals['expectedoutput']); + $actualoutput = core_text::strtolower($actualoutput); $this->assertSame($vals['expectedoutput'], $actualoutput, "Expected: {$vals['expectedoutput']} => Actual: {$actualoutput}, @@ -2280,7 +2280,7 @@ public function test_date_format_string() { // On different systems case of AM PM changes so compare case insensitive. foreach ($tests as $test) { $str = date_format_string(1293876000, $test['str'], $test['tz']); - $this->assertSame(textlib::strtolower($test['expected']), textlib::strtolower($str)); + $this->assertSame(core_text::strtolower($test['expected']), core_text::strtolower($str)); } // Restore system default values. diff --git a/lib/tokeniserlib.php b/lib/tokeniserlib.php index b57c44ad51547..ac9112f72912f 100644 --- a/lib/tokeniserlib.php +++ b/lib/tokeniserlib.php @@ -202,7 +202,7 @@ function tokenise_text($text, $stop_words = array(), $overlap_cjk = false, $join if ($tag) { // Increase or decrease score per word based on tag list($tagname) = explode(' ', $value, 2); - $tagname = textlib::strtolower($tagname); + $tagname = core_text::strtolower($tagname); // Closing or opening tag? if ($tagname[0] == '/') { $tagname = substr($tagname, 1); @@ -241,7 +241,7 @@ function tokenise_text($text, $stop_words = array(), $overlap_cjk = false, $join $accum .= $word .' '; $num = is_numeric($word); // Check word length - if ($num || textlib::strlen($word) >= MINIMUM_WORD_SIZE) { + if ($num || core_text::strlen($word) >= MINIMUM_WORD_SIZE) { // Normalize numbers if ($num && $join_numbers) { $word = (int)ltrim($word, '-0'); @@ -318,10 +318,10 @@ function tokenise_split($text, $stop_words, $overlap_cjk, $join_numbers) { function tokenise_simplify($text, $overlap_cjk, $join_numbers) { // Decode entities to UTF-8 - $text = textlib::entities_to_utf8($text, true); + $text = core_text::entities_to_utf8($text, true); // Lowercase - $text = textlib::strtolower($text); + $text = core_text::strtolower($text); // Simple CJK handling if ($overlap_cjk) { @@ -374,7 +374,7 @@ function tokenise_simplify($text, $overlap_cjk, $join_numbers) { function tokenise_expand_cjk($matches) { $str = $matches[0]; - $l = textlib::strlen($str); + $l = core_text::strlen($str); // Passthrough short words if ($l <= MINIMUM_WORD_SIZE) { return ' '. $str .' '; @@ -385,7 +385,7 @@ function tokenise_expand_cjk($matches) { // Begin loop for ($i = 0; $i < $l; ++$i) { // Grab next character - $current = textlib::substr($str, 0, 1); + $current = core_text::substr($str, 0, 1); $str = substr($str, strlen($current)); $chars[] = $current; if ($i >= MINIMUM_WORD_SIZE - 1) { @@ -402,5 +402,5 @@ function tokenise_expand_cjk($matches) { */ function tokenise_truncate_word(&$text) { - $text = textlib::substr($text, 0, MAXIMUM_WORD_SIZE); + $text = core_text::substr($text, 0, MAXIMUM_WORD_SIZE); } diff --git a/lib/upgradelib.php b/lib/upgradelib.php index 1f552d5a57dde..1ce09beb3bd3d 100644 --- a/lib/upgradelib.php +++ b/lib/upgradelib.php @@ -1981,7 +1981,7 @@ function upgrade_rename_old_backup_files_using_shortname() { } require_once($CFG->dirroot.'/backup/util/includes/backup_includes.php'); - $backupword = str_replace(' ', '_', textlib::strtolower(get_string('backupfilename'))); + $backupword = str_replace(' ', '_', core_text::strtolower(get_string('backupfilename'))); $backupword = trim(clean_filename($backupword), '_'); $filename = $backupword . '-' . backup::FORMAT_MOODLE . '-' . backup::TYPE_1COURSE . '-'; $regex = '#^'.preg_quote($filename, '#').'.*\.mbz$#'; @@ -2032,13 +2032,13 @@ function upgrade_rename_old_backup_files_using_shortname() { $newname = $filename . $bcinfo->original_course_id . '-'; if ($useshortname) { $shortname = str_replace(' ', '_', $bcinfo->original_course_shortname); - $shortname = textlib::strtolower(trim(clean_filename($shortname), '_')); + $shortname = core_text::strtolower(trim(clean_filename($shortname), '_')); $newname .= $shortname . '-'; } $backupdateformat = str_replace(' ', '_', get_string('backupnameformat', 'langconfig')); $date = userdate($bcinfo->backup_date, $backupdateformat, 99, false); - $date = textlib::strtolower(trim(clean_filename($date), '_')); + $date = core_text::strtolower(trim(clean_filename($date), '_')); $newname .= $date; if (isset($bcinfo->root_settings['users']) && !$bcinfo->root_settings['users']) { diff --git a/lib/weblib.php b/lib/weblib.php index 43e58092ea253..ca1dc5a8e05b5 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -844,11 +844,11 @@ function break_up_long_words($string, $maxsize=20, $cutchar=' ') { /// Process the string adding the cut when necessary $output = ''; - $length = textlib::strlen($string); + $length = core_text::strlen($string); $wordlength = 0; for ($i=0; $i<$length; $i++) { - $char = textlib::substr($string, $i, 1); + $char = core_text::substr($string, $i, 1); if ($char == ' ' or $char == "\t" or $char == "\n" or $char == "\r" or $char == "<" or $char == ">") { $wordlength = 0; } else { @@ -1421,7 +1421,7 @@ function format_text_email($text, $format) { case FORMAT_WIKI: // there should not be any of these any more! $text = wikify_links($text); - return textlib::entities_to_utf8(strip_tags($text), true); + return core_text::entities_to_utf8(strip_tags($text), true); break; case FORMAT_HTML: @@ -1432,7 +1432,7 @@ function format_text_email($text, $format) { case FORMAT_MARKDOWN: default: $text = wikify_links($text); - return textlib::entities_to_utf8(strip_tags($text), true); + return core_text::entities_to_utf8(strip_tags($text), true); break; } } @@ -1873,7 +1873,7 @@ function highlightfast($needle, $haystack) { return $haystack; } - $parts = explode(textlib::strtolower($needle), textlib::strtolower($haystack)); + $parts = explode(core_text::strtolower($needle), core_text::strtolower($haystack)); if (count($parts) === 1) { return $haystack; @@ -2321,10 +2321,10 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid if ($course->format == 'weeks' or empty($thissection->summary)) { $item = $strsection ." ". $mod->sectionnum; } else { - if (textlib::strlen($thissection->summary) < ($width-3)) { + if (core_text::strlen($thissection->summary) < ($width-3)) { $item = $thissection->summary; } else { - $item = textlib::substr($thissection->summary, 0, $width).'...'; + $item = core_text::substr($thissection->summary, 0, $width).'...'; } } $menu[] = '
  • '.$item.''; @@ -2340,8 +2340,8 @@ function navmenulist($course, $sections, $modinfo, $strsection, $strjumpto, $wid $url = $mod->modname .'/view.php?id='. $mod->id; $mod->name = strip_tags(format_string($mod->name ,true)); - if (textlib::strlen($mod->name) > ($width+5)) { - $mod->name = textlib::substr($mod->name, 0, $width).'...'; + if (core_text::strlen($mod->name) > ($width+5)) { + $mod->name = core_text::substr($mod->name, 0, $width).'...'; } if (!$mod->visible) { $mod->name = '('.$mod->name.')'; @@ -2631,12 +2631,12 @@ function obfuscate_email($email) { function obfuscate_text($plaintext) { $i=0; - $length = textlib::strlen($plaintext); + $length = core_text::strlen($plaintext); $obfuscated=''; $prev_obfuscated = false; while ($i < $length) { - $char = textlib::substr($plaintext, $i, 1); - $ord = textlib::utf8ord($char); + $char = core_text::substr($plaintext, $i, 1); + $ord = core_text::utf8ord($char); $numerical = ($ord >= ord('0')) && ($ord <= ord('9')); if ($prev_obfuscated and $numerical ) { $obfuscated.='&#'.$ord.';'; diff --git a/login/forgot_password.php b/login/forgot_password.php index 8f51b6df59e77..c77dac7012baf 100644 --- a/login/forgot_password.php +++ b/login/forgot_password.php @@ -126,7 +126,7 @@ // first try the username if (!empty($data->username)) { - $username = textlib::strtolower($data->username); // mimic the login page process, if they forget username they need to use email for reset + $username = core_text::strtolower($data->username); // mimic the login page process, if they forget username they need to use email for reset $user = $DB->get_record('user', array('username'=>$username, 'mnethostid'=>$CFG->mnet_localhost_id, 'deleted'=>0, 'suspended'=>0)); } else { diff --git a/login/index.php b/login/index.php index 6996eb4f0ac2b..4d83009391d61 100644 --- a/login/index.php +++ b/login/index.php @@ -119,7 +119,7 @@ if ($frm and isset($frm->username)) { // Login WITH cookies - $frm->username = trim(textlib::strtolower($frm->username)); + $frm->username = trim(core_text::strtolower($frm->username)); if (is_enabled_auth('none') ) { if ($frm->username !== clean_param($frm->username, PARAM_USERNAME)) { diff --git a/login/signup_form.php b/login/signup_form.php index 87513e0e82133..49ad2217474f6 100644 --- a/login/signup_form.php +++ b/login/signup_form.php @@ -130,7 +130,7 @@ function validation($data, $files) { $errors['username'] = get_string('usernameexists'); } else { //check allowed characters - if ($data['username'] !== textlib::strtolower($data['username'])) { + if ($data['username'] !== core_text::strtolower($data['username'])) { $errors['username'] = get_string('usernamelowercase'); } else { if ($data['username'] !== clean_param($data['username'], PARAM_USERNAME)) { diff --git a/login/token.php b/login/token.php index 6839cc0df9735..412b24725e80e 100644 --- a/login/token.php +++ b/login/token.php @@ -36,7 +36,7 @@ if (!$CFG->enablewebservices) { throw new moodle_exception('enablewsdescription', 'webservice'); } -$username = trim(textlib::strtolower($username)); +$username = trim(core_text::strtolower($username)); if (is_restored_user($username)) { throw new moodle_exception('restoredaccountresetpassword', 'webservice'); } diff --git a/message/lib.php b/message/lib.php index bd642ce697dfc..b6a848c128f29 100644 --- a/message/lib.php +++ b/message/lib.php @@ -499,8 +499,8 @@ function message_print_usergroup_selector($viewing, $courses, $coursecontexts, $ if (has_capability('moodle/course:viewparticipants', $coursecontexts[$course->id])) { //Not using short_text() as we want the end of the course name. Not the beginning. $shortname = format_string($course->shortname, true, array('context' => $coursecontexts[$course->id])); - if (textlib::strlen($shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { - $courses_options[MESSAGE_VIEW_COURSE.$course->id] = '...'.textlib::substr($shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); + if (core_text::strlen($shortname) > MESSAGE_MAX_COURSE_NAME_LENGTH) { + $courses_options[MESSAGE_VIEW_COURSE.$course->id] = '...'.core_text::substr($shortname, -MESSAGE_MAX_COURSE_NAME_LENGTH); } else { $courses_options[MESSAGE_VIEW_COURSE.$course->id] = $shortname; } @@ -766,7 +766,7 @@ function message_get_recent_conversations($user, $limitfrom=0, $limitto=100) { // Sort the conversations by $conversation->timecreated, newest to oldest // There may be multiple conversations with the same timecreated // The conversations array contains both read and unread messages (different tables) so sorting by ID won't work - $result = collatorlib::asort_objects_by_property($conversations, 'timecreated', collatorlib::SORT_NUMERIC); + $result = core_collator::asort_objects_by_property($conversations, 'timecreated', core_collator::SORT_NUMERIC); $conversations = array_reverse($conversations); return $conversations; @@ -1844,7 +1844,7 @@ function message_get_history($user1, $user2, $limitnum=0, $viewingnewmessages=fa } } - $result = collatorlib::asort_objects_by_property($messages, 'timecreated', collatorlib::SORT_NUMERIC); + $result = core_collator::asort_objects_by_property($messages, 'timecreated', core_collator::SORT_NUMERIC); //if we only want the last $limitnum messages $messagecount = count($messages); diff --git a/mod/assign/adminlib.php b/mod/assign/adminlib.php index 45703624e6a96..ff916eaa6caef 100644 --- a/mod/assign/adminlib.php +++ b/mod/assign/adminlib.php @@ -63,10 +63,9 @@ public function search($query) { } $found = false; - $textlib = new textlib(); foreach (core_component::get_plugin_list($this->subtype) as $name => $notused) { - if (strpos($textlib::strtolower(get_string('pluginname', $this->subtype . '_' . $name)), + if (strpos(core_text::strtolower(get_string('pluginname', $this->subtype . '_' . $name)), $query) !== false) { $found = true; break; diff --git a/mod/book/db/upgradelib.php b/mod/book/db/upgradelib.php index 5411930443ca7..fa0dc47bd879f 100644 --- a/mod/book/db/upgradelib.php +++ b/mod/book/db/upgradelib.php @@ -76,7 +76,7 @@ function mod_book_migrate_moddata_dir_to_legacy($book, $context, $path) { continue; } - if (textlib::strlen($filepath) > 255) { + if (core_text::strlen($filepath) > 255) { echo $OUTPUT->notification(" File path longer than 255 chars, skipping: ".$fulldir.$item->getFilename()); unset($item); // release file handle continue; diff --git a/mod/book/tool/importhtml/locallib.php b/mod/book/tool/importhtml/locallib.php index 7b64a210d30b6..34a317a98b681 100644 --- a/mod/book/tool/importhtml/locallib.php +++ b/mod/book/tool/importhtml/locallib.php @@ -215,7 +215,7 @@ function toolbook_importhtml_fix_encoding($html) { $head = $matches[1]; if (preg_match('/charset=([^"]+)/is', $head, $matches)) { $enc = $matches[1]; - return textlib::convert($html, $enc, 'utf-8'); + return core_text::convert($html, $enc, 'utf-8'); } } return iconv('UTF-8', 'UTF-8//IGNORE', $html); @@ -299,9 +299,9 @@ function toolbook_importhtml_get_chapter_files($package, $type) { } } - collatorlib::ksort($tophtmlfiles, collatorlib::SORT_NATURAL); - collatorlib::ksort($subhtmlfiles, collatorlib::SORT_NATURAL); - collatorlib::ksort($topdirs, collatorlib::SORT_NATURAL); + core_collator::ksort($tophtmlfiles, core_collator::SORT_NATURAL); + core_collator::ksort($subhtmlfiles, core_collator::SORT_NATURAL); + core_collator::ksort($topdirs, core_collator::SORT_NATURAL); $chapterfiles = array(); @@ -313,7 +313,7 @@ function toolbook_importhtml_get_chapter_files($package, $type) { if (empty($htmlfiles)) { continue; } - collatorlib::ksort($htmlfiles, collatorlib::SORT_NATURAL); + core_collator::ksort($htmlfiles, core_collator::SORT_NATURAL); if (isset($htmlfiles[$dir.'/index.html'])) { $htmlfile = $htmlfiles[$dir.'/index.html']; } else if (isset($htmlfiles[$dir.'/index.htm'])) { diff --git a/mod/data/import_form.php b/mod/data/import_form.php index a4aa8b8881dae..4ae95c6511c29 100644 --- a/mod/data/import_form.php +++ b/mod/data/import_form.php @@ -21,7 +21,7 @@ function definition() { $mform->addElement('text', 'fieldenclosure', get_string('fieldenclosure', 'data')); $mform->setType('fieldenclosure', PARAM_CLEANHTML); - $choices = textlib::get_encodings(); + $choices = core_text::get_encodings(); $mform->addElement('select', 'encoding', get_string('fileencoding', 'mod_data'), $choices); $mform->setDefault('encoding', 'UTF-8'); diff --git a/mod/data/view.php b/mod/data/view.php index 31927210a3106..2437350f7ecbe 100644 --- a/mod/data/view.php +++ b/mod/data/view.php @@ -230,7 +230,7 @@ $search = ''; } - if (textlib::strlen($search) < 2) { + if (core_text::strlen($search) < 2) { $search = ''; } $SESSION->dataprefs[$data->id]['search'] = $search; // Make it sticky diff --git a/mod/feedback/import.php b/mod/feedback/import.php index 7733292a4a520..5678f98e1be71 100644 --- a/mod/feedback/import.php +++ b/mod/feedback/import.php @@ -284,6 +284,6 @@ function feedback_check_xml_utf8($text) { //encoding is given in $match[2] if (isset($match[0]) AND isset($match[1]) AND isset($match[2])) { $enc = $match[2]; - return textlib::convert($text, $enc); + return core_text::convert($text, $enc); } } diff --git a/mod/forum/mod_form.php b/mod/forum/mod_form.php index ae86d69023dc0..f9f0358b0fc6b 100644 --- a/mod/forum/mod_form.php +++ b/mod/forum/mod_form.php @@ -49,7 +49,7 @@ function definition() { $this->add_intro_editor(true, get_string('forumintro', 'forum')); $forumtypes = forum_get_forum_types(); - collatorlib::asort($forumtypes, collatorlib::SORT_STRING); + core_collator::asort($forumtypes, core_collator::SORT_STRING); $mform->addElement('select', 'type', get_string('forumtype', 'forum'), $forumtypes); $mform->addHelpButton('type', 'forumtype', 'forum'); $mform->setDefault('type', 'general'); diff --git a/mod/glossary/edit_form.php b/mod/glossary/edit_form.php index 03d964e90969b..a2206910dd392 100644 --- a/mod/glossary/edit_form.php +++ b/mod/glossary/edit_form.php @@ -118,7 +118,7 @@ function validation($data, $files) { if ($DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND LOWER(concept) = :concept AND id != :id', array( 'glossaryid' => $glossary->id, - 'concept' => textlib::strtolower($data['concept']), + 'concept' => core_text::strtolower($data['concept']), 'id' => $id))) { $errors['concept'] = get_string('errconceptalreadyexists', 'glossary'); } @@ -129,7 +129,7 @@ function validation($data, $files) { if ($DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND LOWER(concept) = :concept', array( 'glossaryid' => $glossary->id, - 'concept' => textlib::strtolower($data['concept'])))) { + 'concept' => core_text::strtolower($data['concept'])))) { $errors['concept'] = get_string('errconceptalreadyexists', 'glossary'); } } diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 1c67b47f75a40..92daac29a5c08 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -72,7 +72,7 @@ $PAGE->navbar->add($strglossaries, new moodle_url('/mod/glossary/index.php', array('id'=>$course->id))); $PAGE->navbar->add(get_string("categories","glossary")); if (!empty($action)) { - $navaction = get_string($action). " " . textlib::strtolower(get_string("category","glossary")); + $navaction = get_string($action). " " . core_text::strtolower(get_string("category","glossary")); $PAGE->navbar->add($navaction); } $PAGE->set_title(format_string($glossary->name)); diff --git a/mod/glossary/exportentry.php b/mod/glossary/exportentry.php index 6b38886c444ab..738f27294c0cc 100644 --- a/mod/glossary/exportentry.php +++ b/mod/glossary/exportentry.php @@ -72,7 +72,7 @@ if ($DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND LOWER(concept) = :concept', array( 'glossaryid' => $mainglossary->id, - 'concept' => textlib::strtolower($entry->concept)))) { + 'concept' => core_text::strtolower($entry->concept)))) { $PAGE->set_title(format_string($glossary->name)); $PAGE->set_heading($course->fullname); echo $OUTPUT->header(); diff --git a/mod/glossary/import.php b/mod/glossary/import.php index 388616af430b4..e146796bb0122 100644 --- a/mod/glossary/import.php +++ b/mod/glossary/import.php @@ -210,7 +210,7 @@ $dupentry = $DB->record_exists_select('glossary_entries', 'glossaryid = :glossaryid AND LOWER(concept) = :concept', array( 'glossaryid' => $glossary->id, - 'concept' => textlib::strtolower($newentry->concept))); + 'concept' => core_text::strtolower($newentry->concept))); } if ($dupentry) { $permissiongranted = 0; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 7fa2109017a62..239aebb80d628 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -1011,7 +1011,7 @@ function glossary_get_entries_search($concept, $courseid) { $bypassteacher = 0; //This means YES } - $conceptlower = textlib::strtolower(trim($concept)); + $conceptlower = core_text::strtolower(trim($concept)); $params = array('courseid1'=>$courseid, 'courseid2'=>$courseid, 'conceptlower'=>$conceptlower, 'concept'=>$concept); @@ -2114,9 +2114,9 @@ function glossary_print_sorting_links($cm, $mode, $sortkey = '',$sortorder = '') */ function glossary_sort_entries ( $entry0, $entry1 ) { - if ( textlib::strtolower(ltrim($entry0->concept)) < textlib::strtolower(ltrim($entry1->concept)) ) { + if ( core_text::strtolower(ltrim($entry0->concept)) < core_text::strtolower(ltrim($entry1->concept)) ) { return -1; - } elseif ( textlib::strtolower(ltrim($entry0->concept)) > textlib::strtolower(ltrim($entry1->concept)) ) { + } elseif ( core_text::strtolower(ltrim($entry0->concept)) > core_text::strtolower(ltrim($entry1->concept)) ) { return 1; } else { return 0; diff --git a/mod/glossary/print.php b/mod/glossary/print.php index 52f0ea3125ca4..e6f4b9d4b84a8 100644 --- a/mod/glossary/print.php +++ b/mod/glossary/print.php @@ -189,12 +189,12 @@ // Setting the pivot for the current entry $pivot = $entry->glossarypivot; - $upperpivot = textlib::strtoupper($pivot); - $pivottoshow = textlib::strtoupper(format_string($pivot, true, $fmtoptions)); + $upperpivot = core_text::strtoupper($pivot); + $pivottoshow = core_text::strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { - $upperpivot = textlib::substr($upperpivot, 0, 1); - $pivottoshow = textlib::substr($pivottoshow, 0, 1); + $upperpivot = core_text::substr($upperpivot, 0, 1); + $pivottoshow = core_text::substr($pivottoshow, 0, 1); } // If there's group break diff --git a/mod/glossary/sql.php b/mod/glossary/sql.php index 9e19a97784ea7..43ec30f9a432e 100644 --- a/mod/glossary/sql.php +++ b/mod/glossary/sql.php @@ -88,14 +88,14 @@ case GLOSSARY_AUTHOR_VIEW: $where = ''; - $params['hookup'] = textlib::strtoupper($hook); + $params['hookup'] = core_text::strtoupper($hook); if ( $sqlsortkey == 'firstname' ) { $usernamefield = $DB->sql_fullname('u.firstname' , 'u.lastname'); } else { $usernamefield = $DB->sql_fullname('u.lastname' , 'u.firstname'); } - $where = "AND " . $DB->sql_substr("upper($usernamefield)", 1, textlib::strlen($hook)) . " = :hookup"; + $where = "AND " . $DB->sql_substr("upper($usernamefield)", 1, core_text::strlen($hook)) . " = :hookup"; if ( $hook == 'ALL' ) { $where = ''; @@ -114,10 +114,10 @@ $printpivot = 0; $where = ''; - $params['hookup'] = textlib::strtoupper($hook); + $params['hookup'] = core_text::strtoupper($hook); if ($hook != 'ALL' and $hook != 'SPECIAL') { - $where = "AND " . $DB->sql_substr("upper(concept)", 1, textlib::strlen($hook)) . " = :hookup"; + $where = "AND " . $DB->sql_substr("upper(concept)", 1, core_text::strlen($hook)) . " = :hookup"; } $sqlselect = "SELECT ge.*, ge.concept AS glossarypivot"; @@ -181,7 +181,7 @@ if (substr($searchterm,0,1) == '+') { $searchterm = trim($searchterm, '+-'); - if (textlib::strlen($searchterm) < 2) { + if (core_text::strlen($searchterm) < 2) { continue; } $searchterm = preg_quote($searchterm, '|'); @@ -190,7 +190,7 @@ } else if (substr($searchterm,0,1) == "-") { $searchterm = trim($searchterm, '+-'); - if (textlib::strlen($searchterm) < 2) { + if (core_text::strlen($searchterm) < 2) { continue; } $searchterm = preg_quote($searchterm, '|'); @@ -198,7 +198,7 @@ $params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)"; } else { - if (textlib::strlen($searchterm) < 2) { + if (core_text::strlen($searchterm) < 2) { continue; } $searchcond[] = $DB->sql_like($concat, ":ss$i", false, true, $NOT); @@ -240,8 +240,8 @@ case 'letter': if ($hook != 'ALL' and $hook != 'SPECIAL') { - $params['hookup'] = textlib::strtoupper($hook); - $where = "AND " . $DB->sql_substr("upper(concept)", 1, textlib::strlen($hook)) . " = :hookup"; + $params['hookup'] = core_text::strtoupper($hook); + $where = "AND " . $DB->sql_substr("upper(concept)", 1, core_text::strlen($hook)) . " = :hookup"; } if ($hook == 'SPECIAL') { //Create appropiate IN contents diff --git a/mod/glossary/view.php b/mod/glossary/view.php index b276b8a20d0c1..1290cdfdf98bc 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -419,12 +419,12 @@ // Setting the pivot for the current entry $pivot = $entry->glossarypivot; - $upperpivot = textlib::strtoupper($pivot); - $pivottoshow = textlib::strtoupper(format_string($pivot, true, $fmtoptions)); + $upperpivot = core_text::strtoupper($pivot); + $pivottoshow = core_text::strtoupper(format_string($pivot, true, $fmtoptions)); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { - $upperpivot = textlib::substr($upperpivot, 0, 1); - $pivottoshow = textlib::substr($pivottoshow, 0, 1); + $upperpivot = core_text::substr($upperpivot, 0, 1); + $pivottoshow = core_text::substr($pivottoshow, 0, 1); } // if there's a group break diff --git a/mod/label/lib.php b/mod/label/lib.php index 051064383f6ab..a9aea19a32449 100644 --- a/mod/label/lib.php +++ b/mod/label/lib.php @@ -36,8 +36,8 @@ */ function get_label_name($label) { $name = strip_tags(format_string($label->intro,true)); - if (textlib::strlen($name) > LABEL_MAX_NAME_LENGTH) { - $name = textlib::substr($name, 0, LABEL_MAX_NAME_LENGTH)."..."; + if (core_text::strlen($name) > LABEL_MAX_NAME_LENGTH) { + $name = core_text::substr($name, 0, LABEL_MAX_NAME_LENGTH)."..."; } if (empty($name)) { diff --git a/mod/lesson/format.php b/mod/lesson/format.php index a6a5dc4f1fdaf..228413d165592 100644 --- a/mod/lesson/format.php +++ b/mod/lesson/format.php @@ -551,7 +551,7 @@ public function clean_question_name($name) { $name = clean_param($name, PARAM_TEXT); // Matches what the question editing form does. $name = trim($name); $trimlength = 251; - while (textlib::strlen($name) > 255 && $trimlength > 0) { + while (core_text::strlen($name) > 255 && $trimlength > 0) { $name = shorten_text($name, $trimlength); $trimlength -= 10; } @@ -640,8 +640,8 @@ public function cleaninput($str) { "—" => "-", ); $str = strtr($str, $html_code_list); - // Use textlib entities_to_utf8 function to convert only numerical entities. - $str = textlib::entities_to_utf8($str, false); + // Use core_text entities_to_utf8 function to convert only numerical entities. + $str = core_text::entities_to_utf8($str, false); return $str; } diff --git a/mod/lti/locallib.php b/mod/lti/locallib.php index 4c10fab37aee5..dd1d9788d23fb 100644 --- a/mod/lti/locallib.php +++ b/mod/lti/locallib.php @@ -438,8 +438,8 @@ function lti_split_custom_parameters($customstr) { if ( $pos === false || $pos < 1 ) { continue; } - $key = trim(textlib::substr($line, 0, $pos)); - $val = trim(textlib::substr($line, $pos+1, strlen($line))); + $key = trim(core_text::substr($line, 0, $pos)); + $val = trim(core_text::substr($line, $pos+1, strlen($line))); $key = lti_map_keyname($key); $retval['custom_'.$key] = $val; } @@ -455,7 +455,7 @@ function lti_split_custom_parameters($customstr) { */ function lti_map_keyname($key) { $newkey = ""; - $key = textlib::strtolower(trim($key)); + $key = core_text::strtolower(trim($key)); foreach (str_split($key) as $ch) { if ( ($ch >= 'a' && $ch <= 'z') || ($ch >= '0' && $ch <= '9') ) { $newkey .= $ch; diff --git a/mod/quiz/settings.php b/mod/quiz/settings.php index cc99350d9d6ca..49e3a55bc275d 100644 --- a/mod/quiz/settings.php +++ b/mod/quiz/settings.php @@ -38,7 +38,7 @@ $strreportname = get_string($report . 'report', 'quiz_'.$report); $reportsbyname[$strreportname] = $report; } -collatorlib::ksort($reportsbyname); +core_collator::ksort($reportsbyname); // First get a list of quiz reports with there own settings pages. If there none, // we use a simpler overall menu structure. @@ -48,7 +48,7 @@ $strrulename = get_string('pluginname', 'quizaccess_' . $rule); $rulesbyname[$strrulename] = $rule; } -collatorlib::ksort($rulesbyname); +core_collator::ksort($rulesbyname); // Create the quiz settings page. if (empty($reportsbyname) && empty($rulesbyname)) { diff --git a/mod/survey/download.php b/mod/survey/download.php index e9f8eb648eb84..8d2a23613ff02 100644 --- a/mod/survey/download.php +++ b/mod/survey/download.php @@ -159,7 +159,7 @@ /// Sending HTTP headers $workbook->send($downloadfilename); /// Creating the first worksheet - $myxls = $workbook->add_worksheet(textlib::substr(strip_tags(format_string($survey->name,true)), 0, 31)); + $myxls = $workbook->add_worksheet(core_text::substr(strip_tags(format_string($survey->name,true)), 0, 31)); $header = array("surveyid","surveyname","userid","firstname","lastname","email","idnumber","time", "notes"); $col=0; @@ -234,7 +234,7 @@ /// Sending HTTP headers $workbook->send($downloadfilename); /// Creating the first worksheet - $myxls = $workbook->add_worksheet(textlib::substr(strip_tags(format_string($survey->name,true)), 0, 31)); + $myxls = $workbook->add_worksheet(core_text::substr(strip_tags(format_string($survey->name,true)), 0, 31)); $header = array("surveyid","surveyname","userid","firstname","lastname","email","idnumber","time", "notes"); $col=0; diff --git a/mod/upgrade.txt b/mod/upgrade.txt index c8302661b1df9..bc46994f7d199 100644 --- a/mod/upgrade.txt +++ b/mod/upgrade.txt @@ -43,7 +43,7 @@ optional - no changes needed: required changes in code: * fix missing parameter types in optional_param() and required_param() * use new optional_param_array(), required_param_array() or clean_param_array() when dealing with array parameters -* textlib->asort() replaced by specialized collatorlib::asort() +* core_text::asort() replaced by specialized core_collator::asort() * use new make_temp_directory() and make_cache_directory() diff --git a/mod/wiki/locallib.php b/mod/wiki/locallib.php index de3046888dde0..40f439fbd7ffe 100644 --- a/mod/wiki/locallib.php +++ b/mod/wiki/locallib.php @@ -1303,8 +1303,8 @@ function wiki_print_page_content($page, $context, $subwikiid) { */ function wiki_trim_string($text, $limit = 25) { - if (textlib::strlen($text) > $limit) { - $text = textlib::substr($text, 0, $limit) . '...'; + if (core_text::strlen($text) > $limit) { + $text = core_text::substr($text, 0, $limit) . '...'; } return $text; diff --git a/mod/wiki/pagelib.php b/mod/wiki/pagelib.php index 75310f2ec1535..7a5f9fcf95102 100644 --- a/mod/wiki/pagelib.php +++ b/mod/wiki/pagelib.php @@ -1624,9 +1624,9 @@ private function print_page_list_content() { foreach ($pages as $page) { // We need to format the title here to account for any filtering $letter = format_string($page->title, true, array('context' => $this->modcontext)); - $letter = textlib::substr($letter, 0, 1); + $letter = core_text::substr($letter, 0, 1); if (preg_match('/^[a-zA-Z]$/', $letter)) { - $letter = textlib::strtoupper($letter); + $letter = core_text::strtoupper($letter); $stdaux->{$letter}[] = wiki_parser_link($page); } else { $stdaux->{$strspecial}[] = wiki_parser_link($page); diff --git a/question/engine/bank.php b/question/engine/bank.php index 2cf05dc0e86b2..38b8f3df204a1 100644 --- a/question/engine/bank.php +++ b/question/engine/bank.php @@ -183,7 +183,7 @@ public static function sort_qtype_array($qtypes, $config = null) { } ksort($sortorder); - collatorlib::asort($otherqtypes); + core_collator::asort($otherqtypes); $sortedqtypes = array(); foreach ($sortorder as $name) { diff --git a/question/engine/datalib.php b/question/engine/datalib.php index 9c0c7cfa6229a..47dc925395f4f 100644 --- a/question/engine/datalib.php +++ b/question/engine/datalib.php @@ -108,9 +108,9 @@ public function insert_question_attempt(question_attempt $qa, $context) { $record->minfraction = $qa->get_min_fraction(); $record->flagged = $qa->is_flagged(); $record->questionsummary = $qa->get_question_summary(); - if (textlib::strlen($record->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) { + if (core_text::strlen($record->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) { // It seems some people write very long quesions! MDL-30760 - $record->questionsummary = textlib::substr($record->questionsummary, + $record->questionsummary = core_text::substr($record->questionsummary, 0, question_bank::MAX_SUMMARY_LENGTH - 3) . '...'; } $record->rightanswer = $qa->get_right_answer_summary(); diff --git a/question/engine/upgrade/upgradelib.php b/question/engine/upgrade/upgradelib.php index 531889dbe77c7..438bf74ca2ae2 100644 --- a/question/engine/upgrade/upgradelib.php +++ b/question/engine/upgrade/upgradelib.php @@ -246,9 +246,9 @@ public function save_usage($preferredbehaviour, $attempt, $qas, $quizlayout) { $qa = $qas[$questionid]; $qa->questionusageid = $attempt->uniqueid; $qa->slot = $i; - if (textlib::strlen($qa->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) { + if (core_text::strlen($qa->questionsummary) > question_bank::MAX_SUMMARY_LENGTH) { // It seems some people write very long quesions! MDL-30760 - $qa->questionsummary = textlib::substr($qa->questionsummary, + $qa->questionsummary = core_text::substr($qa->questionsummary, 0, question_bank::MAX_SUMMARY_LENGTH - 3) . '...'; } $this->insert_record('question_attempts', $qa); diff --git a/question/format.php b/question/format.php index c4ff0de1a8d4a..df9e40b1e69c9 100644 --- a/question/format.php +++ b/question/format.php @@ -533,7 +533,7 @@ protected function readdata($filename) { $filearray = file($filename); // If the first line of the file starts with a UTF-8 BOM, remove it. - $filearray[0] = textlib::trim_utf8_bom($filearray[0]); + $filearray[0] = core_text::trim_utf8_bom($filearray[0]); // Check for Macintosh OS line returns (ie file on one line), and fix. if (preg_match("~\r~", $filearray[0]) AND !preg_match("~\n~", $filearray[0])) { @@ -653,7 +653,7 @@ public function clean_question_name($name) { $name = clean_param($name, PARAM_TEXT); // Matches what the question editing form does. $name = trim($name); $trimlength = 251; - while (textlib::strlen($name) > 255 && $trimlength > 0) { + while (core_text::strlen($name) > 255 && $trimlength > 0) { $name = shorten_text($name, $trimlength); $trimlength -= 10; } @@ -960,8 +960,8 @@ public function cleaninput($str) { "—" => "-", ); $str = strtr($str, $html_code_list); - // Use textlib entities_to_utf8 function to convert only numerical entities. - $str = textlib::entities_to_utf8($str, false); + // Use core_text entities_to_utf8 function to convert only numerical entities. + $str = core_text::entities_to_utf8($str, false); return $str; } diff --git a/question/format/learnwise/format.php b/question/format/learnwise/format.php index 57cc525b0f9b9..71d35739d5869 100644 --- a/question/format/learnwise/format.php +++ b/question/format/learnwise/format.php @@ -80,8 +80,8 @@ protected function readquestion($lines) { preg_match("//i", $text, $matches); $type = strtolower($matches[1]); // Multichoice or multianswerchoice. - $questiontext = textlib::entities_to_utf8($this->stringbetween($text, '', '')); - $questionhint = textlib::entities_to_utf8($this->stringbetween($text, '', '')); + $questiontext = core_text::entities_to_utf8($this->stringbetween($text, '', '')); + $questionhint = core_text::entities_to_utf8($this->stringbetween($text, '', '')); $questionaward = $this->stringbetween($text, '', ''); $optionlist = $this->stringbetween($text, '', ''); @@ -100,7 +100,7 @@ protected function readquestion($lines) { $correct = $this->stringbetween($option, ' correct="', '">'); $answer = $this->stringbetween($option, '">', ''); $optionscorrect[$n] = $correct; - $optionstext[$n] = textlib::entities_to_utf8($answer); + $optionstext[$n] = core_text::entities_to_utf8($answer); ++$n; } } else if ($type == 'multianswerchoice') { @@ -126,7 +126,7 @@ protected function readquestion($lines) { $answer = $this->stringbetween($option, '">', ''); $optionscorrect[$n] = $correct; - $optionstext[$n] = textlib::entities_to_utf8($answer); + $optionstext[$n] = core_text::entities_to_utf8($answer); $optionsaward[$n] = $award; ++$n; } diff --git a/question/type/multianswer/renderer.php b/question/type/multianswer/renderer.php index d67d0fc86202c..d9f8a8a1da300 100644 --- a/question/type/multianswer/renderer.php +++ b/question/type/multianswer/renderer.php @@ -189,9 +189,9 @@ public function subquestion(question_attempt $qa, question_display_options $opti } // Work out a good input field size. - $size = max(1, textlib::strlen(trim($response)) + 1); + $size = max(1, core_text::strlen(trim($response)) + 1); foreach ($subq->answers as $ans) { - $size = max($size, textlib::strlen(trim($ans->answer))); + $size = max($size, core_text::strlen(trim($ans->answer))); } $size = min(60, round($size + rand(0, $size*0.15))); // The rand bit is to make guessing harder. diff --git a/report/completion/index.php b/report/completion/index.php index 89f0830730ffc..e80bb56668761 100644 --- a/report/completion/index.php +++ b/report/completion/index.php @@ -142,7 +142,7 @@ if ($csv) { $shortname = format_string($course->shortname, true, array('context' => $context)); - $shortname = preg_replace('/[^a-z0-9-]/', '_',textlib::strtolower(strip_tags($shortname))); + $shortname = preg_replace('/[^a-z0-9-]/', '_',core_text::strtolower(strip_tags($shortname))); $export = new csv_export_writer(); $export->set_filename('completion-'.$shortname); diff --git a/report/log/locallib.php b/report/log/locallib.php index 30d1404d491f4..084d252749303 100644 --- a/report/log/locallib.php +++ b/report/log/locallib.php @@ -233,8 +233,8 @@ function report_log_print_mnet_selector_form($hostid, $course, $selecteduser=0, } $section = $cm->sectionnum; $modname = strip_tags($cm->get_formatted_name()); - if (textlib::strlen($modname) > 55) { - $modname = textlib::substr($modname, 0, 50)."..."; + if (core_text::strlen($modname) > 55) { + $modname = core_text::substr($modname, 0, 50)."..."; } if (!$cm->visible) { $modname = "(".$modname.")"; @@ -487,8 +487,8 @@ function report_log_print_selector_form($course, $selecteduser=0, $selecteddate= } $section = $cm->sectionnum; $modname = strip_tags($cm->get_formatted_name()); - if (textlib::strlen($modname) > 55) { - $modname = textlib::substr($modname, 0, 50)."..."; + if (core_text::strlen($modname) > 55) { + $modname = core_text::substr($modname, 0, 50)."..."; } if (!$cm->visible) { $modname = "(".$modname.")"; diff --git a/report/progress/index.php b/report/progress/index.php index 3df14ed14b66c..681f4cd83694f 100644 --- a/report/progress/index.php +++ b/report/progress/index.php @@ -58,7 +58,7 @@ function csv_quote($value) { global $excel; if ($excel) { - return textlib::convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE'); + return core_text::convert('"'.str_replace('"',"'",$value).'"','UTF-8','UTF-16LE'); } else { return '"'.str_replace('"',"'",$value).'"'; } @@ -133,7 +133,7 @@ function csv_quote($value) { $shortname = format_string($course->shortname, true, array('context' => $context)); header('Content-Disposition: attachment; filename=progress.'. - preg_replace('/[^a-z0-9-]/','_',textlib::strtolower(strip_tags($shortname))).'.csv'); + preg_replace('/[^a-z0-9-]/','_',core_text::strtolower(strip_tags($shortname))).'.csv'); // Unicode byte-order mark for Excel if ($excel) { header('Content-Type: text/csv; charset=UTF-16LE'); diff --git a/repository/filesystem/lib.php b/repository/filesystem/lib.php index 5730492a0fe35..6cbdcacee6d21 100644 --- a/repository/filesystem/lib.php +++ b/repository/filesystem/lib.php @@ -110,8 +110,8 @@ public function get_listing($path = '', $page = '') { } } } - collatorlib::asort($fileslist, collatorlib::SORT_STRING); - collatorlib::asort($dirslist, collatorlib::SORT_STRING); + core_collator::asort($fileslist, core_collator::SORT_STRING); + core_collator::asort($dirslist, core_collator::SORT_STRING); // fill the $list['list'] foreach ($dirslist as $file) { if (!empty($path)) { diff --git a/repository/googledocs/lib.php b/repository/googledocs/lib.php index 0380fdc9a145e..40c056e3a5203 100644 --- a/repository/googledocs/lib.php +++ b/repository/googledocs/lib.php @@ -391,8 +391,8 @@ protected function query($q, $path = null, $page = 0) { // Filter and order the results. $files = array_filter($files, array($this, 'filter')); - collatorlib::ksort($files, collatorlib::SORT_NATURAL); - collatorlib::ksort($folders, collatorlib::SORT_NATURAL); + core_collator::ksort($files, core_collator::SORT_NATURAL); + core_collator::ksort($folders, core_collator::SORT_NATURAL); return array_merge(array_values($folders), array_values($files)); } diff --git a/repository/lib.php b/repository/lib.php index ca78900ebec5f..8c197ce30cbf9 100644 --- a/repository/lib.php +++ b/repository/lib.php @@ -2549,8 +2549,8 @@ public static function instance_form_validation($mform, $data, $errors) { * @return string short filename */ public function get_short_filename($str, $maxlength) { - if (textlib::strlen($str) >= $maxlength) { - return trim(textlib::substr($str, 0, $maxlength)).'...'; + if (core_text::strlen($str) >= $maxlength) { + return trim(core_text::substr($str, 0, $maxlength)).'...'; } else { return $str; } diff --git a/repository/local/lib.php b/repository/local/lib.php index 93bdd2062ec06..b1853bf205580 100644 --- a/repository/local/lib.php +++ b/repository/local/lib.php @@ -82,7 +82,7 @@ public function get_listing($encodedpath = '', $page = '') { if (!is_array($extensions)) { $extensions = array($extensions); } - $extensions = array_map('textlib::strtolower', $extensions); + $extensions = array_map('core_text::strtolower', $extensions); } // build file tree diff --git a/tag/coursetagslib.php b/tag/coursetagslib.php index 4ba4b86b2a58e..f2814186d7d45 100644 --- a/tag/coursetagslib.php +++ b/tag/coursetagslib.php @@ -284,7 +284,7 @@ function coursetag_store_keywords($tags, $courseid, $userid=0, $tagtype='officia //add tag if does not exist if (!$tagid = tag_get_id($tag)) { $tag_id_array = tag_add(array($tag), $tagtype); - $tagid = $tag_id_array[textlib::strtolower($tag)]; + $tagid = $tag_id_array[core_text::strtolower($tag)]; } //ordering $ordering = 0; diff --git a/tag/lib.php b/tag/lib.php index 0afc5636cd973..b6d32036fecdc 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -286,7 +286,7 @@ function tag_get($field, $value, $returnfields='id, name, rawname') { global $DB; if ($field == 'name') { - $value = textlib::strtolower($value); // To cope with input that might just be wrong case + $value = core_text::strtolower($value); // To cope with input that might just be wrong case } return $DB->get_record('tag', array($field=>$value), $returnfields); } @@ -446,7 +446,7 @@ function tag_get_id($tags, $return_value=null) { //TODO MDL-31152 test this and see if it helps performance without breaking anything //foreach($tags as $key => $tag) { - // $clean_tag = textlib::strtolower($tag); + // $clean_tag = core_text::strtolower($tag); // if ( array_key_exists($clean_tag), $tag_id_cache) ) { // $result[$clean_tag] = $tag_id_cache[$clean_tag]; // $tags[$key] = ''; // prevent further processing for this one. @@ -455,8 +455,8 @@ function tag_get_id($tags, $return_value=null) { $tags = array_values(tag_normalize($tags)); foreach($tags as $key => $tag) { - $tags[$key] = textlib::strtolower($tag); - $result[textlib::strtolower($tag)] = null; // key must exists : no value for a key means the tag wasn't found. + $tags[$key] = core_text::strtolower($tag); + $result[core_text::strtolower($tag)] = null; // key must exists : no value for a key means the tag wasn't found. } if (empty($tags)) { @@ -563,7 +563,7 @@ function tag_rename($tagid, $newrawname) { return false; } - if (! $newname_clean = textlib::strtolower($newrawname_clean)) { + if (! $newname_clean = core_text::strtolower($newrawname_clean)) { return false; } @@ -674,7 +674,7 @@ function tag_display_name($tagobject, $html=TAG_RETURN_HTML) { if (empty($CFG->keeptagnamecase)) { //this is the normalized tag name - $tagname = textlib::strtotitle($tagobject->name); + $tagname = core_text::strtotitle($tagobject->name); } else { //original casing of the tag name $tagname = $tagobject->rawname; @@ -760,7 +760,7 @@ function tag_add($tags, $type="default") { // note that the difference between rawname and name is only // capitalization : the rawname is NOT the same at the rawtag. $tag_object->rawname = $tag; - $tag_name_lc = textlib::strtolower($tag); + $tag_name_lc = core_text::strtolower($tag); $tag_object->name = $tag_name_lc; //var_dump($tag_object); $tags_ids[$tag_name_lc] = $DB->insert_record('tag', $tag_object); @@ -813,7 +813,7 @@ function tag_autocomplete($text) { global $DB; return $DB->get_records_sql("SELECT tg.id, tg.name, tg.rawname FROM {tag} tg - WHERE tg.name LIKE ?", array(textlib::strtolower($text)."%")); + WHERE tg.name LIKE ?", array(core_text::strtolower($text)."%")); } /** @@ -1124,7 +1124,7 @@ function tag_normalize($rawtags, $case = TAG_CASE_LOWER) { continue; } if ( !array_key_exists($rawtag, $cleaned_tags_lc) ) { - $cleaned_tags_lc[$rawtag] = textlib::strtolower( clean_param($rawtag, PARAM_TAG) ); + $cleaned_tags_lc[$rawtag] = core_text::strtolower( clean_param($rawtag, PARAM_TAG) ); $cleaned_tags_mc[$rawtag] = clean_param($rawtag, PARAM_TAG); } if ( $case == TAG_CASE_LOWER ) { diff --git a/tag/locallib.php b/tag/locallib.php index 857c175f7ff47..db00484df0941 100644 --- a/tag/locallib.php +++ b/tag/locallib.php @@ -390,8 +390,8 @@ function tag_print_user_box($user, $return=false) { } //truncate name if it's too big - if (textlib::strlen($fullname) > 26) { - $fullname = textlib::substr($fullname, 0, 26) .'...'; + if (core_text::strlen($fullname) > 26) { + $fullname = core_text::substr($fullname, 0, 26) .'...'; } $output .= ''. $fullname .''; diff --git a/user/editadvanced_form.php b/user/editadvanced_form.php index ac6a3917eeb1b..ae94f687f79ec 100644 --- a/user/editadvanced_form.php +++ b/user/editadvanced_form.php @@ -206,7 +206,7 @@ function validation($usernew, $files) { $err['username'] = get_string('usernameexists'); } //check allowed characters - if ($usernew->username !== textlib::strtolower($usernew->username)) { + if ($usernew->username !== core_text::strtolower($usernew->username)) { $err['username'] = get_string('usernamelowercase'); } else { if ($usernew->username !== clean_param($usernew->username, PARAM_USERNAME)) { diff --git a/user/lib.php b/user/lib.php index 357facb110cb4..737a98a359b3c 100644 --- a/user/lib.php +++ b/user/lib.php @@ -40,7 +40,7 @@ function user_create_user($user) { } //check username - if ($user->username !== textlib::strtolower($user->username)) { + if ($user->username !== core_text::strtolower($user->username)) { throw new moodle_exception('usernamelowercase'); } else { if ($user->username !== clean_param($user->username, PARAM_USERNAME)) { @@ -102,7 +102,7 @@ function user_update_user($user) { //check username if (isset($user->username)) { - if ($user->username !== textlib::strtolower($user->username)) { + if ($user->username !== core_text::strtolower($user->username)) { throw new moodle_exception('usernamelowercase'); } else { if ($user->username !== clean_param($user->username, PARAM_USERNAME)) {