Index: trunk/phase3/includes/specials/SpecialGlobalTemplateUsage.php |
— | — | @@ -18,37 +18,32 @@ |
19 | 19 | * Entry point |
20 | 20 | */ |
21 | 21 | public function execute( $par ) { |
22 | | - global $wgOut, $wgRequest; |
23 | | - |
24 | | - $target = $par ? $par : $wgRequest->getVal( 'target' ); |
| 22 | + $target = $par ? $par : $this->getRequest()->getVal( 'target' ); |
25 | 23 | $this->target = Title::newFromText( $target ); |
26 | 24 | |
27 | 25 | $this->setHeaders(); |
28 | 26 | |
29 | 27 | $this->showForm(); |
30 | 28 | |
31 | | - if ( is_null( $this->target ) ) { |
32 | | - $wgOut->setPageTitle( wfMsg( 'globaltemplateusage' ) ); |
33 | | - return; |
34 | | - } |
| 29 | + if ( $this->target !== null ) { |
| 30 | + $this->getOutput()->setPageTitle( wfMsg( 'globaltemplateusage-for', $this->target->getPrefixedText() ) ); |
35 | 31 | |
36 | | - $wgOut->setPageTitle( wfMsg( 'globaltemplateusage-for', $this->target->getPrefixedText() ) ); |
37 | | - |
38 | | - $this->showResult(); |
| 32 | + $this->showResult(); |
| 33 | + } |
39 | 34 | } |
40 | 35 | |
41 | 36 | /** |
42 | 37 | * Shows the search form |
43 | 38 | */ |
44 | 39 | private function showForm() { |
45 | | - global $wgScript, $wgOut, $wgRequest; |
| 40 | + global $wgScript; |
46 | 41 | |
47 | 42 | /* Build form */ |
48 | 43 | $html = Xml::openElement( 'form', array( 'action' => $wgScript ) ) . "\n"; |
49 | 44 | // Name of SpecialPage |
50 | | - $html .= Html::hidden( 'title', $this->getTitle( )->getPrefixedText( ) ) . "\n"; |
| 45 | + $html .= Html::hidden( 'title', $this->getTitle()->getPrefixedText() ) . "\n"; |
51 | 46 | // Limit |
52 | | - $html .= Html::hidden( 'limit', $wgRequest->getInt( 'limit', 50 ) ); |
| 47 | + $html .= Html::hidden( 'limit', $this->getRequest()->getInt( 'limit', 50 ) ); |
53 | 48 | // Input box with target prefilled if available |
54 | 49 | $formContent = "\t" . Xml::input( 'target', 40, is_null( $this->target ) ? '' |
55 | 50 | : $this->target->getPrefixedText( ) ) |
— | — | @@ -61,34 +56,32 @@ |
62 | 57 | // Wrap the entire form in a nice fieldset |
63 | 58 | $html .= Xml::fieldSet( wfMsg( 'globaltemplateusage-text' ), $formContent ) . "\n</form>"; |
64 | 59 | |
65 | | - $wgOut->addHtml( $html ); |
| 60 | + $this->getOutput()->addHtml( $html ); |
66 | 61 | } |
67 | 62 | |
68 | 63 | /** |
69 | | - * Creates as queryer and executes it based on $wgRequest |
| 64 | + * Creates as queryer and executes it based on the WebRequest object |
70 | 65 | */ |
71 | 66 | private function showResult() { |
72 | | - global $wgRequest; |
73 | | - |
| 67 | + $request = $this->getRequest(); |
74 | 68 | $query = new GlobalUsageQuery( $this->target ); |
75 | 69 | |
76 | | - // Extract params from $wgRequest |
77 | | - if ( $wgRequest->getText( 'from' ) ) { |
78 | | - $query->setOffset( $wgRequest->getText( 'from' ) ); |
79 | | - } elseif ( $wgRequest->getText( 'to' ) ) { |
80 | | - $query->setOffset( $wgRequest->getText( 'to' ), true ); |
| 70 | + // Extract params from the WebRequest object |
| 71 | + if ( $request->getText( 'from' ) ) { |
| 72 | + $query->setOffset( $request->getText( 'from' ) ); |
| 73 | + } elseif ( $request->getText( 'to' ) ) { |
| 74 | + $query->setOffset( $request->getText( 'to' ), true ); |
81 | 75 | } |
82 | | - $query->setLimit( $wgRequest->getInt( 'limit', 50 ) ); |
| 76 | + $query->setLimit( $request->getInt( 'limit', 50 ) ); |
83 | 77 | |
84 | 78 | // Perform query |
85 | 79 | $query->searchTemplate(); |
86 | 80 | |
87 | | - // Show result |
88 | | - global $wgOut; |
| 81 | + $out = $this->getOutput(); |
89 | 82 | |
90 | 83 | // Don't show form element if there is no data |
91 | 84 | if ( $query->count() == 0 ) { |
92 | | - $wgOut->addWikiMsg( 'globaltemplateusage-no-results', $this->target->getPrefixedText( ) ); |
| 85 | + $out->addWikiMsg( 'globaltemplateusage-no-results', $this->target->getPrefixedText( ) ); |
93 | 86 | return; |
94 | 87 | } |
95 | 88 | |
— | — | @@ -96,24 +89,24 @@ |
97 | 90 | $targetName = $this->target->getPrefixedText( ); |
98 | 91 | |
99 | 92 | // Top navbar |
100 | | - $wgOut->addHtml( $navbar ); |
| 93 | + $out->addHtml( $navbar ); |
101 | 94 | |
102 | | - $wgOut->addHtml( '<div id="mw-globaltemplateusage-result">' ); |
| 95 | + $out->addHtml( '<div id="mw-globaltemplateusage-result">' ); |
103 | 96 | foreach ( $query->getSingleResult() as $wiki => $result ) { |
104 | | - $wgOut->addHtml( |
| 97 | + $out->addHtml( |
105 | 98 | '<h2>' . wfMsgExt( |
106 | 99 | 'globaltemplateusage-on-wiki', 'parseinline', |
107 | 100 | $targetName, WikiMap::getWikiName( $wiki ) ) |
108 | 101 | . "</h2><ul>\n" ); |
109 | 102 | foreach ( $result as $item ) { |
110 | | - $wgOut->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); |
| 103 | + $out->addHtml( "\t<li>" . self::formatItem( $item ) . "</li>\n" ); |
111 | 104 | } |
112 | | - $wgOut->addHtml( "</ul>\n" ); |
| 105 | + $out->addHtml( "</ul>\n" ); |
113 | 106 | } |
114 | | - $wgOut->addHtml( '</div>' ); |
| 107 | + $out->addHtml( '</div>' ); |
115 | 108 | |
116 | 109 | // Bottom navbar |
117 | | - $wgOut->addHtml( $navbar ); |
| 110 | + $out->addHtml( $navbar ); |
118 | 111 | } |
119 | 112 | |
120 | 113 | /** |
— | — | @@ -139,13 +132,10 @@ |
140 | 133 | * @return string Navbar HTML |
141 | 134 | */ |
142 | 135 | protected function getNavBar( $query ) { |
143 | | - global $wgLang, $wgUser; |
144 | | - |
145 | | - $skin = $wgUser->getSkin(); |
146 | | - |
| 136 | + $lang = $this->getLang(); |
147 | 137 | $target = $this->target->getPrefixedText(); |
148 | 138 | $limit = $query->getLimit(); |
149 | | - $fmtLimit = $wgLang->formatNum( $limit ); |
| 139 | + $fmtLimit = $lang->formatNum( $limit ); |
150 | 140 | |
151 | 141 | # Find out which strings are for the prev and which for the next links |
152 | 142 | $offset = $query->getOffsetString(); |
— | — | @@ -172,7 +162,7 @@ |
173 | 163 | if ( $to ) { |
174 | 164 | $attr = array( 'title' => $pTitle, 'class' => 'mw-prevlink' ); |
175 | 165 | $q = array( 'limit' => $limit, 'to' => $to, 'target' => $target ); |
176 | | - $plink = $skin->link( $title, $prev, $attr, $q ); |
| 166 | + $plink = Linker::link( $title, $prev, $attr, $q ); |
177 | 167 | } else { |
178 | 168 | $plink = $prev; |
179 | 169 | } |
— | — | @@ -181,7 +171,7 @@ |
182 | 172 | if ( $from ) { |
183 | 173 | $attr = array( 'title' => $nTitle, 'class' => 'mw-nextlink' ); |
184 | 174 | $q = array( 'limit' => $limit, 'from' => $from, 'target' => $target ); |
185 | | - $nlink = $skin->link( $title, $next, $attr, $q ); |
| 175 | + $nlink = Linker::link( $title, $next, $attr, $q ); |
186 | 176 | } else { |
187 | 177 | $nlink = $next; |
188 | 178 | } |
— | — | @@ -189,15 +179,15 @@ |
190 | 180 | # Make links to set number of items per page |
191 | 181 | $numLinks = array(); |
192 | 182 | foreach ( array( 20, 50, 100, 250, 500 ) as $num ) { |
193 | | - $fmtLimit = $wgLang->formatNum( $num ); |
| 183 | + $fmtLimit = $lang->formatNum( $num ); |
194 | 184 | |
195 | 185 | $q = array( 'offset' => $offset, 'limit' => $num, 'target' => $target ); |
196 | 186 | $lTitle = wfMsgExt( 'shown-title', array( 'parsemag', 'escape' ), $num ); |
197 | 187 | $attr = array( 'title' => $lTitle, 'class' => 'mw-numlink' ); |
198 | 188 | |
199 | | - $numLinks[] = $skin->link( $title, $fmtLimit, $attr, $q ); |
| 189 | + $numLinks[] = Linker::link( $title, $fmtLimit, $attr, $q ); |
200 | 190 | } |
201 | | - $nums = $wgLang->pipeList( $numLinks ); |
| 191 | + $nums = $lang->pipeList( $numLinks ); |
202 | 192 | |
203 | 193 | return wfMsgHtml( 'viewprevnext', $plink, $nlink, $nums ); |
204 | 194 | } |