mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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
This commit is contained in:
parent
301989d203
commit
c52f67aae5
@ -146,7 +146,7 @@ class HTTP {
|
|||||||
$mimeTypes = file('/etc/mime.types');
|
$mimeTypes = file('/etc/mime.types');
|
||||||
foreach($mimeTypes as $typeSpec) {
|
foreach($mimeTypes as $typeSpec) {
|
||||||
if(($typeSpec = trim($typeSpec)) && substr($typeSpec,0,1) != "#") {
|
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) {
|
if(sizeof($parts) > 1) {
|
||||||
$mimeType = array_shift($parts);
|
$mimeType = array_shift($parts);
|
||||||
foreach($parts as $ext) {
|
foreach($parts as $ext) {
|
||||||
|
@ -96,7 +96,7 @@ class HTTPRequest extends Object implements ArrayAccess {
|
|||||||
$this->url = $matches[1];
|
$this->url = $matches[1];
|
||||||
$this->extension = $matches[2];
|
$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();
|
else $this->dirParts = array();
|
||||||
|
|
||||||
$this->getVars = (array)$getVars;
|
$this->getVars = (array)$getVars;
|
||||||
|
@ -183,9 +183,9 @@ class DataObjectSet extends ViewableData implements IteratorAggregate, Countable
|
|||||||
$length = $query->limit['limit'];
|
$length = $query->limit['limit'];
|
||||||
$start = $query->limit['start'];
|
$start = $query->limit['start'];
|
||||||
} else if(stripos($query->limit, 'OFFSET')) {
|
} else if(stripos($query->limit, 'OFFSET')) {
|
||||||
list($length, $start) = split(" +OFFSET +", trim($query->limit));
|
list($length, $start) = preg_split("/ +OFFSET +/", trim($query->limit));
|
||||||
} else {
|
} else {
|
||||||
$result = split(" *, *", trim($query->limit));
|
$result = preg_split("/ *, */", trim($query->limit));
|
||||||
$start = $result[0];
|
$start = $result[0];
|
||||||
$length = isset($result[1]) ? $result[1] : null;
|
$length = isset($result[1]) ? $result[1] : null;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ class YamlFixture extends Object {
|
|||||||
foreach($fields as $fieldName => $fieldVal) {
|
foreach($fields as $fieldName => $fieldVal) {
|
||||||
if($obj->many_many($fieldName) || $obj->has_many($fieldName)) {
|
if($obj->many_many($fieldName) || $obj->has_many($fieldName)) {
|
||||||
$parsedItems = array();
|
$parsedItems = array();
|
||||||
$items = split(' *, *',trim($fieldVal));
|
$items = preg_split('/ *, */',trim($fieldVal));
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
$parsedItems[] = $this->parseFixtureVal($item);
|
$parsedItems[] = $this->parseFixtureVal($item);
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ class Enum extends DBField {
|
|||||||
function __construct($name, $enum = NULL, $default = NULL) {
|
function __construct($name, $enum = NULL, $default = NULL) {
|
||||||
if($enum) {
|
if($enum) {
|
||||||
if(!is_array($enum)){
|
if(!is_array($enum)){
|
||||||
$enum = split(" *, *", trim($enum));
|
$enum = preg_split("/ *, */", trim($enum));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->enum = $enum;
|
$this->enum = $enum;
|
||||||
|
@ -90,7 +90,7 @@ class CsvBulkLoader extends BulkLoader {
|
|||||||
|
|
||||||
} elseif(strpos($fieldName, '.') !== false) {
|
} elseif(strpos($fieldName, '.') !== false) {
|
||||||
// we have a relation column with dot notation
|
// 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)
|
$relationObj = $obj->getComponent($relationName); // always gives us an component (either empty or existing)
|
||||||
$obj->setComponent($relationName, $relationObj);
|
$obj->setComponent($relationName, $relationObj);
|
||||||
$relationObj->write();
|
$relationObj->write();
|
||||||
|
@ -460,7 +460,7 @@ function loadMimeTypes() {
|
|||||||
$mimeTypes = file_exists($mimetypePathGeneric) ? file($mimetypePathGeneric) : file($mimetypePathCustom);
|
$mimeTypes = file_exists($mimetypePathGeneric) ? file($mimetypePathGeneric) : file($mimetypePathCustom);
|
||||||
foreach($mimeTypes as $typeSpec) {
|
foreach($mimeTypes as $typeSpec) {
|
||||||
if(($typeSpec = trim($typeSpec)) && substr($typeSpec,0,1) != "#") {
|
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) {
|
if(sizeof($parts) > 1) {
|
||||||
$mimeType = array_shift($parts);
|
$mimeType = array_shift($parts);
|
||||||
foreach($parts as $ext) {
|
foreach($parts as $ext) {
|
||||||
|
@ -209,7 +209,7 @@ class CheckboxSetField extends OptionsetField {
|
|||||||
// Items is an array or single piece of string (including comma seperated string)
|
// Items is an array or single piece of string (including comma seperated string)
|
||||||
} else {
|
} else {
|
||||||
if(!is_array($items)) {
|
if(!is_array($items)) {
|
||||||
$items = split(' *, *', trim($items));
|
$items = preg_split('/ *, */', trim($items));
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($items as $item) {
|
foreach($items as $item) {
|
||||||
|
@ -72,7 +72,7 @@ HTML;
|
|||||||
|
|
||||||
// If we've already got values selected, make sure that we've got them in our tree
|
// If we've already got values selected, make sure that we've got them in our tree
|
||||||
if($_REQUEST['forceValues']) {
|
if($_REQUEST['forceValues']) {
|
||||||
$forceValues = split(" *, *", trim($_REQUEST['forceValues']));
|
$forceValues = preg_split("/ *, */", trim($_REQUEST['forceValues']));
|
||||||
foreach($forceValues as $value) {
|
foreach($forceValues as $value) {
|
||||||
$obj->markToExpose($this->getByKey($value));
|
$obj->markToExpose($this->getByKey($value));
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ HTML;
|
|||||||
if(!$saveDest) user_error("TreeMultiselectField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
|
if(!$saveDest) user_error("TreeMultiselectField::saveInto() Field '$fieldName' not found on $record->class.$record->ID", E_USER_ERROR);
|
||||||
|
|
||||||
if($this->value) {
|
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
|
// Allows you to modify the items on your object before save
|
||||||
|
@ -51,7 +51,7 @@ HTML;
|
|||||||
$saveDest = $record->$fieldName();
|
$saveDest = $record->$fieldName();
|
||||||
|
|
||||||
if($this->value) {
|
if($this->value) {
|
||||||
$items = split(" *, *", trim($this->value));
|
$items = preg_split("/ *, */", trim($this->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
$saveDest->setByIDList($items);
|
$saveDest->setByIDList($items);
|
||||||
|
@ -138,7 +138,7 @@ class SearchForm extends Form {
|
|||||||
protected function addStarsToKeywords($keywords) {
|
protected function addStarsToKeywords($keywords) {
|
||||||
if(!trim($keywords)) return "";
|
if(!trim($keywords)) return "";
|
||||||
// Add * to each keyword
|
// Add * to each keyword
|
||||||
$splitWords = split(" +" , trim($keywords));
|
$splitWords = preg_split("/ +/" , trim($keywords));
|
||||||
while(list($i,$word) = each($splitWords)) {
|
while(list($i,$word) = each($splitWords)) {
|
||||||
if($word[0] == '"') {
|
if($word[0] == '"') {
|
||||||
while(list($i,$subword) = each($splitWords)) {
|
while(list($i,$subword) = each($splitWords)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user