diff options
author | Nils Adermann <naderman@naderman.de> | 2007-03-12 09:43:14 +0000 |
---|---|---|
committer | Nils Adermann <naderman@naderman.de> | 2007-03-12 09:43:14 +0000 |
commit | 47a3bc1b081f0aa8766f87b51c8d25db75c203a8 (patch) | |
tree | 4e40f227a766754896ac09013a29733115d5196d /phpBB | |
parent | 51088c46fb5cb5c36759a91f6a7229b28f2df0d1 (diff) | |
download | forums-47a3bc1b081f0aa8766f87b51c8d25db75c203a8.tar forums-47a3bc1b081f0aa8766f87b51c8d25db75c203a8.tar.gz forums-47a3bc1b081f0aa8766f87b51c8d25db75c203a8.tar.bz2 forums-47a3bc1b081f0aa8766f87b51c8d25db75c203a8.tar.xz forums-47a3bc1b081f0aa8766f87b51c8d25db75c203a8.zip |
- correct size conversion (px to percentage)
git-svn-id: file:///svn/phpbb/trunk@7172 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/develop/adjust_sizes.php | 18 | ||||
-rw-r--r-- | phpBB/install/convertors/functions_phpbb20.php | 10 |
2 files changed, 15 insertions, 13 deletions
diff --git a/phpBB/develop/adjust_sizes.php b/phpBB/develop/adjust_sizes.php index e5d28a14b9..8683a5b9dc 100644 --- a/phpBB/develop/adjust_sizes.php +++ b/phpBB/develop/adjust_sizes.php @@ -24,6 +24,11 @@ $user->setup(); $echos = 0; +function replace_size($matches) +{ + return '[size=' . ceil(100.0 * (((double) $matches[1])/12.0)) . ':' . $matches[2] . ']'; +} + // Adjust user signatures $sql = 'SELECT user_id, user_sig, user_sig_bbcode_uid FROM ' . USERS_TABLE; @@ -36,9 +41,8 @@ while ($row = $db->sql_fetchrow($result)) // Only if a bbcode uid is present, the signature present and a size tag used... if ($bbcode_uid && $row['user_sig'] && strpos($row['user_sig'], '[size=') !== false) { - $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); - $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); - $row['user_sig'] = preg_replace($match_size, $replace_size, $row['user_sig']); + + $row['user_sig'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['user_sig']); $sql = 'UPDATE ' . USERS_TABLE . " SET user_sig = '" . $db->sql_escape($row['user_sig']) . "' WHERE user_id = " . $row['user_id']; @@ -71,9 +75,7 @@ while ($row = $db->sql_fetchrow($result)) // Only if a bbcode uid is present, bbcode enabled and a size tag used... if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['post_text'], '[size=') !== false) { - $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); - $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); - $row['post_text'] = preg_replace($match_size, $replace_size, $row['post_text']); + $row['post_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['post_text']); $sql = 'UPDATE ' . POSTS_TABLE . " SET post_text = '" . $db->sql_escape($row['post_text']) . "' WHERE post_id = " . $row['post_id']; @@ -105,9 +107,7 @@ while ($row = $db->sql_fetchrow($result)) // Only if a bbcode uid is present, bbcode enabled and a size tag used... if ($row['enable_bbcode'] && $bbcode_uid && strpos($row['message_text'], '[size=') !== false) { - $match_size = array('/\[size=[0-7]:' . $bbcode_uid . '\]/', '/\[size=[8-9]:' . $bbcode_uid . '\]/', '/\[size=1[0-2]:' . $bbcode_uid . '\]/', '/\[size=1[3-8]:' . $bbcode_uid . '\]/', '/\[size=(?:[2][0-9]|19):' . $bbcode_uid . '\]/'); - $replace_size = array('[size=50:' . $bbcode_uid . ']', '[size=85:' . $bbcode_uid . ']', '[size=100:' . $bbcode_uid . ']', '[size=150:' . $bbcode_uid . ']', '[size=200:' . $bbcode_uid . ']'); - $row['message_text'] = preg_replace($match_size, $replace_size, $row['message_text']); + $row['message_text'] = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $row['message_text']); $sql = 'UPDATE ' . PRIVMSGS_TABLE . " SET message_text = '" . $db->sql_escape($row['message_text']) . "' WHERE msg_id = " . $row['msg_id']; diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index e4f2a88013..26f5407915 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -1131,6 +1131,11 @@ function phpbb_convert_topic_type($topic_type) return POST_NORMAL; } +function phpbb_replace_size($matches) +{ + return '[size=' . ceil(100.0 * (((double) $matches[1])/12.0)) . ':' . $matches[2] . ']'; +} + /** * Reparse the message stripping out the bbcode_uid values and adding new ones and setting the bitfield * @todo What do we want to do about HTML in messages - currently it gets converted to the entities, but there may be some objections to this @@ -1151,10 +1156,7 @@ function phpbb_prepare_message($message) // Adjust size... if (strpos($message, '[size=') !== false) { - // Doing it with a map. - $match_size = array('/\[size=[0-7]:' . $convert->row['old_bbcode_uid'] . '\]/', '/\[size=[8-9]:' . $convert->row['old_bbcode_uid'] . '\]/', '/\[size=1[0-2]:' . $convert->row['old_bbcode_uid'] . '\]/', '/\[size=1[3-8]:' . $convert->row['old_bbcode_uid'] . '\]/', '/\[size=(?:[2-9][0-9]|19):' . $convert->row['old_bbcode_uid'] . '\]/'); - $replace_size = array('[size=50:' . $convert->row['old_bbcode_uid'] . ']', '[size=85:' . $convert->row['old_bbcode_uid'] . ']', '[size=100:' . $convert->row['old_bbcode_uid'] . ']', '[size=150:' . $convert->row['old_bbcode_uid'] . ']', '[size=200:' . $convert->row['old_bbcode_uid'] . ']'); - $message = preg_replace($match_size, $replace_size, $message); + $message = preg_replace_callback('/\[size=(\d*):' . $bbcode_uid . '\]/', 'replace_size', $message); } $message = preg_replace('/\:(([a-z0-9]:)?)' . $convert->row['old_bbcode_uid'] . '/s', '', $message); |