* (bug 153) Adjust thumbnail size calculations to match consistently;
[lhc/web/wiklou.git] / includes / SpecialMaintenance.php
index 8ae913c..961248c 100644 (file)
@@ -9,9 +9,8 @@
  * shortcut to get the current language "special" namespace name
  */
 function sns() {
-       global $wgLang ;
-       $ns = $wgLang->getNamespaces() ;
-       return $ns[NS_SPECIAL] ;
+       global $wgContLang;
+       return $wgContLang->getNsText(NS_SPECIAL);
 }
 
 
@@ -19,7 +18,7 @@ function sns() {
  * Entry point
  */
 function wfSpecialMaintenance( $par=NULL ) {
-       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest, $wgLanguageCode;
+       global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest, $wgContLanguageCode;
        global $wgMiserMode;
 
        # This pages is expensive ressource wise
@@ -39,28 +38,27 @@ function wfSpecialMaintenance( $par=NULL ) {
 
        # Call the subfunction requested by the user
        switch( $subfunction ) {
-       case 'disambiguations': return wfSpecialDisambiguations() ; break;
+       case 'disambiguations': return wfSpecialDisambiguations();
        
        # doubleredirects & brokenredirects are old maintenance subpages.
-       case 'doubleredirects': return wfSpecialDoubleRedirects() ; break;
-       case 'brokenredirects': return wfSpecialBrokenRedirects() ; break;
+       case 'doubleredirects': return wfSpecialDoubleRedirects();
+       case 'brokenredirects': return wfSpecialBrokenRedirects();
        
-       case 'selflinks':       return wfSpecialSelfLinks()       ; break;
-       case 'mispeelings':     return wfSpecialMispeelings()     ; break;
-       case 'missinglanguagelinks': return wfSpecialMissingLanguageLinks() ; break;
+       case 'selflinks':       return wfSpecialSelfLinks()      ;
+       case 'mispeelings':     return wfSpecialMispeelings()    ;
+       case 'missinglanguagelinks': return wfSpecialMissingLanguageLinks();
        }
        
        if ( !is_null( $submitmll ) ) return wfSpecialMissingLanguageLinks() ;
 
        $sk = $wgUser->getSkin();
-       $ns = $wgLang->getNamespaces() ;
 
        # Generate page output
        
        $r = wfMsg('maintnancepagetext') ;
        
        # Links to subfunctions
-       $r .= "<UL>\n" ;
+       $r .= "<ul>\n" ;
        $r .= "<li>".$sk->makeKnownLink( sns().':Disambiguations', wfMsg('disambiguations')) . "</li>\n";
        $r .= '<li>'.$sk->makeKnownLink( sns().':DoubleRedirects', wfMsg('doubleredirects')) . "</li>\n";
        $r .= '<li>'.$sk->makeKnownLink( sns().':BrokenRedirects', wfMsg('brokenredirects')) . "</li>\n";
@@ -71,25 +69,26 @@ function wfSpecialMaintenance( $par=NULL ) {
        $r .= '<li>';
          $l = getMPL('missinglanguagelinks');
          $l = str_replace ( '</a>' , '' , $l ) ;
-         $l = str_replace ( '<a ' , '<FORM method="post" ' , $l ) ;
+         $l = str_replace ( '<a ' , '<form method="post" ' , $l ) ;
+         $l = str_replace ( ' href=' , ' action=' , $l ) ;
          $l = explode ( '>' , $l ) ;
          $l = $l[0] ;
        $r .= $l.">\n" ;
        $r .= '<input type="submit" name="submitmll" value="' ;
        $r .= htmlspecialchars(wfMsg('missinglanguagelinksbutton'), ENT_QUOTES);
-       $r .= "\">\n" ;
+       $r .= "\" />\n" ;
        $r .= "<select name=\"thelang\">\n" ;
        
-       $a = $wgLang->getLanguageNames();
+       $a = $wgContLang->getLanguageNames();
        $ak = array_keys ( $a ) ;
        foreach ( $ak AS $k ) {
-               if ( $k != $wgLanguageCode )
+               if ( $k != $wgContLanguageCode )
                        $r .= "<option value='{$k}'>{$a[$k]}</option>\n" ;
        }
        $r .= "</select>\n" ;
-       $r .= "</FORM>\n</li>" ;
+       $r .= "</form>\n</li>" ;
 
-       $r .= "</UL>\n" ;
+       $r .= "</ul>\n" ;
        $wgOut->addHTML ( $r ) ;
 }
 
@@ -104,11 +103,10 @@ function getMPL ( $x ) {
 
 
 function getMaintenancePageBacklink( $subfunction ) {
-       global $wgUser , $wgLang;
-       $sk = $wgUser->getSkin() ;
-       $ns = $wgLang->getNamespaces() ;
+       global $wgUser, $wgContLang;
+       $sk = $wgUser->getSkin();
        $r = $sk->makeKnownLink (
-               $ns[-1].':Maintenance',
+               $wgContLang->getNsText( NS_SPECIAL ) . ':Maintenance',
                wfMsg( 'maintenancebacklink' ) ) ;
        $t = wfMsg ( $subfunction ) ;
        
@@ -157,25 +155,25 @@ function wfSpecialSelfLinks() {
 
        list( $limit, $offset ) = wfCheckLimits();
 
-       $sql = "SELECT cur_namespace,cur_title FROM cur,links " . 
-         "WHERE l_from=l_to AND l_to=cur_id " . 
+       $sql = "SELECT page_namespace,page_title FROM page,links " . 
+         "WHERE l_from=l_to AND l_to=page_id " . 
          "LIMIT {$offset}, {$limit}";
 
        $res = wfQuery( $sql, DB_SLAVE, $fname );
 
        $top = getMaintenancePageBacklink( 'selflinks' );
-       $top .= '<p>'.wfMsg('selflinkstext')."</p><br>\n";
+       $top .= '<p>'.wfMsg('selflinkstext')."</p><br />\n";
        $top .= wfShowingResults( $offset, $limit );
        $wgOut->addHTML( "<p>{$top}\n" );
 
        $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
        $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=selflinks" , $sl ) ;
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       $wgOut->addHTML( "<br />{$sl}\n" );
 
        $sk = $wgUser->getSkin();
        $s = '<ol start=' . ( $offset + 1 ) . '>';
        while ( $obj = wfFetchObject( $res ) ) {
-               $title = Title::makeTitle( $obj->cur_namespace, $obj->cur_title );
+               $title = Title::makeTitle( $obj->page_namespace, $obj->page_title );
                $s .= "<li>".$sk->makeKnownLinkObj( $title )."</li>\n" ;
        }
        wfFreeResult( $res );
@@ -188,7 +186,7 @@ function wfSpecialSelfLinks() {
  * 
  */
 function wfSpecialMispeelings () {
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
+       global $wgUser, $wgOut, $wgContLang, $wgTitle;
        $sk = $wgUser->getSkin();
        $fname = 'wfSpecialMispeelings';
 
@@ -199,7 +197,7 @@ function wfSpecialMispeelings () {
        # Determine page name
        $ms = wfMsg ( 'mispeelingspage' ) ;
        $mss = str_replace ( ' ' , '_' , $ms );
-       $msp = $wgLang->getNsText(4).':'.$ms ;
+       $msp = $wgContLang->getNsText(4).':'.$ms ;
        $msl = $sk->makeKnownLink ( $msp ) ;
 
        # Load list from database
@@ -218,8 +216,8 @@ function wfSpecialMispeelings () {
                        $y = $x ;
                        $x = preg_replace( '/^(\S+).*$/', '$1', $x );
                        $sql = "SELECT DISTINCT cur_title FROM $cur,$searchindex WHERE cur_id=si_page AND ".
-                               "cur_namespace=0 AND cur_is_redirect=0 AND " .
-                               "(MATCH(si_text) AGAINST ('" . $dbr->strencode( $wgLang->stripForSearch( $x ) ) . "'))" ;
+                               "cur_namespace=".NS_MAIN." AND cur_is_redirect=0 AND " .
+                               "(MATCH(si_text) AGAINST ('" . $dbr->strencode( $wgContLang->stripForSearch( $x ) ) . "'))" ;
                        $res = $dbr->query( $sql, $fname );
                        while ( $obj = $dbr->fetchObject ( $res ) ) {
                                if ( $cnt >= $offset AND $cnt < $offset+$limit ) {
@@ -239,13 +237,13 @@ function wfSpecialMispeelings () {
                }
        }
        $top = getMaintenancePageBacklink( 'mispeelings' );
-       $top .= "<p>".wfMsg( 'mispeelingstext', $msl )."</p><br>\n";
+       $top .= "<p>".wfMsg( 'mispeelingstext', $msl )."</p><br />\n";
        $top .= wfShowingResults( $offset, $limit );
        $wgOut->addHTML( "<p>{$top}\n" );
 
        $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
        $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=mispeelings" , $sl ) ;
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       $wgOut->addHTML( "<br />{$sl}\n" );
 
        $s = implode ( '' , $b ) ;
        if ( count ( $b ) > 0 ) $s .= '</ol>';
@@ -257,7 +255,7 @@ function wfSpecialMispeelings () {
  *
  */
 function wfSpecialMissingLanguageLinks() {
-       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest;
+       global $wgUser, $wgOut, $wgContLang, $wgTitle, $wgRequest;
        
        $fname = 'wfSpecialMissingLanguageLinks';
        $thelang = $wgRequest->getText( 'thelang' );
@@ -268,23 +266,24 @@ function wfSpecialMissingLanguageLinks() {
        $cur = $dbr->tableName( 'cur' );
 
        $sql = "SELECT cur_title FROM $cur " .
-         "WHERE cur_namespace=0 AND cur_is_redirect=0 " .
-         "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[{$thelang}:%' " .
+         "WHERE cur_namespace=".NS_MAIN." AND cur_is_redirect=0 " .
+         "AND cur_title NOT LIKE '%/%' AND cur_text NOT LIKE '%[[" . wfStrencode( $thelang ) . ":%' " .
          "LIMIT {$offset}, {$limit}";
 
        $res = $dbr->query( $sql, $fname );
 
 
-       $mll = wfMsg( 'missinglanguagelinkstext', $wgLang->getLanguageName($thelang) );
+       $mll = wfMsg( 'missinglanguagelinkstext', $wgContLang->getLanguageName($thelang) );
 
        $top = getMaintenancePageBacklink( 'missinglanguagelinks' );
-       $top .= "<p>$mll</p><br>";
+       $top .= "<p>$mll</p><br />";
        $top .= wfShowingResults( $offset, $limit );
        $wgOut->addHTML( "<p>{$top}\n" );
 
        $sl = wfViewPrevNext( $offset, $limit, 'REPLACETHIS' ) ;
-       $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=missinglanguagelinks&thelang={$thelang}" , $sl ) ;
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       $sl = str_replace ( 'REPLACETHIS' , sns().":Maintenance&subfunction=missinglanguagelinks&thelang=".
+                                               htmlspecialchars($thelang), $sl ) ;
+       $wgOut->addHTML( "<br />{$sl}\n" );
 
        $sk = $wgUser->getSkin();
        $s = '<ol start=' . ( $offset + 1 ) . '>';