Changeset 4041
- Timestamp:
- 07/25/2006 06:36:10 AM (19 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/admin-ajax.php
r3863 r4041 145 145 if ( !$cat = get_category( $cat ) ) 146 146 die('0'); 147 $pad = 0; 147 $level = 0; 148 $cat_full_name = $cat->cat_name; 148 149 $_cat = $cat; 149 150 while ( $_cat->category_parent ) { 150 151 $_cat = get_category( $_cat->category_parent ); 151 $pad++; 152 } 153 $pad = str_repeat('— ', $pad); 152 $cat_full_name = $_cat->cat_name . ' — ' . $cat_full_name; 153 $level++; 154 } 155 $cat_full_name = wp_specialchars( $cat_full_name, 1 ); 154 156 155 157 $r = "<?xml version='1.0' standalone='yes'?><ajaxresponse>"; 156 $r .= "<cat><id>$cat->cat_ID</id><newitem><![CDATA[<table><tbody>"; 157 $r .= "<tr id='cat-$cat->cat_ID'><th scope='row'>$cat->cat_ID</th><td>$pad $cat->cat_name</td>"; 158 $r .= "<td>$cat->category_description</td><td>$cat->category_count</td><td>$cat->link_count</td>"; 159 $r .= "<td><a href='categories.php?action=edit&cat_ID=$cat->cat_ID' class='edit'>" . __('Edit') . "</a></td>"; 160 $r .= "<td><a href='categories.php?action=delete&cat_ID=$cat->cat_ID' onclick='return deleteSomething( \"cat\", $cat->cat_ID, \""; 161 $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)); 162 $r .= "\" );' class='delete'>".__('Delete')."</a></td></tr>"; 158 $r .= "<cat><id>$cat->cat_ID</id><name>$cat_full_name</name><newitem><![CDATA[<table><tbody>"; 159 $r .= _cat_row( $cat, $level, $cat_full_name ); 163 160 $r .= "</tbody></table>]]></newitem></cat></ajaxresponse>"; 164 161 header('Content-type: text/xml'); 165 162 die($r); 166 167 163 break; 168 164 case 'add-meta' : -
trunk/wp-admin/admin-db.php
r4022 r4041 109 109 110 110 $category_parent = (int) $category_parent; 111 if ( empty ($category_parent))111 if ( empty($category_parent) || !get_category( $category_parent ) ) 112 112 $category_parent = 0; 113 113 -
trunk/wp-admin/admin-functions.php
r4035 r4041 685 685 // Dandy new recursive multiple category stuff. 686 686 function cat_rows($parent = 0, $level = 0, $categories = 0) { 687 global $wpdb, $class;688 689 687 if (!$categories) 690 688 $categories = get_categories('hide_empty=0'); … … 693 691 foreach ($categories as $category) { 694 692 if ($category->category_parent == $parent) { 695 $category->cat_name = wp_specialchars($category->cat_name,'double'); 696 $pad = str_repeat('— ', $level); 697 if ( current_user_can('manage_categories') ) { 698 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; 699 $default_cat_id = get_option('default_category'); 700 $default_link_cat_id = get_option('default_link_category'); 701 702 if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) 703 $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&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 "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" 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>"; 704 else 705 $edit .= "<td style='text-align:center'>".__("Default"); 706 } 707 else 708 $edit = ''; 709 710 $class = ('alternate' == $class) ? '' : 'alternate'; 711 712 $category->category_count = number_format( $category->category_count ); 713 $category->link_count = number_format( $category->link_count ); 714 echo "<tr id='cat-$category->cat_ID' class='$class'><th scope='row'>$category->cat_ID</th><td>$pad $category->cat_name</td> 715 <td>$category->category_description</td> 716 <td align='center'>$category->category_count</td> 717 <td align='center'>$category->link_count</td> 718 <td>$edit</td> 719 </tr>"; 693 echo "\t" . _cat_row( $category, $level ); 720 694 cat_rows($category->cat_ID, $level +1, $categories); 721 695 } … … 724 698 return false; 725 699 } 700 } 701 702 function _cat_row( $category, $level, $name_override = false ) { 703 global $class; 704 705 $pad = str_repeat('— ', $level); 706 if ( current_user_can('manage_categories') ) { 707 $edit = "<a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>".__('Edit')."</a></td>"; 708 $default_cat_id = get_option('default_category'); 709 $default_link_cat_id = get_option('default_link_category'); 710 711 if ( ($category->cat_ID != $default_cat_id) && ($category->cat_ID != $default_link_cat_id) ) 712 $edit .= "<td><a href='" . wp_nonce_url("categories.php?action=delete&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 "%s".\\nAll of its posts will go into the default category of "%s"\\nAll of its bookmarks will go into the default category of "%s".\\n"OK" to delete, "Cancel" 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>"; 713 else 714 $edit .= "<td style='text-align:center'>".__("Default"); 715 } else 716 $edit = ''; 717 718 $class = ( ( defined('DOING_AJAX') && DOING_AJAX ) || " class='alternate'" == $class ) ? '' : " class='alternate'"; 719 720 $category->category_count = number_format( $category->category_count ); 721 $category->link_count = number_format( $category->link_count ); 722 return "<tr id='cat-$category->cat_ID'$class> 723 <th scope='row'>$category->cat_ID</th> 724 <td>" . ( $name_override ? $name_override : $pad . ' ' . $category->cat_name ) . "</td> 725 <td>$category->category_description</td> 726 <td align='center'>$category->category_count</td> 727 <td align='center'>$category->link_count</td> 728 <td>$edit</td>\n\t</tr>\n"; 726 729 } 727 730 -
trunk/wp-admin/categories.js
r3684 r4041 1 addLoadEvent(newCategoryAddIn); 2 function newCategoryAddIn() { 1 addLoadEvent(function() { 3 2 if (!theList.theList) return false; 4 3 document.forms.addcat.submit.onclick = function(e) {return killSubmit('theList.ajaxAdder("cat", "addcat");', e); }; 5 } 4 theList.addComplete = function(what, where, update) { 5 var name = getNodeValue(theList.ajaxAdd.responseXML, 'name'); 6 var id = getNodeValue(theList.ajaxAdd.responseXML, 'id'); 7 var options = document.forms['addcat'].category_parent.options; 8 options[options.length] = new Option(name, id); 9 }; 10 theList.delComplete = function(what, id) { 11 var options = document.forms['addcat'].category_parent.options; 12 for ( var o = 0; o < options.length; o++ ) 13 if ( id == options[o].value ) 14 options[o] = null; 15 }; 16 });
Note: See TracChangeset
for help on using the changeset viewer.