5 * @subpackage SpecialPage
9 * shortcut to get the current language "special" namespace name
13 return $wgContLang->getNsText(NS_SPECIAL
);
20 function wfSpecialMaintenance( $par=NULL ) {
21 global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest, $wgContLanguageCode;
24 # This pages is expensive ressource wise
26 $wgOut->addWikiText( wfMsg( 'perfdisabled' ) );
30 # Get parameters from the URL
31 $submitmll = $wgRequest->getVal( 'submitmll' );
36 $subfunction = $wgRequest->getText( 'subfunction' );
39 # Call the subfunction requested by the user
40 switch( $subfunction ) {
41 case 'disambiguations': return wfSpecialDisambiguations() ; break;
43 # doubleredirects & brokenredirects are old maintenance subpages.
44 case 'doubleredirects': return wfSpecialDoubleRedirects() ; break;
45 case 'brokenredirects': return wfSpecialBrokenRedirects() ; break;
47 case 'selflinks': return wfSpecialSelfLinks() ; break;
48 case 'mispeelings': return wfSpecialMispeelings() ; break;
49 case 'missinglanguagelinks': return wfSpecialMissingLanguageLinks() ; break;
52 if ( !is_null( $submitmll ) ) return wfSpecialMissingLanguageLinks() ;
54 $sk = $wgUser->getSkin();
56 # Generate page output
58 $r = wfMsg('maintnancepagetext') ;
60 # Links to subfunctions
62 $r .= "<li>".$sk->makeKnownLink( sns().':Disambiguations', wfMsg('disambiguations')) . "</li>\n";
63 $r .= '<li>'.$sk->makeKnownLink( sns().':DoubleRedirects', wfMsg('doubleredirects')) . "</li>\n";
64 $r .= '<li>'.$sk->makeKnownLink( sns().':BrokenRedirects', wfMsg('brokenredirects')) . "</li>\n";
65 #$r .= "<li>".getMPL("selflinks")."</li>\n" ; # Doesn't work
66 $r .= '<li>'.getMPL("mispeelings")."</li>\n" ;
68 # Interface for the missing language links
70 $l = getMPL('missinglanguagelinks');
71 $l = str_replace ( '</a>' , '' , $l ) ;
72 $l = str_replace ( '<a ' , '<form method="post" ' , $l ) ;
73 $l = str_replace ( ' href=' , ' action=' , $l ) ;
74 $l = explode ( '>' , $l ) ;
77 $r .= '<input type="submit" name="submitmll" value="' ;
78 $r .= htmlspecialchars(wfMsg('missinglanguagelinksbutton'), ENT_QUOTES
);
80 $r .= "<select name=\"thelang\">\n" ;
82 $a = $wgContLang->getLanguageNames();
83 $ak = array_keys ( $a ) ;
84 foreach ( $ak AS $k ) {
85 if ( $k != $wgContLanguageCode )
86 $r .= "<option value='{$k}'>{$a[$k]}</option>\n" ;
89 $r .= "</form>\n</li>" ;
92 $wgOut->addHTML ( $r ) ;
96 * Generate a maintenance page link
98 function getMPL ( $x ) {
99 global $wgUser , $wgLang;
100 $sk = $wgUser->getSkin() ;
101 return $sk->makeKnownLink( sns().":Maintenance" , wfMsg($x), 'subfunction='.$x ) ;
105 function getMaintenancePageBacklink( $subfunction ) {
106 global $wgUser, $wgContLang;
107 $sk = $wgUser->getSkin();
108 $r = $sk->makeKnownLink (
109 $wgContLang->getNsText( NS_SPECIAL
) . ':Maintenance',
110 wfMsg( 'maintenancebacklink' ) ) ;
111 $t = wfMsg ( $subfunction ) ;
113 $s = '<table width="100%" border="0"><tr><td>';
114 $s .= '<h2>'.$t.'</h2></td><td align="right">';
115 $s .= "{$r}</td></tr></table>\n" ;
121 * Disambiguations, DoubleRedirects and BrokenRedirects are now using the
122 * QueryPage class. Code is in a Special*.php file.
126 function wfSpecialDoubleRedirects() {
128 $t = Title
::makeTitle( NS_SPECIAL
, "DoubleRedirects" );
129 $wgOut->redirect ($t->getFullURL());
132 function wfSpecialBrokenRedirects() {
134 $t = Title
::makeTitle( NS_SPECIAL
, "BrokenRedirects" );
135 $wgOut->redirect ($t->getFullURL());
138 function wfSpecialDisambiguations() {
140 $t = Title
::makeTitle( NS_SPECIAL
, "Disambiguations" );
141 $wgOut->redirect ($t->getFullURL());
147 * This doesn't really work anymore, because self-links are now displayed as
148 * unlinked bold text, and are not entered into the link table.
152 function wfSpecialSelfLinks() {
153 global $wgUser, $wgOut, $wgLang, $wgTitle;
154 $fname = 'wfSpecialSelfLinks';
156 list( $limit, $offset ) = wfCheckLimits();
158 $sql = "SELECT page_namespace,page_title FROM page,links " .
159 "WHERE l_from=l_to AND l_to=page_id " .
160 "LIMIT {$offset}, {$limit}";
162 $res = wfQuery( $sql, DB_SLAVE
, $fname );
164 $top = getMaintenancePageBacklink( 'selflinks' );
165 $top .= '<p>'.wfMsg('selflinkstext')."</p><br />\n";
166 $top .= wfShowingResults( $offset, $limit );
167 $wgOut->addHTML( "<p>{$top}\n" );
169 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
170 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=selflinks" , $sl ) ;
171 $wgOut->addHTML( "<br />{$sl}\n" );
173 $sk = $wgUser->getSkin();
174 $s = '<ol start=' . ( $offset +
1 ) . '>';
175 while ( $obj = wfFetchObject( $res ) ) {
176 $title = Title
::makeTitle( $obj->page_namespace
, $obj->page_title
);
177 $s .= "<li>".$sk->makeKnownLinkObj( $title )."</li>\n" ;
179 wfFreeResult( $res );
181 $wgOut->addHTML( $s );
182 $wgOut->addHTML( "<p>{$sl}\n" );
188 function wfSpecialMispeelings () {
189 global $wgUser, $wgOut, $wgContLang, $wgTitle;
190 $sk = $wgUser->getSkin();
191 $fname = 'wfSpecialMispeelings';
193 list( $limit, $offset ) = wfCheckLimits();
194 $dbr =& wfGetDB( DB_SLAVE
);
195 extract( $dbr->tableNames( 'cur', 'searchindex' ) );
197 # Determine page name
198 $ms = wfMsg ( 'mispeelingspage' ) ;
199 $mss = str_replace ( ' ' , '_' , $ms );
200 $msp = $wgContLang->getNsText(4).':'.$ms ;
201 $msl = $sk->makeKnownLink ( $msp ) ;
203 # Load list from database
204 $l = $dbr->selectField( 'cur', 'cur_text', array( 'cur_title' => $mss, 'cur_namespace' => 4 ), $fname );
205 $l = explode ( "\n" , $l ) ;
208 if ( substr ( trim ( $x ) , 0 , 1 ) == '*' )
209 $a[] = strtolower ( trim ( substr ( trim ( $x ) , 1 ) ) );
214 foreach ( $a AS $x ) {
215 if ( $cnt < $offset+
$limit && $x != '' ) {
217 $x = preg_replace( '/^(\S+).*$/', '$1', $x );
218 $sql = "SELECT DISTINCT cur_title FROM $cur,$searchindex WHERE cur_id=si_page AND ".
219 "cur_namespace=".NS_MAIN
." AND cur_is_redirect=0 AND " .
220 "(MATCH(si_text) AGAINST ('" . $dbr->strencode( $wgContLang->stripForSearch( $x ) ) . "'))" ;
221 $res = $dbr->query( $sql, $fname );
222 while ( $obj = $dbr->fetchObject ( $res ) ) {
223 if ( $cnt >= $offset AND $cnt < $offset+
$limit ) {
225 if ( count ( $b ) > 0 ) $b[] = "</OL>\n" ;
226 $b[] = "<H3>{$y}</H3>\n<OL start=".($cnt+
1).">\n" ;
230 $sk->makeKnownLink ( $obj->cur_title
).
232 $sk->makeBrokenLink ( $obj->cur_title
, wfMsg ( "qbedit" ) ).
239 $top = getMaintenancePageBacklink( 'mispeelings' );
240 $top .= "<p>".wfMsg( 'mispeelingstext', $msl )."</p><br />\n";
241 $top .= wfShowingResults( $offset, $limit );
242 $wgOut->addHTML( "<p>{$top}\n" );
244 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
245 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=mispeelings" , $sl ) ;
246 $wgOut->addHTML( "<br />{$sl}\n" );
248 $s = implode ( '' , $b ) ;
249 if ( count ( $b ) > 0 ) $s .= '</ol>';
250 $wgOut->addHTML( $s );
251 $wgOut->addHTML( "<p>{$sl}\n" );
257 function wfSpecialMissingLanguageLinks() {
258 global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest;
260 $fname = 'wfSpecialMissingLanguageLinks';
261 $thelang = $wgRequest->getText( 'thelang' );
262 if ( $thelang == 'w' ) $thelang = 'en' ; # Fix for international wikis
264 list( $limit, $offset ) = wfCheckLimits();
265 $dbr =& wfGetDB( DB_SLAVE
);
266 $cur = $dbr->tableName( 'cur' );
268 $sql = "SELECT cur_title FROM $cur " .
269 "WHERE cur_namespace=".NS_MAIN
." AND cur_is_redirect=0 " .
270 "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[" . wfStrencode( $thelang ) . ":%' " .
271 "LIMIT {$offset}, {$limit}";
273 $res = $dbr->query( $sql, $fname );
276 $mll = wfMsg( 'missinglanguagelinkstext', $wgContLang->getLanguageName($thelang) );
278 $top = getMaintenancePageBacklink( 'missinglanguagelinks' );
279 $top .= "<p>$mll</p><br />";
280 $top .= wfShowingResults( $offset, $limit );
281 $wgOut->addHTML( "<p>{$top}\n" );
283 $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
284 $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=missinglanguagelinks&thelang=".
285 htmlspecialchars($thelang), $sl ) ;
286 $wgOut->addHTML( "<br />{$sl}\n" );
288 $sk = $wgUser->getSkin();
289 $s = '<ol start=' . ( $offset +
1 ) . '>';
290 while ( $obj = $dbr->fetchObject( $res ) )
291 $s .= "<li>".$sk->makeKnownLink ( $obj->cur_title
)."</li>\n" ;
292 $dbr->freeResult( $res );
294 $wgOut->addHTML( $s );
295 $wgOut->addHTML( "<p>{$sl}\n" );