Merge branch 'w32_MDL-40438_m26_textlib' of https://github.com/skodak/moodle

Conflicts:
	lib/weblib.php
This commit is contained in:
Sam Hemelryk
2013-08-07 10:23:32 +12:00
127 changed files with 426 additions and 428 deletions
+1 -1
View File
@@ -115,7 +115,7 @@
$blocknames[$blockid] = $blockname;
}
}
collatorlib::asort($blocknames);
core_collator::asort($blocknames);
foreach ($blocknames as $blockid=>$strblockname) {
$block = $blocks[$blockid];
+1 -1
View File
@@ -55,7 +55,7 @@ foreach (core_component::get_plugin_list('local') as $plugin => $plugindir) {
}
$plugins[$plugin] = $strpluginname;
}
collatorlib::asort($plugins);
core_collator::asort($plugins);
foreach ($plugins as $plugin => $name) {
$uninstall = '';
+1 -1
View File
@@ -103,7 +103,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
$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') {
+3 -3
View File
@@ -137,8 +137,8 @@ class hub_selector_form extends moodleform {
$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 @@ class site_registration_form extends moodleform {
$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);
+1 -1
View File
@@ -57,7 +57,7 @@ foreach (core_component::get_plugin_list('report') as $plugin => $plugindir) {
}
$plugins[$plugin] = $strpluginname;
}
collatorlib::asort($plugins);
core_collator::asort($plugins);
$like = $DB->sql_like('plugin', '?', true, true, false, '|');
$params = array('report|_%');
@@ -99,8 +99,8 @@ class core_role_define_role_table_advanced extends core_role_capability_table_wi
$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');
}
+4 -4
View File
@@ -117,18 +117,18 @@ class tool_uploadcourse_helper {
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;
@@ -57,7 +57,7 @@ class tool_uploadcourse_step1_form extends tool_uploadcourse_base_form {
$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');
+1 -1
View File
@@ -145,7 +145,7 @@ if (!file_exists($options['file'])) {
}
// Encoding.
$encodings = textlib::get_encodings();
$encodings = core_text::get_encodings();
if (!isset($encodings[$options['encoding']])) {
echo get_string('invalidencoding', 'tool_uploadcourse')."\n";
echo $help;
+5 -5
View File
@@ -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;
+1 -1
View File
@@ -53,7 +53,7 @@ class admin_uploaduser_form1 extends moodleform {
$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');
@@ -75,8 +75,8 @@ class check_oracle_semantics extends XMLDBCheckAction {
// 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
+1 -1
View File
@@ -57,7 +57,7 @@ foreach (core_component::get_plugin_list('tool') as $plugin => $plugindir) {
}
$plugins[$plugin] = $strpluginname;
}
collatorlib::asort($plugins);
core_collator::asort($plugins);
$like = $DB->sql_like('plugin', '?', true, true, false, '|');
$params = array('tool|_%');
+5 -5
View File
@@ -61,7 +61,7 @@ class auth_plugin_cas extends auth_plugin_ldap {
*/
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 @@ class auth_plugin_cas extends auth_plugin_ldap {
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 @@ class auth_plugin_cas extends auth_plugin_ldap {
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)) {
+8 -8
View File
@@ -58,8 +58,8 @@ class auth_plugin_db extends auth_plugin_base {
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 @@ class auth_plugin_db extends auth_plugin_base {
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 @@ class auth_plugin_db extends auth_plugin_base {
$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 @@ class auth_plugin_db extends auth_plugin_base {
// 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 @@ class auth_plugin_db extends auth_plugin_base {
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 @@ class auth_plugin_db extends auth_plugin_base {
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 @@ class auth_plugin_db extends auth_plugin_base {
}
$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)) {
+32 -32
View File
@@ -168,8 +168,8 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
* @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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
* @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 @@ class auth_plugin_ldap extends auth_plugin_base {
* @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 @@ class auth_plugin_ldap extends auth_plugin_base {
}
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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
$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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
* @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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
$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 @@ class auth_plugin_ldap extends auth_plugin_base {
$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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
$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 @@ class auth_plugin_ldap extends auth_plugin_base {
// (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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
// 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 @@ class auth_plugin_ldap extends auth_plugin_base {
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 @@ class auth_plugin_ldap extends auth_plugin_base {
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);
+1 -1
View File
@@ -1222,7 +1222,7 @@ class moodle1_question_bank_handler extends moodle1_xml_handler {
// 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'] .= ' <img src="' . $data['image'] . '" />';
+1 -1
View File
@@ -1233,7 +1233,7 @@ class moodle1_file_manager implements loggable {
}
$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');
}
@@ -204,7 +204,7 @@ abstract class backup_plan_dbops extends backup_dbops {
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 @@ abstract class backup_plan_dbops extends backup_dbops {
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 @@ abstract class backup_plan_dbops extends backup_dbops {
// 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 = '';
@@ -554,7 +554,7 @@ abstract class backup_cron_automated_helper {
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)) {
@@ -49,7 +49,7 @@ class block_activity_modules extends block_list {
}
}
collatorlib::asort($modfullnames);
core_collator::asort($modfullnames);
foreach ($modfullnames as $modname => $modfullname) {
if ($modname === 'resources') {
+1 -1
View File
@@ -272,7 +272,7 @@ class community_hub_search_form extends moodleform {
$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);
+3 -3
View File
@@ -210,12 +210,12 @@ if (empty($completions)) {
$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;
}
}
+10 -10
View File
@@ -255,31 +255,31 @@ class block_navigation extends block_base {
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 @@ class block_navigation extends block_base {
* @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 @@ class block_navigation extends block_base {
* @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 @@ class block_navigation extends block_base {
*/
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;
}
+3 -3
View File
@@ -223,7 +223,7 @@
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 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).'...');
}
}
+3 -3
View File
@@ -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.
+2 -2
View File
@@ -588,9 +588,9 @@ class dndupload_ajax_processor {
* @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);
}
+5 -5
View File
@@ -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).'...';
}
}
+1 -1
View File
@@ -194,7 +194,7 @@ if ((!empty($moveupcat) or !empty($movedowncat)) and confirm_sesskey()) {
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));
+1 -1
View File
@@ -248,7 +248,7 @@ class course_publication_form extends moodleform {
$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');
+2 -2
View File
@@ -708,8 +708,8 @@ class core_course_renderer extends plugin_renderer_base {
// 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).
+2 -2
View File
@@ -855,7 +855,7 @@ class enrol_database_plugin extends enrol_plugin {
}
return $text;
} else {
return textlib::convert($text, 'utf-8', $dbenc);
return core_text::convert($text, 'utf-8', $dbenc);
}
}
@@ -870,7 +870,7 @@ class enrol_database_plugin extends enrol_plugin {
}
return $text;
} else {
return textlib::convert($text, $dbenc, 'utf-8');
return core_text::convert($text, $dbenc, 'utf-8');
}
}
+4 -4
View File
@@ -252,7 +252,7 @@ class enrol_flatfile_plugin extends enrol_plugin {
$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 @@ class enrol_flatfile_plugin extends enrol_plugin {
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 @@ class enrol_flatfile_plugin extends enrol_plugin {
$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;
+1 -1
View File
@@ -34,7 +34,7 @@ if ($ADMIN->fulltree) {
$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));
+1 -1
View File
@@ -167,7 +167,7 @@ class enrol_flatfile_testcase extends advanced_testcase {
// 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');
+1 -1
View File
@@ -61,7 +61,7 @@ class enrol_guest_enrol_form extends moodleform {
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');
+2 -2
View File
@@ -327,7 +327,7 @@ class enrol_ldap_plugin extends enrol_plugin {
$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 @@ class enrol_ldap_plugin extends enrol_plugin {
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))) {
+2 -2
View File
@@ -63,7 +63,7 @@ class admin_setting_configtext_trim_lower extends admin_setting_configtext {
return $validated;
}
if ($this->lowercase) {
$data = textlib::strtolower($data);
$data = core_text::strtolower($data);
}
if (!$this->enabled) {
return '';
@@ -134,7 +134,7 @@ class admin_setting_ldap_rolemapping extends admin_setting {
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');
}
}
+1 -1
View File
@@ -171,7 +171,7 @@ if (strlen($result) > 0) {
}
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;
+1 -1
View File
@@ -101,7 +101,7 @@ class enrol_self_enrol_form extends moodleform {
} 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');
+1 -1
View File
@@ -141,7 +141,7 @@ class edit_scale_form extends moodleform {
$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) {
+1 -1
View File
@@ -41,7 +41,7 @@ class grade_import_form extends moodleform {
// 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'])) {
+1 -1
View File
@@ -101,7 +101,7 @@ class group_form extends moodleform {
$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);
}
+1 -1
View File
@@ -93,7 +93,7 @@ class grouping_form extends moodleform {
$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);
}
+5 -5
View File
@@ -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'));
+1 -1
View File
@@ -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'];
}
+29 -29
View File
@@ -1235,7 +1235,7 @@ class admin_externalpage implements part_of_admin_tree {
$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 @@ class admin_settingpage implements part_of_admin_tree {
$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 @@ abstract class admin_setting {
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 @@ abstract class admin_setting {
$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 @@ class admin_setting_configmulticheckbox extends admin_setting {
}
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 @@ class admin_setting_configselect extends admin_setting {
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 @@ class admin_setting_configmultiselect extends admin_setting_configselect {
}
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 @@ class admin_page_managemods extends admin_externalpage {
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 @@ class admin_setting_manageenrols extends admin_setting {
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 @@ class admin_page_manageblocks extends admin_externalpage {
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 @@ class admin_page_managemessageoutputs extends admin_externalpage {
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 @@ class admin_page_manageqbehaviours extends admin_externalpage {
$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 @@ class admin_page_manageqtypes extends admin_externalpage {
$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 @@ class admin_page_manageportfolios extends admin_externalpage {
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 @@ class admin_page_managerepositories extends admin_externalpage {
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 @@ class admin_setting_manageauths extends admin_setting {
}
$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 @@ class admin_setting_manageeditors extends admin_setting {
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 @@ class admin_setting_manageformats extends admin_setting {
$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 @@ class admin_page_managefilters extends admin_externalpage {
$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 @@ class admin_setting_managerepository extends admin_setting {
}
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 @@ class admin_setting_manageexternalservices extends admin_setting {
$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 @@ class admin_setting_managewebserviceprotocols extends admin_setting {
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;
}
}
+4 -4
View File
@@ -56,7 +56,7 @@ define('RFC2445_TYPE_UTC_OFFSET', 13);
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
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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');
+24 -24
View File
@@ -141,7 +141,7 @@ class core_collator {
* @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 @@ class core_collator {
* 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 @@ class core_collator {
$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 @@ class core_collator {
// 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 @@ class core_collator {
*
* @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 @@ class core_collator {
*
* @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 @@ class core_collator {
* 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;
+9 -9
View File
@@ -310,14 +310,14 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
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 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
}
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 @@ class coursecat implements renderable, cacheable_object, IteratorAggregate {
}
}
}
// 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);
}
+2 -2
View File
@@ -85,9 +85,9 @@ class csv_import_reader {
$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.
+4 -4
View File
@@ -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);
}
+5 -5
View File
@@ -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();
}
+1 -1
View File
@@ -142,7 +142,7 @@ class tiynce_subplugins_settings extends admin_setting {
}
$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;
}
}
@@ -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 @@ class GoogleSpell extends SpellChecker {
}
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);
+1 -1
View File
@@ -166,7 +166,7 @@ class MoodleExcelWorksheet {
// 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!
+2 -2
View File
@@ -143,7 +143,7 @@ abstract class file_info {
$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 @@ abstract class file_info {
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;
}
+1 -1
View File
@@ -566,7 +566,7 @@ class file_info_area_course_legacy extends file_info_stored {
$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);
+3 -3
View File
@@ -368,7 +368,7 @@ class file_info_stored extends file_info {
$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 @@ class file_info_stored extends file_info {
}
$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 @@ class file_info_stored extends file_info {
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];
}
+6 -6
View File
@@ -131,17 +131,17 @@ abstract class file_archive implements Iterator {
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 @@ abstract class file_archive implements Iterator {
$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);
+4 -4
View File
@@ -648,9 +648,9 @@ class file_storage {
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 @@ class file_storage {
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 @@ class file_storage {
$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')."
+5 -5
View File
@@ -170,7 +170,7 @@ class zip_archive extends file_archive {
$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 @@ class zip_archive extends file_archive {
}
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 @@ class zip_archive extends file_archive {
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;
+5 -5
View File
@@ -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);
}
}
+1 -1
View File
@@ -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);
}
+2 -2
View File
@@ -1247,7 +1247,7 @@ class graph {
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 @@ class graph {
// 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);
+2 -2
View File
@@ -731,8 +731,8 @@ class html2text
{
$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
+1 -1
View File
@@ -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).
+1 -1
View File
@@ -156,7 +156,7 @@ abstract class core_media {
* @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) {
+1 -1
View File
@@ -172,7 +172,7 @@ class course_modinfo extends stdClass {
$modnamesused[$mod->modname] = $modnames[$mod->modname];
}
}
collatorlib::asort($modnamesused);
core_collator::asort($modnamesused);
return $modnamesused;
}
+35 -36
View File
@@ -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 .= '<div>'. get_string('errorminpasswordlength', 'auth', $CFG->minpasswordlength) .'</div>';
}
@@ -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 @@ class core_string_manager implements string_manager {
}
$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 @@ class core_string_manager implements string_manager {
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;
}
+2 -2
View File
@@ -69,11 +69,11 @@ class moodle_phpmailer extends PHPMailer {
}
/**
* 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') {
+1 -1
View File
@@ -193,7 +193,7 @@ class phpunit_util extends testing_util {
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();
}
+1 -1
View File
@@ -1250,7 +1250,7 @@ function get_import_export_formats($type) {
}
}
collatorlib::asort($fileformatnames);
core_collator::asort($fileformatnames);
return $fileformatnames;
}
+1 -1
View File
@@ -214,7 +214,7 @@ class moodle_simplepie_sanitize extends SimplePie_Sanitize {
}
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;
+2 -2
View File
@@ -54,9 +54,9 @@ class core_html2text_testcase extends basic_testcase {
}
/**
* Textlib integration.
* core_text integration.
*/
public function test_textlib() {
public function test_core_text() {
$text = '<strong>Žluťoučký koníček</strong>';
$result = html_to_text($text, null, false, false);
$this->assertSame($result, 'ŽLUŤOUČKÝ KONÍČEK');
+5 -5
View File
@@ -1679,8 +1679,8 @@ class core_moodlelib_testcase extends advanced_testcase {
$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 @@ class core_moodlelib_testcase extends advanced_testcase {
);
// 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 @@ class core_moodlelib_testcase extends advanced_testcase {
// 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.
+7 -7
View File
@@ -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);
}
+3 -3
View File
@@ -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']) {
+15 -15
View File
@@ -864,11 +864,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 {
@@ -1437,7 +1437,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:
@@ -1448,7 +1448,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;
}
}
@@ -1900,7 +1900,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;
@@ -2338,10 +2338,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[] = '<li class="section"><span>'.$item.'</span>';
@@ -2356,9 +2356,9 @@ 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).'...';
$mod->name = strip_tags(format_string($mod->name ,true));
if (core_text::strlen($mod->name) > ($width+5)) {
$mod->name = core_text::substr($mod->name, 0, $width).'...';
}
if (!$mod->visible) {
$mod->name = '('.$mod->name.')';
@@ -2641,13 +2641,13 @@ function obfuscate_email($email) {
* @return string The obfuscated text
*/
function obfuscate_text($plaintext) {
$i = 0;
$length = textlib::strlen($plaintext);
$obfuscated = '';
$i=0;
$length = core_text::strlen($plaintext);
$obfuscated='';
$prevobfuscated = 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 ($prevobfuscated and $numerical ) {
$obfuscated.='&#'.$ord.';';
+1 -1
View File
@@ -126,7 +126,7 @@ if ($mform->is_cancelled()) {
// 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 {
+1 -1
View File
@@ -119,7 +119,7 @@ if ($user !== false or $frm !== false or $errormsg !== '') {
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)) {
+1 -1
View File
@@ -130,7 +130,7 @@ class login_signup_form extends moodleform {
$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)) {
+1 -1
View File
@@ -36,7 +36,7 @@ echo $OUTPUT->header();
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');
}
+4 -4
View File
@@ -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);
+1 -2
View File
@@ -63,10 +63,9 @@ class assign_admin_page_manage_assign_plugins extends admin_externalpage {
}
$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;
+1 -1
View File
@@ -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;
+5 -5
View File
@@ -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'])) {
+1 -1
View File
@@ -21,7 +21,7 @@ class mod_data_import_form extends moodleform {
$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');
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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);
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ class mod_forum_mod_form extends moodleform_mod {
$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');
+2 -2
View File
@@ -118,7 +118,7 @@ class mod_glossary_entry_form extends moodleform {
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 @@ class mod_glossary_entry_form extends moodleform {
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');
}
}
+1 -1
View File
@@ -72,7 +72,7 @@ $strglossary = get_string("modulename", "glossary");
$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));
+1 -1
View File
@@ -72,7 +72,7 @@ if (!$mainglossary->allowduplicatedentries) {
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();
+1 -1
View File
@@ -210,7 +210,7 @@ if ($xml = glossary_read_imported_file($result)) {
$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;
+3 -3
View File
@@ -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;
+4 -4
View File
@@ -189,12 +189,12 @@ if ( $allentries ) {
// 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
+9 -9
View File
@@ -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

Some files were not shown because too many files have changed in this diff Show More