Index: branches/querypage-work/phase3/includes/QueryPage.php |
— | — | @@ -658,7 +658,7 @@ |
659 | 659 | if( $title instanceof Title ) { |
660 | 660 | if( $this->isCached() ) { |
661 | 661 | $pageLink = $title->exists() |
662 | | - ? '<s>' . $skin->makeLinkObj( $title ) . '</s>' |
| 662 | + ? '<s>' . $skin->link( $title ) . '</s>' |
663 | 663 | : $skin->makeBrokenLinkObj( $title ); |
664 | 664 | } else { |
665 | 665 | $pageLink = $skin->makeBrokenLinkObj( $title ); |
Property changes on: branches/querypage-work/phase3/includes/QueryPage.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
666 | 666 | Merged /trunk/phase3/includes/QueryPage.php:r49490-50372 |
Index: branches/querypage-work/phase3/includes/specials/SpecialSearch.php |
— | — | @@ -37,8 +37,8 @@ |
38 | 38 | $search = str_replace( "\n", " ", $wgRequest->getText( 'search', $titleParam ) ); |
39 | 39 | $class = $wgUseOldSearchUI ? 'SpecialSearchOld' : 'SpecialSearch'; |
40 | 40 | $searchPage = new $class( $wgRequest, $wgUser ); |
41 | | - if( $wgRequest->getVal( 'fulltext' ) |
42 | | - || !is_null( $wgRequest->getVal( 'offset' )) |
| 41 | + if( $wgRequest->getVal( 'fulltext' ) |
| 42 | + || !is_null( $wgRequest->getVal( 'offset' )) |
43 | 43 | || !is_null( $wgRequest->getVal( 'searchx' )) ) |
44 | 44 | { |
45 | 45 | $searchPage->showResults( $search ); |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | $this->active = 'advanced'; |
76 | 76 | $this->sk = $user->getSkin(); |
77 | 77 | $this->didYouMeanHtml = ''; # html of did you mean... link |
78 | | - $this->fulltext = $request->getVal('fulltext'); |
| 78 | + $this->fulltext = $request->getVal('fulltext'); |
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
— | — | @@ -116,9 +116,9 @@ |
117 | 117 | public function showResults( $term ) { |
118 | 118 | global $wgOut, $wgUser, $wgDisableTextSearch, $wgContLang; |
119 | 119 | wfProfileIn( __METHOD__ ); |
120 | | - |
| 120 | + |
121 | 121 | $sk = $wgUser->getSkin(); |
122 | | - |
| 122 | + |
123 | 123 | $this->searchEngine = SearchEngine::create(); |
124 | 124 | $search =& $this->searchEngine; |
125 | 125 | $search->setLimitOffset( $this->limit, $this->offset ); |
— | — | @@ -126,9 +126,9 @@ |
127 | 127 | $search->showRedirects = $this->searchRedirects; |
128 | 128 | $search->prefix = $this->mPrefix; |
129 | 129 | $term = $search->transformSearchTerm($term); |
130 | | - |
| 130 | + |
131 | 131 | $this->setupPage( $term ); |
132 | | - |
| 132 | + |
133 | 133 | if( $wgDisableTextSearch ) { |
134 | 134 | global $wgSearchForwardUrl; |
135 | 135 | if( $wgSearchForwardUrl ) { |
— | — | @@ -152,10 +152,10 @@ |
153 | 153 | wfProfileOut( __METHOD__ ); |
154 | 154 | return; |
155 | 155 | } |
156 | | - |
| 156 | + |
157 | 157 | $t = Title::newFromText( $term ); |
158 | | - |
159 | | - // fetch search results |
| 158 | + |
| 159 | + // fetch search results |
160 | 160 | $rewritten = $search->replacePrefixes($term); |
161 | 161 | |
162 | 162 | $titleMatches = $search->searchTitle( $rewritten ); |
— | — | @@ -168,8 +168,8 @@ |
169 | 169 | # mirror Go/Search behaviour of original request .. |
170 | 170 | $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() ); |
171 | 171 | if($this->fulltext != NULL) |
172 | | - $didYouMeanParams['fulltext'] = $this->fulltext; |
173 | | - $stParams = wfArrayToCGI( |
| 172 | + $didYouMeanParams['fulltext'] = $this->fulltext; |
| 173 | + $stParams = wfArrayToCGI( |
174 | 174 | $didYouMeanParams, |
175 | 175 | $this->powerSearchOptions() |
176 | 176 | ); |
— | — | @@ -179,9 +179,9 @@ |
180 | 180 | |
181 | 181 | $this->didYouMeanHtml = '<div class="searchdidyoumean">'.wfMsg('search-suggest',$suggestLink).'</div>'; |
182 | 182 | } |
183 | | - |
184 | | - // start rendering the page |
185 | | - $wgOut->addHtml( |
| 183 | + |
| 184 | + // start rendering the page |
| 185 | + $wgOut->addHtml( |
186 | 186 | Xml::openElement( 'table', array( 'border'=>0, 'cellpadding'=>0, 'cellspacing'=>0 ) ) . |
187 | 187 | Xml::openElement( 'tr' ) . |
188 | 188 | Xml::openElement( 'td' ) . "\n" . |
— | — | @@ -190,14 +190,14 @@ |
191 | 191 | Xml::closeElement('tr') . |
192 | 192 | Xml::closeElement('table') |
193 | 193 | ); |
194 | | - |
| 194 | + |
195 | 195 | // Sometimes the search engine knows there are too many hits |
196 | 196 | if( $titleMatches instanceof SearchResultTooMany ) { |
197 | 197 | $wgOut->addWikiText( '==' . wfMsg( 'toomanymatches' ) . "==\n" ); |
198 | 198 | wfProfileOut( __METHOD__ ); |
199 | 199 | return; |
200 | 200 | } |
201 | | - |
| 201 | + |
202 | 202 | $filePrefix = $wgContLang->getFormattedNsText(NS_FILE).':'; |
203 | 203 | if( '' === trim( $term ) || $filePrefix === trim( $term ) ) { |
204 | 204 | $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); |
— | — | @@ -206,54 +206,54 @@ |
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
210 | | - // show direct page/create link |
211 | | - if( !is_null($t) ) { |
212 | | - if( !$t->exists() ) { |
213 | | - $wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) ); |
214 | | - } else { |
215 | | - $wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) ); |
216 | | - } |
217 | | - } |
218 | 210 | |
219 | 211 | // Get number of results |
220 | | - $titleMatchesSQL = $titleMatches ? $titleMatches->numRows() : 0; |
221 | | - $textMatchesSQL = $textMatches ? $textMatches->numRows() : 0; |
| 212 | + $titleMatchesNum = $titleMatches ? $titleMatches->numRows() : 0; |
| 213 | + $textMatchesNum = $textMatches ? $textMatches->numRows() : 0; |
222 | 214 | // Total initial query matches (possible false positives) |
223 | | - $numSQL = $titleMatchesSQL + $textMatchesSQL; |
| 215 | + $num = $titleMatchesNum + $textMatchesNum; |
| 216 | + |
224 | 217 | // Get total actual results (after second filtering, if any) |
225 | 218 | $numTitleMatches = $titleMatches && !is_null( $titleMatches->getTotalHits() ) ? |
226 | | - $titleMatches->getTotalHits() : $titleMatchesSQL; |
| 219 | + $titleMatches->getTotalHits() : $titleMatchesNum; |
227 | 220 | $numTextMatches = $textMatches && !is_null( $textMatches->getTotalHits() ) ? |
228 | | - $textMatches->getTotalHits() : $textMatchesSQL; |
229 | | - $totalRes = $numTitleMatches + $numTextMatches; |
| 221 | + $textMatches->getTotalHits() : $textMatchesNum; |
230 | 222 | |
| 223 | + // get total number of results if backend can calculate it |
| 224 | + $totalRes = 0; |
| 225 | + if($titleMatches && !is_null( $titleMatches->getTotalHits() ) ) |
| 226 | + $totalRes += $titleMatches->getTotalHits(); |
| 227 | + if($textMatches && !is_null( $textMatches->getTotalHits() )) |
| 228 | + $totalRes += $textMatches->getTotalHits(); |
| 229 | + |
231 | 230 | // show number of results and current offset |
232 | | - if( $numSQL > 0 ) { |
233 | | - if( $numSQL > 0 ) { |
234 | | - $top = wfMsgExt('showingresultstotal', array( 'parseinline' ), |
235 | | - $this->offset+1, $this->offset+$numSQL, $totalRes, $numSQL ); |
236 | | - } elseif( $numSQL >= $this->limit ) { |
237 | | - $top = wfShowingResults( $this->offset, $this->limit ); |
| 231 | + $wgOut->addHTML( $this->formHeader($term, $num, $totalRes)); |
| 232 | + |
| 233 | + $wgOut->addHtml( "<div class='searchresults'>" ); |
| 234 | + |
| 235 | + // show direct page/create link |
| 236 | + if( !is_null($t) ) { |
| 237 | + if( !$t->exists() ) { |
| 238 | + $wgOut->addWikiMsg( 'searchmenu-new', wfEscapeWikiText( $t->getPrefixedText() ) ); |
238 | 239 | } else { |
239 | | - $top = wfShowingResultsNum( $this->offset, $this->limit, $numSQL ); |
| 240 | + $wgOut->addWikiMsg( 'searchmenu-exists', wfEscapeWikiText( $t->getPrefixedText() ) ); |
240 | 241 | } |
241 | | - $wgOut->addHTML( "<p class='mw-search-numberresults'>{$top}</p>\n" ); |
242 | 242 | } |
243 | 243 | |
244 | 244 | // prev/next links |
245 | | - if( $numSQL || $this->offset ) { |
| 245 | + if( $num || $this->offset ) { |
246 | 246 | $prevnext = wfViewPrevNext( $this->offset, $this->limit, |
247 | 247 | SpecialPage::getTitleFor( 'Search' ), |
248 | 248 | wfArrayToCGI( $this->powerSearchOptions(), array( 'search' => $term ) ), |
249 | | - max( $titleMatchesSQL, $textMatchesSQL ) < $this->limit |
| 249 | + max( $titleMatchesNum, $textMatchesNum ) < $this->limit |
250 | 250 | ); |
251 | | - $wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" ); |
| 251 | + //$wgOut->addHTML( "<p class='mw-search-pager-top'>{$prevnext}</p>\n" ); |
252 | 252 | wfRunHooks( 'SpecialSearchResults', array( $term, &$titleMatches, &$textMatches ) ); |
253 | 253 | } else { |
254 | 254 | wfRunHooks( 'SpecialSearchNoResults', array( $term ) ); |
255 | | - } |
| 255 | + } |
256 | 256 | |
257 | | - $wgOut->addHtml( "<div class='searchresults'>" ); |
| 257 | + |
258 | 258 | if( $titleMatches ) { |
259 | 259 | if( $numTitleMatches > 0 ) { |
260 | 260 | $wgOut->wrapWikiMsg( "==$1==\n", 'titlematches' ); |
— | — | @@ -265,10 +265,10 @@ |
266 | 266 | // output appropriate heading |
267 | 267 | if( $numTextMatches > 0 && $numTitleMatches > 0 ) { |
268 | 268 | // if no title matches the heading is redundant |
269 | | - $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' ); |
| 269 | + $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' ); |
270 | 270 | } elseif( $totalRes == 0 ) { |
271 | 271 | # Don't show the 'no text matches' if we received title matches |
272 | | - $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' ); |
| 272 | + # $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' ); |
273 | 273 | } |
274 | 274 | // show interwiki results if any |
275 | 275 | if( $textMatches->hasInterwikiResults() ) { |
— | — | @@ -281,20 +281,20 @@ |
282 | 282 | |
283 | 283 | $textMatches->free(); |
284 | 284 | } |
285 | | - if( $totalRes === 0 ) { |
| 285 | + if( $num === 0 ) { |
286 | 286 | $wgOut->addWikiMsg( 'search-nonefound' ); |
287 | 287 | } |
288 | 288 | $wgOut->addHtml( "</div>" ); |
289 | | - if( $totalRes === 0 ) { |
| 289 | + if( $num === 0 ) { |
290 | 290 | $wgOut->addHTML( $this->searchAdvanced ? $this->powerSearchFocus() : $this->searchFocus() ); |
291 | 291 | } |
292 | 292 | |
293 | | - if( $numSQL || $this->offset ) { |
| 293 | + if( $num || $this->offset ) { |
294 | 294 | $wgOut->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" ); |
295 | 295 | } |
296 | 296 | wfProfileOut( __METHOD__ ); |
297 | 297 | } |
298 | | - |
| 298 | + |
299 | 299 | /** |
300 | 300 | * |
301 | 301 | */ |
— | — | @@ -304,14 +304,14 @@ |
305 | 305 | $nsAllSet = array_keys( SearchEngine::searchableNamespaces() ); |
306 | 306 | if( $this->searchAdvanced ) |
307 | 307 | $this->active = 'advanced'; |
308 | | - else if( $this->namespaces === NS_FILE || $this->startsWithImage( $term ) ) |
| 308 | + else if( $this->namespaces === array(NS_FILE) || $this->startsWithImage( $term ) ) |
309 | 309 | $this->active = 'images'; |
310 | | - elseif( $this->namespaces === $nsAllSet ) |
| 310 | + elseif( $this->namespaces === $nsAllSet || $this->startsWithAll( $term ) ) |
311 | 311 | $this->active = 'all'; |
312 | 312 | elseif( $this->namespaces === SearchEngine::defaultNamespaces() ) |
313 | 313 | $this->active = 'default'; |
314 | | - elseif( $this->namespaces === SearchEngine::projectNamespaces() ) |
315 | | - $this->active = 'project'; |
| 314 | + elseif( $this->namespaces === SearchEngine::helpNamespaces() ) |
| 315 | + $this->active = 'help'; |
316 | 316 | else |
317 | 317 | $this->active = 'advanced'; |
318 | 318 | # Should advanced UI be used? |
— | — | @@ -319,7 +319,7 @@ |
320 | 320 | if( !empty( $term ) ) { |
321 | 321 | $wgOut->setPageTitle( wfMsg( 'searchresults') ); |
322 | 322 | $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term ) ) ); |
323 | | - } |
| 323 | + } |
324 | 324 | $wgOut->setArticleRelated( false ); |
325 | 325 | $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
326 | 326 | } |
— | — | @@ -358,8 +358,8 @@ |
359 | 359 | } |
360 | 360 | |
361 | 361 | /** |
362 | | - * Show whole set of results |
363 | | - * |
| 362 | + * Show whole set of results |
| 363 | + * |
364 | 364 | * @param SearchResultSet $matches |
365 | 365 | */ |
366 | 366 | protected function showMatches( &$matches ) { |
— | — | @@ -433,13 +433,13 @@ |
434 | 434 | ."</span>"; |
435 | 435 | $section = ''; |
436 | 436 | if( !is_null($sectionTitle) ) |
437 | | - $section = "<span class='searchalttitle'>" |
| 437 | + $section = "<span class='searchalttitle'>" |
438 | 438 | .wfMsg('search-section', $this->sk->makeKnownLinkObj( $sectionTitle, $sectionText)) |
439 | 439 | ."</span>"; |
440 | 440 | |
441 | 441 | // format text extract |
442 | 442 | $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>"; |
443 | | - |
| 443 | + |
444 | 444 | // format score |
445 | 445 | if( is_null( $result->getScore() ) ) { |
446 | 446 | // Search engine doesn't report scoring info |
— | — | @@ -465,7 +465,7 @@ |
466 | 466 | $stParams = wfArrayToCGI( $this->powerSearchOptions(), |
467 | 467 | array('search' => wfMsgForContent('searchrelated').':'.$t->getPrefixedText(), |
468 | 468 | 'fulltext' => wfMsg('search') )); |
469 | | - |
| 469 | + |
470 | 470 | $related = ' -- ' . $sk->makeKnownLinkObj( $st, |
471 | 471 | wfMsg('search-relatedarticle'), $stParams ); |
472 | 472 | } |
— | — | @@ -508,7 +508,7 @@ |
509 | 509 | |
510 | 510 | /** |
511 | 511 | * Show results from other wikis |
512 | | - * |
| 512 | + * |
513 | 513 | * @param SearchResultSet $matches |
514 | 514 | */ |
515 | 515 | protected function showInterwiki( &$matches, $query ) { |
— | — | @@ -517,7 +517,7 @@ |
518 | 518 | $terms = $wgContLang->convertForSearchResult( $matches->termMatches() ); |
519 | 519 | |
520 | 520 | $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>". |
521 | | - wfMsg('search-interwiki-caption')."</div>\n"; |
| 521 | + wfMsg('search-interwiki-caption')."</div>\n"; |
522 | 522 | $off = $this->offset + 1; |
523 | 523 | $out .= "<ul class='mw-search-iwresults'>\n"; |
524 | 524 | |
— | — | @@ -527,9 +527,9 @@ |
528 | 528 | foreach($customLines as $line) { |
529 | 529 | $parts = explode(":",$line,2); |
530 | 530 | if(count($parts) == 2) // validate line |
531 | | - $customCaptions[$parts[0]] = $parts[1]; |
| 531 | + $customCaptions[$parts[0]] = $parts[1]; |
532 | 532 | } |
533 | | - |
| 533 | + |
534 | 534 | $prev = null; |
535 | 535 | while( $result = $matches->next() ) { |
536 | 536 | $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions ); |
— | — | @@ -543,25 +543,25 @@ |
544 | 544 | wfProfileOut( __METHOD__ ); |
545 | 545 | return $out; |
546 | 546 | } |
547 | | - |
| 547 | + |
548 | 548 | /** |
549 | 549 | * Show single interwiki link |
550 | 550 | * |
551 | 551 | * @param SearchResult $result |
552 | 552 | * @param string $lastInterwiki |
553 | 553 | * @param array $terms |
554 | | - * @param string $query |
| 554 | + * @param string $query |
555 | 555 | * @param array $customCaptions iw prefix -> caption |
556 | 556 | */ |
557 | 557 | protected function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) { |
558 | 558 | wfProfileIn( __METHOD__ ); |
559 | 559 | global $wgContLang, $wgLang; |
560 | | - |
| 560 | + |
561 | 561 | if( $result->isBrokenTitle() ) { |
562 | 562 | wfProfileOut( __METHOD__ ); |
563 | 563 | return "<!-- Broken link in search result -->\n"; |
564 | 564 | } |
565 | | - |
| 565 | + |
566 | 566 | $t = $result->getTitle(); |
567 | 567 | |
568 | 568 | $link = $this->sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms)); |
— | — | @@ -576,31 +576,31 @@ |
577 | 577 | ."</span>"; |
578 | 578 | |
579 | 579 | $out = ""; |
580 | | - // display project name |
| 580 | + // display project name |
581 | 581 | if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()) { |
582 | 582 | if( key_exists($t->getInterwiki(),$customCaptions) ) |
583 | 583 | // captions from 'search-interwiki-custom' |
584 | 584 | $caption = $customCaptions[$t->getInterwiki()]; |
585 | 585 | else{ |
586 | | - // default is to show the hostname of the other wiki which might suck |
| 586 | + // default is to show the hostname of the other wiki which might suck |
587 | 587 | // if there are many wikis on one hostname |
588 | 588 | $parsed = parse_url($t->getFullURL()); |
589 | | - $caption = wfMsg('search-interwiki-default', $parsed['host']); |
590 | | - } |
| 589 | + $caption = wfMsg('search-interwiki-default', $parsed['host']); |
| 590 | + } |
591 | 591 | // "more results" link (special page stuff could be localized, but we might not know target lang) |
592 | | - $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search"); |
| 592 | + $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search"); |
593 | 593 | $searchLink = $this->sk->makeKnownLinkObj( $searchTitle, wfMsg('search-interwiki-more'), |
594 | | - wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search'))); |
| 594 | + wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search'))); |
595 | 595 | $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'> |
596 | 596 | {$searchLink}</span>{$caption}</div>\n<ul>"; |
597 | 597 | } |
598 | 598 | |
599 | | - $out .= "<li>{$link} {$redirect}</li>\n"; |
| 599 | + $out .= "<li>{$link} {$redirect}</li>\n"; |
600 | 600 | wfProfileOut( __METHOD__ ); |
601 | 601 | return $out; |
602 | 602 | } |
603 | | - |
604 | 603 | |
| 604 | + |
605 | 605 | /** |
606 | 606 | * Generates the power search box at bottom of [[Special:Search]] |
607 | 607 | * @param $term string: search term |
— | — | @@ -619,13 +619,13 @@ |
620 | 620 | array( 'type' => 'text') ); |
621 | 621 | $searchButton = Xml::submitButton( wfMsg( 'powersearch' ) ) . "\n"; |
622 | 622 | $searchTitle = SpecialPage::getTitleFor( 'Search' ); |
623 | | - |
| 623 | + |
624 | 624 | $redirectText = ''; |
625 | | - // show redirects check only if backend supports it |
| 625 | + // show redirects check only if backend supports it |
626 | 626 | if( $this->searchEngine->acceptListRedirects() ) { |
627 | 627 | $redirectText = "<p>". $redirect . " " . $redirectLabel ."</p>"; |
628 | 628 | } |
629 | | - |
| 629 | + |
630 | 630 | $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) . |
631 | 631 | Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n" . |
632 | 632 | "<p>" . |
— | — | @@ -633,7 +633,7 @@ |
634 | 634 | "</p>\n" . |
635 | 635 | '<input type="hidden" name="advanced" value="'.$this->searchAdvanced."\"/>\n". |
636 | 636 | $tables . |
637 | | - "<hr style=\"clear: both;\" />\n". |
| 637 | + "<hr style=\"clear: both;\" />\n". |
638 | 638 | $redirectText ."\n". |
639 | 639 | "<div style=\"padding-top:2px;padding-bottom:2px;\">". |
640 | 640 | $searchField . |
— | — | @@ -648,10 +648,10 @@ |
649 | 649 | } */ |
650 | 650 | return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) . |
651 | 651 | Xml::element( 'legend', null, wfMsg('powersearch-legend') ) . |
652 | | - $this->formHeader($term) . $out . $this->didYouMeanHtml . |
| 652 | + $out . $this->didYouMeanHtml . |
653 | 653 | Xml::closeElement( 'fieldset' ); |
654 | 654 | } |
655 | | - |
| 655 | + |
656 | 656 | protected function searchFocus() { |
657 | 657 | global $wgJsMimeType; |
658 | 658 | return "<script type=\"$wgJsMimeType\">" . |
— | — | @@ -670,70 +670,87 @@ |
671 | 671 | "</script>"; |
672 | 672 | } |
673 | 673 | |
674 | | - protected function formHeader( $term ) { |
| 674 | + protected function formHeader( $term, $resultsShown, $totalNum ) { |
675 | 675 | global $wgContLang, $wgCanonicalNamespaceNames, $wgLang; |
676 | | - |
| 676 | + |
677 | 677 | $sep = ' '; |
678 | | - $out = Xml::openElement('div', array( 'style' => 'padding-bottom:0.5em;' ) ); |
| 678 | + $out = Xml::openElement('div', array( 'class' => 'mw-search-formheader' ) ); |
| 679 | + $out .= Xml::openElement('div'); |
679 | 680 | |
680 | 681 | $bareterm = $term; |
681 | 682 | if( $this->startsWithImage( $term ) ) |
682 | 683 | $bareterm = substr( $term, strpos( $term, ':' ) + 1 ); // delete all/image prefix |
683 | | - |
| 684 | + |
684 | 685 | $nsAllSet = array_keys( SearchEngine::searchableNamespaces() ); |
685 | 686 | |
686 | 687 | // search profiles headers |
687 | 688 | $m = wfMsg( 'searchprofile-articles' ); |
688 | | - $tt = wfMsg( 'searchprofile-articles-tooltip', |
| 689 | + $tt = wfMsg( 'searchprofile-articles-tooltip', |
689 | 690 | $wgLang->commaList( SearchEngine::namespacesAsText( SearchEngine::defaultNamespaces() ) ) ); |
| 691 | + $tt = Sanitizer::decodeCharReferences( $tt ); // need to allow entities |
690 | 692 | if( $this->active == 'default' ) { |
691 | | - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
| 693 | + $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
692 | 694 | } else { |
693 | 695 | $out .= $this->makeSearchLink( $bareterm, SearchEngine::defaultNamespaces(), $m, $tt ); |
694 | 696 | } |
695 | 697 | $out .= $sep; |
696 | | - |
| 698 | + |
697 | 699 | $m = wfMsg( 'searchprofile-images' ); |
698 | 700 | $tt = wfMsg( 'searchprofile-images-tooltip' ); |
699 | 701 | if( $this->active == 'images' ) { |
700 | | - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
| 702 | + $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
701 | 703 | } else { |
702 | | - $imageTextForm = $wgContLang->getFormattedNsText(NS_FILE).':'.$bareterm; |
703 | | - $out .= $this->makeSearchLink( $imageTextForm, array( NS_FILE ) , $m, $tt ); |
| 704 | + $out .= $this->makeSearchLink( $bareterm, array( NS_FILE ) , $m, $tt ); |
704 | 705 | } |
705 | 706 | $out .= $sep; |
706 | 707 | |
707 | 708 | $m = wfMsg( 'searchprofile-project' ); |
708 | | - $tt = wfMsg( 'searchprofile-project-tooltip', |
709 | | - $wgLang->commaList( SearchEngine::namespacesAsText( SearchEngine::projectNamespaces() ) ) ); |
710 | | - if( $this->active == 'project' ) { |
711 | | - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
| 709 | + $tt = wfMsg( 'searchprofile-project-tooltip', |
| 710 | + $wgLang->commaList( SearchEngine::namespacesAsText( SearchEngine::helpNamespaces() ) ) ); |
| 711 | + $tt = Sanitizer::decodeCharReferences( $tt ); // need to allow entities |
| 712 | + if( $this->active == 'help' ) { |
| 713 | + $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
712 | 714 | } else { |
713 | | - $out .= $this->makeSearchLink( $bareterm, SearchEngine::projectNamespaces(), $m, $tt ); |
| 715 | + $out .= $this->makeSearchLink( $bareterm, SearchEngine::helpNamespaces(), $m, $tt ); |
714 | 716 | } |
715 | 717 | $out .= $sep; |
716 | | - |
| 718 | + |
717 | 719 | $m = wfMsg( 'searchprofile-everything' ); |
718 | 720 | $tt = wfMsg( 'searchprofile-everything-tooltip' ); |
719 | 721 | if( $this->active == 'all' ) { |
720 | | - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
| 722 | + $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
721 | 723 | } else { |
722 | 724 | $out .= $this->makeSearchLink( $bareterm, $nsAllSet, $m, $tt ); |
723 | 725 | } |
724 | 726 | $out .= $sep; |
725 | | - |
| 727 | + |
726 | 728 | $m = wfMsg( 'searchprofile-advanced' ); |
727 | 729 | $tt = wfMsg( 'searchprofile-advanced-tooltip' ); |
728 | 730 | if( $this->active == 'advanced' ) { |
729 | | - $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
| 731 | + $out .= Xml::element( 'strong', array( 'title'=>$tt ), $m ); |
730 | 732 | } else { |
731 | 733 | $out .= $this->makeSearchLink( $bareterm, $this->namespaces, $m, $tt, array( 'advanced' => '1' ) ); |
732 | 734 | } |
733 | 735 | $out .= Xml::closeElement('div') ; |
734 | 736 | |
| 737 | + if ( $resultsShown > 0 ) { |
| 738 | + if ( $totalNum > 0 ){ |
| 739 | + $top = wfMsgExt('showingresultsheader', array( 'parseinline' ), |
| 740 | + $this->offset+1, $this->offset+$resultsShown, $totalNum, $term, $resultsShown ); |
| 741 | + } elseif ( $resultsShown >= $this->limit ) { |
| 742 | + $top = wfShowingResults( $this->offset, $this->limit ); |
| 743 | + } else { |
| 744 | + $top = wfShowingResultsNum( $this->offset, $this->limit, $resultsShown ); |
| 745 | + } |
| 746 | + $out .= "<p>{$top}</p>\n"; |
| 747 | + } else |
| 748 | + $out .= "<p> </p>\n"; |
| 749 | + |
| 750 | + $out .= Xml::closeElement('div') ; |
| 751 | + |
735 | 752 | return $out; |
736 | 753 | } |
737 | | - |
| 754 | + |
738 | 755 | protected function shortDialog( $term ) { |
739 | 756 | global $wgScript; |
740 | 757 | $searchTitle = SpecialPage::getTitleFor( 'Search' ); |
— | — | @@ -760,19 +777,16 @@ |
761 | 778 | $out .= Xml::input( 'search', 50, $term, array( 'type' => 'text', 'id' => 'searchText' ) ) . "\n"; |
762 | 779 | $out .= Xml::hidden( 'fulltext', 'Search' ); |
763 | 780 | $out .= Xml::submitButton( wfMsg( 'searchbutton' ) ); |
764 | | - $out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')'; |
| 781 | + //$out .= ' (' . wfMsgExt('searchmenu-help',array('parseinline') ) . ')'; |
765 | 782 | $out .= Xml::closeElement( 'form' ); |
766 | 783 | // Add prefix link for single-namespace searches |
767 | 784 | $t = Title::newFromText( $term ); |
768 | 785 | /*if( $t != null && count($this->namespaces) === 1 ) { |
769 | 786 | $out .= wfMsgExt( 'searchmenu-prefix', array('parseinline'), $term ); |
770 | 787 | }*/ |
771 | | - return Xml::openElement( 'fieldset', array('id' => 'mw-searchoptions','style' => 'margin:0em;') ) . |
772 | | - Xml::element( 'legend', null, wfMsg('searchmenu-legend') ) . |
773 | | - $this->formHeader($term) . $out . $this->didYouMeanHtml . |
774 | | - Xml::closeElement( 'fieldset' ); |
| 788 | + return $out . $this->didYouMeanHtml; |
775 | 789 | } |
776 | | - |
| 790 | + |
777 | 791 | /** Make a search link with some target namespaces */ |
778 | 792 | protected function makeSearchLink( $term, $namespaces, $label, $tooltip, $params=array() ) { |
779 | 793 | $opt = $params; |
— | — | @@ -781,18 +795,18 @@ |
782 | 796 | } |
783 | 797 | $opt['redirs'] = $this->searchRedirects ? 1 : 0; |
784 | 798 | |
785 | | - $st = SpecialPage::getTitleFor( 'Search' ); |
| 799 | + $st = SpecialPage::getTitleFor( 'Search' ); |
786 | 800 | $stParams = wfArrayToCGI( array( 'search' => $term, 'fulltext' => wfMsg( 'search' ) ), $opt ); |
787 | 801 | |
788 | | - return Xml::element( 'a', |
789 | | - array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip ), |
790 | | - $label ); |
| 802 | + return Xml::element( 'a', |
| 803 | + array( 'href'=> $st->getLocalURL( $stParams ), 'title' => $tooltip ), |
| 804 | + $label ); |
791 | 805 | } |
792 | | - |
| 806 | + |
793 | 807 | /** Check if query starts with image: prefix */ |
794 | 808 | protected function startsWithImage( $term ) { |
795 | 809 | global $wgContLang; |
796 | | - |
| 810 | + |
797 | 811 | $p = explode( ':', $term ); |
798 | 812 | if( count( $p ) > 1 ) { |
799 | 813 | return $wgContLang->getNsIndex( $p[0] ) == NS_FILE; |
— | — | @@ -800,6 +814,18 @@ |
801 | 815 | return false; |
802 | 816 | } |
803 | 817 | |
| 818 | + /** Check if query starts with all: prefix */ |
| 819 | + protected function startsWithAll( $term ) { |
| 820 | + |
| 821 | + $allkeyword = wfMsgForContent('searchall'); |
| 822 | + |
| 823 | + $p = explode( ':', $term ); |
| 824 | + if( count( $p ) > 1 ) { |
| 825 | + return $p[0] == $allkeyword; |
| 826 | + } |
| 827 | + return false; |
| 828 | + } |
| 829 | + |
804 | 830 | protected function namespaceTables( $namespaces, $rowsPerTable = 3 ) { |
805 | 831 | global $wgContLang; |
806 | 832 | // Group namespaces into rows according to subject. |
— | — | @@ -861,7 +887,7 @@ |
862 | 888 | } |
863 | 889 | |
864 | 890 | $this->searchRedirects = $request->getcheck( 'redirs' ) ? true : false; |
865 | | - $this->fulltext = $request->getVal('fulltext'); |
| 891 | + $this->fulltext = $request->getVal('fulltext'); |
866 | 892 | } |
867 | 893 | |
868 | 894 | /** |
— | — | @@ -936,15 +962,15 @@ |
937 | 963 | // did you mean... suggestions |
938 | 964 | if($textMatches && $textMatches->hasSuggestion()){ |
939 | 965 | $st = SpecialPage::getTitleFor( 'Search' ); |
940 | | - |
941 | | - # mirror Go/Search behaviour of original request |
| 966 | + |
| 967 | + # mirror Go/Search behaviour of original request |
942 | 968 | $didYouMeanParams = array( 'search' => $textMatches->getSuggestionQuery() ); |
943 | 969 | if($this->fulltext != NULL) |
944 | | - $didYouMeanParams['fulltext'] = $this->fulltext; |
945 | | - $stParams = wfArrayToCGI( |
| 970 | + $didYouMeanParams['fulltext'] = $this->fulltext; |
| 971 | + $stParams = wfArrayToCGI( |
946 | 972 | $didYouMeanParams, |
947 | 973 | $this->powerSearchOptions() |
948 | | - ); |
| 974 | + ); |
949 | 975 | |
950 | 976 | $suggestLink = $sk->makeKnownLinkObj( $st, |
951 | 977 | $textMatches->getSuggestionSnippet(), |
— | — | @@ -991,7 +1017,7 @@ |
992 | 1018 | return; |
993 | 1019 | } |
994 | 1020 | |
995 | | - $wgOut->addHTML( $this->shortDialog( $term ) ); |
| 1021 | + $wgOut->addHTML( $this->shortDialog( $term ) ); |
996 | 1022 | |
997 | 1023 | // Sometimes the search engine knows there are too many hits |
998 | 1024 | if ($titleMatches instanceof SearchResultTooMany) { |
— | — | @@ -1001,7 +1027,7 @@ |
1002 | 1028 | wfProfileOut( __METHOD__ ); |
1003 | 1029 | return; |
1004 | 1030 | } |
1005 | | - |
| 1031 | + |
1006 | 1032 | // show number of results |
1007 | 1033 | $num = ( $titleMatches ? $titleMatches->numRows() : 0 ) |
1008 | 1034 | + ( $textMatches ? $textMatches->numRows() : 0); |
— | — | @@ -1012,7 +1038,7 @@ |
1013 | 1039 | $totalNum += $textMatches->getTotalHits(); |
1014 | 1040 | if ( $num > 0 ) { |
1015 | 1041 | if ( $totalNum > 0 ){ |
1016 | | - $top = wfMsgExt('showingresultstotal', array( 'parseinline' ), |
| 1042 | + $top = wfMsgExt('showingresultstotal', array( 'parseinline' ), |
1017 | 1043 | $this->offset+1, $this->offset+$num, $totalNum, $num ); |
1018 | 1044 | } elseif ( $num >= $this->limit ) { |
1019 | 1045 | $top = wfShowingResults( $this->offset, $this->limit ); |
— | — | @@ -1050,7 +1076,7 @@ |
1051 | 1077 | if($titleMatches) |
1052 | 1078 | $wgOut->wrapWikiMsg( "==$1==\n", 'textmatches' ); |
1053 | 1079 | else // if no title matches the heading is redundant |
1054 | | - $wgOut->addHTML("<hr/>"); |
| 1080 | + $wgOut->addHTML("<hr/>"); |
1055 | 1081 | } elseif( $num == 0 ) { |
1056 | 1082 | # Don't show the 'no text matches' if we received title matches |
1057 | 1083 | $wgOut->wrapWikiMsg( "==$1==\n", 'notextmatches' ); |
— | — | @@ -1077,7 +1103,7 @@ |
1078 | 1104 | |
1079 | 1105 | #------------------------------------------------------------------ |
1080 | 1106 | # Private methods below this line |
1081 | | - |
| 1107 | + |
1082 | 1108 | /** |
1083 | 1109 | * |
1084 | 1110 | */ |
— | — | @@ -1086,7 +1112,7 @@ |
1087 | 1113 | if( !empty( $term ) ){ |
1088 | 1114 | $wgOut->setPageTitle( wfMsg( 'searchresults') ); |
1089 | 1115 | $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'searchresults-title', $term) ) ); |
1090 | | - } |
| 1116 | + } |
1091 | 1117 | $subtitlemsg = ( Title::newFromText( $term ) ? 'searchsubtitle' : 'searchsubtitleinvalid' ); |
1092 | 1118 | $wgOut->setSubtitle( $wgOut->parse( wfMsg( $subtitlemsg, wfEscapeWikiText($term) ) ) ); |
1093 | 1119 | $wgOut->setArticleRelated( false ); |
— | — | @@ -1126,8 +1152,8 @@ |
1127 | 1153 | } |
1128 | 1154 | |
1129 | 1155 | /** |
1130 | | - * Show whole set of results |
1131 | | - * |
| 1156 | + * Show whole set of results |
| 1157 | + * |
1132 | 1158 | * @param SearchResultSet $matches |
1133 | 1159 | */ |
1134 | 1160 | function showMatches( &$matches ) { |
— | — | @@ -1137,12 +1163,12 @@ |
1138 | 1164 | $terms = $wgContLang->convertForSearchResult( $matches->termMatches() ); |
1139 | 1165 | |
1140 | 1166 | $out = ""; |
1141 | | - |
| 1167 | + |
1142 | 1168 | $infoLine = $matches->getInfo(); |
1143 | 1169 | if( !is_null($infoLine) ) |
1144 | 1170 | $out .= "\n<!-- {$infoLine} -->\n"; |
1145 | | - |
1146 | | - |
| 1171 | + |
| 1172 | + |
1147 | 1173 | $off = $this->offset + 1; |
1148 | 1174 | $out .= "<ul class='mw-search-results'>\n"; |
1149 | 1175 | |
— | — | @@ -1166,12 +1192,12 @@ |
1167 | 1193 | function showHit( $result, $terms ) { |
1168 | 1194 | wfProfileIn( __METHOD__ ); |
1169 | 1195 | global $wgUser, $wgContLang, $wgLang; |
1170 | | - |
| 1196 | + |
1171 | 1197 | if( $result->isBrokenTitle() ) { |
1172 | 1198 | wfProfileOut( __METHOD__ ); |
1173 | 1199 | return "<!-- Broken link in search result -->\n"; |
1174 | 1200 | } |
1175 | | - |
| 1201 | + |
1176 | 1202 | $t = $result->getTitle(); |
1177 | 1203 | $sk = $wgUser->getSkin(); |
1178 | 1204 | |
— | — | @@ -1206,13 +1232,13 @@ |
1207 | 1233 | ."</span>"; |
1208 | 1234 | $section = ''; |
1209 | 1235 | if( !is_null($sectionTitle) ) |
1210 | | - $section = "<span class='searchalttitle'>" |
| 1236 | + $section = "<span class='searchalttitle'>" |
1211 | 1237 | .wfMsg('search-section', $sk->makeKnownLinkObj( $sectionTitle, $sectionText)) |
1212 | 1238 | ."</span>"; |
1213 | 1239 | |
1214 | 1240 | // format text extract |
1215 | 1241 | $extract = "<div class='searchresult'>".$result->getTextSnippet($terms)."</div>"; |
1216 | | - |
| 1242 | + |
1217 | 1243 | // format score |
1218 | 1244 | if( is_null( $result->getScore() ) ) { |
1219 | 1245 | // Search engine doesn't report scoring info |
— | — | @@ -1239,11 +1265,11 @@ |
1240 | 1266 | $stParams = wfArrayToCGI( $this->powerSearchOptions(), |
1241 | 1267 | array('search' => wfMsgForContent('searchrelated').':'.$t->getPrefixedText(), |
1242 | 1268 | 'fulltext' => wfMsg('search') )); |
1243 | | - |
| 1269 | + |
1244 | 1270 | $related = ' -- ' . $sk->makeKnownLinkObj( $st, |
1245 | 1271 | wfMsg('search-relatedarticle'), $stParams ); |
1246 | 1272 | } |
1247 | | - |
| 1273 | + |
1248 | 1274 | // Include a thumbnail for media files... |
1249 | 1275 | if( $t->getNamespace() == NS_FILE ) { |
1250 | 1276 | $img = wfFindFile( $t ); |
— | — | @@ -1283,7 +1309,7 @@ |
1284 | 1310 | |
1285 | 1311 | /** |
1286 | 1312 | * Show results from other wikis |
1287 | | - * |
| 1313 | + * |
1288 | 1314 | * @param SearchResultSet $matches |
1289 | 1315 | */ |
1290 | 1316 | function showInterwiki( &$matches, $query ) { |
— | — | @@ -1292,7 +1318,7 @@ |
1293 | 1319 | global $wgContLang; |
1294 | 1320 | $terms = $wgContLang->convertForSearchResult( $matches->termMatches() ); |
1295 | 1321 | |
1296 | | - $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".wfMsg('search-interwiki-caption')."</div>\n"; |
| 1322 | + $out = "<div id='mw-search-interwiki'><div id='mw-search-interwiki-caption'>".wfMsg('search-interwiki-caption')."</div>\n"; |
1297 | 1323 | $off = $this->offset + 1; |
1298 | 1324 | $out .= "<ul start='{$off}' class='mw-search-iwresults'>\n"; |
1299 | 1325 | |
— | — | @@ -1302,10 +1328,10 @@ |
1303 | 1329 | foreach($customLines as $line){ |
1304 | 1330 | $parts = explode(":",$line,2); |
1305 | 1331 | if(count($parts) == 2) // validate line |
1306 | | - $customCaptions[$parts[0]] = $parts[1]; |
| 1332 | + $customCaptions[$parts[0]] = $parts[1]; |
1307 | 1333 | } |
1308 | | - |
1309 | | - |
| 1334 | + |
| 1335 | + |
1310 | 1336 | $prev = null; |
1311 | 1337 | while( $result = $matches->next() ) { |
1312 | 1338 | $out .= $this->showInterwikiHit( $result, $prev, $terms, $query, $customCaptions ); |
— | — | @@ -1320,30 +1346,30 @@ |
1321 | 1347 | wfProfileOut( __METHOD__ ); |
1322 | 1348 | return $out; |
1323 | 1349 | } |
1324 | | - |
| 1350 | + |
1325 | 1351 | /** |
1326 | 1352 | * Show single interwiki link |
1327 | 1353 | * |
1328 | 1354 | * @param SearchResult $result |
1329 | 1355 | * @param string $lastInterwiki |
1330 | 1356 | * @param array $terms |
1331 | | - * @param string $query |
| 1357 | + * @param string $query |
1332 | 1358 | * @param array $customCaptions iw prefix -> caption |
1333 | 1359 | */ |
1334 | 1360 | function showInterwikiHit( $result, $lastInterwiki, $terms, $query, $customCaptions) { |
1335 | 1361 | wfProfileIn( __METHOD__ ); |
1336 | 1362 | global $wgUser, $wgContLang, $wgLang; |
1337 | | - |
| 1363 | + |
1338 | 1364 | if( $result->isBrokenTitle() ) { |
1339 | 1365 | wfProfileOut( __METHOD__ ); |
1340 | 1366 | return "<!-- Broken link in search result -->\n"; |
1341 | 1367 | } |
1342 | | - |
| 1368 | + |
1343 | 1369 | $t = $result->getTitle(); |
1344 | 1370 | $sk = $wgUser->getSkin(); |
1345 | | - |
| 1371 | + |
1346 | 1372 | $link = $sk->makeKnownLinkObj( $t, $result->getTitleSnippet($terms)); |
1347 | | - |
| 1373 | + |
1348 | 1374 | // format redirect if any |
1349 | 1375 | $redirectTitle = $result->getRedirectTitle(); |
1350 | 1376 | $redirectText = $result->getRedirectSnippet($terms); |
— | — | @@ -1354,30 +1380,30 @@ |
1355 | 1381 | ."</span>"; |
1356 | 1382 | |
1357 | 1383 | $out = ""; |
1358 | | - // display project name |
| 1384 | + // display project name |
1359 | 1385 | if(is_null($lastInterwiki) || $lastInterwiki != $t->getInterwiki()){ |
1360 | 1386 | if( key_exists($t->getInterwiki(),$customCaptions) ) |
1361 | 1387 | // captions from 'search-interwiki-custom' |
1362 | 1388 | $caption = $customCaptions[$t->getInterwiki()]; |
1363 | 1389 | else{ |
1364 | | - // default is to show the hostname of the other wiki which might suck |
| 1390 | + // default is to show the hostname of the other wiki which might suck |
1365 | 1391 | // if there are many wikis on one hostname |
1366 | 1392 | $parsed = parse_url($t->getFullURL()); |
1367 | | - $caption = wfMsg('search-interwiki-default', $parsed['host']); |
1368 | | - } |
| 1393 | + $caption = wfMsg('search-interwiki-default', $parsed['host']); |
| 1394 | + } |
1369 | 1395 | // "more results" link (special page stuff could be localized, but we might not know target lang) |
1370 | | - $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search"); |
| 1396 | + $searchTitle = Title::newFromText($t->getInterwiki().":Special:Search"); |
1371 | 1397 | $searchLink = $sk->makeKnownLinkObj( $searchTitle, wfMsg('search-interwiki-more'), |
1372 | | - wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search'))); |
| 1398 | + wfArrayToCGI(array('search' => $query, 'fulltext' => 'Search'))); |
1373 | 1399 | $out .= "</ul><div class='mw-search-interwiki-project'><span class='mw-search-interwiki-more'>{$searchLink}</span>{$caption}</div>\n<ul>"; |
1374 | 1400 | } |
1375 | 1401 | |
1376 | | - $out .= "<li>{$link} {$redirect}</li>\n"; |
| 1402 | + $out .= "<li>{$link} {$redirect}</li>\n"; |
1377 | 1403 | wfProfileOut( __METHOD__ ); |
1378 | 1404 | return $out; |
1379 | 1405 | } |
1380 | | - |
1381 | 1406 | |
| 1407 | + |
1382 | 1408 | /** |
1383 | 1409 | * Generates the power search box at bottom of [[Special:Search]] |
1384 | 1410 | * @param $term string: search term |
— | — | @@ -1432,9 +1458,9 @@ |
1433 | 1459 | $searchTitle = SpecialPage::getTitleFor( 'Search' ); |
1434 | 1460 | $searchHiddens = Xml::hidden( 'title', $searchTitle->getPrefixedText() ) . "\n"; |
1435 | 1461 | $searchHiddens .= Xml::hidden( 'fulltext', 'Advanced search' ) . "\n"; |
1436 | | - |
| 1462 | + |
1437 | 1463 | $out = Xml::openElement( 'form', array( 'id' => 'powersearch', 'method' => 'get', 'action' => $wgScript ) ) . |
1438 | | - Xml::fieldset( wfMsg( 'powersearch-legend' ), |
| 1464 | + Xml::fieldset( wfMsg( 'powersearch-legend' ), |
1439 | 1465 | "<p>" . |
1440 | 1466 | wfMsgExt( 'powersearch-ns', array( 'parseinline' ) ) . |
1441 | 1467 | "</p>\n" . |
— | — | @@ -1447,7 +1473,7 @@ |
1448 | 1474 | " " . |
1449 | 1475 | $searchField . |
1450 | 1476 | " " . |
1451 | | - $searchHiddens . |
| 1477 | + $searchHiddens . |
1452 | 1478 | $searchButton ) . |
1453 | 1479 | "</form>"; |
1454 | 1480 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialListgrouprights.php |
— | — | @@ -26,6 +26,7 @@ |
27 | 27 | public function execute( $par ) { |
28 | 28 | global $wgOut, $wgImplicitGroups, $wgMessageCache; |
29 | 29 | global $wgGroupPermissions, $wgAddGroups, $wgRemoveGroups; |
| 30 | + global $wgGroupsAddToSelf, $wgGroupsRemoveFromSelf; |
30 | 31 | $wgMessageCache->loadAllMessages(); |
31 | 32 | |
32 | 33 | $this->setHeaders(); |
— | — | @@ -76,13 +77,16 @@ |
77 | 78 | $addgroups = isset( $wgAddGroups[$group] ) ? $wgAddGroups[$group] : array(); |
78 | 79 | $removegroups = isset( $wgRemoveGroups[$group] ) ? $wgRemoveGroups[$group] : array(); |
79 | 80 | |
| 81 | + $addgroupsSelf = isset( $wgGroupsAddToSelf[$group] ) ? $wgGroupsAddToSelf[$group] : array(); |
| 82 | + $removegroupsSelf = isset( $wgGroupsRemoveFromSelf[$group] ) ? $wgGroupsRemoveFromSelf[$group] : array(); |
| 83 | + |
80 | 84 | $wgOut->addHTML( |
81 | 85 | '<tr> |
82 | 86 | <td>' . |
83 | 87 | $grouppage . $grouplink . |
84 | 88 | '</td> |
85 | 89 | <td>' . |
86 | | - self::formatPermissions( $permissions, $addgroups, $removegroups ) . |
| 90 | + self::formatPermissions( $permissions, $addgroups, $removegroups, $addgroupsSelf, $removegroupsSelf ) . |
87 | 91 | '</td> |
88 | 92 | </tr>' |
89 | 93 | ); |
— | — | @@ -98,7 +102,7 @@ |
99 | 103 | * @param $permissions Array of permission => bool (from $wgGroupPermissions items) |
100 | 104 | * @return string List of all granted permissions, separated by comma separator |
101 | 105 | */ |
102 | | - private static function formatPermissions( $permissions, $add, $remove ) { |
| 106 | + private static function formatPermissions( $permissions, $add, $remove, $addSelf, $removeSelf ) { |
103 | 107 | global $wgLang; |
104 | 108 | $r = array(); |
105 | 109 | foreach( $permissions as $permission => $granted ) { |
— | — | @@ -121,6 +125,16 @@ |
122 | 126 | } else if( is_array( $remove ) && count( $remove ) ) { |
123 | 127 | $r[] = wfMsgExt( 'listgrouprights-removegroup', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $remove ) ), count( $remove ) ); |
124 | 128 | } |
| 129 | + if( $addSelf === true ){ |
| 130 | + $r[] = wfMsgExt( 'listgrouprights-addgroup-self-all', array( 'escape' ) ); |
| 131 | + } else if( is_array( $addSelf ) && count( $addSelf ) ) { |
| 132 | + $r[] = wfMsgExt( 'listgrouprights-addgroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $addSelf ) ), count( $addSelf ) ); |
| 133 | + } |
| 134 | + if( $removeSelf === true ){ |
| 135 | + $r[] = wfMsgExt( 'listgrouprights-removegroup-self-all', array( 'escape' ) ); |
| 136 | + } else if( is_array( $removeSelf ) && count( $removeSelf ) ) { |
| 137 | + $r[] = wfMsgExt( 'listgrouprights-removegroup-self', array( 'parseinline' ), $wgLang->listToText( array_map( array( 'User', 'makeGroupLinkWiki' ), $removeSelf ) ), count( $removeSelf ) ); |
| 138 | + } |
125 | 139 | if( empty( $r ) ) { |
126 | 140 | return ''; |
127 | 141 | } else { |
Index: branches/querypage-work/phase3/includes/specials/SpecialMostlinked.php |
— | — | @@ -76,7 +76,7 @@ |
77 | 77 | function formatResult( $skin, $result ) { |
78 | 78 | global $wgLang; |
79 | 79 | $title = Title::makeTitleSafe( $result->namespace, $result->title ); |
80 | | - $link = $skin->makeLinkObj( $title ); |
| 80 | + $link = $skin->link( $title ); |
81 | 81 | $wlh = $this->makeWlhLink( $title, |
82 | 82 | wfMsgExt( 'nlinks', array( 'parsemag', 'escape'), |
83 | 83 | $wgLang->formatNum( $result->value ) ), $skin ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialProtectedpages.php |
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | $skin = $wgUser->getSkin(); |
67 | 67 | |
68 | 68 | $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title ); |
69 | | - $link = $skin->makeLinkObj( $title ); |
| 69 | + $link = $skin->link( $title ); |
70 | 70 | |
71 | 71 | $description_items = array (); |
72 | 72 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialMIMEsearch.php |
— | — | @@ -72,7 +72,7 @@ |
73 | 73 | $wgLang->formatNum( $result->img_size ) ); |
74 | 74 | $dimensions = wfMsgHtml( 'widthheight', $wgLang->formatNum( $result->img_width ), |
75 | 75 | $wgLang->formatNum( $result->img_height ) ); |
76 | | - $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); |
| 76 | + $user = $skin->link( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); |
77 | 77 | $time = $wgLang->timeanddate( $result->img_timestamp ); |
78 | 78 | |
79 | 79 | return "($download) $plink . . $dimensions . . $bytes . . $user . . $time"; |
Index: branches/querypage-work/phase3/includes/specials/SpecialRandompage.php |
— | — | @@ -36,8 +36,9 @@ |
37 | 37 | public function execute( $par ) { |
38 | 38 | global $wgOut, $wgContLang; |
39 | 39 | |
40 | | - if ($par) |
| 40 | + if ($par) { |
41 | 41 | $this->setNamespace( $wgContLang->getNsIndex( $par ) ); |
| 42 | + } |
42 | 43 | |
43 | 44 | $title = $this->getRandomTitle(); |
44 | 45 | |
— | — | @@ -78,8 +79,6 @@ |
79 | 80 | |
80 | 81 | private function selectRandomPageFromDB( $randstr ) { |
81 | 82 | global $wgExtraRandompageSQL; |
82 | | - $fname = 'RandomPage::selectRandomPageFromDB'; |
83 | | - |
84 | 83 | $dbr = wfGetDB( DB_SLAVE ); |
85 | 84 | |
86 | 85 | $use_index = $dbr->useIndexClause( 'page_random' ); |
— | — | @@ -98,7 +97,7 @@ |
99 | 98 | ORDER BY page_random"; |
100 | 99 | |
101 | 100 | $sql = $dbr->limitResult( $sql, 1, 0 ); |
102 | | - $res = $dbr->query( $sql, $fname ); |
| 101 | + $res = $dbr->query( $sql, __METHOD__ ); |
103 | 102 | return $dbr->fetchObject( $res ); |
104 | 103 | } |
105 | 104 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialBlockip.php |
— | — | @@ -11,13 +11,11 @@ |
12 | 12 | */ |
13 | 13 | function wfSpecialBlockip( $par ) { |
14 | 14 | global $wgUser, $wgOut, $wgRequest; |
15 | | - |
16 | 15 | # Can't block when the database is locked |
17 | 16 | if( wfReadOnly() ) { |
18 | 17 | $wgOut->readOnlyPage(); |
19 | 18 | return; |
20 | 19 | } |
21 | | - |
22 | 20 | # Permission check |
23 | 21 | if( !$wgUser->isAllowed( 'block' ) ) { |
24 | 22 | $wgOut->permissionRequired( 'block' ); |
— | — | @@ -27,9 +25,9 @@ |
28 | 26 | $ipb = new IPBlockForm( $par ); |
29 | 27 | |
30 | 28 | $action = $wgRequest->getVal( 'action' ); |
31 | | - if ( 'success' == $action ) { |
| 29 | + if( 'success' == $action ) { |
32 | 30 | $ipb->showSuccess(); |
33 | | - } else if ( $wgRequest->wasPosted() && 'submit' == $action && |
| 31 | + } else if( $wgRequest->wasPosted() && 'submit' == $action && |
34 | 32 | $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) { |
35 | 33 | $ipb->doSubmit(); |
36 | 34 | } else { |
— | — | @@ -44,9 +42,10 @@ |
45 | 43 | */ |
46 | 44 | class IPBlockForm { |
47 | 45 | var $BlockAddress, $BlockExpiry, $BlockReason; |
48 | | -# var $BlockEmail; |
| 46 | + // The maximum number of edits a user can have and still be hidden |
| 47 | + const HIDEUSER_CONTRIBLIMIT = 1000; |
49 | 48 | |
50 | | - function IPBlockForm( $par ) { |
| 49 | + public function __construct( $par ) { |
51 | 50 | global $wgRequest, $wgUser, $wgBlockAllowsUTEdit; |
52 | 51 | |
53 | 52 | $this->BlockAddress = $wgRequest->getVal( 'wpBlockAddress', $wgRequest->getVal( 'ip', $par ) ); |
— | — | @@ -70,7 +69,7 @@ |
71 | 70 | $this->BlockReblock = $wgRequest->getBool( 'wpChangeBlock', false ); |
72 | 71 | } |
73 | 72 | |
74 | | - function showForm( $err ) { |
| 73 | + public function showForm( $err ) { |
75 | 74 | global $wgOut, $wgUser, $wgSysopUserBans; |
76 | 75 | |
77 | 76 | $wgOut->setPagetitle( wfMsg( 'blockip' ) ); |
— | — | @@ -90,17 +89,17 @@ |
91 | 90 | $user = User::newFromName( $this->BlockAddress ); |
92 | 91 | |
93 | 92 | $alreadyBlocked = false; |
94 | | - if ( $err && $err[0] != 'ipb_already_blocked' ) { |
| 93 | + if( $err && $err[0] != 'ipb_already_blocked' ) { |
95 | 94 | $key = array_shift($err); |
96 | 95 | $msg = wfMsgReal($key, $err); |
97 | 96 | $wgOut->setSubtitle( wfMsgHtml( 'formerror' ) ); |
98 | 97 | $wgOut->addHTML( Xml::tags( 'p', array( 'class' => 'error' ), $msg ) ); |
99 | | - } elseif ( $this->BlockAddress ) { |
| 98 | + } elseif( $this->BlockAddress ) { |
100 | 99 | $userId = 0; |
101 | | - if ( is_object( $user ) ) |
| 100 | + if( is_object( $user ) ) |
102 | 101 | $userId = $user->getId(); |
103 | 102 | $currentBlock = Block::newFromDB( $this->BlockAddress, $userId ); |
104 | | - if ( !is_null($currentBlock) && !$currentBlock->mAuto && # The block exists and isn't an autoblock |
| 103 | + if( !is_null($currentBlock) && !$currentBlock->mAuto && # The block exists and isn't an autoblock |
105 | 104 | ( $currentBlock->mRangeStart == $currentBlock->mRangeEnd || # The block isn't a rangeblock |
106 | 105 | # or if it is, the range is what we're about to block |
107 | 106 | ( $currentBlock->mAddress == $this->BlockAddress ) ) ) { |
— | — | @@ -125,12 +124,11 @@ |
126 | 125 | $scBlockExpiryOptions = wfMsgForContent( 'ipboptions' ); |
127 | 126 | |
128 | 127 | $showblockoptions = $scBlockExpiryOptions != '-'; |
129 | | - if (!$showblockoptions) |
130 | | - $mIpbother = $mIpbexpiry; |
| 128 | + if( !$showblockoptions ) $mIpbother = $mIpbexpiry; |
131 | 129 | |
132 | 130 | $blockExpiryFormOptions = Xml::option( wfMsg( 'ipbotheroption' ), 'other' ); |
133 | 131 | foreach (explode(',', $scBlockExpiryOptions) as $option) { |
134 | | - if ( strpos($option, ":") === false ) $option = "$option:$option"; |
| 132 | + if( strpos($option, ":") === false ) $option = "$option:$option"; |
135 | 133 | list($show, $value) = explode(":", $option); |
136 | 134 | $show = htmlspecialchars($show); |
137 | 135 | $value = htmlspecialchars($value); |
— | — | @@ -162,7 +160,7 @@ |
163 | 161 | </tr> |
164 | 162 | <tr>" |
165 | 163 | ); |
166 | | - if ( $showblockoptions ) { |
| 164 | + if( $showblockoptions ) { |
167 | 165 | $wgOut->addHTML(" |
168 | 166 | <td class='mw-label'> |
169 | 167 | {$mIpbexpiry} |
— | — | @@ -233,7 +231,7 @@ |
234 | 232 | ); |
235 | 233 | |
236 | 234 | global $wgSysopEmailBans, $wgBlockAllowsUTEdit; |
237 | | - if ( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { |
| 235 | + if( $wgSysopEmailBans && $wgUser->isAllowed( 'blockemail' ) ) { |
238 | 236 | $wgOut->addHTML(" |
239 | 237 | <tr id='wpEnableEmailBan'> |
240 | 238 | <td> </td> |
— | — | @@ -247,7 +245,7 @@ |
248 | 246 | } |
249 | 247 | |
250 | 248 | // Allow some users to hide name from block log, blocklist and listusers |
251 | | - if ( $wgUser->isAllowed( 'hideuser' ) ) { |
| 249 | + if( $wgUser->isAllowed( 'hideuser' ) ) { |
252 | 250 | $wgOut->addHTML(" |
253 | 251 | <tr id='wpEnableHideUser'> |
254 | 252 | <td> </td> |
— | — | @@ -328,12 +326,12 @@ |
329 | 327 | $rxIP = "($rxIP4|$rxIP6)"; |
330 | 328 | |
331 | 329 | # Check for invalid specifications |
332 | | - if ( !preg_match( "/^$rxIP$/", $this->BlockAddress ) ) { |
| 330 | + if( !preg_match( "/^$rxIP$/", $this->BlockAddress ) ) { |
333 | 331 | $matches = array(); |
334 | | - if ( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { |
| 332 | + if( preg_match( "/^($rxIP4)\\/(\\d{1,2})$/", $this->BlockAddress, $matches ) ) { |
335 | 333 | # IPv4 |
336 | | - if ( $wgSysopRangeBans ) { |
337 | | - if ( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) { |
| 334 | + if( $wgSysopRangeBans ) { |
| 335 | + if( !IP::isIPv4( $this->BlockAddress ) || $matches[2] < 16 || $matches[2] > 32 ) { |
338 | 336 | return array('ip_range_invalid'); |
339 | 337 | } |
340 | 338 | $this->BlockAddress = Block::normaliseRange( $this->BlockAddress ); |
— | — | @@ -341,10 +339,10 @@ |
342 | 340 | # Range block illegal |
343 | 341 | return array('range_block_disabled'); |
344 | 342 | } |
345 | | - } else if ( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) { |
| 343 | + } else if( preg_match( "/^($rxIP6)\\/(\\d{1,3})$/", $this->BlockAddress, $matches ) ) { |
346 | 344 | # IPv6 |
347 | | - if ( $wgSysopRangeBans ) { |
348 | | - if ( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) { |
| 345 | + if( $wgSysopRangeBans ) { |
| 346 | + if( !IP::isIPv6( $this->BlockAddress ) || $matches[2] < 64 || $matches[2] > 128 ) { |
349 | 347 | return array('ip_range_invalid'); |
350 | 348 | } |
351 | 349 | $this->BlockAddress = Block::normaliseRange( $this->BlockAddress ); |
— | — | @@ -354,7 +352,7 @@ |
355 | 353 | } |
356 | 354 | } else { |
357 | 355 | # Username block |
358 | | - if ( $wgSysopUserBans ) { |
| 356 | + if( $wgSysopUserBans ) { |
359 | 357 | $user = User::newFromName( $this->BlockAddress ); |
360 | 358 | if( !is_null( $user ) && $user->getId() ) { |
361 | 359 | # Use canonical name |
— | — | @@ -369,15 +367,15 @@ |
370 | 368 | } |
371 | 369 | } |
372 | 370 | |
373 | | - if ( $wgUser->isBlocked() && ( $wgUser->getId() !== $userId ) ) { |
| 371 | + if( $wgUser->isBlocked() && ( $wgUser->getId() !== $userId ) ) { |
374 | 372 | return array( 'cant-block-while-blocked' ); |
375 | 373 | } |
376 | 374 | |
377 | 375 | $reasonstr = $this->BlockReasonList; |
378 | | - if ( $reasonstr != 'other' && $this->BlockReason != '' ) { |
| 376 | + if( $reasonstr != 'other' && $this->BlockReason != '' ) { |
379 | 377 | // Entry from drop down menu + additional comment |
380 | 378 | $reasonstr .= wfMsgForContent( 'colon-separator' ) . $this->BlockReason; |
381 | | - } elseif ( $reasonstr == 'other' ) { |
| 379 | + } elseif( $reasonstr == 'other' ) { |
382 | 380 | $reasonstr = $this->BlockReason; |
383 | 381 | } |
384 | 382 | |
— | — | @@ -385,11 +383,11 @@ |
386 | 384 | if( $expirestr == 'other' ) |
387 | 385 | $expirestr = $this->BlockOther; |
388 | 386 | |
389 | | - if ( ( strlen( $expirestr ) == 0) || ( strlen( $expirestr ) > 50) ) { |
| 387 | + if( ( strlen( $expirestr ) == 0) || ( strlen( $expirestr ) > 50) ) { |
390 | 388 | return array('ipb_expiry_invalid'); |
391 | 389 | } |
392 | 390 | |
393 | | - if ( false === ($expiry = Block::parseExpiryInput( $expirestr )) ) { |
| 391 | + if( false === ($expiry = Block::parseExpiryInput( $expirestr )) ) { |
394 | 392 | // Bad expiry. |
395 | 393 | return array('ipb_expiry_invalid'); |
396 | 394 | } |
— | — | @@ -397,19 +395,18 @@ |
398 | 396 | if( $this->BlockHideName ) { |
399 | 397 | // Recheck params here... |
400 | 398 | if( !$userId || !$wgUser->isAllowed('hideuser') ) { |
401 | | - // IP users should not be hidden |
402 | | - $this->BlockHideName = false; |
| 399 | + $this->BlockHideName = false; // IP users should not be hidden |
403 | 400 | } else if( $expiry !== 'infinity' ) { |
404 | 401 | // Bad expiry. |
405 | 402 | return array('ipb_expiry_temp'); |
406 | | - } else if( User::edits($userId) > 3000 ) { |
| 403 | + } else if( User::edits($userId) > self::HIDEUSER_CONTRIBLIMIT ) { |
407 | 404 | // Typically, the user should have a handful of edits. |
408 | 405 | // Disallow hiding users with many edits for performance. |
409 | 406 | return array('ipb_hide_invalid'); |
410 | 407 | } |
411 | 408 | } |
412 | 409 | |
413 | | - # Create block |
| 410 | + # Create block object |
414 | 411 | # Note: for a user block, ipb_address is only for display purposes |
415 | 412 | $block = new Block( $this->BlockAddress, $userId, $wgUser->getId(), |
416 | 413 | $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, |
— | — | @@ -419,11 +416,11 @@ |
420 | 417 | |
421 | 418 | # Should this be privately logged? |
422 | 419 | $suppressLog = (bool)$this->BlockHideName; |
423 | | - if ( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { |
| 420 | + if( wfRunHooks('BlockIp', array(&$block, &$wgUser)) ) { |
424 | 421 | # Try to insert block. Is there a conflicting block? |
425 | | - if ( !$block->insert() ) { |
| 422 | + if( !$block->insert() ) { |
426 | 423 | # Show form unless the user is already aware of this... |
427 | | - if ( !$this->BlockReblock ) { |
| 424 | + if( !$this->BlockReblock ) { |
428 | 425 | return array( 'ipb_already_blocked' ); |
429 | 426 | # Otherwise, try to update the block... |
430 | 427 | } else { |
— | — | @@ -445,7 +442,7 @@ |
446 | 443 | $log_action = 'reblock'; |
447 | 444 | # Unset _deleted fields if requested |
448 | 445 | if( $currentBlock->mHideName && !$this->BlockHideName ) { |
449 | | - $this->unsuppressUserName( $this->BlockAddress, $userId ); |
| 446 | + self::unsuppressUserName( $this->BlockAddress, $userId ); |
450 | 447 | } |
451 | 448 | } |
452 | 449 | } else { |
— | — | @@ -455,13 +452,12 @@ |
456 | 453 | |
457 | 454 | # Set *_deleted fields if requested |
458 | 455 | if( $this->BlockHideName ) { |
459 | | - $this->suppressUserName( $this->BlockAddress, $userId ); |
| 456 | + self::suppressUserName( $this->BlockAddress, $userId, $reasonstr ); |
460 | 457 | } |
461 | 458 | |
462 | | - if ( $this->BlockWatchUser && |
463 | | - # Only show watch link when this is no range block |
464 | | - $block->mRangeStart == $block->mRangeEnd) { |
465 | | - $wgUser->addWatch ( Title::makeTitle( NS_USER, $this->BlockAddress ) ); |
| 459 | + # Only show watch link when this is no range block |
| 460 | + if( $this->BlockWatchUser && $block->mRangeStart == $block->mRangeEnd ) { |
| 461 | + $wgUser->addWatch( Title::makeTitle( NS_USER, $this->BlockAddress ) ); |
466 | 462 | } |
467 | 463 | |
468 | 464 | # Block constructor sanitizes certain block options on insert |
— | — | @@ -477,7 +473,7 @@ |
478 | 474 | $log_type = $suppressLog ? 'suppress' : 'block'; |
479 | 475 | $log = new LogPage( $log_type ); |
480 | 476 | $log->addEntry( $log_action, Title::makeTitle( NS_USER, $this->BlockAddress ), |
481 | | - $reasonstr, $logParams ); |
| 477 | + $reasonstr, $logParams ); |
482 | 478 | |
483 | 479 | # Report to the user |
484 | 480 | return array(); |
— | — | @@ -486,17 +482,30 @@ |
487 | 483 | } |
488 | 484 | } |
489 | 485 | |
490 | | - private function suppressUserName( $name, $userId ) { |
| 486 | + public static function suppressUserName( $name, $userId, $reason = '' ) { |
| 487 | + $user = User::newFromName( $name, false ); |
| 488 | + # Delete the user pages that exists |
| 489 | + $title = $user->getUserPage(); |
| 490 | + if( ($id = $title->getArticleID(GAID_FOR_UPDATE)) ) { |
| 491 | + $article = new Article( $title ); |
| 492 | + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); |
| 493 | + } |
| 494 | + # Delete the user talk pages that exists |
| 495 | + $title = $user->getTalkPage(); |
| 496 | + if( $id = $title->getArticleID(GAID_FOR_UPDATE) ) { |
| 497 | + $article = new Article( $title ); |
| 498 | + $article->doDeleteArticle( $reason, true /*suppress*/, $id ); |
| 499 | + } |
491 | 500 | $op = '|'; // bitwise OR |
492 | | - return $this->setUsernameBitfields( $name, $userId, $op ); |
| 501 | + return self::setUsernameBitfields( $name, $userId, $op ); |
493 | 502 | } |
494 | 503 | |
495 | | - private function unsuppressUserName( $name, $userId ) { |
| 504 | + public static function unsuppressUserName( $name, $userId ) { |
496 | 505 | $op = '&'; // bitwise AND |
497 | | - return $this->setUsernameBitfields( $name, $userId, $op ); |
| 506 | + return self::setUsernameBitfields( $name, $userId, $op ); |
498 | 507 | } |
499 | 508 | |
500 | | - private function setUsernameBitfields( $name, $userId, $op ) { |
| 509 | + private static function setUsernameBitfields( $name, $userId, $op ) { |
501 | 510 | if( $op !== '|' && $op !== '&' ) return false; // sanity check |
502 | 511 | $dbw = wfGetDB( DB_MASTER ); |
503 | 512 | $delUser = Revision::DELETED_USER | Revision::DELETED_RESTRICTED; |
— | — | @@ -509,14 +518,16 @@ |
510 | 519 | # current bitfields with the inverse of Revision::DELETED_USER. The |
511 | 520 | # username bit is made to 0 (x & 0 = 0), while others are unchanged (x & 1 = x). |
512 | 521 | # The same goes for the sysop-restricted *_deleted bit. |
513 | | - if( $op == '&' ) $delUser = "~{$delUser}"; |
514 | | - if( $op == '&' ) $delAction = "~{$delAction}"; |
| 522 | + if( $op == '&' ) { |
| 523 | + $delUser = "~{$delUser}"; |
| 524 | + $delAction = "~{$delAction}"; |
| 525 | + } |
515 | 526 | # Hide name from live edits |
516 | 527 | $dbw->update( 'revision', array("rev_deleted = rev_deleted $op $delUser"), |
517 | 528 | array('rev_user' => $userId), __METHOD__ ); |
518 | 529 | # Hide name from deleted edits |
519 | 530 | $dbw->update( 'archive', array("ar_deleted = ar_deleted $op $delUser"), |
520 | | - array('ar_user_text' => $userId), __METHOD__ ); |
| 531 | + array('ar_user_text' => $name), __METHOD__ ); |
521 | 532 | # Hide name from logs |
522 | 533 | $dbw->update( 'logging', array("log_deleted = log_deleted $op $delUser"), |
523 | 534 | array('log_user' => $userId, "log_type != 'suppress'"), __METHOD__ ); |
— | — | @@ -543,11 +554,10 @@ |
544 | 555 | * UI entry point for blocking |
545 | 556 | * Wraps around doBlock() |
546 | 557 | */ |
547 | | - function doSubmit() |
548 | | - { |
| 558 | + public function doSubmit() { |
549 | 559 | global $wgOut; |
550 | 560 | $retval = $this->doBlock(); |
551 | | - if(empty($retval)) { |
| 561 | + if( empty($retval) ) { |
552 | 562 | $titleObj = SpecialPage::getTitleFor( 'Blockip' ); |
553 | 563 | $wgOut->redirect( $titleObj->getFullURL( 'action=success&ip=' . |
554 | 564 | urlencode( $this->BlockAddress ) ) ); |
— | — | @@ -556,7 +566,7 @@ |
557 | 567 | $this->showForm( $retval ); |
558 | 568 | } |
559 | 569 | |
560 | | - function showSuccess() { |
| 570 | + public function showSuccess() { |
561 | 571 | global $wgOut; |
562 | 572 | |
563 | 573 | $wgOut->setPagetitle( wfMsg( 'blockip' ) ); |
— | — | @@ -565,7 +575,7 @@ |
566 | 576 | $wgOut->addHTML( $text ); |
567 | 577 | } |
568 | 578 | |
569 | | - function showLogFragment( $out, $title ) { |
| 579 | + private function showLogFragment( $out, $title ) { |
570 | 580 | global $wgUser; |
571 | 581 | $out->addHTML( Xml::element( 'h2', NULL, LogPage::logName( 'block' ) ) ); |
572 | 582 | $count = LogEventsList::showLogExtract( $out, 'block', $title->getPrefixedText(), '', 10 ); |
— | — | @@ -603,11 +613,11 @@ |
604 | 614 | if( !$this->BlockEnableAutoblock && !IP::isIPAddress( $this->BlockAddress ) ) |
605 | 615 | // Same as anononly, this is not displayed when blocking an IP address |
606 | 616 | $flags[] = 'noautoblock'; |
607 | | - if ( $this->BlockEmail ) |
| 617 | + if( $this->BlockEmail ) |
608 | 618 | $flags[] = 'noemail'; |
609 | | - if ( !$this->BlockAllowUsertalk && $wgBlockAllowsUTEdit ) |
| 619 | + if( !$this->BlockAllowUsertalk && $wgBlockAllowsUTEdit ) |
610 | 620 | $flags[] = 'nousertalk'; |
611 | | - if ( $this->BlockHideName ) |
| 621 | + if( $this->BlockHideName ) |
612 | 622 | $flags[] = 'hiddenname'; |
613 | 623 | return implode( ',', $flags ); |
614 | 624 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialVersion.php |
— | — | @@ -80,25 +80,30 @@ |
81 | 81 | static function softwareInformation() { |
82 | 82 | $dbr = wfGetDB( DB_SLAVE ); |
83 | 83 | |
84 | | - return Xml::element( 'h2', array( 'id' => 'mw-version-software' ), wfMsg( 'version-software' ) ) . |
85 | | - Xml::openElement( 'table', array( 'id' => 'sv-software' ) ) . |
| 84 | + // Put the software in an array of form 'name' => 'version'. All messages should |
| 85 | + // be loaded here, so feel free to use wfMsg*() in the 'name'. Raw HTML or wikimarkup |
| 86 | + // can be used |
| 87 | + $software = array(); |
| 88 | + $software['[http://www.mediawiki.org/ MediaWiki]'] = self::getVersionLinked(); |
| 89 | + $software['[http://www.php.net/ PHP]'] = phpversion() . " (" . php_sapi_name() . ")"; |
| 90 | + $software[$dbr->getSoftwareLink()] = $dbr->getServerVersion(); |
| 91 | + |
| 92 | + // Allow a hook to add/remove items |
| 93 | + wfRunHooks( 'SoftwareInfo', array( &$software ) ); |
| 94 | + |
| 95 | + $out = Xml::element( 'h2', array( 'id' => 'mw-version-software' ), wfMsg( 'version-software' ) ) . |
| 96 | + Xml::openElement( 'table', array( 'id' => 'sv-software' ) ) . |
86 | 97 | "<tr> |
87 | 98 | <th>" . wfMsg( 'version-software-product' ) . "</th> |
88 | 99 | <th>" . wfMsg( 'version-software-version' ) . "</th> |
89 | | - </tr>\n |
90 | | - <tr> |
91 | | - <td>[http://www.mediawiki.org/ MediaWiki]</td> |
92 | | - <td>" . self::getVersionLinked() . "</td> |
93 | | - </tr>\n |
94 | | - <tr> |
95 | | - <td>[http://www.php.net/ PHP]</td> |
96 | | - <td>" . phpversion() . " (" . php_sapi_name() . ")</td> |
97 | | - </tr>\n |
98 | | - <tr> |
99 | | - <td>" . $dbr->getSoftwareLink() . "</td> |
100 | | - <td>" . $dbr->getServerVersion() . "</td> |
101 | | - </tr>\n" . |
102 | | - Xml::closeElement( 'table' ); |
| 100 | + </tr>\n"; |
| 101 | + foreach( $software as $name => $version ) { |
| 102 | + $out .= "<tr> |
| 103 | + <td>" . $name . "</td> |
| 104 | + <td>" . $version . "</td> |
| 105 | + </tr>\n"; |
| 106 | + } |
| 107 | + return $out . Xml::closeElement( 'table' ); |
103 | 108 | } |
104 | 109 | |
105 | 110 | /** |
— | — | @@ -106,11 +111,18 @@ |
107 | 112 | * |
108 | 113 | * @return mixed |
109 | 114 | */ |
110 | | - public static function getVersion() { |
| 115 | + public static function getVersion( $flags = '' ) { |
111 | 116 | global $wgVersion, $IP; |
112 | 117 | wfProfileIn( __METHOD__ ); |
113 | | - $svn = self::getSvnRevision( $IP ); |
114 | | - $version = $svn ? "$wgVersion (r$svn)" : $wgVersion; |
| 118 | + $svn = self::getSvnRevision( $IP, false, false , false ); |
| 119 | + $svnCo = self::getSvnRevision( $IP, true, false , false ); |
| 120 | + if ( !$svn ) { |
| 121 | + $version = $wgVersion; |
| 122 | + } elseif( $flags === 'nodb' ) { |
| 123 | + $version = "$wgVersion ($svnCo)"; |
| 124 | + } else { |
| 125 | + $version = $wgVersion . wfMsg( 'version-svn-revision', $svn, $svnCo ); |
| 126 | + } |
115 | 127 | wfProfileOut( __METHOD__ ); |
116 | 128 | return $version; |
117 | 129 | } |
— | — | @@ -124,9 +136,13 @@ |
125 | 137 | public static function getVersionLinked() { |
126 | 138 | global $wgVersion, $IP; |
127 | 139 | wfProfileIn( __METHOD__ ); |
128 | | - $svn = self::getSvnRevision( $IP ); |
129 | | - $viewvc = 'http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/?pathrev='; |
130 | | - $version = $svn ? "$wgVersion ([{$viewvc}{$svn} r$svn])" : $wgVersion; |
| 140 | + $svn = self::getSvnRevision( $IP, false, false, false ); |
| 141 | + $svnCo = self::getSvnRevision( $IP, true, false, false ); |
| 142 | + $svnDir = self::getSvnRevision( $IP, true, false, true ); |
| 143 | + $viewvcStart = 'http://svn.wikimedia.org/viewvc/mediawiki/'; |
| 144 | + $viewvcEnd = '/?pathrev='; |
| 145 | + $viewvc = $viewvcStart . $svnDir . $viewvcEnd; |
| 146 | + $version = $svn ? $wgVersion . " [{$viewvc}{$svnCo} " . wfMsg( 'version-svn-revision', $svn, $svnCo ) . ']' : $wgVersion; |
131 | 147 | wfProfileOut( __METHOD__ ); |
132 | 148 | return $version; |
133 | 149 | } |
— | — | @@ -158,7 +174,16 @@ |
159 | 175 | |
160 | 176 | foreach ( $wgExtensionCredits[$type] as $extension ) { |
161 | 177 | $version = null; |
162 | | - $subVersion = ''; |
| 178 | + $subVersion = null; |
| 179 | + $subVersionCo = null; |
| 180 | + $viewvc = null; |
| 181 | + if ( isset( $extension['path'] ) ) { |
| 182 | + $subVersion = self::getSvnRevision(dirname($extension['path']), false, true, false); |
| 183 | + $subVersionCo = self::getSvnRevision(dirname($extension['path']), true, true, false); |
| 184 | + $subVersionDir = self::getSvnRevision(dirname($extension['path']), false, true, true); |
| 185 | + if ($subVersionDir) |
| 186 | + $viewvc = $subVersionDir . $subVersionCo; |
| 187 | + } |
163 | 188 | if ( isset( $extension['version'] ) ) { |
164 | 189 | $version = $extension['version']; |
165 | 190 | } |
— | — | @@ -166,6 +191,9 @@ |
167 | 192 | $out .= $this->formatCredits( |
168 | 193 | isset ( $extension['name'] ) ? $extension['name'] : '', |
169 | 194 | $version, |
| 195 | + $subVersion, |
| 196 | + $subVersionCo, |
| 197 | + $viewvc, |
170 | 198 | isset ( $extension['author'] ) ? $extension['author'] : '', |
171 | 199 | isset ( $extension['url'] ) ? $extension['url'] : null, |
172 | 200 | isset ( $extension['description'] ) ? $extension['description'] : '', |
— | — | @@ -177,24 +205,24 @@ |
178 | 206 | |
179 | 207 | if ( count( $wgExtensionFunctions ) ) { |
180 | 208 | $out .= $this->openExtType( wfMsg( 'version-extension-functions' ) ); |
181 | | - $out .= '<tr><td colspan="3">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n"; |
| 209 | + $out .= '<tr><td colspan="4">' . $this->listToText( $wgExtensionFunctions ) . "</td></tr>\n"; |
182 | 210 | } |
183 | 211 | |
184 | 212 | if ( $cnt = count( $tags = $wgParser->getTags() ) ) { |
185 | 213 | for ( $i = 0; $i < $cnt; ++$i ) |
186 | 214 | $tags[$i] = "<{$tags[$i]}>"; |
187 | 215 | $out .= $this->openExtType( wfMsg( 'version-parser-extensiontags' ) ); |
188 | | - $out .= '<tr><td colspan="3">' . $this->listToText( $tags ). "</td></tr>\n"; |
| 216 | + $out .= '<tr><td colspan="4">' . $this->listToText( $tags ). "</td></tr>\n"; |
189 | 217 | } |
190 | 218 | |
191 | 219 | if( $cnt = count( $fhooks = $wgParser->getFunctionHooks() ) ) { |
192 | 220 | $out .= $this->openExtType( wfMsg( 'version-parser-function-hooks' ) ); |
193 | | - $out .= '<tr><td colspan="3">' . $this->listToText( $fhooks ) . "</td></tr>\n"; |
| 221 | + $out .= '<tr><td colspan="4">' . $this->listToText( $fhooks ) . "</td></tr>\n"; |
194 | 222 | } |
195 | 223 | |
196 | 224 | if ( count( $wgSkinExtensionFunctions ) ) { |
197 | 225 | $out .= $this->openExtType( wfMsg( 'version-skin-extension-functions' ) ); |
198 | | - $out .= '<tr><td colspan="3">' . $this->listToText( $wgSkinExtensionFunctions ) . "</td></tr>\n"; |
| 226 | + $out .= '<tr><td colspan="4">' . $this->listToText( $wgSkinExtensionFunctions ) . "</td></tr>\n"; |
199 | 227 | } |
200 | 228 | $out .= Xml::closeElement( 'table' ); |
201 | 229 | return $out; |
— | — | @@ -212,9 +240,12 @@ |
213 | 241 | } |
214 | 242 | } |
215 | 243 | |
216 | | - function formatCredits( $name, $version = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) { |
| 244 | + function formatCredits( $name, $version = null, $subVersion = null, $subVersionCo = null, $subVersionURL = null, $author = null, $url = null, $description = null, $descriptionMsg = null ) { |
| 245 | + $haveSubversion = $subVersion; |
217 | 246 | $extension = isset( $url ) ? "[$url $name]" : $name; |
218 | | - $version = isset( $version ) ? "(" . wfMsg( 'version-version' ) . " $version)" : ''; |
| 247 | + $version = isset( $version ) ? wfMsg( 'version-version', $version ) : ''; |
| 248 | + $subVersion = isset( $subVersion ) ? wfMsg( 'version-svn-revision', $subVersion, $subVersionCo ) : ''; |
| 249 | + $subVersion = isset( $subVersionURL ) ? "[$subVersionURL $subVersion]" : $subVersion; |
219 | 250 | |
220 | 251 | # Look for a localized description |
221 | 252 | if( isset( $descriptionMsg ) ) { |
— | — | @@ -224,11 +255,19 @@ |
225 | 256 | } |
226 | 257 | } |
227 | 258 | |
228 | | - return "<tr> |
| 259 | + if ( $haveSubversion ) { |
| 260 | + $extNameVer = "<tr> |
229 | 261 | <td><em>$extension $version</em></td> |
230 | | - <td>$description</td> |
231 | | - <td>" . $this->listToText( (array)$author ) . "</td> |
232 | | - </tr>\n"; |
| 262 | + <td><em>$subVersion</em></td>"; |
| 263 | + } else { |
| 264 | + $extNameVer = "<tr> |
| 265 | + <td colspan=\"2\"><em>$extension $version</em></td>"; |
| 266 | + } |
| 267 | + $extDescAuthor = "<td>$description</td> |
| 268 | + <td>" . $this->listToText( (array)$author ) . "</td> |
| 269 | + </tr>\n"; |
| 270 | + return $ret = $extNameVer . $extDescAuthor; |
| 271 | + return $ret; |
233 | 272 | } |
234 | 273 | |
235 | 274 | /** |
— | — | @@ -261,7 +300,7 @@ |
262 | 301 | } |
263 | 302 | |
264 | 303 | private function openExtType($text, $name = null) { |
265 | | - $opt = array( 'colspan' => 3 ); |
| 304 | + $opt = array( 'colspan' => 4 ); |
266 | 305 | $out = ''; |
267 | 306 | |
268 | 307 | if(!$this->firstExtOpened) { |
— | — | @@ -329,10 +368,16 @@ |
330 | 369 | /** |
331 | 370 | * Retrieve the revision number of a Subversion working directory. |
332 | 371 | * |
333 | | - * @param string $dir |
334 | | - * @return mixed revision number as int, or false if not a SVN checkout |
| 372 | + * @param String $dir Directory of the svn checkout |
| 373 | + * @param Boolean $coRev optional to return value whether is Last Modified |
| 374 | + * or Checkout revision number |
| 375 | + * @param Boolean $extension optional to check the path whether is from |
| 376 | + * Wikimedia SVN server or not |
| 377 | + * @param Boolean $relPath optional to get the end part of the checkout path |
| 378 | + * @return mixed revision number as int, end part of the checkout path, |
| 379 | + * or false if not a SVN checkout |
335 | 380 | */ |
336 | | - public static function getSvnRevision( $dir ) { |
| 381 | + public static function getSvnRevision( $dir, $coRev = false, $extension = false, $relPath = false) { |
337 | 382 | // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html |
338 | 383 | $entries = $dir . '/.svn/entries'; |
339 | 384 | |
— | — | @@ -367,8 +412,42 @@ |
368 | 413 | } |
369 | 414 | return false; |
370 | 415 | } else { |
371 | | - // subversion is release 1.4 |
372 | | - return intval( $content[3] ); |
| 416 | + // subversion is release 1.4 or above |
| 417 | + if ($relPath) { |
| 418 | + $endPath = strstr( $content[4], 'tags' ); |
| 419 | + if (!$endPath) { |
| 420 | + $endPath = strstr( $content[4], 'branches' ); |
| 421 | + if (!$endPath) { |
| 422 | + $endPath = strstr( $content[4], 'trunk' ); |
| 423 | + if (!$endPath) |
| 424 | + return false; |
| 425 | + } |
| 426 | + } |
| 427 | + $endPath = trim ( $endPath ); |
| 428 | + if ($extension) { |
| 429 | + $wmSvnPath = 'svn.wikimedia.org/svnroot/mediawiki'; |
| 430 | + $isWMSvn = strstr($content[5],$wmSvnPath); |
| 431 | + if (!strcmp($isWMSvn,null)) { |
| 432 | + return false; |
| 433 | + } else { |
| 434 | + $viewvcStart = 'http://svn.wikimedia.org/viewvc/mediawiki/'; |
| 435 | + if (strstr( $content[4], 'trunk' )) |
| 436 | + $viewvcEnd = '/?pathrev='; |
| 437 | + else |
| 438 | + // Avoids 404 error using pathrev when it does not found |
| 439 | + $viewvcEnd = '/?revision='; |
| 440 | + $viewvc = $viewvcStart . $endPath . $viewvcEnd; |
| 441 | + return $viewvc; |
| 442 | + } |
| 443 | + } |
| 444 | + return $endPath; |
| 445 | + } |
| 446 | + if ($coRev) |
| 447 | + // get the directory checkout revsion number |
| 448 | + return intval( $content[3]) ; |
| 449 | + else |
| 450 | + // get the directory last modified revision number |
| 451 | + return intval( $content[10] ); |
373 | 452 | } |
374 | 453 | } |
375 | 454 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialBooksources.php |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * |
8 | 8 | * @author Rob Church <robchur@gmail.com> |
9 | 9 | * @todo Validate ISBNs using the standard check-digit method |
10 | | - * @ingroup SpecialPages |
| 10 | + * @ingroup SpecialPage |
11 | 11 | */ |
12 | 12 | class SpecialBookSources extends SpecialPage { |
13 | 13 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialListfiles.php |
— | — | @@ -140,8 +140,10 @@ |
141 | 141 | return "$link ($download)"; |
142 | 142 | case 'img_user_text': |
143 | 143 | if ( $this->mCurrentRow->img_user ) { |
144 | | - $link = $this->getSkin()->makeLinkObj( Title::makeTitle( NS_USER, $value ), |
145 | | - htmlspecialchars( $value ) ); |
| 144 | + $link = $this->getSkin()->link( |
| 145 | + Title::makeTitle( NS_USER, $value ), |
| 146 | + htmlspecialchars( $value ) |
| 147 | + ); |
146 | 148 | } else { |
147 | 149 | $link = htmlspecialchars( $value ); |
148 | 150 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialUserlogin.php |
— | — | @@ -948,8 +948,6 @@ |
949 | 949 | * @private |
950 | 950 | */ |
951 | 951 | function onCookieRedirectCheck( $type ) { |
952 | | - global $wgUser; |
953 | | - |
954 | 952 | if ( !$this->hasSessionCookie() ) { |
955 | 953 | if ( $type == 'new' ) { |
956 | 954 | return $this->mainLoginForm( wfMsgExt( 'nocookiesnew', array( 'parseinline' ) ) ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialUnusedcategories.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | |
37 | 37 | function formatResult( $skin, $result ) { |
38 | 38 | $title = Title::makeTitle( NS_CATEGORY, $result->title ); |
39 | | - return $skin->makeLinkObj( $title, $title->getText() ); |
| 39 | + return $skin->link( $title, $title->getText() ); |
40 | 40 | } |
41 | 41 | } |
42 | 42 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialDoubleRedirects.php |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | } |
76 | 76 | } |
77 | 77 | if ( !$result ) { |
78 | | - return '<s>' . $skin->makeLinkObj( $titleA, '', 'redirect=no' ) . '</s>'; |
| 78 | + return '<s>' . $skin->link( $titleA, null, array(), array( 'redirect' => 'no' ) ) . '</s>'; |
79 | 79 | } |
80 | 80 | |
81 | 81 | $titleB = Title::makeTitle( $result->nsb, $result->tb ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialExport.php |
— | — | @@ -45,6 +45,7 @@ |
46 | 46 | $this->images = $wgRequest->getCheck( 'images' ); // Doesn't do anything yet |
47 | 47 | $this->pageLinkDepth = $this->validateLinkDepth( |
48 | 48 | $wgRequest->getIntOrNull( 'pagelink-depth' ) ); |
| 49 | + $nsindex = ''; |
49 | 50 | |
50 | 51 | if ( $wgRequest->getCheck( 'addcat' ) ) { |
51 | 52 | $page = $wgRequest->getText( 'pages' ); |
— | — | @@ -352,6 +353,7 @@ |
353 | 354 | $pageSet = $this->getLinks( $inputPages, $pageSet, 'pagelinks', |
354 | 355 | array( 'pl_namespace AS namespace', 'pl_title AS title' ), |
355 | 356 | array( 'page_id=pl_from' ) ); |
| 357 | + $inputPages = array_keys( $pageSet ); |
356 | 358 | } |
357 | 359 | return $pageSet; |
358 | 360 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialCategories.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | $from = $par; |
15 | 15 | } |
16 | 16 | $cap = new CategoryPager( $from ); |
| 17 | + $cap->doQuery(); |
17 | 18 | $wgOut->addHTML( |
18 | 19 | XML::openElement( 'div', array('class' => 'mw-spcontent') ) . |
19 | 20 | wfMsgExt( 'categoriespagetext', array( 'parse' ) ) . |
— | — | @@ -74,9 +75,6 @@ |
75 | 76 | |
76 | 77 | /* Override getBody to apply LinksBatch on resultset before actually outputting anything. */ |
77 | 78 | public function getBody() { |
78 | | - if (!$this->mQueryDone) { |
79 | | - $this->doQuery(); |
80 | | - } |
81 | 79 | $batch = new LinkBatch; |
82 | 80 | |
83 | 81 | $this->mResult->rewind(); |
— | — | @@ -92,7 +90,7 @@ |
93 | 91 | function formatRow($result) { |
94 | 92 | global $wgLang; |
95 | 93 | $title = Title::makeTitle( NS_CATEGORY, $result->cat_title ); |
96 | | - $titleText = $this->getSkin()->makeLinkObj( $title, htmlspecialchars( $title->getText() ) ); |
| 94 | + $titleText = $this->getSkin()->link( $title, htmlspecialchars( $title->getText() ) ); |
97 | 95 | $count = wfMsgExt( 'nmembers', array( 'parsemag', 'escape' ), |
98 | 96 | $wgLang->formatNum( $result->cat_pages ) ); |
99 | 97 | return Xml::tags('li', null, "$titleText ($count)" ) . "\n"; |
Index: branches/querypage-work/phase3/includes/specials/SpecialWantedcategories.php |
— | — | @@ -40,7 +40,7 @@ |
41 | 41 | $text = $wgContLang->convert( $nt->getText() ); |
42 | 42 | |
43 | 43 | $plink = $this->isCached() ? |
44 | | - $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ) : |
| 44 | + $skin->link( $nt, htmlspecialchars( $text ) ) : |
45 | 45 | $skin->makeBrokenLinkObj( $nt, htmlspecialchars( $text ) ); |
46 | 46 | |
47 | 47 | $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), |
Index: branches/querypage-work/phase3/includes/specials/SpecialDeletedContributions.php |
— | — | @@ -106,10 +106,9 @@ |
107 | 107 | * @todo This would probably look a lot nicer in a table. |
108 | 108 | */ |
109 | 109 | function formatRow( $row ) { |
| 110 | + global $wgUser, $wgLang; |
110 | 111 | wfProfileIn( __METHOD__ ); |
111 | 112 | |
112 | | - global $wgLang, $wgUser; |
113 | | - |
114 | 113 | $sk = $this->getSkin(); |
115 | 114 | |
116 | 115 | $rev = new Revision( array( |
— | — | @@ -156,7 +155,7 @@ |
157 | 156 | '×tamp=' . $rev->getTimestamp() ); |
158 | 157 | } |
159 | 158 | |
160 | | - $pagelink = $sk->makeLinkObj( $page ); |
| 159 | + $pagelink = $sk->link( $page ); |
161 | 160 | |
162 | 161 | if( $rev->isMinor() ) { |
163 | 162 | $mflag = '<span class="minor">' . $this->messages['minoreditletter'] . '</span> '; |
— | — | @@ -164,8 +163,23 @@ |
165 | 164 | $mflag = ''; |
166 | 165 | } |
167 | 166 | |
| 167 | + if( $wgUser->isAllowed( 'deleterevision' ) ) { |
| 168 | + // If revision was hidden from sysops |
| 169 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 170 | + $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), |
| 171 | + '(' . $this->message['rev-delundel'] . ')' ) . ' '; |
| 172 | + // Otherwise, show the link... |
| 173 | + } else { |
| 174 | + $query = array( 'target' => $page->getPrefixedDbkey(), |
| 175 | + 'artimestamp' => $rev->getTimestamp() ); |
| 176 | + $del = $this->mSkin->revDeleteLink( $query, |
| 177 | + $rev->isDeleted( Revision::DELETED_RESTRICTED ) ) . ' '; |
| 178 | + } |
| 179 | + } else { |
| 180 | + $del = ''; |
| 181 | + } |
168 | 182 | |
169 | | - $ret = "{$link} ($last) ({$dellog}) ({$reviewlink}) . . {$mflag} {$pagelink} {$comment}"; |
| 183 | + $ret = "{$del}{$link} ({$last}) ({$dellog}) ({$reviewlink}) . . {$mflag} {$pagelink} {$comment}"; |
170 | 184 | if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
171 | 185 | $ret .= ' ' . wfMsgHtml( 'deletedrev' ); |
172 | 186 | } |
— | — | @@ -290,12 +304,12 @@ |
291 | 305 | if ( 0 == $id ) { |
292 | 306 | $user = $nt->getText(); |
293 | 307 | } else { |
294 | | - $user = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); |
| 308 | + $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); |
295 | 309 | } |
296 | 310 | $talk = $nt->getTalkPage(); |
297 | 311 | if( $talk ) { |
298 | 312 | # Talk page link |
299 | | - $tools[] = $sk->makeLinkObj( $talk, wfMsgHtml( 'talkpagelinktext' ) ); |
| 313 | + $tools[] = $sk->link( $talk, wfMsgHtml( 'talkpagelinktext' ) ); |
300 | 314 | if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && User::isIP( $nt->getText() ) ) ) { |
301 | 315 | # Block link |
302 | 316 | if( $wgUser->isAllowed( 'block' ) ) |
Index: branches/querypage-work/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -148,12 +148,12 @@ |
149 | 149 | if( 0 == $id ) { |
150 | 150 | $user = $nt->getText(); |
151 | 151 | } else { |
152 | | - $user = $sk->makeLinkObj( $nt, htmlspecialchars( $nt->getText() ) ); |
| 152 | + $user = $sk->link( $nt, htmlspecialchars( $nt->getText() ) ); |
153 | 153 | } |
154 | 154 | $talk = $nt->getTalkPage(); |
155 | 155 | if( $talk ) { |
156 | 156 | # Talk page link |
157 | | - $tools[] = $sk->makeLinkObj( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); |
| 157 | + $tools[] = $sk->link( $talk, wfMsgHtml( 'sp-contributions-talk' ) ); |
158 | 158 | if( ( $id != 0 && $wgSysopUserBans ) || ( $id == 0 && IP::isIPAddress( $nt->getText() ) ) ) { |
159 | 159 | # Block link |
160 | 160 | if( $wgUser->isAllowed( 'block' ) ) |
— | — | @@ -473,7 +473,7 @@ |
474 | 474 | * @todo This would probably look a lot nicer in a table. |
475 | 475 | */ |
476 | 476 | function formatRow( $row ) { |
477 | | - global $wgLang, $wgUser, $wgContLang; |
| 477 | + global $wgUser, $wgLang, $wgContLang; |
478 | 478 | wfProfileIn( __METHOD__ ); |
479 | 479 | |
480 | 480 | $sk = $this->getSkin(); |
— | — | @@ -482,7 +482,12 @@ |
483 | 483 | |
484 | 484 | $page = Title::newFromRow( $row ); |
485 | 485 | $page->resetArticleId( $row->rev_page ); // use process cache |
486 | | - $link = $sk->makeLinkObj( $page, $page->getPrefixedText(), $page->isRedirect() ? 'redirect=no' : '' ); |
| 486 | + $link = $sk->link( |
| 487 | + $page, |
| 488 | + $page->getPrefixedText(), |
| 489 | + array(), |
| 490 | + $page->isRedirect() ? array( 'redirect' => 'no' ) : array() |
| 491 | + ); |
487 | 492 | # Mark current revisions |
488 | 493 | $difftext = $topmarktext = ''; |
489 | 494 | if( $row->rev_id == $row->page_latest ) { |
— | — | @@ -532,8 +537,23 @@ |
533 | 538 | } else { |
534 | 539 | $mflag = ''; |
535 | 540 | } |
| 541 | + |
| 542 | + if( $wgUser->isAllowed( 'deleterevision' ) ) { |
| 543 | + // If revision was hidden from sysops |
| 544 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 545 | + $del = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), |
| 546 | + '(' . $this->message['rev-delundel'] . ')' ) . ' '; |
| 547 | + // Otherwise, show the link... |
| 548 | + } else { |
| 549 | + $query = array( 'target' => $page->getPrefixedDbkey(), 'oldid' => $rev->getId() ); |
| 550 | + $del = $this->mSkin->revDeleteLink( $query, |
| 551 | + $rev->isDeleted( Revision::DELETED_RESTRICTED ) ) . ' '; |
| 552 | + } |
| 553 | + } else { |
| 554 | + $del = ''; |
| 555 | + } |
536 | 556 | |
537 | | - $ret = "{$d} {$histlink} {$difftext} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}"; |
| 557 | + $ret = "{$del}{$d} {$histlink} {$difftext} {$nflag}{$mflag} {$link}{$userlink} {$comment} {$topmarktext}"; |
538 | 558 | if( $rev->isDeleted( Revision::DELETED_TEXT ) ) { |
539 | 559 | $ret .= ' ' . wfMsgHtml( 'deletedrev' ); |
540 | 560 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialMovepage.php |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | |
93 | 93 | $skin = $wgUser->getSkin(); |
94 | 94 | |
95 | | - $oldTitleLink = $skin->makeLinkObj( $this->oldTitle ); |
| 95 | + $oldTitleLink = $skin->link( $this->oldTitle ); |
96 | 96 | |
97 | 97 | $wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) ); |
98 | 98 | $wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) ); |
— | — | @@ -468,7 +468,7 @@ |
469 | 469 | $extraOutput []= wfMsgHtml( 'movepage-page-moved', $oldLink, $newLink ); |
470 | 470 | } else { |
471 | 471 | $oldLink = $skin->makeKnownLinkObj( $oldSubpage ); |
472 | | - $newLink = $skin->makeLinkObj( $newSubpage ); |
| 472 | + $newLink = $skin->link( $newSubpage ); |
473 | 473 | $extraOutput []= wfMsgHtml( 'movepage-page-unmoved', $oldLink, $newLink ); |
474 | 474 | } |
475 | 475 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialRemoveRestrictions.php |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | } |
48 | 48 | |
49 | 49 | function wfSpecialRemoveRestrictionsProcess( $r ) { |
50 | | - global $wgUser, $wgRequest; |
| 50 | + global $wgRequest; |
51 | 51 | $reason = $wgRequest->getVal( 'reason' ); |
52 | 52 | $result = $r->delete(); |
53 | 53 | $log = new LogPage( 'restrict' ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialIpblocklist.php |
— | — | @@ -162,7 +162,7 @@ |
163 | 163 | * @return array array(message key, parameters) on failure, empty array on success |
164 | 164 | */ |
165 | 165 | |
166 | | - static function doUnblock(&$id, &$ip, &$reason, &$range = null) { |
| 166 | + static function doUnblock(&$id, &$ip, &$reason, &$range = null, $blocker=null) { |
167 | 167 | if ( $id ) { |
168 | 168 | $block = Block::newFromID( $id ); |
169 | 169 | if ( !$block ) { |
— | — | @@ -184,8 +184,7 @@ |
185 | 185 | if ( !$block ) { |
186 | 186 | return array('ipb_cant_unblock', htmlspecialchars($id)); |
187 | 187 | } |
188 | | - if( $block->mRangeStart != $block->mRangeEnd |
189 | | - && !strstr( $ip, "/" ) ) { |
| 188 | + if( $block->mRangeStart != $block->mRangeEnd && !strstr( $ip, "/" ) ) { |
190 | 189 | /* If the specified IP is a single address, and the block is |
191 | 190 | * a range block, don't unblock the range. */ |
192 | 191 | $range = $block->mAddress; |
— | — | @@ -195,11 +194,22 @@ |
196 | 195 | } |
197 | 196 | // Yes, this is really necessary |
198 | 197 | $id = $block->mId; |
| 198 | + |
| 199 | + # If the name was hidden and the blocking user cannot hide |
| 200 | + # names, then don't allow any block removals... |
| 201 | + if( $blocker && $block->mHideName && !$blocker->isAllowed('hideuser') ) { |
| 202 | + return array('ipb_cant_unblock', htmlspecialchars($id)); |
| 203 | + } |
199 | 204 | |
200 | 205 | # Delete block |
201 | 206 | if ( !$block->delete() ) { |
202 | 207 | return array('ipb_cant_unblock', htmlspecialchars($id)); |
203 | 208 | } |
| 209 | + |
| 210 | + # Unset _deleted fields as needed |
| 211 | + if( $block->mHideName ) { |
| 212 | + IPBlockForm::unsuppressUserName( $block->mAddress, $block->mUser ); |
| 213 | + } |
204 | 214 | |
205 | 215 | # Make log entry |
206 | 216 | $log = new LogPage( 'block' ); |
— | — | @@ -208,10 +218,9 @@ |
209 | 219 | } |
210 | 220 | |
211 | 221 | function doSubmit() { |
212 | | - global $wgOut; |
213 | | - $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range); |
214 | | - if(!empty($retval)) |
215 | | - { |
| 222 | + global $wgOut, $wgUser; |
| 223 | + $retval = self::doUnblock($this->id, $this->ip, $this->reason, $range, $wgUser); |
| 224 | + if( !empty($retval) ) { |
216 | 225 | $key = array_shift($retval); |
217 | 226 | $this->showForm(wfMsgReal($key, $retval)); |
218 | 227 | return; |
Index: branches/querypage-work/phase3/includes/specials/SpecialMostlinkedcategories.php |
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | $nt = Title::makeTitle( $result->namespace, $result->title ); |
54 | 54 | $text = $wgContLang->convert( $nt->getText() ); |
55 | 55 | |
56 | | - $plink = $skin->makeLinkObj( $nt, htmlspecialchars( $text ) ); |
| 56 | + $plink = $skin->link( $nt, htmlspecialchars( $text ) ); |
57 | 57 | |
58 | 58 | $nlinks = wfMsgExt( 'nmembers', array( 'parsemag', 'escape'), |
59 | 59 | $wgLang->formatNum( $result->value ) ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialMergeHistory.php |
— | — | @@ -67,7 +67,7 @@ |
68 | 68 | } |
69 | 69 | |
70 | 70 | function execute() { |
71 | | - global $wgOut, $wgUser; |
| 71 | + global $wgOut; |
72 | 72 | |
73 | 73 | $wgOut->setPagetitle( wfMsgHtml( "mergehistory" ) ); |
74 | 74 | |
— | — | @@ -218,7 +218,7 @@ |
219 | 219 | } |
220 | 220 | |
221 | 221 | function formatRevisionRow( $row ) { |
222 | | - global $wgUser, $wgLang; |
| 222 | + global $wgLang; |
223 | 223 | |
224 | 224 | $rev = new Revision( $row ); |
225 | 225 | |
— | — | @@ -270,7 +270,7 @@ |
271 | 271 | } |
272 | 272 | |
273 | 273 | function merge() { |
274 | | - global $wgOut, $wgUser; |
| 274 | + global $wgOut; |
275 | 275 | # Get the titles directly from the IDs, in case the target page params |
276 | 276 | # were spoofed. The queries are done based on the IDs, so it's best to |
277 | 277 | # keep it consistent... |
Index: branches/querypage-work/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -1442,8 +1442,8 @@ |
1443 | 1443 | */ |
1444 | 1444 | function updatePage( $title ) { |
1445 | 1445 | $title->invalidateCache(); |
| 1446 | + $this->dbw->commit(); // Commit the transaction before the purge is sent |
1446 | 1447 | $title->purgeSquid(); |
1447 | | - $title->touchLinks(); |
1448 | 1448 | // Extensions that require referencing previous revisions may need this |
1449 | 1449 | wfRunHooks( 'ArticleRevisionVisiblitySet', array( &$title ) ); |
1450 | 1450 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialBrokenRedirects.php |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | |
70 | 70 | // $toObj may very easily be false if the $result list is cached |
71 | 71 | if ( !is_object( $toObj ) ) { |
72 | | - return '<s>' . $skin->makeLinkObj( $fromObj ) . '</s>'; |
| 72 | + return '<s>' . $skin->link( $fromObj ) . '</s>'; |
73 | 73 | } |
74 | 74 | |
75 | 75 | $from = $skin->makeKnownLinkObj( $fromObj ,'', 'redirect=no' ); |
Index: branches/querypage-work/phase3/includes/specials/SpecialListusers.php |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | global $wgLang; |
119 | 119 | |
120 | 120 | $userPage = Title::makeTitle( NS_USER, $row->user_name ); |
121 | | - $name = $this->getSkin()->makeLinkObj( $userPage, htmlspecialchars( $userPage->getText() ) ); |
| 121 | + $name = $this->getSkin()->link( $userPage, htmlspecialchars( $userPage->getText() ) ); |
122 | 122 | |
123 | 123 | if( $row->numgroups > 1 || ( $this->requestedGroup && $row->numgroups == 1 ) ) { |
124 | 124 | $list = array(); |
Index: branches/querypage-work/phase3/includes/specials/SpecialFileDuplicateSearch.php |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | $text = $wgContLang->convert( $nt->getText() ); |
55 | 55 | $plink = $skin->makeLink( $nt->getPrefixedText(), $text ); |
56 | 56 | |
57 | | - $user = $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); |
| 57 | + $user = $skin->link( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text ); |
58 | 58 | $time = $wgLang->timeanddate( $result->img_timestamp ); |
59 | 59 | |
60 | 60 | return "$plink . . $user . . $time"; |
Index: branches/querypage-work/phase3/includes/specials/SpecialPreferences.php |
— | — | @@ -1,1309 +1,75 @@ |
2 | 2 | <?php |
3 | | -/** |
4 | | - * Hold things related to displaying and saving user preferences. |
5 | | - * @file |
6 | | - * @ingroup SpecialPage |
7 | | - */ |
8 | 3 | |
9 | | -/** |
10 | | - * Entry point that create the "Preferences" object |
11 | | - */ |
12 | | -function wfSpecialPreferences() { |
13 | | - global $wgRequest; |
| 4 | +class SpecialPreferences extends SpecialPage { |
| 5 | + function __construct() { |
| 6 | + parent::__construct( 'Preferences' ); |
| 7 | + } |
14 | 8 | |
15 | | - $form = new PreferencesForm( $wgRequest ); |
16 | | - $form->execute(); |
17 | | -} |
| 9 | + function execute( $par ) { |
| 10 | + global $wgOut, $wgUser, $wgRequest; |
18 | 11 | |
19 | | -/** |
20 | | - * Preferences form handling |
21 | | - * This object will show the preferences form and can save it as well. |
22 | | - * @ingroup SpecialPage |
23 | | - */ |
24 | | -class PreferencesForm { |
25 | | - var $mQuickbar, $mStubs; |
26 | | - var $mRows, $mCols, $mSkin, $mMath, $mDate, $mUserEmail, $mEmailFlag, $mNick; |
27 | | - var $mUserLanguage, $mUserVariant; |
28 | | - var $mSearch, $mRecent, $mRecentDays, $mTimeZone, $mHourDiff, $mSearchLines, $mSearchChars, $mAction; |
29 | | - var $mReset, $mPosted, $mToggles, $mSearchNs, $mRealName, $mImageSize; |
30 | | - var $mUnderline, $mWatchlistEdits, $mGender; |
| 12 | + $this->setHeaders(); |
| 13 | + $this->outputHeader(); |
31 | 14 | |
32 | | - /** |
33 | | - * Constructor |
34 | | - * Load some values |
35 | | - */ |
36 | | - function __construct( &$request ) { |
37 | | - global $wgContLang, $wgUser, $wgAllowRealName; |
| 15 | + $wgOut->addScriptFile( 'prefs.js' ); |
38 | 16 | |
39 | | - $this->mQuickbar = $request->getVal( 'wpQuickbar' ); |
40 | | - $this->mStubs = $request->getVal( 'wpStubs' ); |
41 | | - $this->mRows = $request->getVal( 'wpRows' ); |
42 | | - $this->mCols = $request->getVal( 'wpCols' ); |
43 | | - $this->mSkin = Skin::normalizeKey( $request->getVal( 'wpSkin' ) ); |
44 | | - $this->mMath = $request->getVal( 'wpMath' ); |
45 | | - $this->mDate = $request->getVal( 'wpDate' ); |
46 | | - $this->mUserEmail = $request->getVal( 'wpUserEmail' ); |
47 | | - $this->mRealName = $wgAllowRealName ? $request->getVal( 'wpRealName' ) : ''; |
48 | | - $this->mEmailFlag = $request->getCheck( 'wpEmailFlag' ) ? 0 : 1; |
49 | | - $this->mNick = $request->getVal( 'wpNick' ); |
50 | | - $this->mUserLanguage = $request->getVal( 'wpUserLanguage' ); |
51 | | - $this->mUserVariant = $request->getVal( 'wpUserVariant' ); |
52 | | - $this->mSearch = $request->getVal( 'wpSearch' ); |
53 | | - $this->mRecent = $request->getVal( 'wpRecent' ); |
54 | | - $this->mRecentDays = $request->getVal( 'wpRecentDays' ); |
55 | | - $this->mTimeZone = $request->getVal( 'wpTimeZone' ); |
56 | | - $this->mHourDiff = $request->getVal( 'wpHourDiff' ); |
57 | | - $this->mSearchLines = $request->getVal( 'wpSearchLines' ); |
58 | | - $this->mSearchChars = $request->getVal( 'wpSearchChars' ); |
59 | | - $this->mImageSize = $request->getVal( 'wpImageSize' ); |
60 | | - $this->mThumbSize = $request->getInt( 'wpThumbSize' ); |
61 | | - $this->mUnderline = $request->getInt( 'wpOpunderline' ); |
62 | | - $this->mAction = $request->getVal( 'action' ); |
63 | | - $this->mReset = $request->getCheck( 'wpReset' ); |
64 | | - $this->mRestoreprefs = $request->getCheck( 'wpRestore' ); |
65 | | - $this->mPosted = $request->wasPosted(); |
66 | | - $this->mSuccess = $request->getCheck( 'success' ); |
67 | | - $this->mWatchlistDays = $request->getVal( 'wpWatchlistDays' ); |
68 | | - $this->mWatchlistEdits = $request->getVal( 'wpWatchlistEdits' ); |
69 | | - $this->mDisableMWSuggest = $request->getCheck( 'wpDisableMWSuggest' ); |
70 | | - $this->mGender = $request->getVal( 'wpGender' ); |
| 17 | + $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. |
71 | 18 | |
72 | | - $this->mSaveprefs = $request->getCheck( 'wpSaveprefs' ) && |
73 | | - $this->mPosted && |
74 | | - $wgUser->matchEditToken( $request->getVal( 'wpEditToken' ) ); |
75 | | - |
76 | | - # User toggles (the big ugly unsorted list of checkboxes) |
77 | | - $this->mToggles = array(); |
78 | | - if ( $this->mPosted ) { |
79 | | - $togs = User::getToggles(); |
80 | | - foreach ( $togs as $tname ) { |
81 | | - $this->mToggles[$tname] = $request->getCheck( "wpOp$tname" ) ? 1 : 0; |
82 | | - } |
83 | | - } |
84 | | - |
85 | | - $this->mUsedToggles = array(); |
86 | | - |
87 | | - # Search namespace options |
88 | | - # Note: namespaces don't necessarily have consecutive keys |
89 | | - $this->mSearchNs = array(); |
90 | | - if ( $this->mPosted ) { |
91 | | - $namespaces = $wgContLang->getNamespaces(); |
92 | | - foreach ( $namespaces as $i => $namespace ) { |
93 | | - if ( $i >= 0 ) { |
94 | | - $this->mSearchNs[$i] = $request->getCheck( "wpNs$i" ) ? 1 : 0; |
95 | | - } |
96 | | - } |
97 | | - } |
98 | | - |
99 | | - # Validate language |
100 | | - if ( !preg_match( '/^[a-z\-]*$/', $this->mUserLanguage ) ) { |
101 | | - $this->mUserLanguage = 'nolanguage'; |
102 | | - } |
103 | | - |
104 | | - wfRunHooks( 'InitPreferencesForm', array( $this, $request ) ); |
105 | | - } |
106 | | - |
107 | | - function execute() { |
108 | | - global $wgUser, $wgOut; |
109 | | - |
110 | 19 | if ( $wgUser->isAnon() ) { |
111 | | - $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', |
112 | | - array( SpecialPage::getTitleFor( 'Preferences' )->getPrefixedDBkey() ) ); |
| 20 | + $wgOut->showErrorPage( 'prefsnologin', 'prefsnologintext', array( $this->getTitle()->getPrefixedDBkey() ) ); |
113 | 21 | return; |
114 | 22 | } |
115 | 23 | if ( wfReadOnly() ) { |
116 | 24 | $wgOut->readOnlyPage(); |
117 | 25 | return; |
118 | 26 | } |
119 | | - if ( $this->mReset ) { |
120 | | - $this->resetPrefs(); |
121 | | - $this->mainPrefsForm( 'reset', wfMsg( 'prefsreset' ) ); |
122 | | - } else if ( $this->mSaveprefs ) { |
123 | | - $this->savePreferences(); |
124 | | - } else if ( $this->mRestoreprefs ) { |
125 | | - $this->restorePreferences(); |
126 | | - } else { |
127 | | - $this->resetPrefs(); |
128 | | - $this->mainPrefsForm( '' ); |
129 | | - } |
130 | | - } |
131 | | - /** |
132 | | - * @access private |
133 | | - */ |
134 | | - function validateInt( &$val, $min=0, $max=0x7fffffff ) { |
135 | | - $val = intval($val); |
136 | | - $val = min($val, $max); |
137 | | - $val = max($val, $min); |
138 | | - return $val; |
139 | | - } |
140 | 27 | |
141 | | - /** |
142 | | - * @access private |
143 | | - */ |
144 | | - function validateFloat( &$val, $min, $max=0x7fffffff ) { |
145 | | - $val = floatval( $val ); |
146 | | - $val = min( $val, $max ); |
147 | | - $val = max( $val, $min ); |
148 | | - return( $val ); |
149 | | - } |
150 | | - |
151 | | - /** |
152 | | - * @access private |
153 | | - */ |
154 | | - function validateIntOrNull( &$val, $min=0, $max=0x7fffffff ) { |
155 | | - $val = trim($val); |
156 | | - if($val === '') { |
157 | | - return null; |
158 | | - } else { |
159 | | - return $this->validateInt( $val, $min, $max ); |
160 | | - } |
161 | | - } |
162 | | - |
163 | | - /** |
164 | | - * @access private |
165 | | - */ |
166 | | - function validateDate( $val ) { |
167 | | - global $wgLang, $wgContLang; |
168 | | - if ( $val !== false && ( |
169 | | - in_array( $val, (array)$wgLang->getDatePreferences() ) || |
170 | | - in_array( $val, (array)$wgContLang->getDatePreferences() ) ) ) |
171 | | - { |
172 | | - return $val; |
173 | | - } else { |
174 | | - return $wgLang->getDefaultDateFormat(); |
175 | | - } |
176 | | - } |
177 | | - |
178 | | - /** |
179 | | - * Used to validate the user inputed timezone before saving it as |
180 | | - * 'timecorrection', will return 'System' if fed bogus data. |
181 | | - * @access private |
182 | | - * @param string $tz the user input Zoneinfo timezone |
183 | | - * @param string $s the user input offset string |
184 | | - * @return string |
185 | | - */ |
186 | | - function validateTimeZone( $tz, $s ) { |
187 | | - $data = explode( '|', $tz, 3 ); |
188 | | - switch ( $data[0] ) { |
189 | | - case 'ZoneInfo': |
190 | | - case 'System': |
191 | | - return $tz; |
192 | | - case 'Offset': |
193 | | - default: |
194 | | - $data = explode( ':', $s, 2 ); |
195 | | - $minDiff = 0; |
196 | | - if( count( $data ) == 2 ) { |
197 | | - $data[0] = intval( $data[0] ); |
198 | | - $data[1] = intval( $data[1] ); |
199 | | - $minDiff = abs( $data[0] ) * 60 + $data[1]; |
200 | | - if ( $data[0] < 0 ) $minDiff = -$minDiff; |
201 | | - } else { |
202 | | - $minDiff = intval( $data[0] ) * 60; |
203 | | - } |
204 | | - |
205 | | - # Max is +14:00 and min is -12:00, see: |
206 | | - # http://en.wikipedia.org/wiki/Timezone |
207 | | - $minDiff = min( $minDiff, 840 ); # 14:00 |
208 | | - $minDiff = max( $minDiff, -720 ); # -12:00 |
209 | | - return 'Offset|'.$minDiff; |
210 | | - } |
211 | | - } |
212 | | - |
213 | | - function validateGender( $val ) { |
214 | | - $valid = array( 'male', 'female', 'unknown' ); |
215 | | - if ( in_array($val, $valid) ) { |
216 | | - return $val; |
217 | | - } else { |
218 | | - return User::getDefaultOption( 'gender' ); |
219 | | - } |
220 | | - } |
221 | | - |
222 | | - /** |
223 | | - * @access private |
224 | | - */ |
225 | | - function savePreferences() { |
226 | | - global $wgUser, $wgOut, $wgParser; |
227 | | - global $wgEnableUserEmail, $wgEnableEmail; |
228 | | - global $wgEmailAuthentication, $wgRCMaxAge; |
229 | | - global $wgAuth, $wgEmailConfirmToEdit; |
230 | | - |
231 | | - $wgUser->setRealName( $this->mRealName ); |
232 | | - $oldOptions = $wgUser->mOptions; |
233 | | - |
234 | | - if( $wgUser->getOption( 'language' ) !== $this->mUserLanguage ) { |
235 | | - $needRedirect = true; |
236 | | - } else { |
237 | | - $needRedirect = false; |
238 | | - } |
239 | | - |
240 | | - # Validate the signature and clean it up as needed |
241 | | - global $wgMaxSigChars; |
242 | | - if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) { |
243 | | - global $wgLang; |
244 | | - $this->mainPrefsForm( 'error', |
245 | | - wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) ); |
| 28 | + if ( $par == 'reset' ) { |
| 29 | + $this->showResetForm(); |
246 | 30 | return; |
247 | | - } elseif( $this->mToggles['fancysig'] ) { |
248 | | - if( $wgParser->validateSig( $this->mNick ) !== false ) { |
249 | | - $this->mNick = $wgParser->cleanSig( $this->mNick ); |
250 | | - } else { |
251 | | - $this->mainPrefsForm( 'error', wfMsg( 'badsig' ) ); |
252 | | - return; |
253 | | - } |
254 | | - } else { |
255 | | - // When no fancy sig used, make sure ~{3,5} get removed. |
256 | | - $this->mNick = $wgParser->cleanSigInSig( $this->mNick ); |
257 | 31 | } |
258 | 32 | |
259 | | - $wgUser->setOption( 'language', $this->mUserLanguage ); |
260 | | - $wgUser->setOption( 'variant', $this->mUserVariant ); |
261 | | - $wgUser->setOption( 'nickname', $this->mNick ); |
262 | | - $wgUser->setOption( 'quickbar', $this->mQuickbar ); |
263 | | - global $wgAllowUserSkin; |
264 | | - if( $wgAllowUserSkin ) { |
265 | | - $wgUser->setOption( 'skin', $this->mSkin ); |
| 33 | + if ( $wgRequest->getCheck( 'success' ) ) { |
| 34 | + $wgOut->wrapWikiMsg( |
| 35 | + '<div class="successbox"><strong>$1</strong></div>', |
| 36 | + 'savedprefs' |
| 37 | + ); |
266 | 38 | } |
267 | | - global $wgUseTeX; |
268 | | - if( $wgUseTeX ) { |
269 | | - $wgUser->setOption( 'math', $this->mMath ); |
| 39 | + |
| 40 | + if ( $wgRequest->getCheck( 'eauth' ) ) { |
| 41 | + $wgOut->wrapWikiMsg( "<div class='error' style='clear: both;'>$1</div>", |
| 42 | + 'eauthentsent', $wgUser->getName() ); |
270 | 43 | } |
271 | | - $wgUser->setOption( 'date', $this->validateDate( $this->mDate ) ); |
272 | | - $wgUser->setOption( 'searchlimit', $this->validateIntOrNull( $this->mSearch ) ); |
273 | | - $wgUser->setOption( 'contextlines', $this->validateIntOrNull( $this->mSearchLines ) ); |
274 | | - $wgUser->setOption( 'contextchars', $this->validateIntOrNull( $this->mSearchChars ) ); |
275 | | - $wgUser->setOption( 'rclimit', $this->validateIntOrNull( $this->mRecent ) ); |
276 | | - $wgUser->setOption( 'rcdays', $this->validateInt($this->mRecentDays, 1, ceil($wgRCMaxAge / (3600*24)))); |
277 | | - $wgUser->setOption( 'wllimit', $this->validateIntOrNull( $this->mWatchlistEdits, 0, 1000 ) ); |
278 | | - $wgUser->setOption( 'rows', $this->validateInt( $this->mRows, 4, 1000 ) ); |
279 | | - $wgUser->setOption( 'cols', $this->validateInt( $this->mCols, 4, 1000 ) ); |
280 | | - $wgUser->setOption( 'stubthreshold', $this->validateIntOrNull( $this->mStubs ) ); |
281 | | - $wgUser->setOption( 'timecorrection', $this->validateTimeZone( $this->mTimeZone, $this->mHourDiff ) ); |
282 | | - $wgUser->setOption( 'imagesize', $this->mImageSize ); |
283 | | - $wgUser->setOption( 'thumbsize', $this->mThumbSize ); |
284 | | - $wgUser->setOption( 'underline', $this->validateInt($this->mUnderline, 0, 2) ); |
285 | | - $wgUser->setOption( 'watchlistdays', $this->validateFloat( $this->mWatchlistDays, 0, 7 ) ); |
286 | | - $wgUser->setOption( 'disablesuggest', $this->mDisableMWSuggest ); |
287 | | - $wgUser->setOption( 'gender', $this->validateGender( $this->mGender ) ); |
288 | 44 | |
289 | | - # Set search namespace options |
290 | | - foreach( $this->mSearchNs as $i => $value ) { |
291 | | - $wgUser->setOption( "searchNs{$i}", $value ); |
292 | | - } |
| 45 | + $htmlForm = Preferences::getFormObject( $wgUser ); |
| 46 | + $htmlForm->setSubmitCallback( array( 'Preferences', 'tryUISubmit' ) ); |
293 | 47 | |
294 | | - if( $wgEnableEmail && $wgEnableUserEmail ) { |
295 | | - $wgUser->setOption( 'disablemail', $this->mEmailFlag ); |
296 | | - } |
297 | | - |
298 | | - # Set user toggles |
299 | | - foreach ( $this->mToggles as $tname => $tvalue ) { |
300 | | - $wgUser->setOption( $tname, $tvalue ); |
301 | | - } |
302 | | - |
303 | | - $error = false; |
304 | | - if( $wgEnableEmail ) { |
305 | | - $newadr = $this->mUserEmail; |
306 | | - $oldadr = $wgUser->getEmail(); |
307 | | - if( ($newadr != '') && ($newadr != $oldadr) ) { |
308 | | - # the user has supplied a new email address on the login page |
309 | | - if( $wgUser->isValidEmailAddr( $newadr ) ) { |
310 | | - # new behaviour: set this new emailaddr from login-page into user database record |
311 | | - $wgUser->setEmail( $newadr ); |
312 | | - # but flag as "dirty" = unauthenticated |
313 | | - $wgUser->invalidateEmail(); |
314 | | - if ($wgEmailAuthentication) { |
315 | | - # Mail a temporary password to the dirty address. |
316 | | - # User can come back through the confirmation URL to re-enable email. |
317 | | - $result = $wgUser->sendConfirmationMail(); |
318 | | - if( WikiError::isError( $result ) ) { |
319 | | - $error = wfMsg( 'mailerror', htmlspecialchars( $result->getMessage() ) ); |
320 | | - } else { |
321 | | - $error = wfMsg( 'eauthentsent', $wgUser->getName() ); |
322 | | - } |
323 | | - } |
324 | | - } else { |
325 | | - $error = wfMsg( 'invalidemailaddress' ); |
326 | | - } |
327 | | - } else { |
328 | | - if( $wgEmailConfirmToEdit && empty( $newadr ) ) { |
329 | | - $this->mainPrefsForm( 'error', wfMsg( 'noemailtitle' ) ); |
330 | | - return; |
331 | | - } |
332 | | - $wgUser->setEmail( $this->mUserEmail ); |
333 | | - } |
334 | | - if( $oldadr != $newadr ) { |
335 | | - wfRunHooks( 'PrefsEmailAudit', array( $wgUser, $oldadr, $newadr ) ); |
336 | | - } |
337 | | - } |
338 | | - |
339 | | - if( !$wgAuth->updateExternalDB( $wgUser ) ){ |
340 | | - $this->mainPrefsForm( 'error', wfMsg( 'externaldberror' ) ); |
341 | | - return; |
342 | | - } |
343 | | - |
344 | | - $msg = ''; |
345 | | - if ( !wfRunHooks( 'SavePreferences', array( $this, $wgUser, &$msg, $oldOptions ) ) ) { |
346 | | - $this->mainPrefsForm( 'error', $msg ); |
347 | | - return; |
348 | | - } |
349 | | - |
350 | | - $wgUser->setCookies(); |
351 | | - $wgUser->saveSettings(); |
352 | | - |
353 | | - if( $needRedirect && $error === false ) { |
354 | | - $title = SpecialPage::getTitleFor( 'Preferences' ); |
355 | | - $wgOut->redirect( $title->getFullURL( 'success' ) ); |
356 | | - return; |
357 | | - } |
358 | | - |
359 | | - $wgOut->parserOptions( ParserOptions::newFromUser( $wgUser ) ); |
360 | | - $this->mainPrefsForm( $error === false ? 'success' : 'error', $error); |
| 48 | + $htmlForm->show(); |
361 | 49 | } |
362 | 50 | |
363 | | - /** |
364 | | - * @access private |
365 | | - */ |
366 | | - function resetPrefs() { |
367 | | - global $wgUser, $wgLang, $wgContLang, $wgContLanguageCode, $wgAllowRealName, $wgLocalTZoffset; |
| 51 | + function showResetForm() { |
| 52 | + global $wgOut; |
368 | 53 | |
369 | | - $this->mUserEmail = $wgUser->getEmail(); |
370 | | - $this->mUserEmailAuthenticationtimestamp = $wgUser->getEmailAuthenticationtimestamp(); |
371 | | - $this->mRealName = ($wgAllowRealName) ? $wgUser->getRealName() : ''; |
| 54 | + $wgOut->addWikiMsg( 'prefs-reset-intro' ); |
372 | 55 | |
373 | | - # language value might be blank, default to content language |
374 | | - $this->mUserLanguage = $wgUser->getOption( 'language', $wgContLanguageCode ); |
| 56 | + $htmlForm = new HTMLForm( array(), 'prefs-restore' ); |
375 | 57 | |
376 | | - $this->mUserVariant = $wgUser->getOption( 'variant'); |
377 | | - $this->mEmailFlag = $wgUser->getOption( 'disablemail' ) == 1 ? 1 : 0; |
378 | | - $this->mNick = $wgUser->getOption( 'nickname' ); |
| 58 | + $htmlForm->setSubmitText( wfMsg( 'restoreprefs' ) ); |
| 59 | + $htmlForm->setTitle( $this->getTitle( 'reset' ) ); |
| 60 | + $htmlForm->setSubmitCallback( array( __CLASS__, 'submitReset' ) ); |
| 61 | + $htmlForm->suppressReset(); |
379 | 62 | |
380 | | - $this->mQuickbar = $wgUser->getOption( 'quickbar' ); |
381 | | - $this->mSkin = Skin::normalizeKey( $wgUser->getOption( 'skin' ) ); |
382 | | - $this->mMath = $wgUser->getOption( 'math' ); |
383 | | - $this->mDate = $wgUser->getDatePreference(); |
384 | | - $this->mRows = $wgUser->getOption( 'rows' ); |
385 | | - $this->mCols = $wgUser->getOption( 'cols' ); |
386 | | - $this->mStubs = $wgUser->getOption( 'stubthreshold' ); |
387 | | - |
388 | | - $tz = $wgUser->getOption( 'timecorrection' ); |
389 | | - $data = explode( '|', $tz, 3 ); |
390 | | - $minDiff = null; |
391 | | - switch ( $data[0] ) { |
392 | | - case 'ZoneInfo': |
393 | | - $this->mTimeZone = $tz; |
394 | | - # Check if the specified TZ exists, and change to 'Offset' if |
395 | | - # not. |
396 | | - if ( !function_exists('timezone_open') || @timezone_open( $data[2] ) === false ) { |
397 | | - $this->mTimeZone = 'Offset'; |
398 | | - $minDiff = intval( $data[1] ); |
399 | | - } |
400 | | - break; |
401 | | - case '': |
402 | | - case 'System': |
403 | | - $this->mTimeZone = 'System|'.$wgLocalTZoffset; |
404 | | - break; |
405 | | - case 'Offset': |
406 | | - $this->mTimeZone = 'Offset'; |
407 | | - $minDiff = intval( $data[1] ); |
408 | | - break; |
409 | | - default: |
410 | | - $this->mTimeZone = 'Offset'; |
411 | | - $data = explode( ':', $tz, 2 ); |
412 | | - if( count( $data ) == 2 ) { |
413 | | - $data[0] = intval( $data[0] ); |
414 | | - $data[1] = intval( $data[1] ); |
415 | | - $minDiff = abs( $data[0] ) * 60 + $data[1]; |
416 | | - if ( $data[0] < 0 ) $minDiff = -$minDiff; |
417 | | - } else { |
418 | | - $minDiff = intval( $data[0] ) * 60; |
419 | | - } |
420 | | - break; |
421 | | - } |
422 | | - if ( is_null( $minDiff ) ) { |
423 | | - $this->mHourDiff = ''; |
424 | | - } else { |
425 | | - $this->mHourDiff = sprintf( '%+03d:%02d', floor($minDiff/60), abs($minDiff)%60 ); |
426 | | - } |
427 | | - |
428 | | - $this->mSearch = $wgUser->getOption( 'searchlimit' ); |
429 | | - $this->mSearchLines = $wgUser->getOption( 'contextlines' ); |
430 | | - $this->mSearchChars = $wgUser->getOption( 'contextchars' ); |
431 | | - $this->mImageSize = $wgUser->getOption( 'imagesize' ); |
432 | | - $this->mThumbSize = $wgUser->getOption( 'thumbsize' ); |
433 | | - $this->mRecent = $wgUser->getOption( 'rclimit' ); |
434 | | - $this->mRecentDays = $wgUser->getOption( 'rcdays' ); |
435 | | - $this->mWatchlistEdits = $wgUser->getOption( 'wllimit' ); |
436 | | - $this->mUnderline = $wgUser->getOption( 'underline' ); |
437 | | - $this->mWatchlistDays = $wgUser->getOption( 'watchlistdays' ); |
438 | | - $this->mDisableMWSuggest = $wgUser->getBoolOption( 'disablesuggest' ); |
439 | | - $this->mGender = $wgUser->getOption( 'gender' ); |
440 | | - |
441 | | - $togs = User::getToggles(); |
442 | | - foreach ( $togs as $tname ) { |
443 | | - $this->mToggles[$tname] = $wgUser->getOption( $tname ); |
444 | | - } |
445 | | - |
446 | | - $namespaces = $wgContLang->getNamespaces(); |
447 | | - foreach ( $namespaces as $i => $namespace ) { |
448 | | - if ( $i >= NS_MAIN ) { |
449 | | - $this->mSearchNs[$i] = $wgUser->getOption( 'searchNs'.$i ); |
450 | | - } |
451 | | - } |
452 | | - |
453 | | - wfRunHooks( 'ResetPreferences', array( $this, $wgUser ) ); |
| 63 | + $htmlForm->show(); |
454 | 64 | } |
455 | | - |
456 | | - /** |
457 | | - * @access private |
458 | | - */ |
459 | | - function restorePreferences() { |
| 65 | + |
| 66 | + static function submitReset( $formData ) { |
460 | 67 | global $wgUser, $wgOut; |
461 | | - $wgUser->restoreOptions(); |
462 | | - $wgUser->setCookies(); |
463 | | - $wgUser->saveSettings(); |
464 | | - $title = SpecialPage::getTitleFor( 'Preferences' ); |
465 | | - $wgOut->redirect( $title->getFullURL( 'success' ) ); |
466 | | - } |
| 68 | + $wgUser->resetOptions(); |
467 | 69 | |
468 | | - /** |
469 | | - * @access private |
470 | | - */ |
471 | | - function namespacesCheckboxes() { |
472 | | - global $wgContLang; |
| 70 | + $url = SpecialPage::getTitleFor( 'Preferences' )->getFullURL( 'success' ); |
473 | 71 | |
474 | | - # Determine namespace checkboxes |
475 | | - $namespaces = $wgContLang->getNamespaces(); |
476 | | - $r1 = null; |
| 72 | + $wgOut->redirect( $url ); |
477 | 73 | |
478 | | - foreach ( $namespaces as $i => $name ) { |
479 | | - if ($i < 0) |
480 | | - continue; |
481 | | - $checked = $this->mSearchNs[$i] ? "checked='checked'" : ''; |
482 | | - $name = str_replace( '_', ' ', $namespaces[$i] ); |
483 | | - |
484 | | - if ( empty($name) ) |
485 | | - $name = wfMsg( 'blanknamespace' ); |
486 | | - |
487 | | - $r1 .= "<input type='checkbox' value='1' name='wpNs$i' id='wpNs$i' {$checked}/> <label for='wpNs$i'>{$name}</label><br />\n"; |
488 | | - } |
489 | | - return $r1; |
| 74 | + return true; |
490 | 75 | } |
491 | | - |
492 | | - |
493 | | - function getToggle( $tname, $trailer = false, $disabled = false ) { |
494 | | - global $wgUser, $wgLang; |
495 | | - |
496 | | - $this->mUsedToggles[$tname] = true; |
497 | | - $ttext = $wgLang->getUserToggle( $tname ); |
498 | | - |
499 | | - $checked = $wgUser->getOption( $tname ) == 1 ? ' checked="checked"' : ''; |
500 | | - $disabled = $disabled ? ' disabled="disabled"' : ''; |
501 | | - $trailer = $trailer ? $trailer : ''; |
502 | | - return "<div class='toggle'><input type='checkbox' value='1' id=\"$tname\" name=\"wpOp$tname\"$checked$disabled />" . |
503 | | - " <span class='toggletext'><label for=\"$tname\">$ttext</label>$trailer</span></div>\n"; |
504 | | - } |
505 | | - |
506 | | - function getToggles( $items ) { |
507 | | - $out = ""; |
508 | | - foreach( $items as $item ) { |
509 | | - if( $item === false ) |
510 | | - continue; |
511 | | - if( is_array( $item ) ) { |
512 | | - list( $key, $trailer ) = $item; |
513 | | - } else { |
514 | | - $key = $item; |
515 | | - $trailer = false; |
516 | | - } |
517 | | - $out .= $this->getToggle( $key, $trailer ); |
518 | | - } |
519 | | - return $out; |
520 | | - } |
521 | | - |
522 | | - function addRow($td1, $td2) { |
523 | | - return "<tr><td class='mw-label'>$td1</td><td class='mw-input'>$td2</td></tr>"; |
524 | | - } |
525 | | - |
526 | | - /** |
527 | | - * Helper function for user information panel |
528 | | - * @param $td1 label for an item |
529 | | - * @param $td2 item or null |
530 | | - * @param $td3 optional help or null |
531 | | - * @return xhtml block |
532 | | - */ |
533 | | - function tableRow( $td1, $td2 = null, $td3 = null ) { |
534 | | - |
535 | | - if ( is_null( $td3 ) ) { |
536 | | - $td3 = ''; |
537 | | - } else { |
538 | | - $td3 = Xml::tags( 'tr', null, |
539 | | - Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td3 ) |
540 | | - ); |
541 | | - } |
542 | | - |
543 | | - if ( is_null( $td2 ) ) { |
544 | | - $td1 = Xml::tags( 'td', array( 'class' => 'pref-label', 'colspan' => '2' ), $td1 ); |
545 | | - $td2 = ''; |
546 | | - } else { |
547 | | - $td1 = Xml::tags( 'td', array( 'class' => 'pref-label' ), $td1 ); |
548 | | - $td2 = Xml::tags( 'td', array( 'class' => 'pref-input' ), $td2 ); |
549 | | - } |
550 | | - |
551 | | - return Xml::tags( 'tr', null, $td1 . $td2 ). $td3 . "\n"; |
552 | | - |
553 | | - } |
554 | | - |
555 | | - /** |
556 | | - * @access private |
557 | | - */ |
558 | | - function mainPrefsForm( $status , $message = '' ) { |
559 | | - global $wgUser, $wgOut, $wgLang, $wgContLang, $wgAuth; |
560 | | - global $wgAllowRealName, $wgImageLimits, $wgThumbLimits; |
561 | | - global $wgDisableLangConversion, $wgDisableTitleConversion; |
562 | | - global $wgEnotifWatchlist, $wgEnotifUserTalk,$wgEnotifMinorEdits; |
563 | | - global $wgRCShowWatchingUsers, $wgEnotifRevealEditorAddress; |
564 | | - global $wgEnableEmail, $wgEnableUserEmail, $wgEmailAuthentication; |
565 | | - global $wgContLanguageCode, $wgDefaultSkin, $wgCookieExpiration; |
566 | | - global $wgEmailConfirmToEdit, $wgEnableMWSuggest, $wgLocalTZoffset; |
567 | | - |
568 | | - $wgOut->setPageTitle( wfMsg( 'preferences' ) ); |
569 | | - $wgOut->setArticleRelated( false ); |
570 | | - $wgOut->setRobotPolicy( 'noindex,nofollow' ); |
571 | | - $wgOut->addScriptFile( 'prefs.js' ); |
572 | | - |
573 | | - $wgOut->disallowUserJs(); # Prevent hijacked user scripts from sniffing passwords etc. |
574 | | - |
575 | | - if ( $this->mSuccess || 'success' == $status ) { |
576 | | - $wgOut->wrapWikiMsg( '<div class="successbox"><strong>$1</strong></div>', 'savedprefs' ); |
577 | | - } else if ( 'error' == $status ) { |
578 | | - $wgOut->addWikiText( '<div class="errorbox"><strong>' . $message . '</strong></div>' ); |
579 | | - } else if ( '' != $status ) { |
580 | | - $wgOut->addWikiText( $message . "\n----" ); |
581 | | - } |
582 | | - |
583 | | - $qbs = $wgLang->getQuickbarSettings(); |
584 | | - $mathopts = $wgLang->getMathNames(); |
585 | | - $dateopts = $wgLang->getDatePreferences(); |
586 | | - $togs = User::getToggles(); |
587 | | - |
588 | | - $titleObj = SpecialPage::getTitleFor( 'Preferences' ); |
589 | | - |
590 | | - # Pre-expire some toggles so they won't show if disabled |
591 | | - $this->mUsedToggles[ 'shownumberswatching' ] = true; |
592 | | - $this->mUsedToggles[ 'showupdated' ] = true; |
593 | | - $this->mUsedToggles[ 'enotifwatchlistpages' ] = true; |
594 | | - $this->mUsedToggles[ 'enotifusertalkpages' ] = true; |
595 | | - $this->mUsedToggles[ 'enotifminoredits' ] = true; |
596 | | - $this->mUsedToggles[ 'enotifrevealaddr' ] = true; |
597 | | - $this->mUsedToggles[ 'ccmeonemails' ] = true; |
598 | | - $this->mUsedToggles[ 'uselivepreview' ] = true; |
599 | | - $this->mUsedToggles[ 'noconvertlink' ] = true; |
600 | | - |
601 | | - |
602 | | - if ( !$this->mEmailFlag ) { $emfc = 'checked="checked"'; } |
603 | | - else { $emfc = ''; } |
604 | | - |
605 | | - |
606 | | - if ($wgEmailAuthentication && ($this->mUserEmail != '') ) { |
607 | | - if( $wgUser->getEmailAuthenticationTimestamp() ) { |
608 | | - // date and time are separate parameters to facilitate localisation. |
609 | | - // $time is kept for backward compat reasons. |
610 | | - // 'emailauthenticated' is also used in SpecialConfirmemail.php |
611 | | - $time = $wgLang->timeAndDate( $wgUser->getEmailAuthenticationTimestamp(), true ); |
612 | | - $d = $wgLang->date( $wgUser->getEmailAuthenticationTimestamp(), true ); |
613 | | - $t = $wgLang->time( $wgUser->getEmailAuthenticationTimestamp(), true ); |
614 | | - $emailauthenticated = wfMsg('emailauthenticated', $time, $d, $t ).'<br />'; |
615 | | - $disableEmailPrefs = false; |
616 | | - } else { |
617 | | - $disableEmailPrefs = true; |
618 | | - $skin = $wgUser->getSkin(); |
619 | | - $emailauthenticated = wfMsg('emailnotauthenticated').'<br />' . |
620 | | - $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Confirmemail' ), |
621 | | - wfMsg( 'emailconfirmlink' ) ) . '<br />'; |
622 | | - } |
623 | | - } else { |
624 | | - $emailauthenticated = ''; |
625 | | - $disableEmailPrefs = false; |
626 | | - } |
627 | | - |
628 | | - if ($this->mUserEmail == '') { |
629 | | - $emailauthenticated = wfMsg( 'noemailprefs' ) . '<br />'; |
630 | | - } |
631 | | - |
632 | | - $ps = $this->namespacesCheckboxes(); |
633 | | - |
634 | | - $enotifwatchlistpages = ($wgEnotifWatchlist) ? $this->getToggle( 'enotifwatchlistpages', false, $disableEmailPrefs ) : ''; |
635 | | - $enotifusertalkpages = ($wgEnotifUserTalk) ? $this->getToggle( 'enotifusertalkpages', false, $disableEmailPrefs ) : ''; |
636 | | - $enotifminoredits = ($wgEnotifWatchlist && $wgEnotifMinorEdits) ? $this->getToggle( 'enotifminoredits', false, $disableEmailPrefs ) : ''; |
637 | | - $enotifrevealaddr = (($wgEnotifWatchlist || $wgEnotifUserTalk) && $wgEnotifRevealEditorAddress) ? $this->getToggle( 'enotifrevealaddr', false, $disableEmailPrefs ) : ''; |
638 | | - |
639 | | - # </FIXME> |
640 | | - |
641 | | - $wgOut->addHTML( |
642 | | - Xml::openElement( 'form', array( |
643 | | - 'action' => $titleObj->getLocalUrl(), |
644 | | - 'method' => 'post', |
645 | | - 'id' => 'mw-preferences-form', |
646 | | - ) ) . |
647 | | - Xml::openElement( 'div', array( 'id' => 'preferences' ) ) |
648 | | - ); |
649 | | - |
650 | | - # User data |
651 | | - |
652 | | - $wgOut->addHTML( |
653 | | - Xml::fieldset( wfMsg('prefs-personal') ) . |
654 | | - Xml::openElement( 'table' ) . |
655 | | - $this->tableRow( Xml::element( 'h2', null, wfMsg( 'prefs-personal' ) ) ) |
656 | | - ); |
657 | | - |
658 | | - # Get groups to which the user belongs |
659 | | - $userEffectiveGroups = $wgUser->getEffectiveGroups(); |
660 | | - $userEffectiveGroupsArray = array(); |
661 | | - foreach( $userEffectiveGroups as $ueg ) { |
662 | | - if( $ueg == '*' ) { |
663 | | - // Skip the default * group, seems useless here |
664 | | - continue; |
665 | | - } |
666 | | - $userEffectiveGroupsArray[] = User::makeGroupLinkHTML( $ueg ); |
667 | | - } |
668 | | - asort( $userEffectiveGroupsArray ); |
669 | | - |
670 | | - $sk = $wgUser->getSkin(); |
671 | | - $toolLinks = array(); |
672 | | - $toolLinks[] = $sk->makeKnownLinkObj( SpecialPage::getTitleFor( 'ListGroupRights' ), wfMsg( 'listgrouprights' ) ); |
673 | | - # At the moment one tool link only but be prepared for the future... |
674 | | - # FIXME: Add a link to Special:Userrights for users who are allowed to use it. |
675 | | - # $wgUser->isAllowed( 'userrights' ) seems to strict in some cases |
676 | | - |
677 | | - $userInformationHtml = |
678 | | - $this->tableRow( wfMsgHtml( 'username' ), htmlspecialchars( $wgUser->getName() ) ) . |
679 | | - $this->tableRow( wfMsgHtml( 'uid' ), htmlspecialchars( $wgUser->getId() ) ) . |
680 | | - |
681 | | - $this->tableRow( |
682 | | - wfMsgExt( 'prefs-memberingroups', array( 'parseinline' ), count( $userEffectiveGroupsArray ) ), |
683 | | - $wgLang->commaList( $userEffectiveGroupsArray ) . |
684 | | - '<br />(' . $wgLang->pipeList( $toolLinks ) . ')' |
685 | | - ) . |
686 | | - |
687 | | - $this->tableRow( |
688 | | - wfMsgHtml( 'prefs-edits' ), |
689 | | - $wgLang->formatNum( $wgUser->getEditCount() ) |
690 | | - ); |
691 | | - |
692 | | - if( wfRunHooks( 'PreferencesUserInformationPanel', array( $this, &$userInformationHtml ) ) ) { |
693 | | - $wgOut->addHTML( $userInformationHtml ); |
694 | | - } |
695 | | - |
696 | | - if ( $wgAllowRealName ) { |
697 | | - $wgOut->addHTML( |
698 | | - $this->tableRow( |
699 | | - Xml::label( wfMsg('yourrealname'), 'wpRealName' ), |
700 | | - Xml::input( 'wpRealName', 25, $this->mRealName, array( 'id' => 'wpRealName' ) ), |
701 | | - Xml::tags('div', array( 'class' => 'prefsectiontip' ), |
702 | | - wfMsgExt( 'prefs-help-realname', 'parseinline' ) |
703 | | - ) |
704 | | - ) |
705 | | - ); |
706 | | - } |
707 | | - if ( $wgEnableEmail ) { |
708 | | - $wgOut->addHTML( |
709 | | - $this->tableRow( |
710 | | - Xml::label( wfMsg('youremail'), 'wpUserEmail' ), |
711 | | - Xml::input( 'wpUserEmail', 25, $this->mUserEmail, array( 'id' => 'wpUserEmail' ) ), |
712 | | - Xml::tags('div', array( 'class' => 'prefsectiontip' ), |
713 | | - wfMsgExt( $wgEmailConfirmToEdit ? 'prefs-help-email-required' : 'prefs-help-email', 'parseinline' ) |
714 | | - ) |
715 | | - ) |
716 | | - ); |
717 | | - } |
718 | | - |
719 | | - global $wgParser, $wgMaxSigChars; |
720 | | - if( mb_strlen( $this->mNick ) > $wgMaxSigChars ) { |
721 | | - $invalidSig = $this->tableRow( |
722 | | - ' ', |
723 | | - Xml::element( 'span', array( 'class' => 'error' ), |
724 | | - wfMsgExt( 'badsiglength', 'parsemag', $wgLang->formatNum( $wgMaxSigChars ) ) ) |
725 | | - ); |
726 | | - } elseif( !empty( $this->mToggles['fancysig'] ) && |
727 | | - false === $wgParser->validateSig( $this->mNick ) ) { |
728 | | - $invalidSig = $this->tableRow( |
729 | | - ' ', |
730 | | - Xml::element( 'span', array( 'class' => 'error' ), wfMsg( 'badsig' ) ) |
731 | | - ); |
732 | | - } else { |
733 | | - $invalidSig = ''; |
734 | | - } |
735 | | - |
736 | | - $wgOut->addHTML( |
737 | | - $this->tableRow( |
738 | | - Xml::label( wfMsg( 'yournick' ), 'wpNick' ), |
739 | | - Xml::input( 'wpNick', 25, $this->mNick, |
740 | | - array( |
741 | | - 'id' => 'wpNick', |
742 | | - // Note: $wgMaxSigChars is enforced in Unicode characters, |
743 | | - // both on the backend and now in the browser. |
744 | | - // Badly-behaved requests may still try to submit |
745 | | - // an overlong string, however. |
746 | | - 'maxlength' => $wgMaxSigChars ) ) |
747 | | - ) . |
748 | | - $invalidSig . |
749 | | - $this->tableRow( ' ', $this->getToggle( 'fancysig' ) ) |
750 | | - ); |
751 | | - |
752 | | - $gender = new XMLSelect( 'wpGender', 'wpGender', $this->mGender ); |
753 | | - $gender->addOption( wfMsg( 'gender-unknown' ), 'unknown' ); |
754 | | - $gender->addOption( wfMsg( 'gender-male' ), 'male' ); |
755 | | - $gender->addOption( wfMsg( 'gender-female' ), 'female' ); |
756 | | - |
757 | | - $wgOut->addHTML( |
758 | | - $this->tableRow( |
759 | | - Xml::label( wfMsg( 'yourgender' ), 'wpGender' ), |
760 | | - $gender->getHTML(), |
761 | | - Xml::tags( 'div', array( 'class' => 'prefsectiontip' ), |
762 | | - wfMsgExt( 'prefs-help-gender', 'parseinline' ) |
763 | | - ) |
764 | | - ) |
765 | | - ); |
766 | | - |
767 | | - list( $lsLabel, $lsSelect) = Xml::languageSelector( $this->mUserLanguage, false ); |
768 | | - $wgOut->addHTML( |
769 | | - $this->tableRow( $lsLabel, $lsSelect ) |
770 | | - ); |
771 | | - |
772 | | - /* see if there are multiple language variants to choose from*/ |
773 | | - if(!$wgDisableLangConversion) { |
774 | | - $variants = $wgContLang->getVariants(); |
775 | | - $variantArray = array(); |
776 | | - |
777 | | - $languages = Language::getLanguageNames( true ); |
778 | | - foreach($variants as $v) { |
779 | | - $v = str_replace( '_', '-', strtolower($v)); |
780 | | - if( array_key_exists( $v, $languages ) ) { |
781 | | - // If it doesn't have a name, we'll pretend it doesn't exist |
782 | | - $variantArray[$v] = $languages[$v]; |
783 | | - } |
784 | | - } |
785 | | - |
786 | | - $options = "\n"; |
787 | | - foreach( $variantArray as $code => $name ) { |
788 | | - $selected = ($code == $this->mUserVariant); |
789 | | - $options .= Xml::option( "$code - $name", $code, $selected ) . "\n"; |
790 | | - } |
791 | | - |
792 | | - if(count($variantArray) > 1) { |
793 | | - $wgOut->addHTML( |
794 | | - $this->tableRow( |
795 | | - Xml::label( wfMsg( 'yourvariant' ), 'wpUserVariant' ), |
796 | | - Xml::tags( 'select', |
797 | | - array( 'name' => 'wpUserVariant', 'id' => 'wpUserVariant' ), |
798 | | - $options |
799 | | - ) |
800 | | - ) |
801 | | - ); |
802 | | - } |
803 | | - |
804 | | - if(count($variantArray) > 1 && !$wgDisableLangConversion && !$wgDisableTitleConversion) { |
805 | | - $wgOut->addHTML( |
806 | | - Xml::tags( 'tr', null, |
807 | | - Xml::tags( 'td', array( 'colspan' => '2' ), |
808 | | - $this->getToggle( "noconvertlink" ) |
809 | | - ) |
810 | | - ) |
811 | | - ); |
812 | | - } |
813 | | - } |
814 | | - |
815 | | - # Password |
816 | | - if( $wgAuth->allowPasswordChange() ) { |
817 | | - $link = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'ResetPass' ), wfMsgHtml( 'prefs-resetpass' ), |
818 | | - array() , array('returnto' => SpecialPage::getTitleFor( 'Preferences') ) ); |
819 | | - $wgOut->addHTML( |
820 | | - $this->tableRow( Xml::element( 'h2', null, wfMsg( 'changepassword' ) ) ) . |
821 | | - $this->tableRow( '<ul><li>' . $link . '</li></ul>' ) ); |
822 | | - } |
823 | | - |
824 | | - # <FIXME> |
825 | | - # Enotif |
826 | | - if ( $wgEnableEmail ) { |
827 | | - |
828 | | - $moreEmail = ''; |
829 | | - if ($wgEnableUserEmail) { |
830 | | - // fixme -- the "allowemail" pseudotoggle is a hacked-together |
831 | | - // inversion for the "disableemail" preference. |
832 | | - $emf = wfMsg( 'allowemail' ); |
833 | | - $disabled = $disableEmailPrefs ? ' disabled="disabled"' : ''; |
834 | | - $moreEmail = |
835 | | - "<input type='checkbox' $emfc $disabled value='1' name='wpEmailFlag' id='wpEmailFlag' /> <label for='wpEmailFlag'>$emf</label>" . |
836 | | - $this->getToggle( 'ccmeonemails', '', $disableEmailPrefs ); |
837 | | - } |
838 | | - |
839 | | - |
840 | | - $wgOut->addHTML( |
841 | | - $this->tableRow( Xml::element( 'h2', null, wfMsg( 'email' ) ) ) . |
842 | | - $this->tableRow( |
843 | | - $emailauthenticated. |
844 | | - $enotifrevealaddr. |
845 | | - $enotifwatchlistpages. |
846 | | - $enotifusertalkpages. |
847 | | - $enotifminoredits. |
848 | | - $moreEmail |
849 | | - ) |
850 | | - ); |
851 | | - } |
852 | | - # </FIXME> |
853 | | - |
854 | | - $wgOut->addHTML( |
855 | | - Xml::closeElement( 'table' ) . |
856 | | - Xml::closeElement( 'fieldset' ) |
857 | | - ); |
858 | | - |
859 | | - |
860 | | - # Quickbar |
861 | | - # |
862 | | - if ($this->mSkin == 'cologneblue' || $this->mSkin == 'standard') { |
863 | | - $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg( 'qbsettings' ) . "</legend>\n" ); |
864 | | - for ( $i = 0; $i < count( $qbs ); ++$i ) { |
865 | | - if ( $i == $this->mQuickbar ) { $checked = ' checked="checked"'; } |
866 | | - else { $checked = ""; } |
867 | | - $wgOut->addHTML( "<div><label><input type='radio' name='wpQuickbar' value=\"$i\"$checked />{$qbs[$i]}</label></div>\n" ); |
868 | | - } |
869 | | - $wgOut->addHTML( "</fieldset>\n\n" ); |
870 | | - } else { |
871 | | - # Need to output a hidden option even if the relevant skin is not in use, |
872 | | - # otherwise the preference will get reset to 0 on submit |
873 | | - $wgOut->addHTML( Xml::hidden( 'wpQuickbar', $this->mQuickbar ) ); |
874 | | - } |
875 | | - |
876 | | - # Skin |
877 | | - # |
878 | | - global $wgAllowUserSkin; |
879 | | - if( $wgAllowUserSkin ) { |
880 | | - $wgOut->addHTML( "<fieldset>\n<legend>\n" . wfMsg( 'skin' ) . "</legend>\n" ); |
881 | | - $mptitle = Title::newMainPage(); |
882 | | - $previewtext = wfMsg( 'skin-preview' ); |
883 | | - # Only show members of Skin::getSkinNames() rather than |
884 | | - # $skinNames (skins is all skin names from Language.php) |
885 | | - $validSkinNames = Skin::getUsableSkins(); |
886 | | - # Sort by UI skin name. First though need to update validSkinNames as sometimes |
887 | | - # the skinkey & UI skinname differ (e.g. "standard" skinkey is "Classic" in the UI). |
888 | | - foreach ( $validSkinNames as $skinkey => &$skinname ) { |
889 | | - $msgName = "skinname-{$skinkey}"; |
890 | | - $localisedSkinName = wfMsg( $msgName ); |
891 | | - if ( !wfEmptyMsg( $msgName, $localisedSkinName ) ) { |
892 | | - $skinname = $localisedSkinName; |
893 | | - } |
894 | | - } |
895 | | - asort($validSkinNames); |
896 | | - foreach( $validSkinNames as $skinkey => $sn ) { |
897 | | - $checked = $skinkey == $this->mSkin ? ' checked="checked"' : ''; |
898 | | - $mplink = htmlspecialchars( $mptitle->getLocalURL( "useskin=$skinkey" ) ); |
899 | | - $previewlink = "(<a target='_blank' href=\"$mplink\">$previewtext</a>)"; |
900 | | - $extraLinks = ''; |
901 | | - global $wgAllowUserCss, $wgAllowUserJs; |
902 | | - if( $wgAllowUserCss ) { |
903 | | - $cssPage = Title::makeTitleSafe( NS_USER, $wgUser->getName().'/'.$skinkey.'.css' ); |
904 | | - $customCSS = $sk->makeLinkObj( $cssPage, wfMsgExt('prefs-custom-css', array() ) ); |
905 | | - $extraLinks .= " ($customCSS)"; |
906 | | - } |
907 | | - if( $wgAllowUserJs ) { |
908 | | - $jsPage = Title::makeTitleSafe( NS_USER, $wgUser->getName().'/'.$skinkey.'.js' ); |
909 | | - $customJS = $sk->makeLinkObj( $jsPage, wfMsgHtml('prefs-custom-js') ); |
910 | | - $extraLinks .= " ($customJS)"; |
911 | | - } |
912 | | - if( $skinkey == $wgDefaultSkin ) |
913 | | - $sn .= ' (' . wfMsg( 'default' ) . ')'; |
914 | | - $wgOut->addHTML( "<input type='radio' name='wpSkin' id=\"wpSkin$skinkey\" value=\"$skinkey\"$checked /> |
915 | | - <label for=\"wpSkin$skinkey\">{$sn}</label> $previewlink{$extraLinks}<br />\n" ); |
916 | | - } |
917 | | - $wgOut->addHTML( "</fieldset>\n\n" ); |
918 | | - } |
919 | | - |
920 | | - # Math |
921 | | - # |
922 | | - global $wgUseTeX; |
923 | | - if( $wgUseTeX ) { |
924 | | - $wgOut->addHTML( "<fieldset>\n<legend>" . wfMsg('math') . '</legend>' ); |
925 | | - foreach ( $mathopts as $k => $v ) { |
926 | | - $checked = ($k == $this->mMath); |
927 | | - $wgOut->addHTML( |
928 | | - Xml::openElement( 'div' ) . |
929 | | - Xml::radioLabel( wfMsg( $v ), 'wpMath', $k, "mw-sp-math-$k", $checked ) . |
930 | | - Xml::closeElement( 'div' ) . "\n" |
931 | | - ); |
932 | | - } |
933 | | - $wgOut->addHTML( "</fieldset>\n\n" ); |
934 | | - } |
935 | | - |
936 | | - # Files |
937 | | - # |
938 | | - $imageLimitOptions = null; |
939 | | - foreach ( $wgImageLimits as $index => $limits ) { |
940 | | - $selected = ($index == $this->mImageSize); |
941 | | - $imageLimitOptions .= Xml::option( "{$limits[0]}×{$limits[1]}" . |
942 | | - wfMsg('unit-pixel'), $index, $selected ); |
943 | | - } |
944 | | - |
945 | | - $imageThumbOptions = null; |
946 | | - foreach ( $wgThumbLimits as $index => $size ) { |
947 | | - $selected = ($index == $this->mThumbSize); |
948 | | - $imageThumbOptions .= Xml::option($size . wfMsg('unit-pixel'), $index, |
949 | | - $selected); |
950 | | - } |
951 | | - |
952 | | - $imageSizeId = 'wpImageSize'; |
953 | | - $thumbSizeId = 'wpThumbSize'; |
954 | | - $wgOut->addHTML( |
955 | | - Xml::fieldset( wfMsg( 'files' ) ) . "\n" . |
956 | | - Xml::openElement( 'table' ) . |
957 | | - '<tr> |
958 | | - <td class="mw-label">' . |
959 | | - Xml::label( wfMsg( 'imagemaxsize' ), $imageSizeId ) . |
960 | | - '</td> |
961 | | - <td class="mw-input">' . |
962 | | - Xml::openElement( 'select', array( 'name' => $imageSizeId, 'id' => $imageSizeId ) ) . |
963 | | - $imageLimitOptions . |
964 | | - Xml::closeElement( 'select' ) . |
965 | | - '</td> |
966 | | - </tr><tr> |
967 | | - <td class="mw-label">' . |
968 | | - Xml::label( wfMsg( 'thumbsize' ), $thumbSizeId ) . |
969 | | - '</td> |
970 | | - <td class="mw-input">' . |
971 | | - Xml::openElement( 'select', array( 'name' => $thumbSizeId, 'id' => $thumbSizeId ) ) . |
972 | | - $imageThumbOptions . |
973 | | - Xml::closeElement( 'select' ) . |
974 | | - '</td> |
975 | | - </tr>' . |
976 | | - Xml::closeElement( 'table' ) . |
977 | | - Xml::closeElement( 'fieldset' ) |
978 | | - ); |
979 | | - |
980 | | - # Date format |
981 | | - # |
982 | | - # Date/Time |
983 | | - # |
984 | | - |
985 | | - $wgOut->addHTML( |
986 | | - Xml::openElement( 'fieldset' ) . |
987 | | - Xml::element( 'legend', null, wfMsg( 'datetime' ) ) . "\n" |
988 | | - ); |
989 | | - |
990 | | - if ($dateopts) { |
991 | | - $wgOut->addHTML( |
992 | | - Xml::openElement( 'fieldset' ) . |
993 | | - Xml::element( 'legend', null, wfMsg( 'dateformat' ) ) . "\n" |
994 | | - ); |
995 | | - $idCnt = 0; |
996 | | - $epoch = '20010115161234'; # Wikipedia day |
997 | | - foreach( $dateopts as $key ) { |
998 | | - if( $key == 'default' ) { |
999 | | - $formatted = wfMsg( 'datedefault' ); |
1000 | | - } else { |
1001 | | - $formatted = $wgLang->timeanddate( $epoch, false, $key ); |
1002 | | - } |
1003 | | - $wgOut->addHTML( |
1004 | | - Xml::tags( 'div', null, |
1005 | | - Xml::radioLabel( $formatted, 'wpDate', $key, "wpDate$idCnt", $key == $this->mDate ) |
1006 | | - ) . "\n" |
1007 | | - ); |
1008 | | - $idCnt++; |
1009 | | - } |
1010 | | - $wgOut->addHTML( Xml::closeElement( 'fieldset' ) . "\n" ); |
1011 | | - } |
1012 | | - |
1013 | | - $nowlocal = Xml::openElement( 'span', array( 'id' => 'wpLocalTime' ) ) . |
1014 | | - $wgLang->time( $now = wfTimestampNow(), true ) . |
1015 | | - Xml::closeElement( 'span' ); |
1016 | | - $nowserver = $wgLang->time( $now, false ) . |
1017 | | - Xml::hidden( 'wpServerTime', substr( $now, 8, 2 ) * 60 + substr( $now, 10, 2 ) ); |
1018 | | - |
1019 | | - $wgOut->addHTML( |
1020 | | - Xml::openElement( 'fieldset' ) . |
1021 | | - Xml::element( 'legend', null, wfMsg( 'timezonelegend' ) ) . |
1022 | | - Xml::openElement( 'table' ) . |
1023 | | - $this->addRow( wfMsg( 'servertime' ), $nowserver ) . |
1024 | | - $this->addRow( wfMsg( 'localtime' ), $nowlocal ) |
1025 | | - ); |
1026 | | - $opt = Xml::openElement( 'select', array( |
1027 | | - 'name' => 'wpTimeZone', |
1028 | | - 'id' => 'wpTimeZone', |
1029 | | - 'onchange' => 'javascript:updateTimezoneSelection(false)' ) ); |
1030 | | - $opt .= Xml::option( wfMsg( 'timezoneuseserverdefault' ), "System|$wgLocalTZoffset", $this->mTimeZone === "System|$wgLocalTZoffset" ); |
1031 | | - $opt .= Xml::option( wfMsg( 'timezoneuseoffset' ), 'Offset', $this->mTimeZone === 'Offset' ); |
1032 | | - |
1033 | | - if ( function_exists( 'timezone_identifiers_list' ) ) { |
1034 | | - # Read timezone list |
1035 | | - $tzs = timezone_identifiers_list(); |
1036 | | - sort( $tzs ); |
1037 | | - |
1038 | | - # Precache localized region names |
1039 | | - $tzRegions = array(); |
1040 | | - $tzRegions['Africa'] = wfMsg( 'timezoneregion-africa' ); |
1041 | | - $tzRegions['America'] = wfMsg( 'timezoneregion-america' ); |
1042 | | - $tzRegions['Antarctica'] = wfMsg( 'timezoneregion-antarctica' ); |
1043 | | - $tzRegions['Arctic'] = wfMsg( 'timezoneregion-arctic' ); |
1044 | | - $tzRegions['Asia'] = wfMsg( 'timezoneregion-asia' ); |
1045 | | - $tzRegions['Atlantic'] = wfMsg( 'timezoneregion-atlantic' ); |
1046 | | - $tzRegions['Australia'] = wfMsg( 'timezoneregion-australia' ); |
1047 | | - $tzRegions['Europe'] = wfMsg( 'timezoneregion-europe' ); |
1048 | | - $tzRegions['Indian'] = wfMsg( 'timezoneregion-indian' ); |
1049 | | - $tzRegions['Pacific'] = wfMsg( 'timezoneregion-pacific' ); |
1050 | | - asort( $tzRegions ); |
1051 | | - |
1052 | | - $selZone = explode( '|', $this->mTimeZone, 3 ); |
1053 | | - $selZone = ( $selZone[0] == 'ZoneInfo' ) ? $selZone[2] : null; |
1054 | | - $now = date_create( 'now' ); |
1055 | | - $optgroup = ''; |
1056 | | - |
1057 | | - foreach ( $tzs as $tz ) { |
1058 | | - $z = explode( '/', $tz, 2 ); |
1059 | | - |
1060 | | - # timezone_identifiers_list() returns a number of |
1061 | | - # backwards-compatibility entries. This filters them out of the |
1062 | | - # list presented to the user. |
1063 | | - if ( count( $z ) != 2 || !array_key_exists( $z[0], $tzRegions ) ) |
1064 | | - continue; |
1065 | | - |
1066 | | - # Localize region |
1067 | | - $z[0] = $tzRegions[$z[0]]; |
1068 | | - |
1069 | | - # Create region groups |
1070 | | - if ( $optgroup != $z[0] ) { |
1071 | | - if ( $optgroup !== '' ) { |
1072 | | - $opt .= Xml::closeElement( 'optgroup' ); |
1073 | | - } |
1074 | | - $optgroup = $z[0]; |
1075 | | - $opt .= Xml::openElement( 'optgroup', array( 'label' => $z[0] ) ) . "\n"; |
1076 | | - } |
1077 | | - |
1078 | | - $minDiff = floor( timezone_offset_get( timezone_open( $tz ), $now ) / 60 ); |
1079 | | - $opt .= Xml::option( str_replace( '_', ' ', $z[0] . '/' . $z[1] ), "ZoneInfo|$minDiff|$tz", $selZone === $tz, array( 'label' => $z[1] ) ) . "\n"; |
1080 | | - } |
1081 | | - if ( $optgroup !== '' ) $opt .= Xml::closeElement( 'optgroup' ); |
1082 | | - } |
1083 | | - $opt .= Xml::closeElement( 'select' ); |
1084 | | - $wgOut->addHTML( |
1085 | | - $this->addRow( |
1086 | | - Xml::label( wfMsg( 'timezoneselect' ), 'wpTimeZone' ), |
1087 | | - $opt ) |
1088 | | - ); |
1089 | | - $wgOut->addHTML( |
1090 | | - $this->addRow( |
1091 | | - Xml::label( wfMsg( 'timezoneoffset' ), 'wpHourDiff' ), |
1092 | | - Xml::input( 'wpHourDiff', 6, $this->mHourDiff, array( |
1093 | | - 'id' => 'wpHourDiff', |
1094 | | - 'onfocus' => 'javascript:updateTimezoneSelection(true)', |
1095 | | - 'onblur' => 'javascript:updateTimezoneSelection(false)' ) ) ) . |
1096 | | - "<tr> |
1097 | | - <td></td> |
1098 | | - <td class='mw-submit'>" . |
1099 | | - Xml::element( 'input', |
1100 | | - array( 'type' => 'button', |
1101 | | - 'value' => wfMsg( 'guesstimezone' ), |
1102 | | - 'onclick' => 'javascript:guessTimezone()', |
1103 | | - 'id' => 'guesstimezonebutton', |
1104 | | - 'style' => 'display:none;' ) ) . |
1105 | | - "</td> |
1106 | | - </tr>" . |
1107 | | - Xml::closeElement( 'table' ) . |
1108 | | - Xml::tags( 'div', array( 'class' => 'prefsectiontip' ), wfMsgExt( 'timezonetext', 'parseinline' ) ). |
1109 | | - Xml::closeElement( 'fieldset' ) . |
1110 | | - Xml::closeElement( 'fieldset' ) . "\n\n" |
1111 | | - ); |
1112 | | - |
1113 | | - # Editing |
1114 | | - # |
1115 | | - global $wgLivePreview; |
1116 | | - $wgOut->addHTML( |
1117 | | - Xml::fieldset( wfMsg( 'textboxsize' ) ) . |
1118 | | - wfMsgHTML( 'prefs-edit-boxsize' ) . ' ' . |
1119 | | - Xml::inputLabel( wfMsg( 'rows' ), 'wpRows', 'wpRows', 3, $this->mRows ) . ' ' . |
1120 | | - Xml::inputLabel( wfMsg( 'columns' ), 'wpCols', 'wpCols', 3, $this->mCols ) . |
1121 | | - $this->getToggles( array( |
1122 | | - 'editsection', |
1123 | | - 'editsectiononrightclick', |
1124 | | - 'editondblclick', |
1125 | | - 'editwidth', |
1126 | | - 'showtoolbar', |
1127 | | - 'previewonfirst', |
1128 | | - 'previewontop', |
1129 | | - 'minordefault', |
1130 | | - 'externaleditor', |
1131 | | - 'externaldiff', |
1132 | | - $wgLivePreview ? 'uselivepreview' : false, |
1133 | | - 'forceeditsummary', |
1134 | | - ) ) |
1135 | | - ); |
1136 | | - |
1137 | | - $wgOut->addHTML( Xml::closeElement( 'fieldset' ) ); |
1138 | | - |
1139 | | - # Recent changes |
1140 | | - global $wgRCMaxAge, $wgUseRCPatrol; |
1141 | | - $wgOut->addHTML( |
1142 | | - Xml::fieldset( wfMsg( 'prefs-rc' ) ) . |
1143 | | - Xml::openElement( 'table' ) . |
1144 | | - '<tr> |
1145 | | - <td class="mw-label">' . |
1146 | | - Xml::label( wfMsg( 'recentchangesdays' ), 'wpRecentDays' ) . |
1147 | | - '</td> |
1148 | | - <td class="mw-input">' . |
1149 | | - Xml::input( 'wpRecentDays', 3, $this->mRecentDays, array( 'id' => 'wpRecentDays' ) ) . ' ' . |
1150 | | - wfMsgExt( 'recentchangesdays-max', 'parsemag', |
1151 | | - $wgLang->formatNum( ceil( $wgRCMaxAge / ( 3600 * 24 ) ) ) ) . |
1152 | | - '</td> |
1153 | | - </tr><tr> |
1154 | | - <td class="mw-label">' . |
1155 | | - Xml::label( wfMsg( 'recentchangescount' ), 'wpRecent' ) . |
1156 | | - '</td> |
1157 | | - <td class="mw-input">' . |
1158 | | - Xml::input( 'wpRecent', 3, $this->mRecent, array( 'id' => 'wpRecent' ) ) . |
1159 | | - '</td> |
1160 | | - </tr>' . |
1161 | | - Xml::closeElement( 'table' ) . |
1162 | | - '<br />' |
1163 | | - ); |
1164 | | - |
1165 | | - $toggles[] = 'hideminor'; |
1166 | | - if( $wgUseRCPatrol ) { |
1167 | | - $toggles[] = 'hidepatrolled'; |
1168 | | - $toggles[] = 'newpageshidepatrolled'; |
1169 | | - } |
1170 | | - if( $wgRCShowWatchingUsers ) $toggles[] = 'shownumberswatching'; |
1171 | | - $toggles[] = 'usenewrc'; |
1172 | | - |
1173 | | - $wgOut->addHTML( |
1174 | | - $this->getToggles( $toggles ) . |
1175 | | - Xml::closeElement( 'fieldset' ) |
1176 | | - ); |
1177 | | - |
1178 | | - # Watchlist |
1179 | | - $watchlistToggles = array( 'watchlisthideminor', 'watchlisthidebots', 'watchlisthideown', |
1180 | | - 'watchlisthideanons', 'watchlisthideliu' ); |
1181 | | - if( $wgUseRCPatrol ) $watchlistToggles[] = 'watchlisthidepatrolled'; |
1182 | | - |
1183 | | - $wgOut->addHTML( |
1184 | | - Xml::fieldset( wfMsg( 'prefs-watchlist' ) ) . |
1185 | | - Xml::inputLabel( wfMsg( 'prefs-watchlist-days' ), 'wpWatchlistDays', 'wpWatchlistDays', 3, $this->mWatchlistDays ) . ' ' . |
1186 | | - wfMsgHTML( 'prefs-watchlist-days-max' ) . |
1187 | | - '<br /><br />' . |
1188 | | - $this->getToggle( 'extendwatchlist' ) . |
1189 | | - Xml::inputLabel( wfMsg( 'prefs-watchlist-edits' ), 'wpWatchlistEdits', 'wpWatchlistEdits', 3, $this->mWatchlistEdits ) . ' ' . |
1190 | | - wfMsgHTML( 'prefs-watchlist-edits-max' ) . |
1191 | | - '<br /><br />' . |
1192 | | - $this->getToggles( $watchlistToggles ) |
1193 | | - ); |
1194 | | - |
1195 | | - if( $wgUser->isAllowed( 'createpage' ) || $wgUser->isAllowed( 'createtalk' ) ) { |
1196 | | - $wgOut->addHTML( $this->getToggle( 'watchcreations' ) ); |
1197 | | - } |
1198 | | - |
1199 | | - foreach( array( 'edit' => 'watchdefault', 'move' => 'watchmoves', 'delete' => 'watchdeletion' ) as $action => $toggle ) { |
1200 | | - if( $wgUser->isAllowed( $action ) ) |
1201 | | - $wgOut->addHTML( $this->getToggle( $toggle ) ); |
1202 | | - } |
1203 | | - $this->mUsedToggles['watchcreations'] = true; |
1204 | | - $this->mUsedToggles['watchdefault'] = true; |
1205 | | - $this->mUsedToggles['watchmoves'] = true; |
1206 | | - $this->mUsedToggles['watchdeletion'] = true; |
1207 | | - |
1208 | | - $wgOut->addHTML( Xml::closeElement( 'fieldset' ) ); |
1209 | | - |
1210 | | - # Search |
1211 | | - $mwsuggest = $wgEnableMWSuggest ? |
1212 | | - $this->addRow( |
1213 | | - Xml::label( wfMsg( 'mwsuggest-disable' ), 'wpDisableMWSuggest' ), |
1214 | | - Xml::check( 'wpDisableMWSuggest', $this->mDisableMWSuggest, array( 'id' => 'wpDisableMWSuggest' ) ) |
1215 | | - ) : ''; |
1216 | | - $wgOut->addHTML( |
1217 | | - // Elements for the search tab itself |
1218 | | - Xml::openElement( 'fieldset' ) . |
1219 | | - Xml::element( 'legend', null, wfMsg( 'searchresultshead' ) ) . |
1220 | | - // Elements for the search options in the search tab |
1221 | | - Xml::openElement( 'fieldset' ) . |
1222 | | - Xml::element( 'legend', null, wfMsg( 'prefs-searchoptions' ) ) . |
1223 | | - Xml::openElement( 'table' ) . |
1224 | | - $this->addRow( |
1225 | | - Xml::label( wfMsg( 'resultsperpage' ), 'wpSearch' ), |
1226 | | - Xml::input( 'wpSearch', 4, $this->mSearch, array( 'id' => 'wpSearch' ) ) |
1227 | | - ) . |
1228 | | - $this->addRow( |
1229 | | - Xml::label( wfMsg( 'contextlines' ), 'wpSearchLines' ), |
1230 | | - Xml::input( 'wpSearchLines', 4, $this->mSearchLines, array( 'id' => 'wpSearchLines' ) ) |
1231 | | - ) . |
1232 | | - $this->addRow( |
1233 | | - Xml::label( wfMsg( 'contextchars' ), 'wpSearchChars' ), |
1234 | | - Xml::input( 'wpSearchChars', 4, $this->mSearchChars, array( 'id' => 'wpSearchChars' ) ) |
1235 | | - ) . |
1236 | | - $mwsuggest . |
1237 | | - Xml::closeElement( 'table' ) . |
1238 | | - Xml::closeElement( 'fieldset' ) . |
1239 | | - // Elements for the namespace options in the search tab |
1240 | | - Xml::openElement( 'fieldset' ) . |
1241 | | - Xml::element( 'legend', null, wfMsg( 'prefs-namespaces' ) ) . |
1242 | | - wfMsgExt( 'defaultns', array( 'parse' ) ) . |
1243 | | - $ps . |
1244 | | - Xml::closeElement( 'fieldset' ) . |
1245 | | - // End of the search tab |
1246 | | - Xml::closeElement( 'fieldset' ) |
1247 | | - ); |
1248 | | - |
1249 | | - # Misc |
1250 | | - # |
1251 | | - $uopt = $wgUser->getOption( 'underline' ); |
1252 | | - $wgOut->addHTML( |
1253 | | - Xml::fieldset( wfMsg( 'prefs-misc' ) ) . |
1254 | | - Xml::openElement( 'table' ) . |
1255 | | - '<tr> |
1256 | | - <td class="mw-label">' . |
1257 | | - // Xml::label() cannot be used because 'stub-threshold' contains plain HTML |
1258 | | - Xml::tags( 'label', array( 'for' => 'wpStubs' ), wfMsg( 'stub-threshold' ) ) . |
1259 | | - '</td> |
1260 | | - <td class="mw-input">' . |
1261 | | - Xml::input( 'wpStubs', 6, $this->mStubs, array( 'id' => 'wpStubs' ) ) . |
1262 | | - '</td> |
1263 | | - </tr><tr> |
1264 | | - <td class="mw-label">' . |
1265 | | - Xml::label( wfMsg( 'tog-underline' ), 'wpOpunderline' ) . |
1266 | | - '</td> |
1267 | | - <td class="mw-input">' . |
1268 | | - Xml::openElement( 'select', array( 'id' => 'wpOpunderline', 'name' => 'wpOpunderline' ) ) . |
1269 | | - Xml::option( wfMsg ( 'underline-never' ), '0', $uopt == 0 ) . |
1270 | | - Xml::option( wfMsg ( 'underline-always' ), '1', $uopt == 1 ) . |
1271 | | - Xml::option( wfMsg ( 'underline-default' ), '2', $uopt == 2 ) . |
1272 | | - Xml::closeElement( 'select' ) . |
1273 | | - '</td> |
1274 | | - </tr>' . |
1275 | | - Xml::closeElement( 'table' ) |
1276 | | - ); |
1277 | | - |
1278 | | - # And now the rest = Misc. |
1279 | | - foreach ( $togs as $tname ) { |
1280 | | - if( !array_key_exists( $tname, $this->mUsedToggles ) ) { |
1281 | | - if( $tname == 'norollbackdiff' && $wgUser->isAllowed( 'rollback' ) ) |
1282 | | - $wgOut->addHTML( $this->getToggle( $tname ) ); |
1283 | | - else |
1284 | | - $wgOut->addHTML( $this->getToggle( $tname ) ); |
1285 | | - } |
1286 | | - } |
1287 | | - |
1288 | | - $wgOut->addHTML( '</fieldset>' ); |
1289 | | - |
1290 | | - wfRunHooks( 'RenderPreferencesForm', array( $this, $wgOut ) ); |
1291 | | - |
1292 | | - $token = htmlspecialchars( $wgUser->editToken() ); |
1293 | | - $skin = $wgUser->getSkin(); |
1294 | | - $rtl = $wgContLang->isRTL() ? 'left' : 'right'; |
1295 | | - $wgOut->addHTML( " |
1296 | | - <table id='prefsubmit' cellpadding='0' width='100%' style='background:none;'><tr> |
1297 | | - <td><input type='submit' name='wpSaveprefs' class='btnSavePrefs' value=\"" . wfMsgHtml( 'saveprefs' ) . |
1298 | | - '"'.$skin->tooltipAndAccesskey('save')." /> |
1299 | | - <input type='submit' name='wpReset' value=\"" . wfMsgHtml( 'resetprefs' ) . "\" /></td> |
1300 | | - <td align='$rtl'><input type='submit' name='wpRestore' value=\"" . wfMsgHtml( 'restoreprefs' ) . "\" /></td> |
1301 | | - </tr></table> |
1302 | | - |
1303 | | - <input type='hidden' name='wpEditToken' value=\"{$token}\" /> |
1304 | | - </div></form>\n" ); |
1305 | | - |
1306 | | - $wgOut->addHTML( Xml::tags( 'div', array( 'class' => "prefcache" ), |
1307 | | - wfMsgExt( 'clearyourcache', 'parseinline' ) ) |
1308 | | - ); |
1309 | | - } |
1310 | 76 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialUndelete.php |
— | — | @@ -833,7 +833,7 @@ |
834 | 834 | * @return string HTML |
835 | 835 | */ |
836 | 836 | function showDiff( $previousRev, $currentRev ) { |
837 | | - global $wgOut, $wgUser; |
| 837 | + global $wgOut; |
838 | 838 | |
839 | 839 | $diffEngine = new DifferenceEngine(); |
840 | 840 | $diffEngine->showDiffStyle(); |
— | — | @@ -866,28 +866,49 @@ |
867 | 867 | if( $isDeleted ) { |
868 | 868 | /// @fixme $rev->getTitle() is null for deleted revs...? |
869 | 869 | $targetPage = SpecialPage::getTitleFor( 'Undelete' ); |
870 | | - $targetQuery = 'target=' . |
871 | | - $this->mTargetObj->getPrefixedUrl() . |
872 | | - '×tamp=' . |
873 | | - wfTimestamp( TS_MW, $rev->getTimestamp() ); |
| 870 | + $targetQuery = array( |
| 871 | + 'target' => $this->mTargetObj->getPrefixedUrl(), |
| 872 | + 'timestamp' => wfTimestamp( TS_MW, $rev->getTimestamp() ) |
| 873 | + ); |
874 | 874 | } else { |
875 | 875 | /// @fixme getId() may return non-zero for deleted revs... |
876 | 876 | $targetPage = $rev->getTitle(); |
877 | | - $targetQuery = 'oldid=' . $rev->getId(); |
| 877 | + $targetQuery = array( 'oldid' => $rev->getId() ); |
878 | 878 | } |
| 879 | + // Add show/hide link if available |
| 880 | + if( $wgUser->isAllowed( 'deleterevision' ) ) { |
| 881 | + // If revision was hidden from sysops |
| 882 | + if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
| 883 | + $del = ' ' . Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), |
| 884 | + '(' . wfMsgHtml('rev-delundel') . ')' ); |
| 885 | + // Otherwise, show the link... |
| 886 | + } else { |
| 887 | + $query = array( 'target' => $this->mTargetObj->getPrefixedDbkey(), |
| 888 | + 'artimestamp' => $rev->getTimestamp() ); |
| 889 | + $del = ' ' . $sk->revDeleteLink( $query, |
| 890 | + $rev->isDeleted( Revision::DELETED_RESTRICTED ) ); |
| 891 | + } |
| 892 | + } else { |
| 893 | + $del = ''; |
| 894 | + } |
879 | 895 | return |
880 | 896 | '<div id="mw-diff-'.$prefix.'title1"><strong>' . |
881 | | - $sk->makeLinkObj( $targetPage, |
882 | | - wfMsgHtml( 'revisionasof', |
883 | | - $wgLang->timeanddate( $rev->getTimestamp(), true ) ), |
884 | | - $targetQuery ) . |
| 897 | + $sk->link( |
| 898 | + $targetPage, |
| 899 | + wfMsgHtml( |
| 900 | + 'revisionasof', |
| 901 | + $wgLang->timeanddate( $rev->getTimestamp(), true ) |
| 902 | + ), |
| 903 | + array(), |
| 904 | + $targetQuery |
| 905 | + ) . |
885 | 906 | ( $isDeleted ? ' ' . wfMsgHtml( 'deletedrev' ) : '' ) . |
886 | 907 | '</strong></div>' . |
887 | 908 | '<div id="mw-diff-'.$prefix.'title2">' . |
888 | 909 | $sk->revUserTools( $rev ) . '<br/>' . |
889 | 910 | '</div>' . |
890 | 911 | '<div id="mw-diff-'.$prefix.'title3">' . |
891 | | - $sk->revComment( $rev ) . '<br/>' . |
| 912 | + $sk->revComment( $rev ) . $del . '<br/>' . |
892 | 913 | '</div>'; |
893 | 914 | } |
894 | 915 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialNewpages.php |
— | — | @@ -247,7 +247,7 @@ |
248 | 248 | * @return string |
249 | 249 | */ |
250 | 250 | public function formatRow( $result ) { |
251 | | - global $wgLang, $wgContLang, $wgUser; |
| 251 | + global $wgLang, $wgContLang; |
252 | 252 | |
253 | 253 | $classes = array(); |
254 | 254 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialProtectedtitles.php |
— | — | @@ -61,7 +61,7 @@ |
62 | 62 | $skin = $wgUser->getSkin(); |
63 | 63 | |
64 | 64 | $title = Title::makeTitleSafe( $row->pt_namespace, $row->pt_title ); |
65 | | - $link = $skin->makeLinkObj( $title ); |
| 65 | + $link = $skin->link( $title ); |
66 | 66 | |
67 | 67 | $description_items = array (); |
68 | 68 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialShortpages.php |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | } |
68 | 68 | $hlink = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' ); |
69 | 69 | $plink = $this->isCached() |
70 | | - ? $skin->makeLinkObj( $title ) |
| 70 | + ? $skin->link( $title ) |
71 | 71 | : $skin->makeKnownLinkObj( $title ); |
72 | 72 | $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), $wgLang->formatNum( htmlspecialchars( $result->value ) ) ); |
73 | 73 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialNewimages.php |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | $ut = $s->img_user_text; |
127 | 127 | |
128 | 128 | $nt = Title::newFromText( $name, NS_FILE ); |
129 | | - $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut ); |
| 129 | + $ul = $sk->link( Title::makeTitle( NS_USER, $ut ), $ut ); |
130 | 130 | |
131 | 131 | $gallery->add( $nt, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp, true )."</i><br />\n" ); |
132 | 132 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialListredirects.php |
— | — | @@ -38,7 +38,12 @@ |
39 | 39 | |
40 | 40 | # Make a link to the redirect itself |
41 | 41 | $rd_title = Title::makeTitle( $result->namespace, $result->title ); |
42 | | - $rd_link = $skin->makeLinkObj( $rd_title, '', 'redirect=no' ); |
| 42 | + $rd_link = $skin->link( |
| 43 | + $rd_title, |
| 44 | + null, |
| 45 | + array(), |
| 46 | + array( 'redirect' => 'no' ) |
| 47 | + ); |
43 | 48 | |
44 | 49 | # Find out where the redirect leads |
45 | 50 | $revision = Revision::newFromTitle( $rd_title ); |
— | — | @@ -47,7 +52,7 @@ |
48 | 53 | $target = Title::newFromRedirect( $revision->getText() ); |
49 | 54 | if( $target ) { |
50 | 55 | $arr = $wgContLang->getArrow() . $wgContLang->getDirMark(); |
51 | | - $targetLink = $skin->makeLinkObj( $target ); |
| 56 | + $targetLink = $skin->link( $target ); |
52 | 57 | return "$rd_link $arr $targetLink"; |
53 | 58 | } else { |
54 | 59 | return "<s>$rd_link</s>"; |
Index: branches/querypage-work/phase3/includes/specials/SpecialUpload.php |
— | — | @@ -288,7 +288,7 @@ |
289 | 289 | * @access private |
290 | 290 | */ |
291 | 291 | function processUpload(){ |
292 | | - global $wgUser, $wgOut, $wgFileExtensions, $wgLang; |
| 292 | + global $wgOut, $wgFileExtensions, $wgLang; |
293 | 293 | $details = null; |
294 | 294 | $value = null; |
295 | 295 | $value = $this->internalProcessUpload( $details ); |
— | — | @@ -1166,7 +1166,7 @@ |
1167 | 1167 | else { |
1168 | 1168 | $wgOut->addHTML( |
1169 | 1169 | "<input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='60' |
1170 | | - value='{$encDestName}' onchange='toggleFilenameFiller()' $destOnkeyup />" |
| 1170 | + value=\"{$encDestName}\" onchange='toggleFilenameFiller()' $destOnkeyup />" |
1171 | 1171 | ); |
1172 | 1172 | } |
1173 | 1173 | |
Index: branches/querypage-work/phase3/includes/specials/SpecialMostlinkedtemplates.php |
— | — | @@ -88,7 +88,7 @@ |
89 | 89 | |
90 | 90 | $skin->link( $title ); |
91 | 91 | return wfSpecialList( |
92 | | - $skin->makeLinkObj( $title ), |
| 92 | + $skin->link( $title ), |
93 | 93 | $this->makeWlhLink( $title, $skin, $result ) |
94 | 94 | ); |
95 | 95 | } |
Index: branches/querypage-work/phase3/includes/specials/SpecialCreatePage.php |
— | — | @@ -0,0 +1,101 @@ |
| 2 | +<?php |
| 3 | +/* This code was adapted from CreatePage.php from: Travis Derouin <travis@wikihow.com> for the Uniwiki extension CreatePage |
| 4 | + * Originally licensed as: GNU GPL v2.0 or later |
| 5 | + * |
| 6 | + * This page has been copied and adapted from the Uniwiki extension CreatePage |
| 7 | + * Originally licensed as: http://www.gnu.org/licenses/gpl-3.0.txt |
| 8 | + * |
| 9 | + * @license GNU GPL v3.0 http://www.gnu.org/licenses/gpl-3.0.txt |
| 10 | + * @author Travis Derouin |
| 11 | + * @author Merrick Schaefer |
| 12 | + * @author Mark Johnston |
| 13 | + * @author Evan Wheeler |
| 14 | + * @author Adam Mckaig (at UNICEF) |
| 15 | + * @author Siebrand Mazeland (integrated into MediaWiki core) |
| 16 | + * @addtogroup SpecialPage |
| 17 | + */ |
| 18 | + |
| 19 | +class SpecialCreatePage extends SpecialPage { |
| 20 | + |
| 21 | + public function __construct() { |
| 22 | + parent::__construct( 'CreatePage', 'createpage' ); |
| 23 | + } |
| 24 | + |
| 25 | + public function execute( $params ) { |
| 26 | + global $wgOut, $wgRequest, $wgUser; |
| 27 | + |
| 28 | + $this->setHeaders(); |
| 29 | + |
| 30 | + if ( !$this->userCanExecute( $wgUser ) ) { |
| 31 | + $this->displayRestrictionError(); |
| 32 | + return; |
| 33 | + } |
| 34 | + |
| 35 | + $wgOut->addWikiMsg( 'createpage-summary' ); |
| 36 | + |
| 37 | + // check to see if we are trying to create a page |
| 38 | + $target = $wgRequest->getVal ( 'target' ); |
| 39 | + $title = Title::newFromText ( $target ); |
| 40 | + |
| 41 | + // check for no title |
| 42 | + if ( $wgRequest->wasPosted() && $target === '' ) { |
| 43 | + $this->error( wfMsg( 'createpage-entertitle' ) ); |
| 44 | + } |
| 45 | + // check for invalid title |
| 46 | + elseif ( $wgRequest->wasPosted() && is_null( $title ) ) { |
| 47 | + $this->error( wfMsg( 'createpage-badtitle', $target ) ); |
| 48 | + } |
| 49 | + elseif ( $target != null ) { |
| 50 | + if ( $title->getArticleID() > 0 ) { |
| 51 | + // if the title exists then let the user know and give other options |
| 52 | + $wgOut->addWikiText ( wfMsg ( 'createpage-titleexists', $title->getFullText() ) . "<br />" ); |
| 53 | + $skin = $wgUser->getSkin(); |
| 54 | + $editlink = $skin->makeLinkObj( $title, wfMsg ( 'createpage-editexisting' ), 'action=edit' ); |
| 55 | + $thisPage = Title::newFromText ( 'CreatePage', NS_SPECIAL ); |
| 56 | + $wgOut->addHTML ( $editlink . '<br />' |
| 57 | + . $skin->makeLinkObj ( $thisPage, wfMsg ( 'createpage-tryagain' ) ) |
| 58 | + ); |
| 59 | + return; |
| 60 | + } else { |
| 61 | + /* TODO - may want to search for closely named pages and give |
| 62 | + * other options here... */ |
| 63 | + |
| 64 | + // otherwise, redirect them to the edit page for their title |
| 65 | + $wgOut->redirect ( $title->getEditURL() ); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + // if this is just a normal GET, then output the form |
| 70 | + |
| 71 | + // prefill the input with the title, if it was passed along |
| 72 | + $newTitle = false; |
| 73 | + $newTitleText = $wgRequest->getVal( 'newtitle', null ); |
| 74 | + if ( $newTitleText != null ) { |
| 75 | + $newTitle = Title::newFromURL( $newTitleText ); |
| 76 | + if ( is_null( $newTitle ) ) |
| 77 | + $newTitle = $newTitleText; |
| 78 | + else |
| 79 | + $newTitle = $newTitle->getText(); |
| 80 | + } |
| 81 | + |
| 82 | + // output the form |
| 83 | + $form = Xml::openElement( 'fieldset' ) . |
| 84 | + Xml::element( 'legend', null, wfMsg( 'createpage' ) ) . # This should really use a different message |
| 85 | + wfMsgWikiHtml( 'createpage-instructions' ) . |
| 86 | + Xml::openElement( 'form', array( 'method' => 'post', 'name' => 'createpageform', 'action' => '' ) ) . |
| 87 | + Xml::element( 'input', array( 'type' => 'text', 'name' => 'target', 'size' => 50, 'value' => $newTitle ) ) . |
| 88 | + '<br />' . |
| 89 | + Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsgHtml( 'createpage-submitbutton' ) ) ) . |
| 90 | + Xml::closeElement( 'form' ) . |
| 91 | + Xml::closeElement( 'fieldset' ); |
| 92 | + $wgOut->addHTML( $form ); |
| 93 | + } |
| 94 | + /* |
| 95 | + * Function to output an error message |
| 96 | + * @param $msg String: message text or HTML |
| 97 | + */ |
| 98 | + function error( $msg ) { |
| 99 | + global $wgOut; |
| 100 | + $wgOut->addHTML( Xml::element( 'p', array( 'class' => 'error' ), $msg ) ); |
| 101 | + } |
| 102 | +} |
Property changes on: branches/querypage-work/phase3/includes/specials/SpecialCreatePage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 103 | + native |
Property changes on: branches/querypage-work/phase3/includes/specials |
___________________________________________________________________ |
Modified: svn:mergeinfo |
2 | 104 | Merged /trunk/phase3/includes/specials:r49528-50372 |