Make WordPress Core


Ignore:
Timestamp:
03/06/2010 06:31:10 PM (14 years ago)
Author:
ryan
Message:

Update ms-sites UI. Props ocean90. see #12460

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/ms-sites.php

    r13460 r13609  
    157157            </div></div>
    158158
    159             <div id="blogedit_blogoptions" class="postbox " >
     159            <div id="blogedit_blogoptions" class="postbox" >
    160160            <h3 class='hndle'><span><?php printf( __('Site options (%soptions)'), $blog_prefix ); ?></span></h3>
    161161            <div class="inside">
     
    179179                                    <tr class="form-field">
    180180                                        <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th>
    181                                         <td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" type="text" id="<?php echo esc_attr($option->option_name) ?>"<?php echo $disabled ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>
     181                                        <td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" id="<?php echo esc_attr($option->option_name) ?>"<?php echo $disabled ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>
    182182                                    </tr>
    183183                                <?php
     
    312312                <table class="form-table">
    313313                        <?php do_action( 'wpmueditblogaction', $id ); ?>
    314                     </table>
     314                </table>
    315315                <p class="submit" style="margin:-15px 0 -5px 230px;"><input type="submit" name="Submit" value="<?php esc_attr_e('Update Options') ?>" /></p>
    316316            </div></div>
     
    327327    case 'list':
    328328    default:
    329         $apage = ( isset($_GET['apage'] ) && intval( $_GET['apage'] ) ) ? absint( $_GET['apage'] ) : 1;
    330         $num = ( isset($_GET['num'] ) && intval( $_GET['num'] ) ) ? absint( $_GET['num'] ) : 15;
    331         $s = isset($_GET['s']) ? esc_attr( trim( $_GET[ 's' ] ) ) : '';
    332         $like_s = like_escape($s);
     329        $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
     330        if ( empty($pagenum) )
     331            $pagenum = 1;
     332
     333        $per_page = (int) get_user_option( 'ms_sites_per_page' );
     334        if ( empty( $per_page ) || $per_page < 1 )
     335            $per_page = 15;
     336
     337        $per_page = apply_filters( 'ms_sites_per_page', $per_page );
     338
     339        $s = isset($_GET['s']) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
     340        $like_s = esc_sql( like_escape( $s ) );
    333341
    334342        $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
    335343
    336         if ( isset($_GET['blog_name']) ) {
    337             $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) ";
    338         } elseif ( isset($_GET['blog_id']) ) {
    339             $query .= " AND   blog_id = '". absint( $_GET['blog_id'] )."' ";
    340         } elseif ( isset($_GET['blog_ip']) ) {
    341             $query = "SELECT *
    342                 FROM {$wpdb->blogs}, {$wpdb->registration_log}
    343                 WHERE site_id = '{$wpdb->siteid}'
    344                 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
    345                 AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";
     344        if ( isset( $_GET['blogstatus'] ) ) {
     345            if ( 'deleted' == $_GET['blogstatus'] ) {
     346                $query .= " AND {$wpdb->blogs}.deleted = '1' ";
     347            } elseif ( 'archived' == $_GET['blogstatus'] ) {
     348                $query .= " AND {$wpdb->blogs}.archived = '1' ";
     349            } elseif ( 'spam' == $_GET['blogstatus'] ) {
     350                $query .= " AND {$wpdb->blogs}.spam = '1' ";
     351            }
    346352        }
    347353
     354        if ( isset( $_GET['searchaction'] ) ) {
     355            if ( 'name' == $_GET['searchaction'] ) {
     356                $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) ";
     357            } elseif ( 'id' == $_GET['searchaction'] ) {
     358                $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' ";
     359            } elseif ( 'ip' == $_GET['searchaction'] ) {
     360                $query = "SELECT *
     361                    FROM {$wpdb->blogs}, {$wpdb->registration_log}
     362                    WHERE site_id = '{$wpdb->siteid}'
     363                    AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
     364                    AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')";
     365            }
     366        }
     367
    348368        $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
    349 
    350369        if ( $order_by == 'registered' ) {
    351370            $query .= ' ORDER BY registered ';
     
    356375        } else {
    357376            $order_by = 'id';
    358             $query .= ' ORDER BY ' . $wpdb->blogs . '.blog_id ';
     377            $query .= " ORDER BY {$wpdb->blogs}.blog_id ";
    359378        }
    360379
    361         $order = isset($_GET['order']) ? $_GET['order'] : 'ASC';
    362         $order = ( 'DESC' == $order ) ? 'DESC' : 'ASC';
     380        $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC";
    363381        $query .= $order;
    364382
    365         if ( !empty($s) )
    366             $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(blog_id)', $query) );
     383        $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(blog_id)', $query) );
     384
     385        $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );
     386        $blog_list = $wpdb->get_results( $query, ARRAY_A );
     387
     388        $num_pages = ceil($total / $per_page);
     389        $page_links = paginate_links( array(
     390            'base' => add_query_arg( 'paged', '%#%' ),
     391            'format' => '',
     392            'prev_text' => __('&laquo;'),
     393            'next_text' => __('&raquo;'),
     394            'total' => $num_pages,
     395            'current' => $pagenum
     396        ));
     397
     398        if ( empty($_GET['mode']) )
     399            $mode = 'list';
    367400        else
    368             $total = $wpdb->get_var( "SELECT COUNT(blog_id) FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ");
    369 
    370         $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num );
    371         $blog_list = $wpdb->get_results( $query, ARRAY_A );
    372 
    373         // Pagination
    374         $url2 = "&amp;order=" . $order . "&amp;sortby=" . $order_by . "&amp;s=";
    375         if ( !empty($_GET[ 'blog_ip' ])  )
    376             $url2 .= "&amp;ip_address=" . urlencode( $s );
    377         else
    378             $url2 .= $s . "&amp;ip_address=" . urlencode( $s );
    379 
    380         $blog_navigation = paginate_links( array(
    381             'base' => add_query_arg( 'apage', '%#%' ).$url2,
    382             'format' => '',
    383             'total' => ceil($total / $num),
    384             'current' => $apage
    385         ));
     401            $mode = esc_attr( $_GET['mode'] );
     402
     403        // for subsubsub and $blog_list
     404        $status_list = array( 'archived' => array( 'site-archived', __('Archived') ), 'spam' => array( 'site-spammed', __('Spam') ), 'deleted' => array( 'site-deleted', __('Deleted') ) );
    386405        ?>
    387406
    388         <div class="wrap" style="position:relative;">
     407        <div class="wrap">
    389408        <?php screen_icon(); ?>
    390         <h2><?php _e('Sites') ?></h2>
     409        <h2><?php _e('Sites') ?>
     410        <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x('Add New', 'sites'); ?></a>
     411        <?php
     412        if ( isset($_GET['s']) && $_GET['s'] )
     413        printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( $s ) );
     414        ?>
     415        </h2>
     416
     417        <ul class="subsubsub">
     418        <?php
     419        $status_links = array();
     420        $status_class = '';
     421        $count = get_blog_count();
     422       
     423        if ( empty($_GET['blogstatus']) || $_GET['blogstatus'] == 'all' )
     424                $status_class = ' class="current"';
     425
     426        $status_links[] = "<li><a href='ms-sites.php?blogstatus=all'$status_class>" . sprintf( __( 'All <span class="count">(%s)</span>' ), number_format_i18n( $count->all ) ) . '</a>';
     427
     428        foreach ( $status_list as $status => $col ) {
     429            $status_class = '';
     430
     431            if ( empty( $count->$status ) )
     432                continue;
     433
     434            if ( isset( $_GET['blogstatus'] ) && ( $_GET['blogstatus'] == $status ) )
     435                $status_class = ' class="current"';
     436
     437            $status_links[] = "<li><a href='ms-sites.php?blogstatus=$status'$status_class>" . sprintf(  $col[1] . ' <span class="count">(%s)</span>' , number_format_i18n( $count->$status ) ) . '</a>';
     438        };
     439
     440        echo implode( " |</li>\n", $status_links ) . '</li>';
     441        unset( $status_links );
     442        ?>
     443        </ul>
    391444
    392445        <form action="ms-sites.php" method="get" id="ms-search">
    393             <input type="hidden" name="action" value="blogs" />
    394             <input type="text" name="s" value="<?php echo($s); ?>" size="17" />
    395             <input type="submit" class="button" name="blog_name" value="<?php esc_attr_e('Search blogs by name') ?>" />
    396             <input type="submit" class="button" name="blog_id" value="<?php esc_attr_e('by blog ID') ?>" />
    397             <input type="submit" class="button" name="blog_ip" value="<?php esc_attr_e('by IP address') ?>" />
     446        <p class="search-box">
     447        <input type="hidden" name="action" value="blogs" />
     448        <input type="text" name="s" value="<?php esc_attr_e( $s ); ?>" />
     449        <input type="submit" class="button" value="<?php esc_attr_e('Search Site by') ?>" />
     450        <select name="searchaction">
     451            <option value="name" selected="selected"><?php _e('Name'); ?></option>
     452            <option value="id"><?php _e('ID'); ?></option>
     453            <option value="ip"><?php _e('IP address'); ?></option>
     454        </select>
     455        </p>
    398456        </form>
    399457
    400         <form id="form-blog-list" action="ms-edit.php?action=allblogs" method="post">
    401 
     458        <form id="form-site-list" action="ms-edit.php?action=allblogs" method="post">
     459        <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" />
    402460        <div class="tablenav">
    403             <?php if ( $blog_navigation ) echo "<div class='tablenav-pages'>$blog_navigation</div>"; ?>
    404 
    405             <div class="alignleft">
    406                 <input type="submit" value="<?php esc_attr_e('Delete') ?>" name="allblog_delete" class="button-secondary delete" />
    407                 <input type="submit" value="<?php esc_attr_e('Mark as Spam') ?>" name="allblog_spam" class="button-secondary" />
    408                 <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="allblog_notspam" class="button-secondary" />
    409                 <?php wp_nonce_field( 'allblogs' ); ?>
    410                 <br class="clear" />
    411             </div>
     461        <div class="alignleft actions">
     462            <select name="action">
     463                <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     464                <option value="delete"><?php _e('Delete'); ?></option>
     465                <option value="spam"><?php _e('Mark as Spam'); ?></option>
     466                <option value="notspam"><?php _e('Not Spam'); ?></option>
     467            </select>
     468            <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
     469            <?php wp_nonce_field('bulk-sites'); ?>
    412470        </div>
    413471
    414         <br class="clear" />
    415 
    416         <?php if ( isset($_GET['s']) && !empty($_GET['s']) ) : ?>
    417             <p><a href="ms-users.php?action=users&s=<?php echo urlencode( stripslashes( $s ) ) ?>"><?php _e('Search Users:') ?> <strong><?php echo stripslashes( $s ); ?></strong></a></p>
    418         <?php endif; ?>
     472        <?php if ( $page_links ) { ?>
     473        <div class="tablenav-pages">
     474        <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
     475        number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
     476        number_format_i18n( min( $pagenum * $per_page, $num_pages ) ),
     477        number_format_i18n( $num_pages ),
     478        $page_links
     479        ); echo $page_links_text; ?>
     480        </div>
     481        <?php } ?>
     482       
     483        <div class="view-switch">
     484            <a href="<?php echo esc_url(add_query_arg('mode', 'list', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('List View') ?>" alt="<?php _e('List View') ?>" /></a>
     485            <a href="<?php echo esc_url(add_query_arg('mode', 'excerpt', $_SERVER['REQUEST_URI'])) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e('Excerpt View') ?>" alt="<?php _e('Excerpt View') ?>" /></a>
     486        </div>
     487
     488        </div>
     489
     490        <div class="clear"></div>
    419491
    420492        <?php
     
    433505
    434506        $posts_columns = apply_filters('wpmu_blogs_columns', $posts_columns);
    435 
    436         $sortby_url = "s=";
    437         if ( !empty($_GET[ 'blog_ip' ]) )
    438             $sortby_url .= "&ip_address=" . urlencode( $s );
    439         else
    440             $sortby_url .= urlencode( $s ) . "&ip_address=" . urlencode( $s );
    441507        ?>
    442508
    443         <table width="100%" cellpadding="3" cellspacing="3" class="widefat">
     509        <table class="widefat">
    444510            <thead>
    445511                <tr>
    446                 <th scope="col" class="check-column"></th>
    447                 <?php foreach($posts_columns as $column_id => $column_display_name) {
    448                     $column_link = "<a href='ms-sites.php?{$sortby_url}&amp;sortby={$column_id}&amp;";
    449                     if ( $order_by == $column_id ) {
    450                         $column_link .= ($order_by == 'DESC') ? 'order=ASC&amp;' : 'order=DESC&amp;';
    451                     }
    452                     $column_link .= "apage={$apage}'>{$column_display_name}</a>";
    453 
     512                <th style="" class="manage-column column-cb check-column" id="cb" scope="col">
     513                    <input type="checkbox" />
     514                </th>
     515                <?php
     516                foreach($posts_columns as $column_id => $column_display_name) {
     517                    $column_link = "<a href='";
     518                    $order2 = '';
     519                    if ( $order_by == $column_id )
     520                        $order2 = ($order == 'DESC') ? 'ASC' : 'DESC';
     521
     522                    $column_link .= esc_url(add_query_arg( array('order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), $_SERVER['REQUEST_URI'] ) );
     523                    $column_link .= "'>{$column_display_name}</a>";
    454524                    $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link;
    455                     ?>
    456                     <th scope="col"><?php echo $col_url ?></th>
     525                ?>
     526                <th scope="col">
     527                    <?php echo $col_url ?>
     528                </th>
    457529                <?php } ?>
    458530                </tr>
    459531            </thead>
     532            <tfoot>
     533                <tr>
     534                <th class="manage-column column-cb check-column" id="cb" scope="col">
     535                    <input type="checkbox" />
     536                </th>
     537                <?php foreach($posts_columns as $column_id => $column_display_name) {
     538                    $column_link = "<a href='";
     539                    $order2 = '';
     540                    if ( $order_by == $column_id )
     541                        $order2 = ($order == 'DESC') ? 'ASC' : 'DESC';
     542                       
     543                    $column_link .= esc_url(add_query_arg( array('order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) );
     544                    $column_link .= "'>{$column_display_name}</a>";
     545                    $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link;
     546                ?>
     547                <th scope="col">
     548                    <?php echo $col_url ?>
     549                </th>
     550                <?php } ?>
     551                </tr>
     552            </tfoot>
    460553            <tbody id="the-list">
    461554            <?php
    462555            if ( $blog_list ) {
    463                 $status_list = array( 'archived' => array( 'site-archived', __('Archived') ), 'spam' => array( 'site-spammed', __('Spam') ), 'deleted' => array( 'site-deleted', __('Deleted') ) );
    464556                $class = '';
    465557                foreach ( $blog_list as $blog ) {
     
    501593
    502594                            case 'blogname': ?>
    503                                 <td valign="top">
     595                                <td class="column-title">
    504596                                    <a href="ms-sites.php?action=editblog&amp;id=<?php echo $blog['blog_id'] ?>" class="edit"><?php echo $blogname; echo $blog_state?></a>
    505                                     <br/>
    506597                                    <?php
     598                                    if ( 'list' != $mode )
     599                                        echo '<p>' . get_blog_option( $blog['blog_id'], 'blogname' ) . '- <em>' . get_blog_option( $blog['blog_id'], 'blogdescription ' ) . '</em></p>';
     600
    507601                                    $actions    = array();
    508602                                    $actions[]  = '<a href="ms-sites.php?action=editblog&amp;id=' . $blog['blog_id'] . '" class="edit">' . __('Edit') . '</a>';
     
    540634                            case 'lastupdated': ?>
    541635                                <td valign="top">
    542                                     <?php echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date(__('Y-m-d \<\b\r \/\> g:i:s a'), $blog['last_updated']); ?>
    543                                 </td>
     636                                    <?php
     637                                    if ( 'list' == $mode )
     638                                        $date = 'Y/m/d';
     639                                    else
     640                                        $date = 'Y/m/d \<\b\r \/\> g:i:s a';
     641                                    echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date( __( $date ), $blog['last_updated'] ); ?>
     642                                </td>
    544643                            <?php
    545644                            break;
    546                             case 'registered': ?>
     645                        case 'registered': ?>
    547646                                <td valign="top">
    548                                     <?php echo mysql2date(__('Y-m-d \<\b\r \/\> g:i:s a'), $blog['registered']); ?>
    549                                 </td>
    550                             <?php
    551                             break;
    552 
     647                                <?php echo mysql2date(__( $date ), $blog['registered'] ); ?>
     648                                </td>
     649                        <?php
     650                        break;
    553651                            case 'users': ?>
    554652                                <td valign="top">
     
    561659                                            $blogusers_warning = __( 'Only showing first 5 users.' ) . ' <a href="' . get_admin_url($blog['blog_id'], 'users.php') . '">' . __( 'More' ) . '</a>';
    562660                                        }
    563                                         foreach ( $blogusers as $key => $val )
    564                                             echo '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ('.$val->user_email.')<br />';
     661                                        foreach ( $blogusers as $key => $val ) {
     662                                            echo '<a href="user-edit.php?user_id=' . $val->user_id . '">' . $val->user_login . '</a> ';
     663                                            if ( 'list' != $mode )
     664                                                echo '(' . $val->user_email . ')';
     665                                            echo '<br />';
     666                                        }
    565667                                        if ( $blogusers_warning != '' )
    566668                                            echo '<strong>' . $blogusers_warning . '</strong><br />';
     
    593695                }
    594696            } else { ?>
    595                 <tr style='background-color: <?php echo $bgcolor; ?>'>
     697                <tr>
    596698                    <td colspan="8"><?php _e('No blogs found.') ?></td>
    597699                </tr>
     
    602704            </tbody>
    603705        </table>
     706        <div class="tablenav">
     707            <?php
     708            if ( $page_links )
     709                echo "<div class='tablenav-pages'>$page_links_text</div>";
     710            ?>
     711
     712            <div class="alignleft actions">
     713            <select name="action2">
     714                <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option>
     715                <option value="delete"><?php _e('Delete'); ?></option>
     716                <option value="spam"><?php _e('Mark as Spam'); ?></option>
     717                <option value="notspam"><?php _e('Not Spam'); ?></option>
     718            </select>
     719            <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
     720            </div>
     721            <br class="clear" />
     722        </div>
     723
    604724        </form>
    605725        </div>
    606726
    607727        <div class="wrap">
    608             <a name="form-add-blog"></a>
     728            <a name="form-add-site"></a>
    609729            <h2><?php _e('Add Site') ?></h2>
    610730            <form method="post" action="ms-edit.php?action=addblog">
     
    612732                <table class="form-table">
    613733                    <tr class="form-field form-required">
    614                         <th style="text-align:center;" scope='row'><?php _e('Site Address') ?></th>
     734                        <th scope='row'><?php _e('Site Address') ?></th>
    615735                        <td>
    616736                        <?php if ( is_subdomain_install() ) { ?>
    617                             <input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?>
     737                            <input name="blog[domain]" type="text" class="regular-text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?>
    618738                        <?php } else {
    619                             echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>
     739                            echo $current_site->domain . $current_site->path ?><input name="blog[domain]" class="regular-text" type="text" title="<?php _e('Domain') ?>"/>
    620740                        <?php }
    621741                        echo "<p>" . __( 'Only the characters a-z and 0-9 recommended.' ) . "</p>";
     
    624744                    </tr>
    625745                    <tr class="form-field form-required">
    626                         <th style="text-align:center;" scope='row'><?php _e('Site Title') ?></th>
    627                         <td><input name="blog[title]" type="text" size="20" title="<?php _e('Title') ?>"/></td>
     746                        <th scope='row'><?php _e('Site Title') ?></th>
     747                        <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e('Title') ?>"/></td>
    628748                    </tr>
    629749                    <tr class="form-field form-required">
    630                         <th style="text-align:center;" scope='row'><?php _e('Admin Email') ?></th>
    631                         <td><input name="blog[email]" type="text" size="20" title="<?php _e('Email') ?>"/></td>
     750                        <th scope='row'><?php _e('Admin Email') ?></th>
     751                        <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e('Email') ?>"/></td>
    632752                    </tr>
    633753                    <tr class="form-field">
Note: See TracChangeset for help on using the changeset viewer.