Manage categories redesign. Add categories search.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-12 09:02:02 +00:00
parent 1bd097fff0
commit 8bd0691aa3
4 changed files with 44 additions and 20 deletions

View File

@ -84,19 +84,39 @@ $messages[5] = __('Category not updated.');
<?php endif; ?> <?php endif; ?>
<div class="wrap"> <div class="wrap">
<form id="posts-filter" action="" method="get">
<?php if ( current_user_can('manage_categories') ) : ?> <?php if ( current_user_can('manage_categories') ) : ?>
<h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2> <h2><?php printf(__('Manage Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
<?php else : ?> <?php else : ?>
<h2><?php _e('Categories') ?> </h2> <h2><?php _e('Manage Categories') ?> </h2>
<?php endif; ?> <?php endif; ?>
<p id="post-search">
<input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
<input type="submit" value="<?php _e( 'Search Categories' ); ?>" />
</p>
<br style="clear:both;" />
<div class="tablenav">
<div style="float: left">
<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" />
</div>
<br style="clear:both;" />
</div>
</form>
<br style="clear:both;" />
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th scope="col" style="text-align: center"><?php _e('ID') ?></th> <th scope="col"><div style="text-align: center"><input type="checkbox" name="TODO" /></div></th>
<th scope="col"><?php _e('Name') ?></th> <th scope="col"><?php _e('Name') ?></th>
<th scope="col"><?php _e('Description') ?></th> <th scope="col"><?php _e('Description') ?></th>
<th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th> <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list" class="list:cat"> <tbody id="the-list" class="list:cat">

View File

@ -6,8 +6,12 @@
// Dandy new recursive multiple category stuff. // Dandy new recursive multiple category stuff.
function cat_rows( $parent = 0, $level = 0, $categories = 0 ) { function cat_rows( $parent = 0, $level = 0, $categories = 0 ) {
if ( !$categories ) if ( !$categories ) {
$categories = get_categories( 'hide_empty=0' ); $args = array('hide_empty' => 0);
if ( !empty($_GET['s']) )
$args['search'] = $_GET['s'];
$categories = get_categories( $args );
}
$children = _get_term_hierarchy('category'); $children = _get_term_hierarchy('category');
@ -38,26 +42,21 @@ function _cat_row( $category, $level, $name_override = false ) {
$pad = str_repeat( '&#8212; ', $level ); $pad = str_repeat( '&#8212; ', $level );
if ( current_user_can( 'manage_categories' ) ) { if ( current_user_can( 'manage_categories' ) ) {
$edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; $edit = "<a href='categories.php?action=edit&amp;cat_ID=$category->term_id'>". ( $name_override ? $name_override : $pad . ' ' . $category->name ) ."</a>";
$default_cat_id = (int) get_option( 'default_category' ); $default_cat_id = (int) get_option( 'default_category' );
} else {
if ( $category->term_id != $default_cat_id ) $edit = ( $name_override ? $name_override : $pad . ' ' . $category->name );
$edit .= "<td><a href='" . wp_nonce_url( "categories.php?action=delete&amp;cat_ID=$category->term_id", 'delete-category_' . $category->term_id ) . "' class='delete:the-list:cat-$category->term_id delete'>".__( 'Delete' )."</a>"; }
else
$edit .= "<td style='text-align:center'>".__( "Default" );
} else
$edit = '';
$class = " class='alternate'" == $class ? '' : " class='alternate'"; $class = " class='alternate'" == $class ? '' : " class='alternate'";
$category->count = number_format_i18n( $category->count ); $category->count = number_format_i18n( $category->count );
$posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count; $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
$output = "<tr id='cat-$category->term_id'$class> $output = "<tr id='cat-$category->term_id'$class>
<th scope='row' style='text-align: center'>$category->term_id</th> <th scope='row' style='text-align: center'><input type='checkbox' name='delete[]' value='$category->term_id' /></th>
<td>" . ( $name_override ? $name_override : $pad . ' ' . $category->name ) . "</td> <td>$edit</td>
<td>$category->description</td> <td>$category->description</td>
<td align='center'>$posts_count</td> <td align='center'>$posts_count</td>\n\t</tr>\n";
<td>$edit</td>\n\t</tr>\n";
return apply_filters('cat_row', $output); return apply_filters('cat_row', $output);
} }

View File

@ -117,7 +117,7 @@ $link_columns = apply_filters('manage_link_columns', $link_columns);
if ( 'all' == $cat_id ) if ( 'all' == $cat_id )
$cat_id = ''; $cat_id = '';
$args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0); $args = array('category' => $cat_id, 'hide_invisible' => 0, 'orderby' => $sqlorderby, 'hide_empty' => 0);
if ( $_GET['s'] ) if ( !empty($_GET['s']) )
$args['search'] = $_GET['s']; $args['search'] = $_GET['s'];
$links = get_bookmarks( $args ); $links = get_bookmarks( $args );
if ( $links ) { if ( $links ) {

View File

@ -525,7 +525,7 @@ function &get_terms($taxonomies, $args = '') {
'hide_empty' => true, 'exclude' => '', 'include' => '', 'hide_empty' => true, 'exclude' => '', 'include' => '',
'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '',
'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '',
'pad_counts' => false, 'offset' => ''); 'pad_counts' => false, 'offset' => '', 'search' => '');
$args = wp_parse_args( $args, $defaults ); $args = wp_parse_args( $args, $defaults );
$args['number'] = absint( $args['number'] ); $args['number'] = absint( $args['number'] );
$args['offset'] = absint( $args['offset'] ); $args['offset'] = absint( $args['offset'] );
@ -635,6 +635,11 @@ function &get_terms($taxonomies, $args = '') {
} else } else
$number = ''; $number = '';
if ( !empty($search) ) {
$search = like_escape($search);
$where .= " AND (t.name LIKE '%$search%')";
}
if ( 'all' == $fields ) if ( 'all' == $fields )
$select_this = 't.*, tt.*'; $select_this = 't.*, tt.*';
else if ( 'ids' == $fields ) else if ( 'ids' == $fields )