Enhances special page links; allow some parameters to be passed via wikilinks to...
authorBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Jul 2003 06:22:03 +0000 (06:22 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Wed, 2 Jul 2003 06:22:03 +0000 (06:22 +0000)
includes/GlobalFunctions.php
includes/OutputPage.php
includes/SpecialAllpages.php
includes/SpecialContributions.php
includes/SpecialMaintenance.php
includes/SpecialRecentchanges.php
includes/SpecialRecentchangeslinked.php
includes/SpecialWhatlinkshere.php
includes/Title.php

index 2a76633..19efb75 100644 (file)
@@ -185,7 +185,8 @@ function wfMsg( $key )
        }
 
        if ( "" == $ret ) {
-               user_error( "Couldn't find text for message \"{$key}\"." );
+               # Let's at least _try_ to be graceful about this.
+               return "&lt;$key&gt;";
        }
        return $ret;
 }
@@ -254,6 +255,7 @@ function wfSpecialPage()
 {
        global $wgUser, $wgOut, $wgTitle, $wgLang;
 
+       /* FIXME: this list probably shouldn't be language-specific, per se */
        $validSP = $wgLang->getValidSpecialPages();
        $sysopSP = $wgLang->getSysopSpecialPages();
        $devSP = $wgLang->getDeveloperSpecialPages();
@@ -261,16 +263,21 @@ function wfSpecialPage()
        $wgOut->setArticleFlag( false );
        $wgOut->setRobotpolicy( "noindex,follow" );
 
-       $t = $wgTitle->getDBkey();
+       $par = NULL;
+       list($t, $par) = split( "/", $wgTitle->getDBkey(), 2 );
+       
        if ( array_key_exists( $t, $validSP ) ||
          ( $wgUser->isSysop() && array_key_exists( $t, $sysopSP ) ) ||
          ( $wgUser->isDeveloper() && array_key_exists( $t, $devSP ) ) ) {
+               if($par !== NULL)
+                       $wgTitle = Title::makeTitle( Namespace::getSpecial(), $t );
+
                $wgOut->setPageTitle( wfMsg( strtolower( $wgTitle->getText() ) ) );
 
                $inc = "Special" . $t . ".php";
                include_once( $inc );
                $call = "wfSpecial" . $t;
-               $call();
+               $call( $par );
        } else if ( array_key_exists( $t, $sysopSP ) ) {
                $wgOut->sysopRequired();
        } else if ( array_key_exists( $t, $devSP ) ) {
index a4c8e3a..50748e4 100644 (file)
@@ -1359,7 +1359,7 @@ class OutputPage {
        {
                global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding;
 
-               $ret = "<!DOCTYPE HTML PUBLIC \"$wgDocType\" \"$wgDTD\">\n";
+               $ret = "<!DOCTYPE HTML PUBLIC \"$wgDocType\"\n        \"$wgDTD\">\n";
 
                if ( "" == $this->mHTMLtitle ) {
                        $this->mHTMLtitle = $this->mPagetitle;
index bbd5fdc..8ba8225 100644 (file)
@@ -1,11 +1,13 @@
 <?
 
-function wfSpecialAllpages()
+function wfSpecialAllpages( $par=NULL )
 {
        global $from, $indexMaxperpage;
        $indexMaxperpage = 480;
 
-       if( isset( $from ) ) {
+       if( $par ) {
+               indexShowChunk( $par );
+       } elseif( isset( $from ) ) {
                indexShowChunk( $from );
        } else {
                indexShowToplevel();
index 1b5fdbb..fc88af8 100644 (file)
@@ -1,18 +1,22 @@
 <?
 
-function wfSpecialContributions()
+function wfSpecialContributions( $par = "" )
 {
        global $wgUser, $wgOut, $wgLang, $target, $hideminor;
        $fname = "wfSpecialContributions";
        $sysop = $wgUser->isSysop();
 
+       if( $par )
+               $target = $par;
+       else
+               $target = wfCleanQueryVar( $target );
+
        if ( "" == $target ) {
                $wgOut->errorpage( "notargettitle", "notargettext" );
                return;
        }
        list( $limit, $offset ) = wfCheckLimits( 50, "" );
 
-       $target = wfCleanQueryVar( $target );
        $nt = Title::newFromURL( $target );
        $nt->setNamespace( Namespace::getUser() );
 
index fefc96b..481c9d4 100644 (file)
@@ -1,20 +1,25 @@
 <?
 
 function sns()
-       {
+{
        global $wgLang ;
        $ns = $wgLang->getNamespaces() ;
        return $ns[-1] ;
-       }
+}
 
-function wfSpecialMaintenance ()
-       {
+function wfSpecialMaintenance( $par=NULL )
+{
        global $wgUser, $wgOut, $wgLang, $wgTitle, $subfunction, $wgLanguageCode, $submitmll;
        global $wgMiserMode;
        if ( $wgMiserMode ) {
                $wgOut->addWikiText( wfMsg( "perfdisabled" ) );
                return;
        }
+       
+       if( $par )
+               $subfunction = $par;
+       else
+               $subfunction = $_REQUEST['subfunction'];
 
        if ( $subfunction == "disambiguations" ) return wfSpecialDisambiguations() ;
        if ( $subfunction == "doubleredirects" ) return wfSpecialDoubleRedirects() ;
@@ -56,17 +61,17 @@ function wfSpecialMaintenance ()
 
        $r .= "</UL>\n" ;
        $wgOut->addHTML ( $r ) ;
-       }
+}
 
 function getMPL ( $x )
-       {
+{
        global $wgUser , $wgLang;
        $sk = $wgUser->getSkin() ;
        return $sk->makeKnownLink(sns().":Maintenance",wfMsg($x),"subfunction={$x}") ;
-       }
+}
 
 function getMaintenancePageBacklink()
-       {
+{
        global $wgUser , $wgLang , $subfunction ;
        $sk = $wgUser->getSkin() ;
        $ns = $wgLang->getNamespaces() ;
@@ -79,7 +84,7 @@ function getMaintenancePageBacklink()
        $s .= "<h2>{$t}</h2></td><td align=right>";
        $s .= "{$r}</td></tr></table>\n" ;
        return $s ;
-       }
+}
 
 
 function wfSpecialDisambiguations()
index e97c6e9..bdc75ad 100644 (file)
@@ -1,11 +1,19 @@
 <?
 
-function wfSpecialRecentchanges()
+function wfSpecialRecentchanges( $par )
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
        global $days, $hideminor, $from, $hidebots; # From query string
        $fname = "wfSpecialRecentchanges";
 
+       if( $par ) {
+               $bits = preg_split( '/\s*,\s*/', trim( $par ) );
+               if( in_array( "hidebots", $bits ) ) $hidebots = 1;
+               if( in_array( "bots", $bits ) ) $hidebots = 0;
+               if( in_array( "hideminor", $bits ) ) $hideminor = 1;
+               if( in_array( "minor", $bits ) ) $hideminor = 0;
+       }
+       
        $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
        $res = wfQuery( $sql, $fname );
        $s = wfFetchObject( $res );
index 0f221b5..cb5f69e 100644 (file)
@@ -2,7 +2,7 @@
 global $IP;
 include_once( "$IP/SpecialRecentchanges.php" );
 
-function wfSpecialRecentchangeslinked()
+function wfSpecialRecentchangeslinked( $par = NULL )
 {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
        global $days, $target, $hideminor; # From query string
@@ -11,6 +11,9 @@ function wfSpecialRecentchangeslinked()
        $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
        $sk = $wgUser->getSkin();
 
+       if( $par ) {
+               $target = $par;
+       }
        if ( "" == $target ) {
                $wgOut->errorpage( "notargettitle", "notargettext" );
                return;
index f9d2a26..9eaaadf 100644 (file)
@@ -1,15 +1,20 @@
 <?
 
-function wfSpecialWhatlinkshere()
+function wfSpecialWhatlinkshere($par = NULL)
 {
        global $wgUser, $wgOut, $target;
        $fname = "wfSpecialWhatlinkshere";
 
+       if($par) {
+               $target = $par;
+       } else {
+               $target = wfCleanQueryVar( $_REQUEST['target'] );
+       }
        if ( "" == $target ) {
                $wgOut->errorpage( "notargettitle", "notargettext" );
                return;
        }
-       $nt = Title::newFromURL( wfCleanQueryVar( $target ) );
+       $nt = Title::newFromURL( $target );
        $wgOut->setPagetitle( $nt->getPrefixedText() );
        $wgOut->setSubtitle( wfMsg( "linklistsub" ) );
 
index e171eb5..f870526 100644 (file)
@@ -128,6 +128,14 @@ class Title {
                if ( "" == $n ) { return $title; }
                else { return "{$n}:{$title}"; }
        }
+       
+       /* static */ function makeTitle( $ns, $title )
+       {
+               $t = new Title();
+               $t->mDbkeyform = Title::makeName( $ns, $title );
+               $t->secureAndSplit();
+               return $t;
+       }
 
        function getPrefixedDBkey()
        {