Index: trunk/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php |
— | — | @@ -44,9 +44,9 @@ |
45 | 45 | /** |
46 | 46 | * Script default values - correctly spelt, naming standard. |
47 | 47 | **/ |
48 | | - var $wgDPlminCategories = 1; // Minimum number of categories to look for |
49 | | - var $wgDPlmaxCategories = 6; // Maximum number of categories to look for |
50 | | - var $wgDPLmaxResultCount = 50; // Maximum number of results to allow |
| 48 | + var $wgDPlminCategories = 1; // Minimum number of categories to look for |
| 49 | + var $wgDPlmaxCategories = 6; // Maximum number of categories to look for |
| 50 | + var $wgDPLmaxResultCount = 50; // Maximum number of results to allow |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @var array Parameters array |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | |
82 | 82 | $this->unload_params(); // populates this->params as a side effect |
83 | 83 | |
84 | | - // if there's an error parsing the params, bail out and return |
| 84 | + // if there's an error parsing the params, bail out and return |
85 | 85 | if ( isset( $this->params['error'] ) ) { |
86 | 86 | if ( false == $this->params['suppressErrors'] ) { |
87 | 87 | $wgOut->disable(); |
— | — | @@ -141,8 +141,11 @@ |
142 | 142 | $comments ); |
143 | 143 | } |
144 | 144 | $feed->outItem( $feedItem ); |
145 | | - }// end while fetchobject |
| 145 | + |
| 146 | + } // end while fetchobject |
| 147 | + |
146 | 148 | $feed->outFooter(); |
| 149 | + |
147 | 150 | } // end public function execute |
148 | 151 | |
149 | 152 | /** |
— | — | @@ -154,13 +157,13 @@ |
155 | 158 | |
156 | 159 | $tables[] = $dbr->tableName( 'page' ); |
157 | 160 | |
158 | | - //this is a little hacky, c1 is dynamically defined as the first category |
159 | | - //so this can't ever work with uncategorized articles |
160 | | - $fields = array('page_namespace', 'page_title', 'page_id', 'c1.cl_timestamp'); |
| 161 | + // this is a little hacky, c1 is dynamically defined as the first category |
| 162 | + // so this can't ever work with uncategorized articles |
| 163 | + $fields = array( 'page_namespace', 'page_title', 'page_id', 'c1.cl_timestamp' ); |
161 | 164 | $conditions = array(); |
162 | 165 | |
163 | 166 | if ( $this->params['nameSpace'] ) { |
164 | | - $conditions['page_namespace'] = $this->params['nameSpace']; |
| 167 | + $conditions['page_namespace'] = $this->params['nameSpace']; |
165 | 168 | } |
166 | 169 | |
167 | 170 | // If flagged revisions is in use, check which options selected. |
— | — | @@ -169,12 +172,12 @@ |
170 | 173 | $filterSet = array( 'only', 'exclude' ); |
171 | 174 | # Either involves the same JOIN here... |
172 | 175 | if ( in_array( $this->params['stable'], $filterSet ) || in_array( $this->params['quality'], $filterSet ) ) { |
173 | | - $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' ); |
| 176 | + $joins['flaggedpages'] = array( 'LEFT JOIN', 'page_id = fp_page_id' ); |
174 | 177 | } |
175 | 178 | |
176 | 179 | switch( $this->params['stable'] ) { |
177 | 180 | case 'only': |
178 | | - $conditions[]='fp_stable IS NOT NULL '; |
| 181 | + $conditions[] = 'fp_stable IS NOT NULL '; |
179 | 182 | break; |
180 | 183 | case 'exclude': |
181 | 184 | $conditions['fp_stable'] = null; |
— | — | @@ -182,7 +185,7 @@ |
183 | 186 | } |
184 | 187 | switch( $this->params['quality'] ) { |
185 | 188 | case 'only': |
186 | | - $conditions[]='fp_quality >= 1'; |
| 189 | + $conditions[] = 'fp_quality >= 1'; |
187 | 190 | break; |
188 | 191 | case 'exclude': |
189 | 192 | $conditions['fp_quality'] = 0; |
— | — | @@ -203,7 +206,7 @@ |
204 | 207 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
205 | 208 | |
206 | 209 | $joins = array(); |
207 | | - for ($i = 0; $i < $this->params['catCount']; $i++) { |
| 210 | + for ( $i = 0; $i < $this->params['catCount']; $i++ ) { |
208 | 211 | $joins["$categorylinks AS c$currentTableNumber"] = array( 'INNER JOIN', |
209 | 212 | array( "page_id = c{$currentTableNumber}.cl_from", |
210 | 213 | "c{$currentTableNumber}.cl_to={$dbr->addQuotes( $this->categories[$i]->getDBKey() ) }" |
— | — | @@ -213,7 +216,7 @@ |
214 | 217 | $currentTableNumber++; |
215 | 218 | } |
216 | 219 | |
217 | | - //exclusion categories disabled pending discussion on whether they are necessary |
| 220 | + // exclusion categories disabled pending discussion on whether they are necessary |
218 | 221 | /* |
219 | 222 | for ( $i = 0; $i < $this->params['notCatCount']; $i++ ) { |
220 | 223 | // echo "notCategory parameter $i<br />\n"; |
— | — | @@ -241,11 +244,11 @@ |
242 | 245 | } |
243 | 246 | |
244 | 247 | |
245 | | - //earlier validation logic ensures this is a reasonable number |
| 248 | + // earlier validation logic ensures this is a reasonable number |
246 | 249 | $options['LIMIT'] = $this->params['count']; |
247 | 250 | |
248 | | - //return $dbr->query( $sqlSelectFrom . $conditions ); |
249 | | - return $dbr->select ( $tables, $fields, $conditions, '', $options, $joins ); |
| 251 | + // return $dbr->query( $sqlSelectFrom . $conditions ); |
| 252 | + return $dbr->select( $tables, $fields, $conditions, '', $options, $joins ); |
250 | 253 | } |
251 | 254 | |
252 | 255 | /** |
— | — | @@ -272,7 +275,8 @@ |
273 | 276 | $this->params['count'] = $wgRequest->getInt( 'count', $this->wgDPLmaxResultCount ); |
274 | 277 | |
275 | 278 | if ( ( $this->params['count'] > $this->wgDPLmaxResultCount ) |
276 | | - || ( $this->params['count'] < 1 ) ) { |
| 279 | + || ( $this->params['count'] < 1 ) ) |
| 280 | + { |
277 | 281 | $this->params['count'] = $this->wgDPLmaxResultCount; |
278 | 282 | } |
279 | 283 | |
— | — | @@ -293,7 +297,7 @@ |
294 | 298 | if ( ( $this->params['catCount'] < 1 && !$this->params['nameSpace'] ) |
295 | 299 | || ( $totalCatCount < $this->wgDPlminCategories ) ) |
296 | 300 | { |
297 | | - $feed = Title::newFromText( 'Published', NS_CATEGORY ); |
| 301 | + $feed = Title::newFromText( 'Published', NS_CATEGORY ); |
298 | 302 | if ( is_object( $feed ) ) { |
299 | 303 | $this->categories[] = $feed; |
300 | 304 | $this->params['catCount'] = count( $this->categories ); |
— | — | @@ -303,10 +307,10 @@ |
304 | 308 | } |
305 | 309 | |
306 | 310 | if ( $totalCatCount > $this->wgDPlmaxCategories ) { |
307 | | - $this->params['error'] = htmlspecialchars( wfMsg( 'googlenewssitemap_toomanycats' ) ); // "!!too many categories!!"; |
| 311 | + $this->params['error'] = htmlspecialchars( wfMsg( 'googlenewssitemap_toomanycats' ) ); |
308 | 312 | } |
309 | 313 | |
310 | | - // disallow showing date if the query doesn't have an inclusion category parameter |
| 314 | + // Disallow showing date if the query doesn't have an inclusion category parameter. |
311 | 315 | if ( $this->params['count'] < 1 ) { |
312 | 316 | $this->params['addFirstCategoryDate'] = false; |
313 | 317 | } |
Index: trunk/extensions/GoogleNewsSitemap/SitemapFeed.php |
— | — | @@ -9,9 +9,10 @@ |
10 | 10 | $this->writer = new XMLWriter(); |
11 | 11 | $wgOut->disable(); |
12 | 12 | } |
| 13 | + |
13 | 14 | /** |
14 | 15 | * Output feed headers |
15 | | - **/ |
| 16 | + */ |
16 | 17 | function outHeader() { |
17 | 18 | global $wgOut, $wgRequest; |
18 | 19 | |
— | — | @@ -19,9 +20,10 @@ |
20 | 21 | $ctype = $wgRequest->getVal( 'ctype', 'application/xml' ); |
21 | 22 | $allowedctypes = array( 'application/xml', 'text/xml', 'application/rss+xml', 'application/atom+xml' ); |
22 | 23 | $mimetype = in_array( $ctype, $allowedctypes ) ? $ctype : 'application/xml'; |
23 | | - header( "Content-type: $mimetype; charset=UTF-8" ); |
24 | | - $wgOut->sendCacheControl(); |
25 | 24 | |
| 25 | + header( "Content-type: $mimetype; charset=UTF-8" ); |
| 26 | + $wgOut->sendCacheControl(); |
| 27 | + |
26 | 28 | $this->writer->openURI( 'php://output' ); |
27 | 29 | $this->writer->setIndent( true ); |
28 | 30 | $this->writer->startDocument( "1.0", "UTF-8" ); |
— | — | @@ -30,10 +32,11 @@ |
31 | 33 | $this->writer->writeAttribute( "xmlns:news", "http://www.google.com/schemas/sitemap-news/0.9" ); |
32 | 34 | $this->writer->flush(); |
33 | 35 | } |
| 36 | + |
34 | 37 | /** |
35 | 38 | * Output a SiteMap 0.9 item |
36 | 39 | * @param FeedSMItem $item to be output |
37 | | - **/ |
| 40 | + */ |
38 | 41 | function outItem( $item ) { |
39 | 42 | $this->writer->startElement( "url" ); |
40 | 43 | $this->writer->startElement( "loc" ); |
— | — | @@ -64,7 +67,7 @@ |
65 | 68 | |
66 | 69 | /** |
67 | 70 | * Output SiteMap 0.9 footer |
68 | | - **/ |
| 71 | + */ |
69 | 72 | function outFooter() { |
70 | 73 | $this->writer->endDocument(); |
71 | 74 | $this->writer->flush(); |