From c52f67aae5c5adb2ad6c18445f48e55cb94da6db Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 18 Jun 2009 09:34:17 +0000 Subject: [PATCH] MINOR ajshort: Replaced usage of the deprecated split() function with preg_split(). git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79568 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- core/HTTP.php | 2 +- core/control/HTTPRequest.php | 2 +- core/model/DataObjectSet.php | 4 ++-- core/model/YamlFixture.php | 2 +- core/model/fieldtypes/Enum.php | 2 +- dev/CsvBulkLoader.php | 2 +- email/Mailer.php | 2 +- forms/CheckboxSetField.php | 2 +- forms/TreeDropdownField.php | 2 +- forms/TreeMultiselectField.php | 2 +- forms/TreeSelectorField.php | 2 +- search/SearchForm.php | 2 +- 12 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/HTTP.php b/core/HTTP.php index 0b1480795..17158ed94 100644 --- a/core/HTTP.php +++ b/core/HTTP.php @@ -146,7 +146,7 @@ class HTTP { $mimeTypes = file('/etc/mime.types'); foreach($mimeTypes as $typeSpec) { if(($typeSpec = trim($typeSpec)) && substr($typeSpec,0,1) != "#") { - $parts = split("[ \t\r\n]+", $typeSpec); + $parts = preg_split("/[ \t\r\n]+/", $typeSpec); if(sizeof($parts) > 1) { $mimeType = array_shift($parts); foreach($parts as $ext) { diff --git a/core/control/HTTPRequest.php b/core/control/HTTPRequest.php index 7294341c5..593b03849 100644 --- a/core/control/HTTPRequest.php +++ b/core/control/HTTPRequest.php @@ -96,7 +96,7 @@ class HTTPRequest extends Object implements ArrayAccess { $this->url = $matches[1]; $this->extension = $matches[2]; } - if($this->url) $this->dirParts = split('/+', $this->url); + if($this->url) $this->dirParts = preg_split('|/+|', $this->url); else $this->dirParts = array(); $this->getVars = (array)$getVars; diff --git a/core/model/DataObjectSet.php b/core/model/DataObjectSet.php index 73fe57d63..223b4e713 100644 --- a/core/model/DataObjectSet.php +++ b/core/model/DataObjectSet.php @@ -183,9 +183,9 @@ class DataObjectSet extends ViewableData implements IteratorAggregate, Countable $length = $query->limit['limit']; $start = $query->limit['start']; } else if(stripos($query->limit, 'OFFSET')) { - list($length, $start) = split(" +OFFSET +", trim($query->limit)); + list($length, $start) = preg_split("/ +OFFSET +/", trim($query->limit)); } else { - $result = split(" *, *", trim($query->limit)); + $result = preg_split("/ *, */", trim($query->limit)); $start = $result[0]; $length = isset($result[1]) ? $result[1] : null; } diff --git a/core/model/YamlFixture.php b/core/model/YamlFixture.php index 031aed09e..53f78bd58 100644 --- a/core/model/YamlFixture.php +++ b/core/model/YamlFixture.php @@ -172,7 +172,7 @@ class YamlFixture extends Object { foreach($fields as $fieldName => $fieldVal) { if($obj->many_many($fieldName) || $obj->has_many($fieldName)) { $parsedItems = array(); - $items = split(' *, *',trim($fieldVal)); + $items = preg_split('/ *, */',trim($fieldVal)); foreach($items as $item) { $parsedItems[] = $this->parseFixtureVal($item); } diff --git a/core/model/fieldtypes/Enum.php b/core/model/fieldtypes/Enum.php index 8296748d8..f6bd7954d 100755 --- a/core/model/fieldtypes/Enum.php +++ b/core/model/fieldtypes/Enum.php @@ -20,7 +20,7 @@ class Enum extends DBField { function __construct($name, $enum = NULL, $default = NULL) { if($enum) { if(!is_array($enum)){ - $enum = split(" *, *", trim($enum)); + $enum = preg_split("/ *, */", trim($enum)); } $this->enum = $enum; diff --git a/dev/CsvBulkLoader.php b/dev/CsvBulkLoader.php index e1347be8e..6e484c13e 100644 --- a/dev/CsvBulkLoader.php +++ b/dev/CsvBulkLoader.php @@ -90,7 +90,7 @@ class CsvBulkLoader extends BulkLoader { } elseif(strpos($fieldName, '.') !== false) { // we have a relation column with dot notation - list($relationName,$columnName) = split('\.', $fieldName); + list($relationName,$columnName) = explode('.', $fieldName); $relationObj = $obj->getComponent($relationName); // always gives us an component (either empty or existing) $obj->setComponent($relationName, $relationObj); $relationObj->write(); diff --git a/email/Mailer.php b/email/Mailer.php index 04d24b798..588bf944e 100644 --- a/email/Mailer.php +++ b/email/Mailer.php @@ -460,7 +460,7 @@ function loadMimeTypes() { $mimeTypes = file_exists($mimetypePathGeneric) ? file($mimetypePathGeneric) : file($mimetypePathCustom); foreach($mimeTypes as $typeSpec) { if(($typeSpec = trim($typeSpec)) && substr($typeSpec,0,1) != "#") { - $parts = split("[ \t\r\n]+", $typeSpec); + $parts = preg_split("/[ \t\r\n]+/", $typeSpec); if(sizeof($parts) > 1) { $mimeType = array_shift($parts); foreach($parts as $ext) { diff --git a/forms/CheckboxSetField.php b/forms/CheckboxSetField.php index a1531e362..75028b9a0 100755 --- a/forms/CheckboxSetField.php +++ b/forms/CheckboxSetField.php @@ -209,7 +209,7 @@ class CheckboxSetField extends OptionsetField { // Items is an array or single piece of string (including comma seperated string) } else { if(!is_array($items)) { - $items = split(' *, *', trim($items)); + $items = preg_split('/ *, */', trim($items)); } foreach($items as $item) { diff --git a/forms/TreeDropdownField.php b/forms/TreeDropdownField.php index 3a7501dea..3dcff4899 100755 --- a/forms/TreeDropdownField.php +++ b/forms/TreeDropdownField.php @@ -72,7 +72,7 @@ HTML; // If we've already got values selected, make sure that we've got them in our tree if($_REQUEST['forceValues']) { - $forceValues = split(" *, *", trim($_REQUEST['forceValues'])); + $forceValues = preg_split("/ *, */", trim($_REQUEST['forceValues'])); foreach($forceValues as $value) { $obj->markToExpose($this->getByKey($value)); } diff --git a/forms/TreeMultiselectField.php b/forms/TreeMultiselectField.php index 25f26457f..8d5f5a792 100755 --- a/forms/TreeMultiselectField.php +++ b/forms/TreeMultiselectField.php @@ -66,7 +66,7 @@ HTML; if(!$saveDest) user_error("TreeMultiselectField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR); if($this->value) { - $items = split(" *, *", trim($this->value)); + $items = preg_split("/ *, */", trim($this->value)); } // Allows you to modify the items on your object before save diff --git a/forms/TreeSelectorField.php b/forms/TreeSelectorField.php index cae75fc38..7b1fdcba2 100755 --- a/forms/TreeSelectorField.php +++ b/forms/TreeSelectorField.php @@ -51,7 +51,7 @@ HTML; $saveDest = $record->$fieldName(); if($this->value) { - $items = split(" *, *", trim($this->value)); + $items = preg_split("/ *, */", trim($this->value)); } $saveDest->setByIDList($items); diff --git a/search/SearchForm.php b/search/SearchForm.php index 8983e38e5..cd2949c05 100755 --- a/search/SearchForm.php +++ b/search/SearchForm.php @@ -138,7 +138,7 @@ class SearchForm extends Form { protected function addStarsToKeywords($keywords) { if(!trim($keywords)) return ""; // Add * to each keyword - $splitWords = split(" +" , trim($keywords)); + $splitWords = preg_split("/ +/" , trim($keywords)); while(list($i,$word) = each($splitWords)) { if($word[0] == '"') { while(list($i,$subword) = each($splitWords)) {