5 * @subpackage SpecialPage
9 * shortcut to get the current language "special" namespace name
13 $ns = $wgContLang->getNamespaces() ;
14 return $ns[NS_SPECIAL
] ;
21 function wfSpecialMaintenance( $par=NULL ) {
22 global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest, $wgContLanguageCode;
25 # This pages is expensive ressource wise
27 $wgOut->addWikiText( wfMsg( 'perfdisabled' ) );
31 # Get parameters from the URL
32 $submitmll = $wgRequest->getVal( 'submitmll' );
37 $subfunction = $wgRequest->getText( 'subfunction' );
40 # Call the subfunction requested by the user
41 switch( $subfunction ) {
42 case 'disambiguations': return wfSpecialDisambiguations() ; break;
44 # doubleredirects & brokenredirects are old maintenance subpages.
45 case 'doubleredirects': return wfSpecialDoubleRedirects() ; break;
46 case 'brokenredirects': return wfSpecialBrokenRedirects() ; break;
48 case 'selflinks': return wfSpecialSelfLinks() ; break;
49 case 'mispeelings': return wfSpecialMispeelings() ; break;
50 case 'missinglanguagelinks': return wfSpecialMissingLanguageLinks() ; break;
53 if ( !is_null( $submitmll ) ) return wfSpecialMissingLanguageLinks() ;
55 $sk = $wgUser->getSkin();
56 $ns = $wgContLang->getNamespaces() ;
58 # Generate page output
60 $r = wfMsg('maintnancepagetext') ;
62 # Links to subfunctions
64 $r .= "<li>".$sk->makeKnownLink( sns().':Disambiguations', wfMsg('disambiguations')) . "</li>\n";
65 $r .= '<li>'.$sk->makeKnownLink( sns().':DoubleRedirects', wfMsg('doubleredirects')) . "</li>\n";
66 $r .= '<li>'.$sk->makeKnownLink( sns().':BrokenRedirects', wfMsg('brokenredirects')) . "</li>\n";
67 #$r .= "<li>".getMPL("selflinks")."</li>\n" ; # Doesn't work
68 $r .= '<li>'.getMPL("mispeelings")."</li>\n" ;
70 # Interface for the missing language links
72 $l = getMPL('missinglanguagelinks');
73 $l = str_replace ( '</a>' , '' , $l ) ;
74 $l = str_replace ( '<a ' , '<FORM method="post" ' , $l ) ;
75 $l = explode ( '>' , $l ) ;
78 $r .= '<input type="submit" name="submitmll" value="' ;
79 $r .= htmlspecialchars(wfMsg('missinglanguagelinksbutton'), ENT_QUOTES
);
81 $r .= "<select name=\"thelang\">\n" ;
83 $a = $wgContLang->getLanguageNames();
84 $ak = array_keys ( $a ) ;
85 foreach ( $ak AS $k ) {
86 if ( $k != $wgContLanguageCode )
87 $r .= "<option value='{$k}'>{$a[$k]}</option>\n" ;
90 $r .= "</FORM>\n</li>" ;
93 $wgOut->addHTML ( $r ) ;
97 * Generate a maintenance page link
99 function getMPL ( $x ) {
100 global $wgUser , $wgLang;
101 $sk = $wgUser->getSkin() ;
102 return $sk->makeKnownLink( sns().":Maintenance" , wfMsg($x), 'subfunction='.$x ) ;
106 function getMaintenancePageBacklink( $subfunction ) {
107 global $wgUser , $wgContLang;
108 $sk = $wgUser->getSkin() ;
109 $ns = $wgContLang->getNamespaces() ;
110 $r = $sk->makeKnownLink (
111 $ns[-1].':Maintenance',
112 wfMsg( 'maintenancebacklink' ) ) ;
113 $t = wfMsg ( $subfunction ) ;
115 $s = '<table width="100%" border="0"><tr><td>';
116 $s .= '<h2>'.$t.'</h2></td><td align="right">';
117 $s .= "{$r}</td></tr></table>\n" ;
123 * Disambiguations, DoubleRedirects and BrokenRedirects are now using the
124 * QueryPage class. Code is in a Special*.php file.
128 function wfSpecialDoubleRedirects() {
130 $t = Title
::makeTitle( NS_SPECIAL
, "DoubleRedirects" );
131 $wgOut->redirect ($t->getFullURL());
134 function wfSpecialBrokenRedirects() {
136 $t = Title
::makeTitle( NS_SPECIAL
, "BrokenRedirects" );
137 $wgOut->redirect ($t->getFullURL());
140 function wfSpecialDisambiguations() {
142 $t = Title
::makeTitle( NS_SPECIAL
, "Disambiguations" );
143 $wgOut->redirect ($t->getFullURL());
149 * This doesn't really work anymore, because self-links are now displayed as
150 * unlinked bold text, and are not entered into the link table.
154 function wfSpecialSelfLinks() {
155 global $wgUser, $wgOut, $wgLang, $wgTitle;
156 $fname = 'wfSpecialSelfLinks';
158 list( $limit, $offset ) = wfCheckLimits();
160 $sql = "SELECT cur_namespace,cur_title FROM cur,links " .
161 "WHERE l_from=l_to AND l_to=cur_id " .
162 "LIMIT {$offset}, {$limit}";
164 $res = wfQuery( $sql, DB_SLAVE
, $fname );
166 $top = getMaintenancePageBacklink( 'selflinks' );
167 $top .= '<p>'.wfMsg('selflinkstext')."</p><br>\n";
168 $top .= wfShowingResults( $offset, $limit );
169 $wgOut->addHTML( "<p>{$top}\n" );
171 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
172 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=selflinks" , $sl ) ;
173 $wgOut->addHTML( "<br>{$sl}\n" );
175 $sk = $wgUser->getSkin();
176 $s = '<ol start=' . ( $offset +
1 ) . '>';
177 while ( $obj = wfFetchObject( $res ) ) {
178 $title = Title
::makeTitle( $obj->cur_namespace
, $obj->cur_title
);
179 $s .= "<li>".$sk->makeKnownLinkObj( $title )."</li>\n" ;
181 wfFreeResult( $res );
183 $wgOut->addHTML( $s );
184 $wgOut->addHTML( "<p>{$sl}\n" );
190 function wfSpecialMispeelings () {
191 global $wgUser, $wgOut, $wgContLang, $wgTitle;
192 $sk = $wgUser->getSkin();
193 $fname = 'wfSpecialMispeelings';
195 list( $limit, $offset ) = wfCheckLimits();
196 $dbr =& wfGetDB( DB_SLAVE
);
197 extract( $dbr->tableNames( 'cur', 'searchindex' ) );
199 # Determine page name
200 $ms = wfMsg ( 'mispeelingspage' ) ;
201 $mss = str_replace ( ' ' , '_' , $ms );
202 $msp = $wgContLang->getNsText(4).':'.$ms ;
203 $msl = $sk->makeKnownLink ( $msp ) ;
205 # Load list from database
206 $l = $dbr->selectField( 'cur', 'cur_text', array( 'cur_title' => $mss, 'cur_namespace' => 4 ), $fname );
207 $l = explode ( "\n" , $l ) ;
210 if ( substr ( trim ( $x ) , 0 , 1 ) == '*' )
211 $a[] = strtolower ( trim ( substr ( trim ( $x ) , 1 ) ) );
216 foreach ( $a AS $x ) {
217 if ( $cnt < $offset+
$limit && $x != '' ) {
219 $x = preg_replace( '/^(\S+).*$/', '$1', $x );
220 $sql = "SELECT DISTINCT cur_title FROM $cur,$searchindex WHERE cur_id=si_page AND ".
221 "cur_namespace=0 AND cur_is_redirect=0 AND " .
222 "(MATCH(si_text) AGAINST ('" . $dbr->strencode( $wgContLang->stripForSearch( $x ) ) . "'))" ;
223 $res = $dbr->query( $sql, $fname );
224 while ( $obj = $dbr->fetchObject ( $res ) ) {
225 if ( $cnt >= $offset AND $cnt < $offset+
$limit ) {
227 if ( count ( $b ) > 0 ) $b[] = "</OL>\n" ;
228 $b[] = "<H3>{$y}</H3>\n<OL start=".($cnt+
1).">\n" ;
232 $sk->makeKnownLink ( $obj->cur_title
).
234 $sk->makeBrokenLink ( $obj->cur_title
, wfMsg ( "qbedit" ) ).
241 $top = getMaintenancePageBacklink( 'mispeelings' );
242 $top .= "<p>".wfMsg( 'mispeelingstext', $msl )."</p><br>\n";
243 $top .= wfShowingResults( $offset, $limit );
244 $wgOut->addHTML( "<p>{$top}\n" );
246 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
247 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=mispeelings" , $sl ) ;
248 $wgOut->addHTML( "<br>{$sl}\n" );
250 $s = implode ( '' , $b ) ;
251 if ( count ( $b ) > 0 ) $s .= '</ol>';
252 $wgOut->addHTML( $s );
253 $wgOut->addHTML( "<p>{$sl}\n" );
259 function wfSpecialMissingLanguageLinks() {
260 global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest;
262 $fname = 'wfSpecialMissingLanguageLinks';
263 $thelang = $wgRequest->getText( 'thelang' );
264 if ( $thelang == 'w' ) $thelang = 'en' ; # Fix for international wikis
266 list( $limit, $offset ) = wfCheckLimits();
267 $dbr =& wfGetDB( DB_SLAVE
);
268 $cur = $dbr->tableName( 'cur' );
270 $sql = "SELECT cur_title FROM $cur " .
271 "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
272 "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' " .
273 "LIMIT {$offset}, {$limit}";
275 $res = $dbr->query( $sql, $fname );
278 $mll = wfMsg( 'missinglanguagelinkstext', $wgContLang->getLanguageName($thelang) );
280 $top = getMaintenancePageBacklink( 'missinglanguagelinks' );
281 $top .= "<p>$mll</p><br>";
282 $top .= wfShowingResults( $offset, $limit );
283 $wgOut->addHTML( "<p>{$top}\n" );
285 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
286 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=missinglanguagelinks&thelang={$thelang}" , $sl ) ;
287 $wgOut->addHTML( "<br>{$sl}\n" );
289 $sk = $wgUser->getSkin();
290 $s = '<ol start=' . ( $offset +
1 ) . '>';
291 while ( $obj = $dbr->fetchObject( $res ) )
292 $s .= "<li>".$sk->makeKnownLink ( $obj->cur_title
)."</li>\n" ;
293 $dbr->freeResult( $res );
295 $wgOut->addHTML( $s );
296 $wgOut->addHTML( "<p>{$sl}\n" );