summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2010-02-06 13:05:44 -0800
committerAndy Staudacher <andy.st@gmail.com>2010-02-06 13:05:44 -0800
commit7099fc71f11ef8d3dd613d96a04a4824a827c714 (patch)
tree56a0cdde8af26c66b27095f15107294c9c75a52c
parent5c0c33782d7dd3556adecb9593f25f2cff06401a (diff)
Fix for ticket 1004: Replace all uses of split with explode (none actually required regular expressions). Thanks to Brian Hartsock for providing a patch!
-rw-r--r--modules/gallery/tests/File_Structure_Test.php2
-rw-r--r--modules/tag/controllers/tags.php6
-rw-r--r--modules/tag/helpers/tag_event.php6
-rw-r--r--modules/tag/helpers/tag_item_rest.php2
-rw-r--r--modules/user/tests/No_Direct_ORM_Access_Test.php4
5 files changed, 10 insertions, 10 deletions
diff --git a/modules/gallery/tests/File_Structure_Test.php b/modules/gallery/tests/File_Structure_Test.php
index 4590e95d..9b2b1480 100644
--- a/modules/gallery/tests/File_Structure_Test.php
+++ b/modules/gallery/tests/File_Structure_Test.php
@@ -195,7 +195,7 @@ class File_Structure_Test extends Gallery_Unit_Test_Case {
foreach ($dir as $file) {
$file_as_string = file_get_contents($file);
if (preg_match('/\t/', $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/\t/', $line)) {
$errors[] = "$file:$l has tab(s) ($line)";
}
diff --git a/modules/tag/controllers/tags.php b/modules/tag/controllers/tags.php
index 1eede907..04400d73 100644
--- a/modules/tag/controllers/tags.php
+++ b/modules/tag/controllers/tags.php
@@ -60,7 +60,7 @@ class Tags_Controller extends Controller {
$form = tag::get_add_form($item);
if ($form->validate()) {
- foreach (split(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
+ foreach (explode(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
$tag = tag::add($item, $tag_name);
@@ -77,9 +77,9 @@ class Tags_Controller extends Controller {
public function autocomplete() {
$tags = array();
- $tag_parts = preg_split("#,#", Input::instance()->get("q"));
+ $tag_parts = explode(",", Input::instance()->get("q"));
$limit = Input::instance()->get("limit");
- $tag_part = end($tag_parts);
+ $tag_part = ltrim(end($tag_parts));
$tag_list = ORM::factory("tag")
->where("name", "LIKE", "{$tag_part}%")
->order_by("name", "ASC")
diff --git a/modules/tag/helpers/tag_event.php b/modules/tag/helpers/tag_event.php
index 403ccd52..10075c02 100644
--- a/modules/tag/helpers/tag_event.php
+++ b/modules/tag/helpers/tag_event.php
@@ -34,7 +34,7 @@ class tag_event_Core {
if (!empty($iptc["2#025"])) {
foreach($iptc["2#025"] as $tag) {
$tag = str_replace("\0", "", $tag);
- foreach (preg_split("/,/", $tag) as $word) {
+ foreach (explode(",", $tag) as $word) {
$word = trim($word);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($word) != "UTF-8") {
$word = utf8_encode($word);
@@ -82,7 +82,7 @@ class tag_event_Core {
static function item_edit_form_completed($item, $form) {
tag::clear_all($item);
- foreach (preg_split("/,/", $form->edit_item->tags->value) as $tag_name) {
+ foreach (explode(",", $form->edit_item->tags->value) as $tag_name) {
if ($tag_name) {
tag::add($item, trim($tag_name));
}
@@ -124,7 +124,7 @@ class tag_event_Core {
}
static function add_photos_form_completed($album, $form) {
- foreach (split(",", $form->add_photos->tags->value) as $tag_name) {
+ foreach (explode(",", $form->add_photos->tags->value) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
$tag = tag::add($album, $tag_name);
diff --git a/modules/tag/helpers/tag_item_rest.php b/modules/tag/helpers/tag_item_rest.php
index 672cec53..fe07fefb 100644
--- a/modules/tag/helpers/tag_item_rest.php
+++ b/modules/tag/helpers/tag_item_rest.php
@@ -34,7 +34,7 @@ class tag_item_rest_Core {
}
static function resolve($tuple) {
- list ($tag_id, $item_id) = split(",", $tuple);
+ list ($tag_id, $item_id) = explode(",", $tuple);
$tag = ORM::factory("tag", $tag_id);
$item = ORM::factory("item", $item_id);
if (!$tag->loaded() || !$item->loaded() || !$tag->has($item) || !access::can("view", $item)) {
diff --git a/modules/user/tests/No_Direct_ORM_Access_Test.php b/modules/user/tests/No_Direct_ORM_Access_Test.php
index c372258e..eb7f09b0 100644
--- a/modules/user/tests/No_Direct_ORM_Access_Test.php
+++ b/modules/user/tests/No_Direct_ORM_Access_Test.php
@@ -31,7 +31,7 @@ class No_Direct_ORM_Access_Test extends Gallery_Unit_Test_Case {
//if (basename(dirname($file)) == "helpers") {
$file_as_string = file_get_contents($file);
if (preg_match("/ORM::factory\\(\"user\"/", $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/ORM::factory\\(\"user\"/', $line)) {
$errors[] = "$file($l) => $line";
}
@@ -54,7 +54,7 @@ class No_Direct_ORM_Access_Test extends Gallery_Unit_Test_Case {
foreach ($dir as $file) {
$file_as_string = file_get_contents($file);
if (preg_match("/ORM::factory\\(\"group\"/", $file_as_string)) {
- foreach (split("\n", $file_as_string) as $l => $line) {
+ foreach (explode("\n", $file_as_string) as $l => $line) {
if (preg_match('/ORM::factory\\(\"group\"/', $line)) {
$errors[] = "$file($l) => $line";
}