Fix HTML on edit category form, allow category slug to be edited.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2004-12-09 01:02:25 +00:00
parent b6c13ceee4
commit d5c7cc229e
1 changed files with 51 additions and 44 deletions

View File

@ -23,12 +23,12 @@ for ($i=0; $i<count($wpvarstoreset); $i += 1) {
switch($action) { switch($action) {
case 'addcat': case 'addcat':
if ($user_level < 3) if ($user_level < 3)
die (__('Cheatin&#8217; uh?')); die (__('Cheatin&#8217; uh?'));
$cat_name= $_POST['cat_name']; $cat_name= $_POST['cat_name'];
$cat_ID = $wpdb->get_var("SELECT cat_ID FROM $wpdb->categories ORDER BY cat_ID DESC LIMIT 1") + 1; $id_result = $wpdb->get_row("SHOW TABLE STATUS LIKE '$wpdb->categories'");
$cat_ID = $id_result->Auto_increment;
$category_nicename = sanitize_title($cat_name, $cat_ID); $category_nicename = sanitize_title($cat_name, $cat_ID);
$category_description = $_POST['category_description']; $category_description = $_POST['category_description'];
$cat = intval($_POST['cat']); $cat = intval($_POST['cat']);
@ -36,7 +36,6 @@ case 'addcat':
$wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')"); $wpdb->query("INSERT INTO $wpdb->categories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', '$cat')");
header('Location: categories.php?message=1#addcat'); header('Location: categories.php?message=1#addcat');
break; break;
case 'Delete': case 'Delete':
@ -73,41 +72,49 @@ case 'edit':
<div class="wrap"> <div class="wrap">
<h2><?php _e('Edit Category') ?></h2> <h2><?php _e('Edit Category') ?></h2>
<form name="editcat" action="categories.php" method="post"> <form name="editcat" action="categories.php" method="post">
<input type="hidden" name="action" value="editedcat" /> <table class="editform" width="100%" cellspacing="2" cellpadding="5">
<input type="hidden" name="cat_ID" value="<?php echo $cat_ID ?>" /> <tr>
<p><?php _e('Category name:') ?><br /> <th width="33%" scope="row"><?php _e('Category name:') ?></th>
<input type="text" name="cat_name" value="<?php echo htmlspecialchars($cat_name); ?>" /></p> <td width="67%"><input name="cat_name" type="text" value="<?php echo htmlspecialchars($cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
<p><?php _e('Category parent:') ?><br /> <input type="hidden" name="cat_ID" value="<?php echo $cat_ID ?>" /></td>
<select name='cat' class='postform'> </tr>
<option value='0'<?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option> <tr>
<th scope="row"><?php _e('Category slug:') ?></th>
<td><input name="category_nicename" type="text" value="<?php echo htmlspecialchars($category->category_nicename); ?>" size="40" /></td>
</tr>
<tr>
<th scope="row"><?php _e('Category parent:') ?></th>
<td>
<select name='cat'>
<option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
<?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?> <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
</select> </select></td>
</p> </tr>
<tr>
<p><?php _e('Description:') ?><br /> <th scope="row"><?php _e('Description:') ?></th>
<textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo htmlspecialchars($category->category_description, ENT_NOQUOTES); ?></textarea></p> <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo htmlspecialchars($category->category_description, ENT_NOQUOTES); ?></textarea></td>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category &raquo;') ?>" /></p> </tr>
</table>
<p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> &raquo;" /></p>
</form> </form>
<p><a href="categories.php"><?php _e('&laquo; Return to category list'); ?></a></p>
</div> </div>
<?php <?php
break; break;
case 'editedcat': case 'editedcat':
if ($user_level < 3) if ($user_level < 3)
die (__('Cheatin&#8217; uh?')); die (__('Cheatin&#8217; uh?'));
$cat_name = $_POST['cat_name']; $cat_name = $_POST['cat_name'];
$cat_ID = (int) $_POST['cat_ID']; $cat_ID = (int) $_POST['cat_ID'];
$category_nicename = sanitize_title($cat_name, $cat_ID); $category_nicename = sanitize_title($_POST['category_nicename'], $cat_ID);
$category_description = $_POST['category_description']; $category_description = $_POST['category_description'];
$wpdb->query("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'"); $wpdb->query("UPDATE $wpdb->categories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = '$cat' WHERE cat_ID = '$cat_ID'");
header('Location: categories.php?message=3'); header('Location: categories.php?message=3');
break; break;
default: default: