Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -15,6 +15,7 @@ |
16 | 16 | * * notcategories = string ; default = null |
17 | 17 | * * namespace = string ; default = null |
18 | 18 | * * count = integer ; default = $wgDPLmaxResultCount = 50 |
| 19 | + * * hourcont = integer ; default -1 (disabled), how many hours before cutoff |
19 | 20 | * * order = string ; default = descending |
20 | 21 | * * ordermethod = string ; default = categoryadd |
21 | 22 | * * redirects = string ; default = exclude |
— | — | @@ -163,6 +164,24 @@ |
164 | 165 | break; |
165 | 166 | } |
166 | 167 | |
| 168 | + if ( $this->params['hourCount'] > 0 |
| 169 | + && $this->params['orderMethod'] !== 'lastedit' ) |
| 170 | + { |
| 171 | + // Limit to last X number of hours added to category, |
| 172 | + // if hourcont is positive and we're sorting by |
| 173 | + // category add date. |
| 174 | + // This feature is here because the Google News |
| 175 | + // Sitemap usecase is only supposed to have |
| 176 | + // articles published in last 2 days on it. |
| 177 | + // Don't do anything with lastedit, since this option |
| 178 | + // doesn't make sense with it (Do we even need that order method?) |
| 179 | + $timeOffset = wfTimestamp( TS_UNIX ) - ( $this->params['hourCount'] * 3600 ); |
| 180 | + $MWTimestamp = wfTimestamp( TS_MW, $timeOffset ); |
| 181 | + if ( $MWTimestamp ) { |
| 182 | + $conditions[] = 'c1.cl_timestamp > ' . $MWTimestamp; |
| 183 | + } |
| 184 | + } |
| 185 | + |
167 | 186 | $currentTableNumber = 1; |
168 | 187 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
169 | 188 | |
— | — | @@ -223,6 +242,7 @@ |
224 | 243 | // $this->notCategories[] = $wgRequest->getArray('notcategory'); |
225 | 244 | $this->params['nameSpace'] = $wgContLang->getNsIndex( $wgRequest->getVal( 'namespace', 0 ) ); |
226 | 245 | $this->params['count'] = $wgRequest->getInt( 'count', $this->wgDPLmaxResultCount ); |
| 246 | + $this->params['hourCount'] = $wgRequest->getInt( 'hourcount', -1 ); |
227 | 247 | |
228 | 248 | if ( ( $this->params['count'] > $this->wgDPLmaxResultCount ) |
229 | 249 | || ( $this->params['count'] < 1 ) ) |