Index: branches/robchurch/reports/includes/reports/ReportPager.php |
— | — | @@ -43,7 +43,7 @@ |
44 | 44 | # Base conditions |
45 | 45 | $conds = $this->report->getExtraConditions( $this->mDb ); |
46 | 46 | if( ( $ns = $this->getNamespace() ) !== false ) |
47 | | - $conds[] = $this->report->getNamespaceClause( $ns ); |
| 47 | + $conds[] = $this->report->getNamespaceClause( intval( $ns ) ); |
48 | 48 | if( !$this->getRedirects() || $this->report->excludeRedirects() ) |
49 | 49 | $conds[] = $this->report->getRedirectClause(); |
50 | 50 | |
— | — | @@ -136,18 +136,13 @@ |
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
140 | | - * Get the namespace to filter results for |
141 | | - * (Returns false if all namespaces should be used) |
| 140 | + * Get the namespace to filter results for, or false |
| 141 | + * to omit filtering |
142 | 142 | * |
143 | 143 | * @return mixed |
144 | 144 | */ |
145 | 145 | public function getNamespace() { |
146 | | - if( $this->report->allowNamespaceFilter() ) { |
147 | | - $ns = $this->mRequest->getVal( 'namespace', '' ); |
148 | | - return $ns !== '' ? intval( $ns ) : false; |
149 | | - } else { |
150 | | - return false; |
151 | | - } |
| 146 | + return $this->report->getNamespace(); |
152 | 147 | } |
153 | 148 | |
154 | 149 | /** |
Index: branches/robchurch/reports/includes/reports/Report.php |
— | — | @@ -80,6 +80,18 @@ |
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
| 84 | + * Get the default namespace to filter on; |
| 85 | + * false to indicate no filtering per default |
| 86 | + * |
| 87 | + * @return bool |
| 88 | + */ |
| 89 | + public function getDefaultNamespace() { |
| 90 | + return ( $ns = $this->getApplicableNamespaces() ) !== false |
| 91 | + ? $ns[0] |
| 92 | + : false; |
| 93 | + } |
| 94 | + |
| 95 | + /** |
84 | 96 | * Is there a more appropriate title to show when |
85 | 97 | * a particular namespace is selected? Return the |
86 | 98 | * message name here |
— | — | @@ -181,11 +193,12 @@ |
182 | 194 | public function execute( $par = false ) { |
183 | 195 | global $wgOut, $wgRequest, $wgLang; |
184 | 196 | $this->setHeaders(); |
| 197 | + # Namespace and redirect filter values |
| 198 | + $namespace = $this->getNamespace(); |
| 199 | + $redirects = $wgRequest->getCheck( 'redirects' ); |
185 | 200 | # Per-namespace title variants |
186 | | - if( ( $ns = $wgRequest->getVal( 'namespace', false ) ) !== false ) { |
187 | | - if( ( $msg = $this->getNamespaceTitleVariant( $ns ) ) !== false ) |
188 | | - $wgOut->setPageTitle( wfMsg( $msg ) ); |
189 | | - } |
| 201 | + if( ( $msg = $this->getNamespaceTitleVariant( $namespace ) ) !== false ) |
| 202 | + $wgOut->setPageTitle( wfMsg( $msg ) ); |
190 | 203 | # Cache information, etc. |
191 | 204 | $pager = $this->getPager(); |
192 | 205 | if( $this->isDisabled() ) { |
— | — | @@ -194,12 +207,7 @@ |
195 | 208 | $wgOut->addHtml( $this->getCacheInfo() ); |
196 | 209 | } |
197 | 210 | # Filtering UI |
198 | | - $wgOut->addHtml( |
199 | | - $this->buildFilterUI( |
200 | | - $wgRequest->getVal( 'namespace', '' ), |
201 | | - $wgRequest->getCheck( 'redirects' ) |
202 | | - ) |
203 | | - ); |
| 211 | + $wgOut->addHtml( $this->buildFilterUI( $namespace, $redirects ) ); |
204 | 212 | # Report results |
205 | 213 | if( ( $count = $pager->getNumRows() ) > 0 ) { |
206 | 214 | $wgOut->addHtml( $pager->getNavigationBar() ); |
— | — | @@ -221,6 +229,23 @@ |
222 | 230 | ? new CachedReportPager( $this ) |
223 | 231 | : new ReportPager( $this ); |
224 | 232 | } |
| 233 | + |
| 234 | + /** |
| 235 | + * Get the namespace to filter results for, or false |
| 236 | + * to omit filtering |
| 237 | + * |
| 238 | + * @return mixed |
| 239 | + */ |
| 240 | + public function getNamespace() { |
| 241 | + global $wgRequest; |
| 242 | + if( $this->allowNamespaceFilter() ) { |
| 243 | + return $wgRequest->getCheck( 'namespace' ) |
| 244 | + ? $wgRequest->getInt( 'namespace' ) |
| 245 | + : $this->getDefaultNamespace(); |
| 246 | + } else { |
| 247 | + return false; |
| 248 | + } |
| 249 | + } |
225 | 250 | |
226 | 251 | /** |
227 | 252 | * Build the filtering form for the top of the page |
— | — | @@ -241,7 +266,6 @@ |
242 | 267 | # Namespace selector |
243 | 268 | if( $this->allowNamespaceFilter() ) { |
244 | 269 | $form .= '<tr><td>' . Xml::label( wfMsg( 'report-filter-namespace' ), 'namespace' ) . '</td>'; |
245 | | - #$form .= '<td>' . Xml::namespaceSelector( $namespace, '' ) . '</td></tr>'; |
246 | 270 | $form .= '<td>' . $this->buildNamespaceSelector( $namespace ) . '</td></tr>'; |
247 | 271 | } |
248 | 272 | # Redirect toggle |
— | — | @@ -271,7 +295,7 @@ |
272 | 296 | $html = Xml::openElement( 'select', array( 'id' => 'namespace', 'name' => 'namespace' ) ); |
273 | 297 | $namespaces = $this->getApplicableNamespaces(); |
274 | 298 | if( $namespaces === false ) { |
275 | | - $html .= Xml::option( wfMsg( 'report-filter-namespace-all' ), '' ); |
| 299 | + $html .= Xml::option( wfMsg( 'report-filter-namespace-all' ), '', $select === false ); |
276 | 300 | $namespaces = array_keys( $wgContLang->getNamespaces() ); |
277 | 301 | } |
278 | 302 | foreach( $namespaces as $index ) { |
— | — | @@ -279,7 +303,7 @@ |
280 | 304 | $label = $index != 0 |
281 | 305 | ? $wgContLang->getFormattedNsText( $index ) |
282 | 306 | : wfMsg( 'blanknamespace' ); |
283 | | - $html .= Xml::option( $label, $index, $select !== '' && $select == $index ); |
| 307 | + $html .= Xml::option( $label, $index, $select === $index ); |
284 | 308 | } |
285 | 309 | } |
286 | 310 | $html .= Xml::closeElement( 'select' ); |
Index: branches/robchurch/reports/includes/reports/CachedReportPager.php |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | # Base conditions |
30 | 30 | $conds['rp_report'] = $this->report->getName(); |
31 | 31 | if( ( $ns = $this->getNamespace() ) !== false ) |
32 | | - $conds['rp_namespace'] = $ns; |
| 32 | + $conds['rp_namespace'] = intval( $ns ); |
33 | 33 | if( !$this->getRedirects() || $this->report->excludeRedirects() ) |
34 | 34 | $conds['rp_redirect'] = 0; |
35 | 35 | |
Index: branches/robchurch/reports/includes/reports/UncategorisedPagesReport.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | NS_IMAGE, |
48 | 48 | NS_TEMPLATE, |
49 | 49 | NS_CATEGORY |
50 | | - ); |
| 50 | + ) + $GLOBALS['wgContentNamespaces']; |
51 | 51 | } |
52 | 52 | |
53 | 53 | /** |