summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-07-25 12:01:00 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-07-25 12:01:00 +0000
commit65fdf82523ea65f8df0ff66d84ef1125f99a440d (patch)
tree44e9fa798b6e16682b0610345ec1d90397cc7fe8
parent29d92778637bec6d154cb4557f52a458d0c265ad (diff)
downloadwordpress-mu-65fdf82523ea65f8df0ff66d84ef1125f99a440d.tar.gz
wordpress-mu-65fdf82523ea65f8df0ff66d84ef1125f99a440d.tar.xz
wordpress-mu-65fdf82523ea65f8df0ff66d84ef1125f99a440d.zip
WP Merge
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@707 7be80a69-a1ef-0310-a953-fb0f7c49ff36
-rw-r--r--wp-admin/admin-ajax.php18
-rw-r--r--wp-admin/admin-db.php2
-rw-r--r--wp-admin/admin-functions.php55
-rw-r--r--wp-admin/categories.js17
-rw-r--r--wp-includes/category.php7
5 files changed, 55 insertions, 44 deletions
diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 088ce31..9c5ac65 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -144,26 +144,22 @@ case 'add-cat' : // From Manage->Categories
die('0');
if ( !$cat = get_category( $cat ) )
die('0');
- $pad = 0;
+ $level = 0;
+ $cat_full_name = $cat->cat_name;
$_cat = $cat;
while ( $_cat->category_parent ) {
$_cat = get_category( $_cat->category_parent );
- $pad++;
+ $cat_full_name = $_cat->cat_name . ' &#8212; ' . $cat_full_name;
+ $level++;
}
- $pad = str_repeat('&#8212; ', $pad);
+ $cat_full_name = wp_specialchars( $cat_full_name, 1 );
$r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>";
- $r .= "<cat><id>$cat->cat_ID</id><newitem><![CDATA[<table><tbody>";
- $r .= "<tr id='cat-$cat->cat_ID'><th scope='row'>$cat->cat_ID</th><td>$pad $cat->cat_name</td>";
- $r .= "<td>$cat->category_description</td><td>$cat->category_count</td><td>$cat->link_count</td>";
- $r .= "<td><a href='categories.php?action=edit&amp;cat_ID=$cat->cat_ID' class='edit'>" . __('Edit') . "</a></td>";
- $r .= "<td><a href='categories.php?action=delete&amp;cat_ID=$cat->cat_ID' onclick='return deleteSomething( \"cat\", $cat->cat_ID, \"";
- $r .= sprintf(__('You are about to delete the category \"%s\". All of its posts and bookmarks will go to the default categories.\\n\"OK\" to delete, \"Cancel\" to stop.'), addslashes($cat->cat_name));
- $r .= "\" );' class='delete'>".__('Delete')."</a></td></tr>";
+ $r .= "<cat><id>$cat->cat_ID</id><name>$cat_full_name</name><newitem><![CDATA[<table><tbody>";
+ $r .= _cat_row( $cat, $level, $cat_full_name );
$r .= "</tbody></table>]]></newitem></cat></ajaxresponse>";
header('Content-type: text/xml');
die($r);
-
break;
case 'add-meta' :
if ( !current_user_can( 'edit_post', $id ) )
diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php
index ea9c5e2..1f7c952 100644
--- a/wp-admin/admin-db.php
+++ b/wp-admin/admin-db.php
@@ -111,7 +111,7 @@ function wp_insert_category($catarr) {
$category_description = apply_filters('pre_category_description', $category_description);
$category_parent = (int) $category_parent;
- if (empty ($category_parent))
+ if ( empty($category_parent) || !get_category( $category_parent ) )
$category_parent = 0;
if ( isset($posts_private) )
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index 8fa5184..9ab92cb 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -700,31 +700,7 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
continue;
}
if ($category->category_parent == $parent) {
- $category->cat_name = wp_specialchars($category->cat_name,'double');
- $pad = str_repeat('&#8212; ', $level);
- if ( current_user_can('manage_categories') ) {
- $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
- $default_cat_id = get_option('default_category');
- $default_link_cat_id = get_option('default_link_category');
-
- if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
- $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
- else
- $edit .= "<td style='text-align:center'>".__("Default");
- }
- else
- $edit = '';
-
- $class = ('alternate' == $class) ? '' : 'alternate';
-
- $category->category_count = number_format( $category->category_count );
- $category->link_count = number_format( $category->link_count );
- echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td>
- <td>$category->category_description</td>
- <td align='center'>$category->category_count</td>
- <td align='center'>$category->link_count</td>
- <td>$edit</td>
- </tr>";
+ echo "\t" . _cat_row( $category, $level );
cat_rows($category->cat_ID, $level +1, $categories);
}
}
@@ -733,6 +709,35 @@ function cat_rows($parent = 0, $level = 0, $categories = 0) {
}
}
+function _cat_row( $category, $level, $name_override = false ) {
+ global $class;
+
+ $pad = str_repeat('&#8212; ', $level);
+ if ( current_user_can('manage_categories') ) {
+ $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>";
+ $default_cat_id = get_option('default_category');
+ $default_link_cat_id = get_option('default_link_category');
+
+ if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) )
+ $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&amp;cat_ID=$category->cat_ID", 'delete-category_' . $category->cat_ID ) . "' onclick=\"return deleteSomething( 'cat', $category->cat_ID, '" . sprintf(__("You are about to delete the category &quot;%s&quot;.\\nAll of its posts will go into the default category of &quot;%s&quot;\\nAll of its bookmarks will go into the default category of &quot;%s&quot;.\\n&quot;OK&quot; to delete, &quot;Cancel&quot; to stop."), js_escape($category->cat_name), js_escape(get_catname($default_cat_id)), js_escape(get_catname($default_link_cat_id))) . "' );\" class='delete'>".__('Delete')."</a>";
+ else
+ $edit .= "<td style='text-align:center'>".__("Default");
+ } else
+ $edit = '';
+
+ $class = ( ( defined('DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'";
+
+ $category->category_count = number_format( $category->category_count );
+ $category->link_count = number_format( $category->link_count );
+ return "<tr id='cat-$category->cat_ID'$class>
+ <th scope='row'>$category->cat_ID</th>
+ <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td>
+ <td>$category->category_description</td>
+ <td align='center'>$category->category_count</td>
+ <td align='center'>$category->link_count</td>
+ <td>$edit</td>\n\t</tr>\n";
+}
+
function page_rows($parent = 0, $level = 0, $pages = 0, $hierarchy = true) {
global $wpdb, $class, $post;
diff --git a/wp-admin/categories.js b/wp-admin/categories.js
index 46ae62f..a636961 100644
--- a/wp-admin/categories.js
+++ b/wp-admin/categories.js
@@ -1,5 +1,16 @@
-addLoadEvent(newCategoryAddIn);
-function newCategoryAddIn() {
+addLoadEvent(function() {
if (!theList.theList) return false;
document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); };
-}
+ theList.addComplete = function(what, where, update) {
+ var name = getNodeValue(theList.ajaxAdd.responseXML, 'name');
+ var id = getNodeValue(theList.ajaxAdd.responseXML, 'id');
+ var options = document.forms['addcat'].category_parent.options;
+ options[options.length] = new Option(name, id);
+ };
+ theList.delComplete = function(what, id) {
+ var options = document.forms['addcat'].category_parent.options;
+ for ( var o = 0; o < options.length; o++ )
+ if ( id == options[o].value )
+ options[o] = null;
+ };
+});
diff --git a/wp-includes/category.php b/wp-includes/category.php
index 30392a7..3127482 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -67,12 +67,11 @@ function &get_categories($args = '') {
$exclusions = apply_filters('list_cats_exclusions', $exclusions, $r );
$where .= $exclusions;
- $having = '';
if ( $hide_empty ) {
if ( 'link' == $type )
- $having = 'HAVING link_count > 0';
+ $where .= ' AND link_count > 0';
else
- $having = 'HAVING category_count > 0';
+ $where .= ' AND category_count > 0';
}
if ( !empty($number) )
@@ -80,7 +79,7 @@ function &get_categories($args = '') {
else
$number = '';
- $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where $having ORDER BY $orderby $order $number");
+ $categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number");
if ( empty($categories) )
return array();