Commit e0085943 authored by Son Nguyen's avatar Son Nguyen

Replace the deprecated split() (Bug #1079451)

split() will be replaced by explode() if using a string as a delimiter
and by preg_split() if using regular expression

Change-Id: I93a84150197fb290f89a04f10d5f0fd1e380f0da
Signed-off-by: default avatarSon Nguyen <son.nguyen@catalyst.net.nz>
parent 7f0562e8
......@@ -67,7 +67,7 @@ if ($type == '') {
if (!isset($options[$type])) {
// Comma-separated list; filter out anything that's not an installed type
$type = join(',', array_unique(array_filter(
split(',', $type),
explode(',', $type),
create_function('$a', 'global $installedtypes; return isset($installedtypes[$a]);')
)));
}
......@@ -208,7 +208,7 @@ function delete_all_notifications_submit() {
$typesql = '';
if ($type != 'all') {
// Treat as comma-separated list of activity type names
$types = split(',', preg_replace('/[^a-z,]+/', '', $type));
$types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) {
......
......@@ -38,7 +38,7 @@ function bulkexport_submit(Pieform $form, $values) {
$usernames = array();
// Read in the usernames explicitly specified
foreach (split("\n", $values['usernames']) as $username) {
foreach (explode("\n", $values['usernames']) as $username) {
$username = trim($username);
if (!empty($username)) {
$usernames[] = $username;
......
......@@ -719,7 +719,7 @@ abstract class ArtefactTypeFileBase extends ArtefactType {
* @param string $institution
*/
public static function get_new_file_title($desired, $parent, $owner=null, $group=null, $institution=null) {
$bits = split('\.', $desired);
$bits = explode('\.', $desired);
if (count($bits) > 1 && preg_match('/[^0-9]/', end($bits))) {
$start = join('.', array_slice($bits, 0, count($bits)-1));
$end = '.' . end($bits);
......@@ -2126,7 +2126,7 @@ class ArtefactTypeArchive extends ArtefactTypeFile {
}
private function read_entry($name, $isfolder, $size) {
$path = split('/', $name);
$path = explode('/', $name);
if ($isfolder) {
array_pop($path);
}
......@@ -2298,7 +2298,7 @@ class ArtefactTypeArchive extends ArtefactTypeFile {
if (!isset($this->data['folderids'][$folder])) {
$parent = '.';
$child = '';
$path = split('/', $folder);
$path = explode('/', $folder);
for ($i = 0; $i < count($path); $i++) {
$child .= $path[$i] . '/';
if (!isset($this->data['folderids'][$child])) {
......
......@@ -1039,10 +1039,10 @@ function auth_get_login_form() {
// clean url, treat get string differently
$get = array();
if (isset($getpart)) {
$getarr = split('&', $getpart);
$getarr = explode('&', $getpart);
if ($getarr) {
foreach ($getarr as $data) {
$arr = split('=', $data);
$arr = explode('=', $data);
$get[$arr[0]] = isset($arr[1]) ? $arr[1] : null;
}
}
......
......@@ -1053,7 +1053,7 @@ function activitylist_html($type='all', $limit=10, $offset=0) {
$typesql = '';
if ($type != 'all') {
// Treat as comma-separated list of activity type names
$types = split(',', preg_replace('/[^a-z,]+/', '', $type));
$types = explode(',', preg_replace('/[^a-z,]+/', '', $type));
if ($types) {
$typesql = ' at.name IN (' . join(',', array_map('db_quote', $types)) . ')';
if (in_array('adminmessages', $types)) {
......
......@@ -603,7 +603,7 @@ class Institution {
$where = '';
}
$querydata = split(' ', preg_replace('/\s\s+/', ' ', strtolower(trim($query))));
$querydata = explode(' ', preg_replace('/\s\s+/', ' ', strtolower(trim($query))));
$namesql = '(
ii.name ' . db_ilike() . ' \'%\' || ? || \'%\'
)
......
......@@ -320,7 +320,7 @@ function get_helpfile_location($plugintype, $pluginname, $form, $element, $page=
$subdir = 'help/';
if ($page) {
$pagebits = split('-', $page);
$pagebits = explode('-', $page);
$file = array_pop($pagebits) . '.html';
if ($plugintype != 'core') {
$subdir .= 'pages/' . join('/', $pagebits) . '/';
......@@ -1043,7 +1043,7 @@ function set_locale_for_language($lang) {
return;
}
if ($args = split(',', get_string_location('locales', 'langconfig', array(), 'raw_langstring', $lang))) {
if ($args = explode(',', get_string_location('locales', 'langconfig', array(), 'raw_langstring', $lang))) {
array_unshift($args, LC_ALL);
call_user_func_array('setlocale', $args);
}
......
......@@ -136,7 +136,7 @@ function parse_name_query($text) {
// Strip off phrase quotes
if ($match[1]{0} == '"') {
$phrase = preg_replace('/\s\s+/', ' ', strtolower(substr($match[1], 1, -1)));
$phraselist = split(' ', $phrase);
$phraselist = explode(' ', $phrase);
if (count($phraselist) == 2) {
$fullnames[] = $phraselist;
} else {
......
......@@ -1204,7 +1204,7 @@ function activate_plugin_submit(Pieform $form, $values) {
global $SESSION;
if ($values['plugintype'] == 'blocktype') {
if (strpos($values['pluginname'], '/') !== false) {
list($artefact, $values['pluginname']) = split('/', $values['pluginname']);
list($artefact, $values['pluginname']) = explode('/', $values['pluginname']);
// Don't enable blocktypes unless the artefact plugin that provides them is also enabled
if ($values['enable'] && !get_field('artefact_installed', 'active', 'name', $artefact)) {
$SESSION->add_error_msg(get_string('pluginnotenabled', 'mahara', $artefact));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment