Skip to:
Content

bbPress.org

Changeset 891


Ignore:
Timestamp:
06/28/2007 07:03:57 AM (19 years ago)
Author:
mdawaffe
Message:

BB_Query_Form generic enough for topics and forms. Fixes #602

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-admin/content-posts.php

    r889 r891  
    77    add_filter( 'get_topic_where', 'no_where' );
    88    add_filter( 'get_topic_link', 'bb_make_link_view_all' );
    9     $post_query = new BB_Query( 'post', array( 'post_status' => 1 ) );
     9    $post_query = new BB_Query_Form( 'post', array( 'post_status' => 1 ) );
    1010    $bb_posts =& $post_query->results;
    1111    $total = $post_query->found_rows;
    1212?>
    1313
    14 <h2><?php _e('Deleted Posts'); ?></h2>
     14<h2><?php
     15$h2_search = $post_query->get( 'post_text' );
     16$h2_forum  = $post_query->get( 'forum_id' );
     17$h2_tag    = $post_query->get( 'tag_id' );
     18$h2_author = $post_query->get( 'post_author_id' );
     19$h2_status = $post_query->get( 'post_status' );
     20
     21$h2_search = $h2_search ? ' ' . sprintf( __('matching &#8220;%s&#8221;'), wp_specialchars( $h2_search ) ) : '';
     22$h2_forum  = $h2_forum  ? ' ' . sprintf( __('in &#8220;%s&#8221;')      , get_forum_name( $h2_forum ) ) : '';
     23$h2_tag    = $h2_tag    ? ' ' . sprintf( __('with tag &#8220;%s&#8221;'), wp_specialchars( get_tag_name( $h2_tag ) ) ) : '';
     24$h2_author = $h2_author ? ' ' . sprintf( __('by %s')                    , wp_specialchars( get_user_name( $h2_author ) ) ) : '';
     25
     26$stati = array( 0 => __('Normal') . ' ', 1 => __('Deleted') . ' ', 'all' => '' );
     27
     28if ( 'all' == $h2_status )
     29    $h2_noun = __('Posts');
     30else
     31    $h2_noun = sprintf( __( '%1$sposts'), $stati[$h2_status], $topic_open[$h2_open] );
     32
     33printf( __( '%1$s%2$s%3$s%4$s%5$s' ), $h2_noun, $h2_search, $h2_forum, $h2_tag, $h2_author );
     34
     35?></h2>
     36
     37<?php $post_query->form( array('tag' => true, 'post_author' => true, 'post_status' => true, 'submit' => __('Filter &#187;')) ); ?>
     38
     39<br class="clear" />
    1540
    1641<ol id="the-list">
  • trunk/bb-admin/content.php

    r884 r891  
    3838?></h2>
    3939
    40 <?php $topic_query->topic_search_form( array('tag' => true, 'author' => true, 'status' => true, 'open' => true, 'submit' => __('Filter &#187;')) ); ?>
     40<?php $topic_query->form( array('tag' => true, 'topic_author' => true, 'topic_status' => true, 'open' => true, 'submit' => __('Filter &#187;')) ); ?>
    4141
    4242<br class="clear" />
  • trunk/bb-admin/style.css

    r881 r891  
    476476}
    477477
    478 #topic-search-form fieldset {
     478.search-form fieldset {
    479479    float: left;
    480480    margin: 0 1.5ex 1em 0;
     
    482482}
    483483
    484 #topic-search-form fieldset legend {
     484.search-form fieldset legend {
    485485    padding: 0 0 .2em 1px;
    486486}
    487487   
    488 #topic-search-form .text-input {
     488.search-form .text-input {
    489489    padding: 4px 3px;
    490490}
    491491
    492 #topic-search-form #topic-search-form-submit {
     492.search-form .submit-input {
    493493    float: left;
    494494    margin: 12px 0 1em;
  • trunk/bb-includes/classes.php

    r890 r891  
    345345                    $where .= " AND t.topic_id IN (" . join(',', $tagged_topic_ids) . ")";
    346346                else
    347                     $where .= " /* No such tag */ AND 0";
     347                    $where .= " AND 0 /* No such tag */";
    348348            endif;
    349349
     
    475475                    $where .= " AND p.topic_id IN (" . join(',', $tagged_topic_ids) . ")";
    476476                else
    477                     $where .= " /* No such tag */ AND 0";
     477                    $where .= " AND 0 /* No such tag */";
    478478            endif;
    479479
     
    698698    }
    699699
    700     function topic_search_form( $args = null ) {
     700    function form( $args = null ) {
     701        $_post = 'post' == $this->type;
     702
    701703        $defaults = array(
    702704            'search' => true,
    703705            'forum'  => true,
    704706            'tag'    => false,
    705             'author' => false,
    706             'status' => false,
    707707            'open'   => false,
    708             'topic_title' => false,
    709 
    710             'id'     => 'topic-search-form',
     708            'topic_author' => false,
     709            'post_author'  => false,
     710            'topic_status' => false,
     711            'post_status'  => false,
     712            'topic_title'  => false,
     713
    711714            'method' => 'get',
    712             'submit' => __('Search &#187;')
     715            'submit' => __('Search &#187;'),
     716            'action' => ''
    713717        );
     718        $defaults['id'] = $_post ? 'post-search-form' : 'topic-search-form';
    714719
    715720        $args = wp_parse_args( $args, $defaults );
     
    719724        $method = 'get' == strtolower($method) ? 'get' : 'post';
    720725        $submit = attribute_escape( $submit );
     726        $action = clean_url( $action );
    721727
    722728        if ( $this->query_vars )
     
    727733        extract($query_vars, EXTR_PREFIX_ALL, 'q');
    728734
    729         $r  = "<form action='' method='$method' id='$id'>\n";
    730 
    731         $q_search = attribute_escape( $q_search );
     735        $r  = "<form action='' method='$method' id='$id' class='search-form'>\n";
     736
    732737        if ( $search ) {
     738            if ( $_post ) {
     739                $s_value = attribute_escape( $q_post_text );
     740                $s_name = 'post_text';
     741                $s_id = 'post-text';
     742            } else {
     743                $s_value = attribute_escape( $q_search );
     744                $s_name = $s_id = 'search';
     745            }
    733746            $r .= "\t<fieldset><legend>" . __('Search&#8230;') . "</legend>\n";
    734             $r .= "\t\t<input name='search' id='search' type='text' class='text-input' value='$q_search'>";
     747            $r .= "\t\t<input name='$s_name' id='$s_id' type='text' class='text-input' value='$s_value'>";
    735748            $r .= "\t</fieldset>\n\n";
    736749        }
     
    749762        }
    750763
    751         if ( $author ) {
     764        if ( $topic_author ) {
    752765            $q_topic_author = attribute_escape( $q_topic_author );
    753             $r .= "\t<fieldset><legend>" . __('Author&#8230;') . "</legend>\n";
     766            $r .= "\t<fieldset><legend>" . __('Topic Author&#8230;') . "</legend>\n";
    754767            $r .= "\t\t<input name='topic_author' id='topic-author' type='text' class='text-input' value='$q_topic_author'>";
    755768            $r .= "\t</fieldset>\n\n";
    756769        }
    757770
    758         if ( $status ) {
    759             $r .= "\t<fieldset><legend>" . __('Status&#8230;') . "</legend>\n";
     771        if ( $post_author ) {
     772            $q_post_author = attribute_escape( $q_post_author );
     773            $r .= "\t<fieldset><legend>" . __('Post Author&#8230;') . "</legend>\n";
     774            $r .= "\t\t<input name='post_author' id='post-author' type='text' class='text-input' value='$q_post_author'>";
     775            $r .= "\t</fieldset>\n\n";
     776        }
     777
     778        $stati = array( 'all' => __('All'), '0' => __('Normal'), '1' => __('Deleted') );
     779
     780        if ( $topic_status ) {
     781            $r .= "\t<fieldset><legend>" . __('Topic Status&#8230;') . "</legend>\n";
    760782            $r .= "\t\t<select name='topic_status' id='topic-status'>\n";
    761             foreach ( array( 'all' => __('All'), '0' => __('Normal'), '1' => __('Deleted') ) as $status => $label ) {
    762                 $label = wp_specialchars( $label );
     783            foreach ( $stati as $status => $label ) {
    763784                $selected = (string) $status == (string) $q_topic_status ? " selected='selected'" : '';
     785                $r .= "\t\t\t<option value='$status'$selected>$label</option>\n";
     786            }
     787            $r .= "\t\t</select>\n";
     788            $r .= "\t</fieldset>\n\n";
     789        }
     790
     791        if ( $post_status ) {
     792            $r .= "\t<fieldset><legend>" . __('Post Status&#8230;') . "</legend>\n";
     793            $r .= "\t\t<select name='post_status' id='post-status'>\n";
     794            foreach ( $stati as $status => $label ) {
     795                $selected = (string) $status == (string) $q_post_status ? " selected='selected'" : '';
    764796                $r .= "\t\t\t<option value='$status'$selected>$label</option>\n";
    765797            }
     
    792824        echo $r;
    793825    }
    794 
    795826}
    796827
  • trunk/bb-includes/template-functions.php

    r884 r891  
    878878        $query_obj =& $bb_query_form;
    879879
    880     $query_obj->topic_search_form( $args );
     880    $query_obj->form( $args );
    881881}
    882882       
Note: See TracChangeset for help on using the changeset viewer.