@@ -63,12 +63,18 @@ function __construct( $init = true ) {
63
63
}
64
64
}
65
65
66
+ /**
67
+ * Retrieves the data based on current filter
68
+ * @param int $p_page page to display; defaults to 1, use null for all pages
69
+ * @param int $p_limit number of records per page, defaults to 25
70
+ * @return array containing list of changesets and number of records
71
+ */
66
72
function find ( $ p_page =1 , $ p_limit =25 ) {
67
73
list ( $ t_filters , $ t_filter_params ) = Source_Twomap ( 'Source_Process_FilterOption ' , $ this ->filters );
68
- list ( $ t_query_tail , $ t_params ) = Source_Process_Filters ( $ t_filters , $ t_filter_params );
74
+ list ( $ t_query_tail, $ t_order , $ t_params ) = Source_Process_Filters ( $ t_filters , $ t_filter_params );
69
75
70
76
$ t_count_query = "SELECT COUNT(c.id) $ t_query_tail " ;
71
- $ t_full_query = "SELECT DISTINCT( c.id ), c.* $ t_query_tail " ;
77
+ $ t_full_query = "SELECT DISTINCT( c.id ), c.* $ t_query_tail $ t_order " ;
72
78
73
79
$ t_count = db_result ( db_query_bound ( $ t_count_query , $ t_params ) );
74
80
@@ -91,6 +97,13 @@ function find( $p_page=1, $p_limit=25 ) {
91
97
}
92
98
}
93
99
100
+ /**
101
+ * Processes the filter criteria to define the query join/where clause, order by
102
+ * clause and parameters
103
+ * @param string $p_filters
104
+ * @param array $p_filter_params
105
+ * @return array query join+where clause, order clause and parameters
106
+ */
94
107
function Source_Process_Filters ( $ p_filters , $ p_filter_params ) {
95
108
$ t_changeset_table = plugin_table ( 'changeset ' , 'Source ' );
96
109
$ t_repo_table = plugin_table ( 'repository ' , 'Source ' );
@@ -139,7 +152,7 @@ function Source_Process_Filters( $p_filters, $p_filter_params ) {
139
152
140
153
$ t_order = 'ORDER BY c.timestamp DESC ' ;
141
154
142
- return array ( "$ t_join $ t_where $ t_order" , $ t_params );
155
+ return array ( "$ t_join $ t_where" , $ t_order , $ t_params );
143
156
}
144
157
145
158
function Source_Process_FilterOption ( $ key , $ option ) {
@@ -604,4 +617,3 @@ function Source_Date_Select( $p_name, $p_selected=null ) {
604
617
print_day_option_list ( $ t_selected [2 ] );
605
618
echo '</select> ' ;
606
619
}
607
-
0 commit comments