Manage links redesign. Add link search.

git-svn-id: http://svn.automattic.com/wordpress/trunk@6798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-12 08:01:32 +00:00
parent 079e285537
commit 1bd097fff0
3 changed files with 49 additions and 25 deletions

View File

@ -13,7 +13,7 @@ $post_stati = array( // array( adj, noun )
'private' => array(__('Private'), __('Private pages'), __('Private (%s)')) 'private' => array(__('Private'), __('Private pages'), __('Private (%s)'))
); );
$post_status_label = __('Pages'); $post_status_label = __('Manage Pages');
$post_status_q = ''; $post_status_q = '';
if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) { if ( isset($_GET['post_status']) && in_array( $_GET['post_status'], array_keys($post_stati) ) ) {
$post_status_label = $post_stati[$_GET['post_status']][1]; $post_status_label = $post_stati[$_GET['post_status']][1];
@ -66,7 +66,7 @@ unset($status_links);
</ul> </ul>
<p id="post-search"> <p id="post-search">
<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
<input type="submit" value="<?php _e( 'Search Pages' ); ?>" /> <input type="submit" value="<?php _e( 'Search Pages' ); ?>" />
</p> </p>

View File

@ -58,29 +58,50 @@ if ( isset($_GET['deleted']) ) {
<div class="wrap"> <div class="wrap">
<form id="posts-filter" action="" method="get">
<h2><?php _e('Manage Links'); ?></h2> <h2><?php _e('Manage Links'); ?></h2>
<p><a href="link-add.php"><?php _e('Add Link'); ?></a> | <a href="edit-link-categories.php"><?php _e('Link Categories'); ?></a> | <a href="link-import.php"><?php _e('Import Links'); ?></a></p>
<p><?php _e('Here you <a href="link-add.php">add links</a> to sites that you visit often and share them on your blog. When you have a list of links in your sidebar to other blogs, it&#8217;s called a &#8220;blogroll.&#8221;'); ?></p> <p id="post-search">
<form id="cats" method="get" action=""> <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
<p><?php <input type="submit" value="<?php _e( 'Search Links' ); ?>" />
</p>
<br style="clear:both;" />
<div class="tablenav">
<div style="float: left">
<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" />
<?php
$categories = get_terms('link_category', "hide_empty=1"); $categories = get_terms('link_category', "hide_empty=1");
$select_cat = "<select name=\"cat_id\">\n"; $select_cat = "<select name=\"cat_id\">\n";
$select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('All') . "</option>\n"; $select_cat .= '<option value="all"' . (($cat_id == 'all') ? " selected='selected'" : '') . '>' . __('View all Categories') . "</option>\n";
foreach ((array) $categories as $cat) foreach ((array) $categories as $cat)
$select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n"; $select_cat .= '<option value="' . $cat->term_id . '"' . (($cat->term_id == $cat_id) ? " selected='selected'" : '') . '>' . sanitize_term_field('name', $cat->name, $cat->term_id, 'link_category', 'display') . "</option>\n";
$select_cat .= "</select>\n"; $select_cat .= "</select>\n";
$select_order = "<select name=\"order_by\">\n"; $select_order = "<select name=\"order_by\">\n";
$select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Link ID') . "</option>\n"; $select_order .= '<option value="order_id"' . (($order_by == 'order_id') ? " selected='selected'" : '') . '>' . __('Order by Link ID') . "</option>\n";
$select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Name') . "</option>\n"; $select_order .= '<option value="order_name"' . (($order_by == 'order_name') ? " selected='selected'" : '') . '>' . __('Order by Name') . "</option>\n";
$select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Address') . "</option>\n"; $select_order .= '<option value="order_url"' . (($order_by == 'order_url') ? " selected='selected'" : '') . '>' . __('Order by Address') . "</option>\n";
$select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Rating') . "</option>\n"; $select_order .= '<option value="order_rating"' . (($order_by == 'order_rating') ? " selected='selected'" : '') . '>' . __('Order by Rating') . "</option>\n";
$select_order .= "</select>\n"; $select_order .= "</select>\n";
printf(__('Currently showing %1$s links ordered by %2$s'), $select_cat, $select_order); echo $select_cat;
echo $select_order;
?> ?>
<input type="submit" name="action" value="<?php _e('Update &raquo;') ?>" /></p> <input type="submit" id="post-query-submit" value="<?php _e('Filter &#187;'); ?>" class="button" />
</div>
<br style="clear:both;" />
</div>
</form> </form>
<br style="clear:both;" />
<?php <?php
$link_columns = array( $link_columns = array(
'name' => '<th width="15%">' . __('Name') . '</th>', 'name' => '<th width="15%">' . __('Name') . '</th>',
@ -88,7 +109,6 @@ $link_columns = array(
'categories' => '<th>' . __('Categories') . '</th>', 'categories' => '<th>' . __('Categories') . '</th>',
'rel' => '<th style="text-align: center">' . __('rel') . '</th>', 'rel' => '<th style="text-align: center">' . __('rel') . '</th>',
'visible' => '<th style="text-align: center">' . __('Visible') . '</th>', 'visible' => '<th style="text-align: center">' . __('Visible') . '</th>',
'action' => '<th colspan="2" style="text-align: center">' . __('Action') . '</th>',
); );
$link_columns = apply_filters('manage_link_columns', $link_columns); $link_columns = apply_filters('manage_link_columns', $link_columns);
?> ?>
@ -96,7 +116,10 @@ $link_columns = apply_filters('manage_link_columns', $link_columns);
<?php <?php
if ( 'all' == $cat_id ) if ( 'all' == $cat_id )
$cat_id = ''; $cat_id = '';
$links = get_bookmarks( "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'] )
$args['search'] = $_GET['s'];
$links = get_bookmarks( $args );
if ( $links ) { if ( $links ) {
?> ?>
@ -109,10 +132,10 @@ if ( $links ) {
<table class="widefat"> <table class="widefat">
<thead> <thead>
<tr> <tr>
<th style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th>
<?php foreach($link_columns as $column_display_name) { <?php foreach($link_columns as $column_display_name) {
echo $column_display_name; echo $column_display_name;
} ?> } ?>
<th style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('links'));" /></th>
</tr> </tr>
</thead> </thead>
<tbody id="the-list" class="list:link"> <tbody id="the-list" class="list:link">
@ -132,10 +155,12 @@ if ( $links ) {
++ $i; ++ $i;
$style = ($i % 2) ? '' : ' class="alternate"'; $style = ($i % 2) ? '' : ' class="alternate"';
?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php ?><tr id="link-<?php echo $link->link_id; ?>" valign="middle" <?php echo $style; ?>><?php
echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
foreach($link_columns as $column_name=>$column_display_name) { foreach($link_columns as $column_name=>$column_display_name) {
switch($column_name) { switch($column_name) {
case 'name': case 'name':
?><td><strong><?php echo $link->link_name; ?></strong><br /><?php
echo "<td><a href='link.php?link_id=$link->link_id&amp;action=edit' class='edit'>$link->link_name</a><br />";
echo $link->link_description . "</td>"; echo $link->link_description . "</td>";
break; break;
case 'url': case 'url':
@ -162,10 +187,6 @@ if ( $links ) {
case 'visible': case 'visible':
?><td align='center'><?php echo $visible; ?></td><?php ?><td align='center'><?php echo $visible; ?></td><?php
break; break;
case 'action':
echo "<td><a href='link.php?link_id=$link->link_id&amp;action=edit' class='edit'>" . __('Edit') . '</a></td>';
echo "<td><a href='" . wp_nonce_url('link.php?link_id='.$link->link_id.'&amp;action=delete', 'delete-bookmark_' . $link->link_id ) . "' class='delete:the-list:link-$link->link_id delete'>" . __('Delete') . '</a></td>';
break;
default: default:
?> ?>
<td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td> <td><?php do_action('manage_link_custom_column', $column_name, $link->link_id); ?></td>
@ -174,7 +195,6 @@ if ( $links ) {
} }
} }
echo '<td align="center"><input type="checkbox" name="linkcheck[]" value="'.$link->link_id.'" /></td>';
echo "\n </tr>\n"; echo "\n </tr>\n";
} }
?> ?>
@ -183,7 +203,6 @@ if ( $links ) {
<div id="ajax-response"></div> <div id="ajax-response"></div>
<p class="submit"><input type="submit" class="button" name="deletebookmarks" id="deletebookmarks" value="<?php _e('Delete Checked Links &raquo;') ?>" onclick="return confirm('<?php echo js_escape(__("You are about to delete these links permanently.\n'Cancel' to stop, 'OK' to delete.")); ?>')" /></p>
</form> </form>
<?php } ?> <?php } ?>

View File

@ -111,7 +111,7 @@ function get_bookmarks($args = '') {
'limit' => -1, 'category' => '', 'limit' => -1, 'category' => '',
'category_name' => '', 'hide_invisible' => 1, 'category_name' => '', 'hide_invisible' => 1,
'show_updated' => 0, 'include' => '', 'show_updated' => 0, 'include' => '',
'exclude' => '' 'exclude' => '', 'search' => ''
); );
$r = wp_parse_args( $args, $defaults ); $r = wp_parse_args( $args, $defaults );
@ -160,6 +160,11 @@ function get_bookmarks($args = '') {
$category = $category->term_id; $category = $category->term_id;
} }
if ( ! empty($search) ) {
$search = like_escape($search);
$search = " AND ( (link_url LIKE '%$search%') OR (link_name LIKE '%$search%') OR (link_description LIKE '%$search%') ) ";
}
$category_query = ''; $category_query = '';
$join = ''; $join = '';
if ( !empty($category) ) { if ( !empty($category) ) {
@ -207,7 +212,7 @@ function get_bookmarks($args = '') {
$visible = "AND link_visible = 'Y'"; $visible = "AND link_visible = 'Y'";
$query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query"; $query = "SELECT * $length $recently_updated_test $get_updated FROM $wpdb->links $join WHERE 1=1 $visible $category_query";
$query .= " $exclusions $inclusions"; $query .= " $exclusions $inclusions $search";
$query .= " ORDER BY $orderby $order"; $query .= " ORDER BY $orderby $order";
if ($limit != -1) if ($limit != -1)
$query .= " LIMIT $limit"; $query .= " LIMIT $limit";