From: Brion Vibber Date: Wed, 2 Jul 2003 06:22:03 +0000 (+0000) Subject: Enhances special page links; allow some parameters to be passed via wikilinks to... X-Git-Tag: 1.1.0~460 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=d7f6cb4ff168d0cc8a768f9055b71c0416bbb9eb;p=lhc%2Fweb%2Fwiklou.git Enhances special page links; allow some parameters to be passed via wikilinks to special pages to make it easier to cite things like backlinks, contribs, options for recentchanges, etc --- diff --git a/includes/GlobalFunctions.php b/includes/GlobalFunctions.php index 2a766338ef..19efb7566a 100644 --- a/includes/GlobalFunctions.php +++ b/includes/GlobalFunctions.php @@ -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 "<$key>"; } 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 ) ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a4c8e3abec..50748e4723 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1359,7 +1359,7 @@ class OutputPage { { global $wgDocType, $wgDTD, $wgUser, $wgLanguageCode, $wgOutputEncoding; - $ret = "\n"; + $ret = "\n"; if ( "" == $this->mHTMLtitle ) { $this->mHTMLtitle = $this->mPagetitle; diff --git a/includes/SpecialAllpages.php b/includes/SpecialAllpages.php index bbd5fdc1ff..8ba82258f4 100644 --- a/includes/SpecialAllpages.php +++ b/includes/SpecialAllpages.php @@ -1,11 +1,13 @@ 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() ); diff --git a/includes/SpecialMaintenance.php b/includes/SpecialMaintenance.php index fefc96b5eb..481c9d406b 100644 --- a/includes/SpecialMaintenance.php +++ b/includes/SpecialMaintenance.php @@ -1,20 +1,25 @@ 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 .= "\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 .= "

{$t}

"; $s .= "{$r}\n" ; return $s ; - } +} function wfSpecialDisambiguations() diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index e97c6e9ebe..bdc75ad1bf 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -1,11 +1,19 @@ setPagetitle( wfMsg( "recentchanges" ) ); $sk = $wgUser->getSkin(); + if( $par ) { + $target = $par; + } if ( "" == $target ) { $wgOut->errorpage( "notargettitle", "notargettext" ); return; diff --git a/includes/SpecialWhatlinkshere.php b/includes/SpecialWhatlinkshere.php index f9d2a26cd6..9eaaadf348 100644 --- a/includes/SpecialWhatlinkshere.php +++ b/includes/SpecialWhatlinkshere.php @@ -1,15 +1,20 @@ errorpage( "notargettitle", "notargettext" ); return; } - $nt = Title::newFromURL( wfCleanQueryVar( $target ) ); + $nt = Title::newFromURL( $target ); $wgOut->setPagetitle( $nt->getPrefixedText() ); $wgOut->setSubtitle( wfMsg( "linklistsub" ) ); diff --git a/includes/Title.php b/includes/Title.php index e171eb574a..f870526db2 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -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() {