Index: trunk/phase3/includes/specials/SpecialGlobalFileUsage.php |
— | — | @@ -13,39 +13,34 @@ |
14 | 14 | * Entry point |
15 | 15 | */ |
16 | 16 | public function execute( $par ) { |
17 | | - global $wgOut, $wgRequest; |
18 | | - |
19 | | - $target = $par ? $par : $wgRequest->getVal( 'target' ); |
| 17 | + $request = $this->getRequest(); |
| 18 | + $target = $par ? $par : $request->getVal( 'target' ); |
20 | 19 | $this->target = Title::makeTitleSafe( NS_FILE, $target ); |
21 | 20 | |
22 | | - $this->filterLocal = $wgRequest->getCheck( 'filterlocal' ); |
| 21 | + $this->filterLocal = $request->getCheck( 'filterlocal' ); |
23 | 22 | |
24 | 23 | $this->setHeaders(); |
25 | 24 | |
26 | 25 | $this->showForm(); |
27 | 26 | |
28 | | - if ( is_null( $this->target ) ) { |
29 | | - $wgOut->setPageTitle( wfMsg( 'globalfileusage' ) ); |
30 | | - return; |
| 27 | + if ( !is_null( $this->target ) ) { |
| 28 | + $this->getOutput()->setPageTitle( wfMsg( 'globalfileusage-for', $this->target->getPrefixedText() ) ); |
| 29 | + $this->showResult(); |
31 | 30 | } |
32 | | - |
33 | | - $wgOut->setPageTitle( wfMsg( 'globalfileusage-for', $this->target->getPrefixedText() ) ); |
34 | | - |
35 | | - $this->showResult(); |
36 | 31 | } |
37 | 32 | |
38 | 33 | /** |
39 | 34 | * Shows the search form |
40 | 35 | */ |
41 | 36 | private function showForm() { |
42 | | - global $wgScript, $wgOut, $wgRequest; |
| 37 | + global $wgScript, $wgContLang; |
43 | 38 | |
44 | 39 | /* Build form */ |
45 | 40 | $html = Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n"; |
46 | 41 | // Name of SpecialPage |
47 | 42 | $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
48 | 43 | // Limit |
49 | | - $html .= Html::hidden( 'limit', $wgRequest->getInt( 'limit', 50 ) ); |
| 44 | + $html .= Html::hidden( 'limit', $this->getRequest()->getInt( 'limit', 50 ) ); |
50 | 45 | // Input box with target prefilled if available |
51 | 46 | $formContent = "\t" . Xml::input( 'target', 40, is_null( $this->target ) ? '' |
52 | 47 | : $this->target->getText() ) |
— | — | @@ -58,50 +53,46 @@ |
59 | 54 | . "\n\t<p>" . Xml::checkLabel( wfMsg( 'globalfileusage-filterlocal' ), |
60 | 55 | 'filterlocal', 'mw-filterlocal', $this->filterLocal ) . '</p>'; |
61 | 56 | |
62 | | - if ( !is_null( $this->target ) && wfFindFile( $this->target ) ) { |
63 | | - // Show the image if it exists |
64 | | - global $wgUser, $wgContLang; |
65 | | - $skin = $wgUser->getSkin(); |
66 | | - |
67 | | - $html .= $skin->makeImageLinkObj( $this->target, |
68 | | - $this->target->getPrefixedText(), |
69 | | - /* $alt */ '', /* $align */ $wgContLang->alignEnd(), |
70 | | - /* $handlerParams */ array(), /* $framed */ false, |
71 | | - /* $thumb */ true ); |
| 57 | + if ( !is_null( $this->target ) ) { |
| 58 | + $file = wfFindFile( $this->target ); |
| 59 | + if ( $file !== null ) { |
| 60 | + // Show the image if it exists |
| 61 | + $html .= Linker::makeImageLink2( $this->target, $file, |
| 62 | + array( 'align' => $this->getLang()->alignEnd(), 'thumbnail' => true ) ); |
| 63 | + } |
72 | 64 | } |
73 | 65 | |
74 | 66 | // Wrap the entire form in a nice fieldset |
75 | 67 | $html .= Xml::fieldSet( wfMsg( 'globalfileusage-text' ), $formContent ) . "\n</form>"; |
76 | 68 | |
77 | | - $wgOut->addHtml( $html ); |
| 69 | + $this->getOutput()->addHtml( $html ); |
78 | 70 | } |
79 | 71 | |
80 | 72 | /** |
81 | | - * Creates as queryer and executes it based on $wgRequest |
| 73 | + * Creates as queryer and executes it based on the WebRequest object |
82 | 74 | */ |
83 | 75 | private function showResult() { |
84 | | - global $wgRequest; |
85 | | - |
| 76 | + $request = $this->getRequest(); |
86 | 77 | $query = new GlobalUsageQuery( $this->target ); |
87 | 78 | |
88 | | - // Extract params from $wgRequest |
89 | | - if ( $wgRequest->getText( 'from' ) ) { |
90 | | - $query->setOffset( $wgRequest->getText( 'from' ) ); |
91 | | - } elseif ( $wgRequest->getText( 'to' ) ) { |
92 | | - $query->setOffset( $wgRequest->getText( 'to' ), true ); |
| 79 | + // Extract params from the WebRequest object |
| 80 | + if ( $request->getText( 'from' ) ) { |
| 81 | + $query->setOffset( $request->getText( 'from' ) ); |
| 82 | + } elseif ( $request->getText( 'to' ) ) { |
| 83 | + $query->setOffset( $request->getText( 'to' ), true ); |
93 | 84 | } |
94 | | - $query->setLimit( $wgRequest->getInt( 'limit', 50 ) ); |
| 85 | + $query->setLimit( $request->getInt( 'limit', 50 ) ); |
95 | 86 | $query->filterLocal( $this->filterLocal ); |
96 | 87 | |
97 | 88 | // Perform query |
98 | 89 | $query->searchFile(); |
99 | 90 | |
100 | 91 | // Show result |
101 | | - global $wgOut; |
| 92 | + $out = $this->getOutput(); |
102 | 93 | |
103 | 94 | // Don't show form element if there is no data |
104 | 95 | if ( $query->count() == 0 ) { |
105 | | - $wgOut->addWikiMsg( 'globalfileusage-no-results', $this->target->getPrefixedText() ); |
| 96 | + $out->addWikiMsg( 'globalfileusage-no-results', $this->target->getPrefixedText() ); |
106 | 97 | return; |
107 | 98 | } |
108 | 99 | |
— | — | @@ -110,24 +101,24 @@ |
111 | 102 | $targetName = $this->target->getText(); |
112 | 103 | |
113 | 104 | // Top navbar |
114 | | - $wgOut->addHtml( $navbar ); |
| 105 | + $out->addHtml( $navbar ); |
115 | 106 | |
116 | | - $wgOut->addHtml( '<div id="mw-globalfileusage-result">' ); |
| 107 | + $out->addHtml( '<div id="mw-globalfileusage-result">' ); |
117 | 108 | foreach ( $query->getSingleResult() as $wiki => $result ) { |
118 | | - $wgOut->addHtml( |
| 109 | + $out->addHtml( |
119 | 110 | '<h2>' . wfMsgExt( |
120 | 111 | 'globalfileusage-on-wiki', 'parseinline', |
121 | 112 | $targetName, WikiMap::getWikiName( $wiki ) ) |
122 | 113 | . "</h2><ul>\n" ); |
123 | 114 | foreach ( $result as $item ) { |
124 | | - $wgOut->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); |
| 115 | + $out->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); |
125 | 116 | } |
126 | | - $wgOut->addHtml( "</ul>\n" ); |
| 117 | + $out->addHtml( "</ul>\n" ); |
127 | 118 | } |
128 | | - $wgOut->addHtml( '</div>' ); |
| 119 | + $out->addHtml( '</div>' ); |
129 | 120 | |
130 | 121 | // Bottom navbar |
131 | | - $wgOut->addHtml( $navbar ); |
| 122 | + $out->addHtml( $navbar ); |
132 | 123 | } |
133 | 124 | |
134 | 125 | /** |
— | — | @@ -153,13 +144,10 @@ |
154 | 145 | * @return string Navbar HTML |
155 | 146 | */ |
156 | 147 | protected function getNavBar( $query ) { |
157 | | - global $wgLang, $wgUser; |
158 | | - |
159 | | - $skin = $wgUser->getSkin(); |
160 | | - |
| 148 | + $lang = $this->getLang(); |
161 | 149 | $target = $this->target->getText(); |
162 | 150 | $limit = $query->getLimit(); |
163 | | - $fmtLimit = $wgLang->formatNum( $limit ); |
| 151 | + $fmtLimit = $lang->formatNum( $limit ); |
164 | 152 | |
165 | 153 | # Find out which strings are for the prev and which for the next links |
166 | 154 | $offset = $query->getOffsetString(); |
— | — | @@ -188,7 +176,7 @@ |
189 | 177 | $q = array( 'limit' => $limit, 'to' => $to, 'target' => $target ); |
190 | 178 | if ( $this->filterLocal ) |
191 | 179 | $q['filterlocal'] = '1'; |
192 | | - $plink = $skin->link( $title, $prev, $attr, $q ); |
| 180 | + $plink = Linker::link( $title, $prev, $attr, $q ); |
193 | 181 | } else { |
194 | 182 | $plink = $prev; |
195 | 183 | } |
— | — | @@ -199,7 +187,7 @@ |
200 | 188 | $q = array( 'limit' => $limit, 'from' => $from, 'target' => $target ); |
201 | 189 | if ( $this->filterLocal ) |
202 | 190 | $q['filterlocal'] = '1'; |
203 | | - $nlink = $skin->link( $title, $next, $attr, $q ); |
| 191 | + $nlink = Linker::link( $title, $next, $attr, $q ); |
204 | 192 | } else { |
205 | 193 | $nlink = $next; |
206 | 194 | } |
— | — | @@ -207,7 +195,7 @@ |
208 | 196 | # Make links to set number of items per page |
209 | 197 | $numLinks = array(); |
210 | 198 | foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { |
211 | | - $fmtLimit = $wgLang->formatNum( $num ); |
| 199 | + $fmtLimit = $lang->formatNum( $num ); |
212 | 200 | |
213 | 201 | $q = array( 'offset' => $offset, 'limit' => $num, 'target' => $target ); |
214 | 202 | if ( $this->filterLocal ) |
— | — | @@ -215,9 +203,9 @@ |
216 | 204 | $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $num ); |
217 | 205 | $attr = array( 'title' => $lTitle, 'class' => 'mw-numlink' ); |
218 | 206 | |
219 | | - $numLinks[] = $skin->link( $title, $fmtLimit, $attr, $q ); |
| 207 | + $numLinks[] = Linker::link( $title, $fmtLimit, $attr, $q ); |
220 | 208 | } |
221 | | - $nums = $wgLang->pipeList( $numLinks ); |
| 209 | + $nums = $lang->pipeList( $numLinks ); |
222 | 210 | |
223 | 211 | return wfMsgHtml( 'viewprevnext', $plink, $nlink, $nums ); |
224 | 212 | } |