diff options
author | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-09-19 01:11:32 +0000 |
---|---|---|
committer | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2002-09-19 01:11:32 +0000 |
commit | e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8 (patch) | |
tree | ee8766fffd58713d8f09f0d42f40f341311c130c | |
parent | 13307c1360721ee1892ae5eb1e7d9d27ec6c3c76 (diff) | |
download | forums-e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8.tar forums-e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8.tar.gz forums-e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8.tar.bz2 forums-e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8.tar.xz forums-e1e52497fa6ce9e5d1d496c8c1af3b3270d465b8.zip |
Preimplementation of smilies order, "smilies" changed into "emoticons" as per Bart comment and sql_query_array() fixed to allow FALSE values
git-svn-id: file:///svn/phpbb/trunk@2893 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r-- | phpBB/admin/admin_forums.php | 6 | ||||
-rw-r--r-- | phpBB/admin/admin_smilies.php | 166 | ||||
-rw-r--r-- | phpBB/admin/subSilver.css | 5 | ||||
-rw-r--r-- | phpBB/db/mysql.php | 4 | ||||
-rw-r--r-- | phpBB/install/schemas/mysql_schema.sql | 2 | ||||
-rw-r--r-- | phpBB/language/lang_english/lang_admin.php | 67 |
6 files changed, 190 insertions, 60 deletions
diff --git a/phpBB/admin/admin_forums.php b/phpBB/admin/admin_forums.php index 76efa5c65c..a501ae60da 100644 --- a/phpBB/admin/admin_forums.php +++ b/phpBB/admin/admin_forums.php @@ -511,7 +511,7 @@ switch ($mode) } ?> <tr> - <td class="catBottom" colspan="2" align="center"><input type="hidden" name="mode" value="<?php echo $newmode ?>" /><input type="hidden" name="forum_id" value="<?php echo $forum_id ?>" /><input type="submit" name="submit" value="<?php echo $buttonvalue ?>" class="mainoption" /></td> + <td class="cat" colspan="2" align="center"><input type="hidden" name="mode" value="<?php echo $newmode ?>" /><input type="hidden" name="forum_id" value="<?php echo $forum_id ?>" /><input type="submit" name="submit" value="<?php echo $buttonvalue ?>" class="mainoption" /></td> </tr> </table> </form> @@ -578,7 +578,7 @@ switch ($mode) } ?> <tr> - <td class="catBottom" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $lang['Move_and_Delete'] ?>" class="mainoption" /></td> + <td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $lang['Move_and_Delete'] ?>" class="mainoption" /></td> </tr> </table> </form> @@ -743,7 +743,7 @@ while ($row = $db->sql_fetchrow($result)) ?> <tr> - <td width="100%" colspan="9" class="catBottom"><input type="text" name="forum_name[<? echo $parent_id ?>]" /> <input type="submit" class="liteoption" name="parent_id[<? echo $parent_id ?>]" value="<?php echo $lang['Create_forum'] ?>" /></td> + <td width="100%" colspan="9" class="cat"><input type="text" name="forum_name[<? echo $parent_id ?>]" /> <input type="submit" class="liteoption" name="parent_id[<? echo $parent_id ?>]" value="<?php echo $lang['Create_forum'] ?>" /></td> </tr> </table></form> diff --git a/phpBB/admin/admin_smilies.php b/phpBB/admin/admin_smilies.php index a76899e965..549bac5831 100644 --- a/phpBB/admin/admin_smilies.php +++ b/phpBB/admin/admin_smilies.php @@ -94,6 +94,7 @@ if (isset($HTTP_POST_VARS['import_pak'])) { if (!empty($HTTP_POST_VARS['smilies_pak'])) { + $smile_order = 0; // // The user has already selected a smilies_pak file.. Import it. // @@ -108,6 +109,7 @@ if (isset($HTTP_POST_VARS['import_pak'])) $smilies = array(); while ($row = $db->sql_fetchrow($result)) { + ++$smile_order; $smilies[$row['code']] = 1; } } @@ -159,11 +161,14 @@ if (isset($HTTP_POST_VARS['import_pak'])) } else { + ++$smile_order; + $sql = array( 'code' => $code, 'smile_url' => $smile_url, 'smile_height' => $smile_height, 'smile_width' => $smile_width, + 'smile_order' => $smile_order, 'emoticon' => $emotion ); $db->sql_query_array('INSERT INTO ' . SMILIES_TABLE, $sql); @@ -274,10 +279,12 @@ function update_smile(newimage) } function update_smile_dimensions() { - document.forms[0].smile_height.value = document.smile_image.height; - document.forms[0].smile_width.value = document.smile_image.width; + if (document.smile_image.height) + { + document.forms[0].smile_height.value = document.smile_image.height; + document.forms[0].smile_width.value = document.smile_image.width; + } } -<?php echo (!empty($default_image)) ? 'update_smile("' . $default_image . '");' : '' ?> //--> </script> @@ -291,7 +298,7 @@ function update_smile_dimensions() </tr> <tr> <td class="row1"><?php echo $lang['Smile_url'] ?></td> - <td class="row1"><select name="smile_url" onChange="update_smile(this.options[selectedIndex].value);"><?php echo $filename_list ?></select> <img name="smile_image" src="../images/spacer.gif" border="0" alt="" onLoad="update_smile_dimensions()" /> </td> + <td class="row1"><select name="smile_url" onChange="update_smile(this.options[selectedIndex].value);"><?php echo $filename_list ?></select> <img name="smile_image" src="<?php echo (!empty($default_image)) ? $phpbb_root_path . $board_config['smilies_path'] . '/' . $default_image : '../images/spacer.gif' ?>" border="0" alt="" onLoad="update_smile_dimensions()" /> </td> </tr> <tr> <td class="row2"><?php echo $lang['Smile_width'] ?></td> @@ -324,11 +331,34 @@ switch ($mode) case 'edit': $smile_id = intval($HTTP_GET_VARS['smile_id']); +/* $sql = 'SELECT * FROM ' . SMILIES_TABLE . " WHERE smilies_id = $smile_id"; $result = $db->sql_query($sql); $smile_data = $db->sql_fetchrow($result); +*/ + $order_list = ''; + $result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE . ' ORDER BY smile_order DESC'); + while ($row = $db->sql_fetchrow($result)) + { + if ($row['smilies_id'] == $smile_id) + { + $after = TRUE; + $smile_data = $row; + } + else + { + $selected = ''; + if (!empty($after)) + { + $selected = ' selected="selected"'; + $after = FALSE; + } + $order_list = '<option value="' . ($row['smile_order'] + 1) . '"' . $selected . '>' . sprintf($lang['After_smile'], htmlspecialchars($row['code'])) . '</option>' . $order_list; + } + } + $order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $lang['First'] . '</option>' . $order_list; $filename_list = ''; foreach ($smilies_images as $smile_url) @@ -336,7 +366,7 @@ switch ($mode) if ($smile_url == $smile_data['smile_url']) { $smile_selected = ' selected="selected"'; - $smile_edit_img = $smile_url;; + $smile_edit_img = $smile_url; } else { @@ -369,7 +399,7 @@ function update_smile_dimensions() <form method="post" action="admin_smilies.<?php echo $phpEx . $SID ?>&mode=modify"><table class="forumline" cellspacing="1" cellpadding="4" border="0" align="center"> <tr> - <th class="thHead" colspan="2"><?php echo $lang['smile_config'] ?></th> + <th class="thHead" colspan="2"><?php echo $lang['Smile_config'] ?></th> </tr> <tr> <td class="row2"><?php echo $lang['Smile_code'] ?></td> @@ -392,6 +422,14 @@ function update_smile_dimensions() <td class="row2"><input type="text" size="3" name="smile_height" value="<?php echo $smile_data['smile_height'] ?>" /></td> </tr> <tr> + <td class="row1"><?php echo $lang['Display_on_posting'] ?></td> + <td class="row1"><input type="checkbox" name="smile_on_posting" <?php echo ($smile_data['smile_on_posting']) ? ' checked="checked"' : '' ?>/></td> + </tr> + <tr> + <td class="row2"><?php echo $lang['Smile_order'] ?></td> + <td class="row2"><select name="smile_order"><?php echo $order_list ?></select></td> + </tr> + <tr> <td class="catBottom" colspan="2" align="center"><input type="hidden" name="smile_id" value="<?php echo $smile_data['smilies_id'] ?>" /><input class="mainoption" type="submit" value="<?php echo $lang['Submit'] ?>" /></td> </tr> </table></form> @@ -403,17 +441,65 @@ function update_smile_dimensions() case 'create': case 'modify': + $smile_width = intval($HTTP_POST_VARS['smile_width']); + $smile_height = intval($HTTP_POST_VARS['smile_height']); + if ($smile_width == 0 || $smile_height == 0) + { + $img_size = @getimagesize($phpbb_root_path . $board_config['smilies_path'] . '/' . stripslashes($HTTP_POST_VARS['smile_url'])); + $smile_width = $img_size[0]; + $smile_height = $img_size[1]; + } $sql = array( - 'code' => htmlspecialchars(stripslashes($HTTP_POST_VARS['smile_code'])), - 'smile_url' => stripslashes($HTTP_POST_VARS['smile_url']), - 'smile_height' => intval($HTTP_POST_VARS['smile_height']), - 'smile_width' => intval($HTTP_POST_VARS['smile_width']), - 'emoticon' => stripslashes($HTTP_POST_VARS['smile_emotion']) + 'code' => htmlspecialchars(stripslashes($HTTP_POST_VARS['smile_code'])), + 'smile_url' => stripslashes($HTTP_POST_VARS['smile_url']), + 'smile_width' => $smile_width, + 'smile_height' => $smile_height, + 'smile_order' => $smile_order, + 'emoticon' => stripslashes($HTTP_POST_VARS['smile_emotion']), + 'smile_on_posting' => (!empty($HTTP_POST_VARS['smile_on_posting'])) ? 1 : 0 ); + $smile_id = $HTTP_POST_VARS['smile_id']; + $smile_order = $HTTP_POST_VARS['smile_order']; + + if ($mode == 'modify') + { + $result = $db->sql_query('SELECT smile_order FROM ' . SMILIES_TABLE . " WHERE smilies_id = $smile_id"); + $order_old = $db->sql_fetchfield('smile_order', 0, $result); + + if ($order_old == $smile_order) + { + $no_update = TRUE; + } + if ($order_old > $smile_order) + { + $sign = '+'; + $where = "smile_order >= $smile_order AND smile_order < $order_old"; + } + else + { + $sign = '-'; + $where = "smile_order > $order_old AND smile_order < $smile_order"; + $sql['smile_order'] = $smile_order - 1; + } + } + else + { + $sign = '+'; + $where = "smile_order > $smile_order"; + } + + if (empty($no_update)) + { + $qry = 'UPDATE ' . SMILIES_TABLE . " + SET smile_order = smile_order $sign 1 + WHERE $where"; + $db->sql_query($qry); + } + if ($mode == 'modify') { - $db->sql_query_array('UPDATE ' . SMILIES_TABLE . ' SET WHERE smilies_id = ' . $HTTP_POST_VARS['smile_id'], $sql); + $db->sql_query_array('UPDATE ' . SMILIES_TABLE . " SET WHERE smilies_id = $smile_id", $sql); message_die(MESSAGE, $lang['Smile_edited'] . $click_return); } else @@ -423,9 +509,39 @@ function update_smile_dimensions() } break; + case 'move_up': + case 'move_down': + $smile_order = intval($HTTP_GET_VARS['smile_order']); + $order_total = $smile_order * 2 + (($mode == 'move_up') ? -1 : 1); + + $sql = 'UPDATE ' . SMILIES_TABLE . " + SET smile_order = $order_total - smile_order + WHERE smile_order IN ($smile_order, " . (($mode == 'move_up') ? $smile_order - 1 : $smile_order + 1) . ')'; + $db->sql_query($sql); + + // + // No break; here, display the smilies admin back + // + default: + // + // By default, check that smile_order is valid and fix it if necessary + // + $order = 0; + $result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE . ' ORDER BY smile_order'); + while ($row = $db->sql_fetchrow($result)) + { + ++$order; + if ($row['smile_order'] != $order) + { + $db->sql_query('UPDATE ' . SMILIES_TABLE . " SET smile_order = $order WHERE smilies_id = " . $row['smilies_id']); + } + } - $result = $db->sql_query('SELECT * FROM ' . SMILIES_TABLE); + $sql = 'SELECT * + FROM ' . SMILIES_TABLE . ' + ORDER BY smile_on_posting DESC, smile_order ASC'; + $result = $db->sql_query($sql); page_header($lang['Emoticons']); ?> @@ -439,15 +555,23 @@ function update_smile_dimensions() <th><?php echo $lang['Smile']; ?></th> <th><?php echo $lang['Emotion']; ?></th> <th colspan="2"><?php echo $lang['Action']; ?></th> + <th colspan="2"><?php echo $lang['Reorder']; ?></th> </tr> <?php - - if ($row = $db->sql_fetchrow($result)) + + $spacer = FALSE; + while ($row = $db->sql_fetchrow($result)) { - do + if (!$spacer && !$row['smile_on_posting']) { - $row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2'; - + $spacer = TRUE; +?> + <tr> + <td class="row3" colspan="7" align="center"><?php echo $lang['Smilies_not_displayed'] ?></td> + </tr> +<?php + } + $row_class = ( $row_class != 'row1' ) ? 'row1' : 'row2'; ?> <tr> <td class="<?php echo $row_class; ?>" align="center"><?php echo htmlspecialchars($row['code']); ?></td> @@ -455,16 +579,16 @@ function update_smile_dimensions() <td class="<?php echo $row_class; ?>" align="center"><?php echo $row['emoticon']; ?></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&mode=edit&smile_id=" . $row['smilies_id']; ?>"><?php echo $lang['Edit']; ?></a></td> <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&mode=delete&smile_id=" . $row['smilies_id']; ?>"><?php echo $lang['Delete']; ?></a></td> + <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&mode=move_up&smile_order=" . $row['smile_order']; ?>"><?php echo $lang['Up']; ?></a></td> + <td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_smilies.$phpEx$SID&mode=move_down&smile_order=" . $row['smile_order']; ?>"><?php echo $lang['Down']; ?></a></td> </tr> <?php - } - while ( $row = $db->sql_fetchrow($result) ); } ?> <tr> - <td class="cat" colspan="5" align="center"><input type="submit" name="add" value="<?php echo $lang['Add_smile']; ?>" class="mainoption" /> <input class="liteoption" type="submit" name="import_pak" value="<?php echo $lang['Import_smilies']; ?>"> <input class="liteoption" type="submit" name="export_pak" value="<?php echo $lang['Export_smilies']; ?>"></td> + <td class="cat" colspan="7" align="center"><input type="submit" name="add" value="<?php echo $lang['Add_smile']; ?>" class="mainoption" /> <input class="liteoption" type="submit" name="import_pak" value="<?php echo $lang['Import_smilies']; ?>"> <input class="liteoption" type="submit" name="export_pak" value="<?php echo $lang['Export_smilies']; ?>"></td> </tr> </table></form> diff --git a/phpBB/admin/subSilver.css b/phpBB/admin/subSilver.css index 58978f37fe..4b50962c2a 100644 --- a/phpBB/admin/subSilver.css +++ b/phpBB/admin/subSilver.css @@ -140,11 +140,6 @@ td.cat { background-color: #D1D7DC; } -td.catBottom { - background-image: url(../templates/subSilver/images/cellpic1.gif); - background-color:#D1D7DC; border: #FFFFFF; height: 28px; -} - .row1 { background-color: #EFEFEF; } diff --git a/phpBB/db/mysql.php b/phpBB/db/mysql.php index 1fafc51152..6a25ea9397 100644 --- a/phpBB/db/mysql.php +++ b/phpBB/db/mysql.php @@ -190,7 +190,7 @@ class sql_db } else { - $values[] = $var; + $values[] = (is_bool($var)) ? intval($var) : $var; } } @@ -211,7 +211,7 @@ class sql_db } else { - $values[] = "$key = $var"; + $values[] = (is_bool($var)) ? "$key = " . intval($var) : "$key = $var"; } } diff --git a/phpBB/install/schemas/mysql_schema.sql b/phpBB/install/schemas/mysql_schema.sql index b1228dff87..c250a650a4 100644 --- a/phpBB/install/schemas/mysql_schema.sql +++ b/phpBB/install/schemas/mysql_schema.sql @@ -431,7 +431,9 @@ CREATE TABLE phpbb_smilies ( smile_url char(50), smile_width tinyint(4) UNSIGNED NOT NULL, smile_height tinyint(4) UNSIGNED NOT NULL, + smile_order tinyint(4) UNSIGNED NOT NULL, emoticon char(50), + smile_on_posting tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, PRIMARY KEY (smilies_id) ); diff --git a/phpBB/language/lang_english/lang_admin.php b/phpBB/language/lang_english/lang_admin.php index f3250be0da..19094cf5b9 100644 --- a/phpBB/language/lang_english/lang_admin.php +++ b/phpBB/language/lang_english/lang_admin.php @@ -576,43 +576,52 @@ $lang['Click_return_forumadmin'] = 'Click %sHere%s to return to Forum Administra // // Smiley Management // -$lang['Emoticons_explain'] = 'From this page you can add, remove and edit the emoticons or smilies users can use in their posts and private messages.'; +$lang['Emoticons_explain'] = 'From this page you can add, remove and edit the emoticons or emoticons users can use in their posts and private messages.'; -$lang['Import_smilies'] = 'Import smilies pak'; -$lang['Import_smilies_explain'] = 'Unzip the smilies package to your smilies directory then select the correct information in this form to import it.'; +$lang['Import_smilies'] = 'Import emoticons pak'; +$lang['Import_smilies_explain'] = 'Unzip the emoticons package to your emoticons directory then select the correct information in this form to import it.'; -$lang['Smilies_import'] = 'Smilies pack import'; -$lang['No_smilies_pak'] = 'No smilies pack found'; +$lang['Smilies_import'] = 'Emoticons pack import'; +$lang['No_smilies_pak'] = 'No emoticons pack found'; $lang['Select_package'] = 'Select a package file'; -$lang['Delete_existing_smilies'] = 'Delete existing smilies before import'; +$lang['Delete_existing_smilies'] = 'Delete existing emoticons before import'; $lang['Smilies_conflicts'] = 'What should be done in case of conflicts?'; -$lang['Keep_existing_smilies'] = 'Keep existing smilies'; -$lang['Replace_existing_smilies'] = 'Replace existing smilies'; -$lang['Smilies_import_success'] = 'The smilies pack was imported successfully'; - -$lang['Export_smilies'] = 'Create smilies pak'; -$lang['Export_smilies_explain'] = 'To create a package of your currently installed smilies, %sclick here%s to download the smilies.pak file. Name this file appropriately, making sure to keep the .pak file extension then create a zip file containing all of your smilies images plus this .pak configuration file.'; - -$lang['Add_smile'] = 'Add a new smile'; -$lang['Edit_smile'] = 'Edit smile'; - -$lang['Smile_config'] = 'Smile configuration'; -$lang['Smile_code'] = 'Smile code'; -$lang['Smile_url'] = 'Smile image file'; -$lang['Smile_height'] = 'Smile height'; -$lang['Smile_width'] = 'Smile width'; -$lang['Smile_emotion'] = 'Smile emotion'; -$lang['Smile_add'] = 'Add a new smile'; -$lang['Smile_edit'] = 'Edit smile'; +$lang['Keep_existing_smilies'] = 'Keep existing emoticons'; +$lang['Replace_existing_smilies'] = 'Replace existing emoticons'; +$lang['Smilies_import_success'] = 'The emoticons pack was imported successfully'; + +$lang['Export_smilies'] = 'Create emoticons pak'; +$lang['Export_smilies_explain'] = 'To create a package of your currently installed emoticons, %sclick here%s to download the emoticons.pak file. Name this file appropriately, making sure to keep the .pak file extension then create a zip file containing all of your emoticons images plus this .pak configuration file.'; + +$lang['Add_smile'] = 'Add a new emoticon'; +$lang['Edit_smile'] = 'Edit emoticon'; + +$lang['Smilies_not_displayed'] = 'The following emoticons are not displayed on posting page'; +$lang['Reorder'] = 'Reorder'; +$lang['Up'] = 'Up'; +$lang['Down'] = 'Down'; +$lang['First'] = 'First'; +$lang['After_smile'] = 'After %s'; +$lang['Display_on_posting'] = 'Display on posting'; + +$lang['Smile_config'] = 'Emoticon configuration'; +$lang['Smile_code'] = 'Emoticon code'; +$lang['Smile_url'] = 'Emoticon image file'; +$lang['Smile_height'] = 'Emoticon height'; +$lang['Smile_width'] = 'Emoticon width'; +$lang['Smile_order'] = 'Emoticon order'; +$lang['Smile_emotion'] = 'Emotion'; +$lang['Smile_add'] = 'Add a new emoticon'; +$lang['Smile_edit'] = 'Edit emoticon'; $lang['Smile'] = 'Smile'; $lang['Emotion'] = 'Emotion'; -$lang['Smile_deleted'] = 'This smile has been successfully removed'; -$lang['Smile_edited'] = 'This smile has been successfully updated'; -$lang['Smile_added'] = 'This smile has been successfully added'; -$lang['Smilies_imported'] = 'The smilies pack has been successfully imported'; +$lang['Smile_deleted'] = 'This emoticon has been successfully removed'; +$lang['Smile_edited'] = 'This emoticon has been successfully updated'; +$lang['Smile_added'] = 'This emoticon has been successfully added'; +$lang['Smilies_imported'] = 'The emoticons pack has been successfully imported'; -$lang['Click_return_smileadmin'] = 'Click %sHere%s to return to Smilies Administration'; +$lang['Click_return_smileadmin'] = 'Click %sHere%s to return to Emoticons Administration'; // |