Design update for link categories management.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6804 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-13 07:32:50 +00:00
parent 7aa24fb904
commit c60237244e
5 changed files with 80 additions and 18 deletions

View File

@ -126,6 +126,12 @@ cat_rows();
</tbody> </tbody>
</table> </table>
<br style="clear:both;" />
<div class="tablenav">
<br style="clear:both;" />
</div>
</div> </div>
<?php if ( current_user_can('manage_categories') ) : ?> <?php if ( current_user_can('manage_categories') ) : ?>

View File

@ -19,24 +19,68 @@ if (isset($_GET['message'])) : ?>
<?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 Link Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
<?php else : ?> <?php else : ?>
<h2><?php _e('Categories') ?> </h2> <h2><?php _e('Manage Link 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">
<?php
$pagenum = absint( $_GET['pagenum'] );
if ( empty($pagenum) )
$pagenum = 1;
if( !$catsperpage || $catsperpage < 0 )
$catsperpage = 3;
$page_links = paginate_links( array(
'base' => add_query_arg( 'pagenum', '%#%' ),
'format' => '',
'total' => ceil(wp_count_terms('link_category') / $catsperpage),
'current' => $pagenum
));
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
<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" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('deletetags'));" /></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('Links') ?></th> <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
<th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list" class="list:link-cat"> <tbody id="the-list" class="list:link-cat">
<?php <?php
$categories = get_terms( 'link_category', 'hide_empty=0' ); $start = ($pagenum - 1) * $catsperpage;
$args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
if ( !empty( $_GET['s'] ) )
$args['search'] = $_GET['s'];
$categories = get_terms( 'link_category', $args );
if ( $categories ) { if ( $categories ) {
$output = ''; $output = '';
foreach ( $categories as $category ) { foreach ( $categories as $category ) {
@ -52,6 +96,17 @@ if ( $categories ) {
</tbody> </tbody>
</table> </table>
<br style="clear:both;" />
<div class="tablenav">
<?php
if ( $page_links )
echo "<div class='tablenav-pages'>$page_links</div>";
?>
<br style="clear:both;" />
</div>
</div> </div>
<?php if ( current_user_can('manage_categories') ) : ?> <?php if ( current_user_can('manage_categories') ) : ?>

View File

@ -117,6 +117,10 @@ if ($posts) {
} // end if ($posts) } // end if ($posts)
?> ?>
<div class="tablenav">
<br style="clear:both;" />
</div>
</div> </div>
<?php include('admin-footer.php'); ?> <?php include('admin-footer.php'); ?>

View File

@ -70,28 +70,21 @@ function link_cat_row( $category ) {
return $category; return $category;
if ( current_user_can( 'manage_categories' ) ) { if ( current_user_can( 'manage_categories' ) ) {
$edit = "<a href='link-category.php?action=edit&amp;cat_ID=$category->term_id' class='edit'>".__( 'Edit' )."</a></td>"; $edit = "<a href='link-category.php?action=edit&amp;cat_ID=$category->term_id' class='edit'>". ( $name_override ? $name_override : $category->name ) ."</a>";
$default_cat_id = (int) get_option( 'default_link_category' ); $default_cat_id = (int) get_option( 'default_link_category' );
$delete_url = wp_nonce_url( "link-category.php?action=delete&amp;cat_ID=$category->term_id", "delete-link-category_$category->term_id" );
if ( $category->term_id != $default_cat_id )
$edit .= "<td><a href='$delete_url' class='delete:the-list:link-cat-$category->term_id delete'>" . __( 'Delete' ) . "</a>";
else
$edit .= "<td style='text-align:center'>" . __( "Default" );
} else { } else {
$edit = ''; $edit = ( $name_override ? $name_override : $category->name );
} }
$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 );
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count; $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
$output = "<tr id='link-cat-$category->term_id'$class> $output = "<tr id='link-cat-$category->term_id'$class>" .
<th scope='row' style='text-align: center'>$category->term_id</th> '<td style="text-align: center"> <input type="checkbox" name="delete_tags[]" value="' . $category->term_id . '" /></td>' .
<td>" . ( $name_override ? $name_override : $category->name ) . "</td> "<td>$edit</td>
<td>$category->description</td> <td>$category->description</td>
<td align='center'>$count</td> <td align='center'>$count</td>";
<td>$edit</td>\n\t</tr>\n";
return apply_filters( 'link_cat_row', $output ); return apply_filters( 'link_cat_row', $output );
} }

View File

@ -203,6 +203,10 @@ if ( $links ) {
<div id="ajax-response"></div> <div id="ajax-response"></div>
<div class="tablenav">
<br style="clear:both;" />
</div>
</form> </form>
<?php } ?> <?php } ?>