aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2014-01-27 18:05:04 +0000
committermistic100 <mistic@piwigo.org>2014-01-27 18:05:04 +0000
commit6fcc5f10df0fbd02877e49aec7b662c64c60acc7 (patch)
tree5359b9244063c672c9c829c2e54bc935e870567f /admin
parent46c2cb6b5f407848ed9bc60812b84f645106fedc (diff)
Merged revision(s) 26972, 26998 from trunk:
replace more preg_replace callback ........ remove *_version_compare methods in languages & plugins & themes classes, unused and outdated (preg_replace /e modifier) git-svn-id: http://piwigo.org/svn/branches/2.6@26999 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/history.php10
-rw-r--r--admin/include/functions.php16
-rw-r--r--admin/include/languages.class.php10
-rw-r--r--admin/include/plugins.class.php19
-rw-r--r--admin/include/themes.class.php10
5 files changed, 18 insertions, 47 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 1df6e4f45..bdeab47e7 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -576,6 +576,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;
@@ -602,13 +603,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']
)
@@ -621,6 +625,8 @@ SELECT id, id_uppercat, uppercats, rank, global_rank
}
}
+ unset($cat_map);
+
mass_updates(
CATEGORIES_TABLE,
array(
diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php
index bb9487bec..c4caa2dc9 100644
--- a/admin/include/languages.class.php
+++ b/admin/include/languages.class.php
@@ -402,16 +402,6 @@ UPDATE '.USER_INFOS_TABLE.'
/**
* Sort functions
*/
- function language_version_compare($a, $b)
- {
- $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
- $replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
-
- $array = preg_replace($pattern, $replacement, array($a, $b));
-
- return version_compare($array[0], $array[1], '>=');
- }
-
function extension_name_compare($a, $b)
{
return strcmp(strtolower($a['extension_name']), strtolower($b['extension_name']));
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index 0ddc85b50..9862bccd4 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -614,25 +614,6 @@ DELETE FROM '. PLUGINS_TABLE .'
/**
* Sort functions
*/
- function plugin_version_compare($a, $b)
- {
- if (strtolower($a) == 'auto') return false;
-
- $array = preg_replace(
- array('/\.+/', '/\.\Z|\A\./'),
- array('.', ''),
- array($a, $b)
- );
-
- $array = preg_replace_callback(
- '/([a-z])/i',
- create_function('$m', 'return intval($m[1], 36);'),
- $array
- );
-
- return version_compare($array[0], $array[1], '>=');
- }
-
function extension_revision_compare($a, $b)
{
if ($a['revision_date'] < $b['revision_date']) return 1;
diff --git a/admin/include/themes.class.php b/admin/include/themes.class.php
index 7832c42e0..824ccf4b9 100644
--- a/admin/include/themes.class.php
+++ b/admin/include/themes.class.php
@@ -689,16 +689,6 @@ SELECT
/**
* Sort functions
*/
- function theme_version_compare($a, $b)
- {
- $pattern = array('/([a-z])/ei', '/\.+/', '/\.\Z|\A\./');
- $replacement = array( "'.'.intval('\\1', 36).'.'", '.', '');
-
- $array = preg_replace($pattern, $replacement, array($a, $b));
-
- return version_compare($array[0], $array[1], '>=');
- }
-
function extension_revision_compare($a, $b)
{
if ($a['revision_date'] < $b['revision_date']) return 1;