aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-01-26 00:38:37 +0000
committermistic100 <mistic@piwigo.org>2014-01-26 00:38:37 +0000
commitfae05b2743c514db2c345b2cf53c317af9d5ac5f (patch)
tree342df4daca0751692a2a45091901a1f7418cbf0b /admin
parent948adde84006257791e5e7239c2c159eeac0d872 (diff)
replace more preg_replace callback
git-svn-id: http://piwigo.org/svn/trunk@26972 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/history.php10
-rw-r--r--admin/include/functions.php16
2 files changed, 18 insertions, 8 deletions
diff --git a/admin/history.php b/admin/history.php
index 8307d5e32..8a2e07926 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -339,6 +339,8 @@ SELECT
id,
name, url_name
FROM '.TAGS_TABLE;
+
+ global $name_of_tag; // used for preg_replace
$name_of_tag = array();
$result = pwg_query($query);
while ($row=pwg_db_fetch_assoc($result))
@@ -399,9 +401,9 @@ SELECT
$tags_string = '';
if (isset($line['tag_ids']))
{
- $tags_string = preg_replace(
- '/(\d+)/e',
- 'isset($name_of_tag["$1"]) ? $name_of_tag["$1"] : "$1"',
+ $tags_string = preg_replace_callback(
+ '/(\d+)/',
+ create_function('$m', 'return isset($name_of_tag[$m[1]]) ? $name_of_tag[$m[1]] : $m[1];'),
str_replace(
',',
', ',
@@ -541,6 +543,8 @@ SELECT
),
)
);
+
+ unset($name_of_tag);
}
// +-----------------------------------------------------------------------+
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 2060e03b4..31f8b0eba 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -582,6 +582,7 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
FROM '.CATEGORIES_TABLE.'
ORDER BY id_uppercat,rank,name';
+ global $cat_map; // used in preg_replace callback
$cat_map = array();
$current_rank = 0;
@@ -608,13 +609,16 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
$datas = array();
+ $cat_map_callback = create_function('$m', 'global $cat_map; return $cat_map[$m[1]]["rank"];');
+
foreach( $cat_map as $id=>$cat )
{
- $new_global_rank = preg_replace(
- '/(\d+)/e',
- "\$cat_map['$1']['rank']",
- str_replace(',', '.', $cat['uppercats'] )
- );
+ $new_global_rank = preg_replace_callback(
+ '/(\d+)/',
+ $cat_map_callback,
+ str_replace(',', '.', $cat['uppercats'] )
+ );
+
if ( $cat['rank_changed']
or $new_global_rank!=$cat['global_rank']
)
@@ -627,6 +631,8 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
}
}
+ unset($cat_map);
+
mass_updates(
CATEGORIES_TABLE,
array(