diff --git a/Source/Source.FilterAPI.php b/Source/Source.FilterAPI.php index 600c478..007caab 100644 --- a/Source/Source.FilterAPI.php +++ b/Source/Source.FilterAPI.php @@ -52,6 +52,9 @@ $this->filters['f.filename'] = new SourceFilterOption(); $this->filters['f.revision'] = new SourceFilterOption(); $this->filters['f.action'] = new SourceFilterOption(); + + $this->filters['date_start'] = new SourceFilterOption(); + $this->filters['date_end'] = new SourceFilterOption(); } } @@ -151,13 +154,13 @@ # Date searching if ( $key == 'date_start' && !is_null( $value ) ) { - $wc = db_aparam(); + $wc = db_param(); $sql = "c.timestamp >= $wc"; return array( $sql, $value ); } if ( $key == 'date_end' && !is_null( $value ) ) { - $wc = db_aparam(); + $wc = db_param(); $sql = "c.timestamp <= $wc"; return array( $sql, $value ); @@ -165,8 +168,8 @@ # Revision Searching if ( $key == 'f.revision' && !is_null( $value ) ) { - $wc1 = db_aparam(); - $wc2 = db_aparam(); + $wc1 = db_param(); + $wc2 = db_param(); $value = "%$value%"; $sql = "( c.revision LIKE $wc1 OR f.revision LIKE $wc2 )"; @@ -180,7 +183,7 @@ $value = explode( ' ', $value ); } - $wc = map( 'db_aparam', $value ); + $wc = map( 'db_param', $value ); $wc = map( create_function( '$item','return "' . $key . ' LIKE $item";' ), $wc ); $value = map( create_function( '$item', 'return "%$item%";' ), $value ); @@ -191,7 +194,7 @@ # Standard values if ( is_array( $value ) ) { - $wc = map( 'db_aparam', $value ); + $wc = map( 'db_param', $value ); $count = count( $value ); if ( $count > 1 ) { @@ -210,7 +213,7 @@ } } } else { - $wc = db_aparam(); + $wc = db_param(); if ( SOURCE_ANY == $how ) { $sql = "$key = $wc"; @@ -239,6 +242,9 @@ $f_filename = Source_FilterOption_Permalink( 'filename' ); $f_message = Source_FilterOption_Permalink( 'message' ); + $f_date_start = Source_FilterOption_Permalink( 'date_start' ); + $f_date_end = Source_FilterOption_Permalink( 'date_end' ); + # Get permalink $t_permalink = Source_FilterOption_Permalink(); @@ -259,9 +265,44 @@ $t_filter->filters['f.revision']->value = $f_revision; $t_filter->filters['f.action']->value = $f_file_action; + $t_filter->filters['date_start']->value = $f_date_start; + $t_filter->filters['date_end']->value = $f_date_end; + return array( $t_filter, $t_permalink ); } +function Source_Date_Validate( $p_string ) { + $t_date = gpc_get_string( $p_string, null ); + if ( !is_null( $t_date ) ) { + list( $t_year, $t_month, $t_day ) = Source_Date_StampArray( $t_date ); + } else { + $t_year = gpc_get_int( "${p_string}_year", 0 ); + $t_month = gpc_get_int( "${p_string}_month", 0 ); + $t_day = gpc_get_int( "${p_string}_day", 0 ); + } + + if ( $t_month < 1 || $t_month > 12 + || $t_day < 1 || $t_day > 31 + || $t_year < 1970 ) { + return null; + } + + $t_default = gpc_get_string( "${p_string}_default", null ); + if ( !is_null( $t_default ) ) { + $t_default = Source_Date_StampArray( $t_default ); + if ( $t_default[0] == $t_year + && $t_default[1] == $t_month + && $t_default[2] == $t_day ) { + return null; + } + } + + $t_month = $t_month < 10 ? "0$t_month" : $t_month; + $t_day = $t_day < 10 ? "0$t_day" : $t_day; + + return "$t_year-$t_month-$t_day"; +} + function Source_FilterOption_Permalink( $p_string=null, $p_array=false ) { static $s_permalink = ''; @@ -284,6 +325,11 @@ } else { $t_input = gpc_get_string( $p_string, null ); + + if ( $p_string == 'date_start' || $p_string == 'date_end' ) { + $t_input = Source_Date_Validate( $p_string ); + } + if ( !is_blank( $t_input ) ) { $s_permalink .= "&$p_string=$t_input"; } @@ -406,7 +452,7 @@ $t_result = db_query_bound( $t_query ); echo ''; + } else { + $t_selected = Source_Date_StampArray( $p_selected ); + } + + echo ' '; + + echo ' '; + + echo ' '; +} diff --git a/Source/pages/search_page.php b/Source/pages/search_page.php index cf601d5..e220621 100644 --- a/Source/pages/search_page.php +++ b/Source/pages/search_page.php @@ -17,6 +17,9 @@ list( $t_filter, $t_permalink ) = Source_Generate_Filter(); +$t_date_start = ( is_null( $t_filter->filters['date_start']->value ) ? 'start' : $t_filter->filters['date_start']->value ); +$t_date_end = ( is_null( $t_filter->filters['date_end']->value ) ? 'now' : $t_filter->filters['date_end']->value ); + html_page_top1( plugin_lang_get( 'title' ) ); html_page_top2(); @@ -52,15 +55,15 @@ -Author Username +Author Revision Bug #'s > -filters['c.author']->value ) ?> filters['c.user_id']->value ) ?> +filters['c.author']->value ) ?> @@ -68,6 +71,18 @@ > +Beginning Date + + + +> +Ending Date + + + + + +> Message