aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul S. Owen <psotfx@users.sourceforge.net>2001-09-01 23:11:34 +0000
committerPaul S. Owen <psotfx@users.sourceforge.net>2001-09-01 23:11:34 +0000
commit71f747a252f1c13c6aeaee36838bbcb6b0d8398c (patch)
tree259146fb9952c97087b714c9312b3cafa71ec2e5
parente1a620276e782462e379387585a8b8ef02315f9f (diff)
downloadforums-71f747a252f1c13c6aeaee36838bbcb6b0d8398c.tar
forums-71f747a252f1c13c6aeaee36838bbcb6b0d8398c.tar.gz
forums-71f747a252f1c13c6aeaee36838bbcb6b0d8398c.tar.bz2
forums-71f747a252f1c13c6aeaee36838bbcb6b0d8398c.tar.xz
forums-71f747a252f1c13c6aeaee36838bbcb6b0d8398c.zip
Updated various internal code, altered some template var names, etc.
git-svn-id: file:///svn/phpbb/trunk@964 89ea8834-ac86-4346-8a33-228a782c2dd0
-rw-r--r--phpBB/admin/admin_smilies.php235
1 files changed, 130 insertions, 105 deletions
diff --git a/phpBB/admin/admin_smilies.php b/phpBB/admin/admin_smilies.php
index e0c666b140..5a200b7401 100644
--- a/phpBB/admin/admin_smilies.php
+++ b/phpBB/admin/admin_smilies.php
@@ -43,6 +43,7 @@ require('pagestart.inc');
// Check to see what mode we should operate in.
//
$mode = ($HTTP_GET_VARS['mode']) ? $HTTP_GET_VARS['mode'] : $HTTP_POST_VARS['mode'];
+
//
// Read a listing of uploaded smilies for use in the add or edit smliey code...
//
@@ -54,28 +55,31 @@ while($file = readdir($dir))
$smiley_images[] = $file;
}
}
+
switch($mode)
{
- //
- // Admin has selected to delete a smiley.
- //
case 'delete':
//
- // Get the data that should be passed.
+ // Admin has selected to delete a smiley.
//
- $smiley_id = ($HTTP_GET_VARS['id']) ? $HTTP_GET_VARS['id']: $HTTP_POST_VARS['id'];
- $sql = 'DELETE FROM ' . SMILIES_TABLE . '
- WHERE smilies_id = ' . $smiley_id;
+
+ $smiley_id = ( !empty($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : $HTTP_POST_VARS['id'];
+
+ $sql = "DELETE FROM " . SMILIES_TABLE . "
+ WHERE smilies_id = " . $smiley_id;
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_remove_err'], "", __LINE__, __FILE__, $sql);
}
+
$template->set_filenames(array(
- "body" => "admin/smile_action.tpl")
+ "body" => "admin/smile_result_body.tpl")
);
+
$template->assign_vars(array(
- "S_SMILEY_URL" => append_sid("admin_smilies.$phpEx"),
+ "U_SMILEY_ADMIN" => append_sid("admin_smilies.$phpEx"),
+
"L_SMILEY_TITLE" => $lang['smiley_title'],
"L_SMILEY_TEXT" => $lang['smiley_return'],
"L_SMILEY_ACTION" => $lang['smiley_del_success'])
@@ -85,94 +89,114 @@ switch($mode)
//
$template->pparse("body");
break;
- //
- // Admin has selected to edit a smiley.
- //
+
case 'edit':
//
- // Get the data for the selected smiley.
+ // Admin has selected to edit a smiley.
//
- $smiley_id = ($HTTP_GET_VARS['id']) ? $HTTP_GET_VARS['id']: $HTTP_POST_VARS['id'];
- $sql = 'SELECT *
- FROM ' . SMILIES_TABLE . '
- WHERE smilies_id = ' . $smiley_id;
+
+ $smiley_id = ( !empty($HTTP_GET_VARS['id']) ) ? $HTTP_GET_VARS['id'] : $HTTP_POST_VARS['id'];
+
+ $sql = "SELECT *
+ FROM " . SMILIES_TABLE . "
+ WHERE smilies_id = " . $smiley_id;
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_edit_err'], "", __LINE__, __FILE__, $sql);
}
+ $smile_data = $db->sql_fetchrow($result);
+
+ $filename_list = "";
+ for( $i = 0; $i < count($smiley_images); $i++ )
+ {
+ if( $smiley_images[$i] == $smile_data['smile_url'] )
+ {
+ $smiley_selected = "selected=\"selected\"";
+ $smiley_edit_img = $smiley_images[$i];
+ }
+ else
+ {
+ $smiley_selected = "";
+ }
+
+ $filename_list .= '<option value="' . $smiley_images[$i] . '"' . $smiley_selected . '>' . $smiley_images[$i] . '</option>';
+ }
+
$template->set_filenames(array(
- "body" => "admin/smile_edit.tpl")
+ "body" => "admin/smile_edit_body.tpl")
);
- $smile_data = $db->sql_fetchrow($result);
+
+ $s_hidden_fields = '<input type="hidden" name="mode" value="save" /><input type="hidden" name="smile_id" value="' . $smile_data['smilies_id'] . '" />';
+
$template->assign_vars(array(
- "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
+ "SMILEY_CODE" => $smile_data['code'],
+ "SMILEY_EMOTICON" => $smile_data['emoticon'],
+
"L_SMILEY_TITLE" => $lang['smiley_title'],
- "L_SMILEY_INSTR" => $lang['smile_instr'],
- "L_SMILEY_CODE_LBL" => $lang['smiley_code'],
- "L_SMILEY_URL_LBL" => $lang['smiley_url'],
- "L_SMILEY_EMOTION_LBL" => $lang['smiley_emot'],
+ "L_SMILEY_CONFIG" => $lang['smiley_config'],
+ "L_SMILEY_EXPLAIN" => $lang['smiley_instr'],
+ "L_SMILEY_CODE" => $lang['smiley_code'],
+ "L_SMILEY_URL" => $lang['smiley_url'],
+ "L_SMILEY_EMOTION" => $lang['smiley_emot'],
"L_SUBMIT" => $lang['Submit_changes'],
"L_RESET" => $lang['Reset_changes'],
- "SMILEY_CODE_VAL" => $smile_data['code'],
- "SMILEY_ID_VAL" => $smile_data['smilies_id'],
- "SMILEY_URL_VAL" => $smile_data['smile_url'],
- "SMILEY_EMOTION" => $smile_data['emoticon'],
- "S_HIDDEN_VAR" => "save",
+
+ "SMILEY_IMG" => $phpbb_root_path . '/' . $board_config['smilies_path'] . '/' . $smiley_edit_img,
+
+ "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
+ "S_HIDDEN_FIELDS" => $s_hidden_fields,
+ "S_FILENAME_OPTIONS" => $filename_list,
"S_SMILEY_BASEDIR" => $phpbb_root_path . '/' . $board_config['smilies_path'])
);
- for( $i = 0; $i < count($smiley_images); $i++ )
- {
- $smiley_selected = ($smiley_images[$i] == $smile_data['smile_url']) ? "SELECTED" : "";
- $template->assign_block_vars("smile_images", array(
- "FILENAME" => $smiley_images[$i],
- "SELECTED" => $smiley_selected)
- );
- }
- //
- // Spit out the edit form.
- //
$template->pparse("body");
break;
- //
- // Admin has selected to add a smiley.
- //
+
case "add":
+ //
+ // Admin has selected to add a smiley.
+ //
+
$template->set_filenames(array(
- "body" => "admin/smile_edit.tpl")
+ "body" => "admin/smile_edit_body.tpl")
);
+
+ $filename_list = "";
+ for( $i = 0; $i < count($smiley_images); $i++ )
+ {
+ $filename_list .= '<option value="' . $smiley_images[$i] . '">' . $smiley_images[$i] . '</option>';
+ }
+
+ $s_hidden_fields = '<input type="hidden" name="mode" value="savenew" />';
+
$template->assign_vars(array(
- "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
"L_SMILEY_TITLE" => $lang['smiley_title'],
"L_SMILEY_CONFIG" => $lang['smiley_config'],
- "L_SMILEY_INSTR" => $lang['smiley_instr'],
- "L_SMILEY_CODE_LBL" => $lang['smiley_code'],
- "L_SMILEY_URL_LBL" => $lang['smiley_url'],
- "L_SMILEY_EMOTION_LBL" => $lang['smiley_emot'],
- "SMILEY_URL_VAL" => $smiley_images[0],
+ "L_SMILEY_EXPLAIN" => $lang['smiley_instr'],
+ "L_SMILEY_CODE" => $lang['smiley_code'],
+ "L_SMILEY_URL" => $lang['smiley_url'],
+ "L_SMILEY_EMOTION" => $lang['smiley_emot'],
"L_SUBMIT" => $lang['Submit_changes'],
"L_RESET" => $lang['Reset_changes'],
- "S_HIDDEN_VAR" => "savenew",
+
+ "SMILEY_IMG" => $phpbb_root_path . '/' . $board_config['smilies_path'] . '/' . $smiley_images[0],
+
+ "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"),
+ "S_HIDDEN_FIELDS" => $s_hidden_fields,
+ "S_FILENAME_OPTIONS" => $filename_list,
"S_SMILEY_BASEDIR" => $phpbb_root_path . '/' . $board_config['smilies_path'])
);
- for( $i = 0; $i < count($smiley_images); $i++ )
- {
- $template->assign_block_vars("smile_images", array(
- "FILENAME" => $smiley_images[$i])
- );
- }
- //
- // Spit out the add form.
- //
$template->pparse("body");
break;
- //
- // Admin has submitted changes while editing a smiley.
- //
+
case "save":
//
+ // Admin has submitted changes while editing a smiley.
+ //
+
+ //
// Get the submitted data, being careful to ensure that we only
// accept the data we are looking for.
//
@@ -184,34 +208,36 @@ switch($mode)
//
// Proceed with updating the smiley table.
//
- $sql = 'UPDATE ' . SMILIES_TABLE . "
- SET code='$smile_code', smile_url='$smile_url', emoticon='$smile_emotion'
+ $sql = "UPDATE " . SMILIES_TABLE . "
+ SET code = '$smile_code', smile_url = '$smile_url', emoticon = '$smile_emotion'
WHERE smilies_id = $smile_id";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_edit_err'], "", __LINE__, __FILE__, $sql);
}
+
$template->set_filenames(array(
- "body" => "admin/smile_action.tpl")
+ "body" => "admin/smile_result_body.tpl")
);
$template->assign_vars(array(
- "S_SMILEY_URL" => append_sid("admin_smilies.$phpEx"),
+ "U_SMILEY_ADMIN" => append_sid("admin_smilies.$phpEx"),
+
"L_SMILEY_TITLE" => $lang['smiley_title'],
"L_SMILEY_TEXT" => $lang['smiley_return'],
"L_SMILEY_ACTION" => $lang['smiley_edit_success'])
);
- //
- // Spit out a results page..
- //
+
$template->pparse("body");
break;
- //
- // Admin has submitted changes while adding a new smiley.
- //
+
case "savenew":
//
+ // Admin has submitted changes while adding a new smiley.
+ //
+
+ //
// Get the submitted data being careful to ensure the the data
// we recieve and process is only the data we are looking for.
//
@@ -222,58 +248,51 @@ switch($mode)
//
// Save the data to the smiley table.
//
- $sql = 'INSERT INTO ' . SMILIES_TABLE . " (code, smile_url, emoticon)
+ $sql = "INSERT INTO " . SMILIES_TABLE . " (code, smile_url, emoticon)
VALUES ('$smile_code', '$smile_url', '$smile_emotion')";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_edit_err'], "", __LINE__, __FILE__, $sql);
}
+
$template->set_filenames(array(
- "body" => "admin/smile_action.tpl")
+ "body" => "admin/smile_result_body.tpl")
);
+
$template->assign_vars(array(
- "S_SMILEY_URL" => append_sid("admin_smilies.$phpEx"),
+ "U_SMILEY_ADMIN" => append_sid("admin_smilies.$phpEx"),
+
"L_SMILEY_TITLE" => $lang['smiley_title'],
"L_SMILEY_TEXT" => $lang['smiley_return'],
"L_SMILEY_ACTION" => $lang['smiley_add_success'])
);
- //
- // Spit out a results page.
- //
+
$template->pparse("body");
break;
- //
- // This is the main display of the page before the admin has selected
- // any options.
- //
+
default:
//
- // Get a listing of smileys.
+ // This is the main display of the page before the admin has selected
+ // any options.
//
- $sql = 'SELECT *
- FROM ' . SMILIES_TABLE;
+ $sql = "SELECT *
+ FROM " . SMILIES_TABLE;
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, $lang['smile_load_err'], "", __LINE__, __FILE__, $sql);
}
+
$smilies = $db->sql_fetchrowset($result);
- $total_smilies = $db->sql_numrows($result);
+
$template->set_filenames(array(
- "body" => "admin/admin_smile.tpl")
+ "body" => "admin/smile_list_body.tpl")
);
- //
- // Set the main text variables for the page.
- //
- $my_path = append_sid("admin_smilies.$phpEx");
- if(!ereg('\?', $my_path))
- {
- $my_path .= '?';
- }
+
+ $s_hidden_fields = '<input type="hidden" name="mode" value="add">';
+
$template->assign_vars(array(
- "S_SMILEY_URL" => $my_path,
- "S_SMILEY_BASEDIR" => $phpbb_root_path . '/' . $board_config['smilies_path'],
"L_ACTION" => $lang['Action'],
"L_SMILEY_TITLE" => $lang['smiley_title'],
"L_SMILEY_TEXT" => $lang['smile_desc'],
@@ -282,18 +301,24 @@ switch($mode)
"L_SMILEY_ADD" => $lang['smile_add'],
"L_CODE" => $lang['Code'],
"L_EMOT" => $lang['Emotion'],
- "L_SMILE" => $lang['Smile'])
+ "L_SMILE" => $lang['Smile'],
+
+ "S_HIDDEN_FIELDS" => $s_hidden_fields,
+ "S_SMILEY_ACTION" => append_sid("admin_smilies.$phpEx"))
);
+
//
- // Loop throuch the rows of smilies setting block vars for the template.
+ // Loop throuh the rows of smilies setting block vars for the template.
//
- for( $i = 0; $i < $total_smilies; $i++ )
+ for( $i = 0; $i < count($smilies); $i++ )
{
$template->assign_block_vars("smiles", array(
- "ID" => $smilies[$i]['smilies_id'],
+ "SMILEY_IMG" => $phpbb_root_path . '/' . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'],
"CODE" => $smilies[$i]['code'],
- "URL" => $smilies[$i]['smile_url'],
- "EMOT" => $smilies[$i]['emoticon'])
+ "EMOT" => $smilies[$i]['emoticon'],
+
+ "U_SMILEY_EDIT" => append_sid("admin_smilies.$phpEx?mode=edit&amp;id=" . $smilies[$i]['smilies_id']),
+ "U_SMILEY_DELETE" => append_sid("admin_smilies.$phpEx?mode=delete&amp;id=" . $smilies[$i]['smilies_id']))
);
}
//
@@ -307,4 +332,4 @@ switch($mode)
//
include('page_footer_admin.'.$phpEx);
-?>
+?> \ No newline at end of file