Index: trunk/phase3/includes/CategoryPage.php |
— | — | @@ -34,11 +34,11 @@ |
35 | 35 | } |
36 | 36 | |
37 | 37 | function view() { |
38 | | - global $wgRequest, $wgUser; |
| 38 | + $request = $this->getContext()->getRequest(); |
| 39 | + $diff = $request->getVal( 'diff' ); |
| 40 | + $diffOnly = $request->getBool( 'diffonly', |
| 41 | + $this->getContext()->getUser()->getOption( 'diffonly' ) ); |
39 | 42 | |
40 | | - $diff = $wgRequest->getVal( 'diff' ); |
41 | | - $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
42 | | - |
43 | 43 | if ( isset( $diff ) && $diffOnly ) { |
44 | 44 | return parent::view(); |
45 | 45 | } |
— | — | @@ -63,18 +63,17 @@ |
64 | 64 | } |
65 | 65 | |
66 | 66 | function closeShowCategory() { |
67 | | - global $wgOut, $wgRequest; |
68 | | - |
69 | 67 | // Use these as defaults for back compat --catrope |
70 | | - $oldFrom = $wgRequest->getVal( 'from' ); |
71 | | - $oldUntil = $wgRequest->getVal( 'until' ); |
| 68 | + $request = $this->getContext()->getRequest(); |
| 69 | + $oldFrom = $request->getVal( 'from' ); |
| 70 | + $oldUntil = $request->getVal( 'until' ); |
72 | 71 | |
73 | | - $reqArray = $wgRequest->getValues(); |
| 72 | + $reqArray = $request->getValues(); |
74 | 73 | |
75 | 74 | $from = $until = array(); |
76 | 75 | foreach ( array( 'page', 'subcat', 'file' ) as $type ) { |
77 | | - $from[$type] = $wgRequest->getVal( "{$type}from", $oldFrom ); |
78 | | - $until[$type] = $wgRequest->getVal( "{$type}until", $oldUntil ); |
| 76 | + $from[$type] = $request->getVal( "{$type}from", $oldFrom ); |
| 77 | + $until[$type] = $request->getVal( "{$type}until", $oldUntil ); |
79 | 78 | |
80 | 79 | // Do not want old-style from/until propagating in nav links. |
81 | 80 | if ( !isset( $reqArray["{$type}from"] ) && isset( $reqArray["from"] ) ) { |
— | — | @@ -88,8 +87,8 @@ |
89 | 88 | unset( $reqArray["from"] ); |
90 | 89 | unset( $reqArray["to"] ); |
91 | 90 | |
92 | | - $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $reqArray ); |
93 | | - $wgOut->addHTML( $viewer->getHTML() ); |
| 91 | + $viewer = new $this->mCategoryViewerClass( $this->mTitle, $this->getContext(), $from, $until, $reqArray ); |
| 92 | + $this->getContext()->getOutput()->addHTML( $viewer->getHTML() ); |
94 | 93 | } |
95 | 94 | } |
96 | 95 | |
— | — | @@ -138,9 +137,26 @@ |
139 | 138 | */ |
140 | 139 | private $query; |
141 | 140 | |
142 | | - function __construct( $title, $from = '', $until = '', $query = array() ) { |
| 141 | + /** |
| 142 | + * Context object |
| 143 | + * @var IContextSource |
| 144 | + */ |
| 145 | + protected $context; |
| 146 | + |
| 147 | + /** |
| 148 | + * Constructor |
| 149 | + * |
| 150 | + * @since 1.19 $context is a second, required parameter |
| 151 | + * @param $title Title |
| 152 | + * @param $context IContextSource |
| 153 | + * @param $from String |
| 154 | + * @param $until String |
| 155 | + * @param $query Array |
| 156 | + */ |
| 157 | + function __construct( $title, IContextSource $context, $from = '', $until = '', $query = array() ) { |
143 | 158 | global $wgCategoryPagingLimit; |
144 | 159 | $this->title = $title; |
| 160 | + $this->context = $context; |
145 | 161 | $this->from = $from; |
146 | 162 | $this->until = $until; |
147 | 163 | $this->limit = $wgCategoryPagingLimit; |
— | — | @@ -156,10 +172,10 @@ |
157 | 173 | * @return string HTML output |
158 | 174 | */ |
159 | 175 | public function getHTML() { |
160 | | - global $wgOut, $wgCategoryMagicGallery, $wgLang; |
| 176 | + global $wgCategoryMagicGallery; |
161 | 177 | wfProfileIn( __METHOD__ ); |
162 | 178 | |
163 | | - $this->showGallery = $wgCategoryMagicGallery && !$wgOut->mNoGallery; |
| 179 | + $this->showGallery = $wgCategoryMagicGallery && !$this->context->getOutput()->mNoGallery; |
164 | 180 | |
165 | 181 | $this->clearCategoryState(); |
166 | 182 | $this->doCategoryQuery(); |
— | — | @@ -187,7 +203,8 @@ |
188 | 204 | $r = wfMsgExt( 'category-empty', array( 'parse' ) ); |
189 | 205 | } |
190 | 206 | |
191 | | - $langAttribs = array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ); |
| 207 | + $lang = $this->getLang(); |
| 208 | + $langAttribs = array( 'lang' => $lang->getCode(), 'dir' => $lang->getDir() ); |
192 | 209 | # put a div around the headings which are in the user language |
193 | 210 | $r = Html::openElement( 'div', $langAttribs ) . $r . '</div>'; |
194 | 211 | |
— | — | @@ -248,8 +265,6 @@ |
249 | 266 | * @param string $sortkey The human-readable sortkey (before transforming to icu or whatever). |
250 | 267 | */ |
251 | 268 | function getSubcategorySortChar( $title, $sortkey ) { |
252 | | - global $wgContLang; |
253 | | - |
254 | 269 | if ( $title->getPrefixedText() == $sortkey ) { |
255 | 270 | $word = $title->getDBkey(); |
256 | 271 | } else { |
— | — | @@ -258,14 +273,13 @@ |
259 | 274 | |
260 | 275 | $firstChar = $this->collation->getFirstLetter( $word ); |
261 | 276 | |
262 | | - return $wgContLang->convert( $firstChar ); |
| 277 | + return $this->getLang()->convert( $firstChar ); |
263 | 278 | } |
264 | 279 | |
265 | 280 | /** |
266 | 281 | * Add a page in the image namespace |
267 | 282 | */ |
268 | 283 | function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) { |
269 | | - global $wgContLang; |
270 | 284 | if ( $this->showGallery ) { |
271 | 285 | $flip = $this->flip['file']; |
272 | 286 | if ( $flip ) { |
— | — | @@ -282,7 +296,7 @@ |
283 | 297 | } |
284 | 298 | $this->imgsNoGallery[] = $link; |
285 | 299 | |
286 | | - $this->imgsNoGallery_start_char[] = $wgContLang->convert( |
| 300 | + $this->imgsNoGallery_start_char[] = $this->getLang()->convert( |
287 | 301 | $this->collation->getFirstLetter( $sortkey ) ); |
288 | 302 | } |
289 | 303 | } |
— | — | @@ -291,8 +305,6 @@ |
292 | 306 | * Add a miscellaneous page |
293 | 307 | */ |
294 | 308 | function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) { |
295 | | - global $wgContLang; |
296 | | - |
297 | 309 | $link = Linker::link( $title ); |
298 | 310 | if ( $isRedirect ) { |
299 | 311 | // This seems kind of pointless given 'mw-redirect' class, |
— | — | @@ -301,7 +313,7 @@ |
302 | 314 | } |
303 | 315 | $this->articles[] = $link; |
304 | 316 | |
305 | | - $this->articles_start_char[] = $wgContLang->convert( |
| 317 | + $this->articles_start_char[] = $this->getLang()->convert->convert( |
306 | 318 | $this->collation->getFirstLetter( $sortkey ) ); |
307 | 319 | } |
308 | 320 | |
— | — | @@ -610,7 +622,7 @@ |
611 | 623 | private function pagingLinks( $first, $last, $type = '' ) { |
612 | 624 | global $wgLang; |
613 | 625 | |
614 | | - $limitText = $wgLang->formatNum( $this->limit ); |
| 626 | + $limitText = $this->getLang()->formatNum( $this->limit ); |
615 | 627 | |
616 | 628 | $prevLink = wfMsgExt( 'prevn', array( 'escape', 'parsemag' ), $limitText ); |
617 | 629 | |
— | — | @@ -685,7 +697,6 @@ |
686 | 698 | * @return String: A message giving the number of items, to output to HTML. |
687 | 699 | */ |
688 | 700 | private function getCountMessage( $rescnt, $dbcnt, $type ) { |
689 | | - global $wgLang; |
690 | 701 | # There are three cases: |
691 | 702 | # 1) The category table figure seems sane. It might be wrong, but |
692 | 703 | # we can't do anything about it if we don't recalculate it on ev- |
— | — | @@ -725,13 +736,22 @@ |
726 | 737 | } else { |
727 | 738 | # Case 3: hopeless. Don't give a total count at all. |
728 | 739 | return wfMsgExt( "category-$type-count-limited", 'parse', |
729 | | - $wgLang->formatNum( $rescnt ) ); |
| 740 | + $this->getLang()->formatNum( $rescnt ) ); |
730 | 741 | } |
731 | 742 | return wfMsgExt( |
732 | 743 | "category-$type-count", |
733 | 744 | 'parse', |
734 | | - $wgLang->formatNum( $rescnt ), |
735 | | - $wgLang->formatNum( $totalcnt ) |
| 745 | + $this->getLang()->formatNum( $rescnt ), |
| 746 | + $this->getLang()->formatNum( $totalcnt ) |
736 | 747 | ); |
737 | 748 | } |
| 749 | + |
| 750 | + /** |
| 751 | + * Returns a language object from the context |
| 752 | + * |
| 753 | + * @return Language |
| 754 | + */ |
| 755 | + protected function getLang() { |
| 756 | + return $this->context->getLang(); |
| 757 | + } |
738 | 758 | } |