* (bug 10457) Reorganize Special:Specialpages.
authorRaimond Spekking <raymond@users.mediawiki.org>
Wed, 5 Mar 2008 15:44:31 +0000 (15:44 +0000)
committerRaimond Spekking <raymond@users.mediawiki.org>
Wed, 5 Mar 2008 15:44:31 +0000 (15:44 +0000)
Customizable by editing [[MediaWiki:specialpages-tpl]]

RELEASE-NOTES
includes/SpecialSpecialpages.php
languages/messages/MessagesDe.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc

index 2535384..f42c7f5 100644 (file)
@@ -38,6 +38,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   reduce broken form submissions
 * Add --old-redirects-only option to maintenance/refreshLinks.php, to add old
   redirects to the redirect table
+* (bug 10457) Reorganize Special:Specialpages. Customizable by editing
+  [[MediaWiki:specialpages-tpl]]
 
 === Bug fixes in 1.13 ===
 
index 4ea956b..24be9aa 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 /**
- *
+ * Main function
  */
 function wfSpecialSpecialpages() {
        global $wgOut, $wgUser, $wgMessageCache;
@@ -13,22 +13,72 @@ function wfSpecialSpecialpages() {
        $wgMessageCache->loadAllMessages();
 
        $wgOut->setRobotpolicy( 'noindex,nofollow' );  # Is this really needed?
-       $sk = $wgUser->getSkin();
 
-       /** Pages available to all */
-       wfSpecialSpecialpages_gen( SpecialPage::getRegularPages(), 'spheading', $sk );
+       # Read the special pages
+       $pagesRegular = SpecialPage::getRegularPages();
+       $pagesRestricted = SpecialPage::getRestrictedPages();
+       if( count( $pagesRegular ) == 0 && count( $pagesRestricted ) == 0 ) {
+               # Yeah, that was pointless. Thanks for coming.
+               return;
+       }
+
+       # Put regular and restricted special pages into sortable arrays
+       $unsortedPagesRegular = wfSpecialSpecialpages_read( $pagesRegular );
+       $unsortedPagesRestricted = wfSpecialSpecialpages_read( $pagesRestricted );
+
+       # Read the template
+       $tpl = wfMsg( 'specialpages-tpl' );
+       $newSpecialPage = '';
+
+       # Parse the template and create a localized wikitext page
+       foreach ( explode( "\n", $tpl ) as $line ) {
+               # Look for 'special:' in the line
+               $pos = strpos( $line, 'special:' );
+               if( $pos >= 0 ) {
+
+                       # Preserve the line start
+                       $lineStart = ( $pos > 0 ) ? substr( $line, 0, $pos ) : '';
 
-       /** Restricted special pages */
-       wfSpecialSpecialpages_gen( SpecialPage::getRestrictedPages(), 'restrictedpheading', $sk );
+                       # Get the canonical special page name
+                       $canonical = strtolower( trim( substr( $line, $pos + 8 ) ) );
+
+                       # Check if it is a valid regular special page name
+                       # Restricted pages will be added at the end
+                       if( isset( $unsortedPagesRegular[$canonical] ) ) {
+                               # Add a new line
+                               $newSpecialPage .= $lineStart . "[[special:" . $canonical . "|" . $unsortedPagesRegular[$canonical] . "]]\n";
+                               # Delete this regular special page from the array to avoid double output
+                               unset( $unsortedPagesRegular[$canonical] );
+                       } else {
+                               # Ok, no valid special page, but add the line to the output
+                               $newSpecialPage .= $line . "\n";
+                       }
+               } else {
+                       $newSpecialPage .= $line . "\n";
+               }
+       }
+
+       # Add the rest
+       $newSpecialPage .= wfSpecialSpecialpages_out( 'specialpages-other', $unsortedPagesRegular );
+       # Add the restricted special pages
+       $newSpecialPage .= wfSpecialSpecialpages_out( 'restrictedpheading', $unsortedPagesRestricted );
+
+       # Output the customized special pages list
+       $wgOut->addWikiText( $newSpecialPage );
+
+       if ( $wgUser->isAllowed( 'editinterface' ) ) {
+               # Output a nice link to edit the template
+               $wgOut->addHtml( wfSpecialSpecialpages_edit() );
+       }
 }
 
 /**
- * sub function generating the list of pages
- * @param $pages the list of pages
- * @param $heading header to be used
- * @param $sk skin object ???
+ * Output the rest special pages as wikitext
+ * @param string $heading Message name for the heading
+ * @param array $sortedPages List of other special pages
+ * @return string $rest Wikitext
  */
-function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
+function wfSpecialSpecialpages_out( $heading, $pages ) {
        global $wgOut, $wgSortSpecialPages;
 
        if( count( $pages ) == 0 ) {
@@ -36,26 +86,44 @@ function wfSpecialSpecialpages_gen($pages,$heading,$sk) {
                return;
        }
 
-       /** Put them into a sortable array */
-       $sortedPages = array();
-       foreach ( $pages as $page ) {
-               if ( $page->isListed() ) {
-                       $sortedPages[$page->getDescription()] = $page->getTitle();
-               }
-       }
-
-       /** Sort */
+       # Sort
        if ( $wgSortSpecialPages ) {
-               ksort( $sortedPages );
+               asort( $pages );
        }
 
-       /** Now output the HTML */
-       $wgOut->addHTML( '<h2>' . wfMsgHtml( $heading ) . "</h2>\n<ul>" );
-       foreach ( $sortedPages as $desc => $title ) {
-               $link = $sk->makeKnownLinkObj( $title , htmlspecialchars( $desc ) );
-               $wgOut->addHTML( "<li>{$link}</li>\n" );
+       # Now output the rest special pages as wikitext
+       $rest = '== ' . wfMsgExt( $heading, array( 'parseinline' ) ) . " ==\n";
+       foreach ( $pages as $title => $desc ) {
+               $rest .= "* [[special:" . $title . "|" . $desc . "]]\n";
        }
-       $wgOut->addHTML( "</ul>\n" );
+       return $rest;
 }
 
+/**
+ * Create array with descriptions and names of special pages
+ * @param array $pagelist List of special pages
+ * @return array $unsortedPagesList Wikitext
+ */
+function wfSpecialSpecialpages_read( $pagelist ) {
+       $unsortedPagesList = array();
+       foreach ( $pagelist as $page ) {
+               if ( $page->isListed() ) {
+                       $name = strtolower( $page->getName() );
+                       $unsortedPagesList[$name] = $page->getDescription();
+               }
+       }
+       return $unsortedPagesList;
+}
 
+/**
+ * Build edit link to MediaWiki:specialpages-tpl
+ *
+ * @return string
+ */
+function wfSpecialSpecialpages_edit() {
+       global $wgUser, $wgContLang;
+       $align = $wgContLang->isRtl() ? 'left' : 'right';
+       $skin = $wgUser->getSkin();
+       $link = $skin->makeLink ( 'MediaWiki:specialpages-tpl', wfMsgHtml( 'specialpages-edit' ) );
+       return '<p style="float:' . $align . ';" class="mw-specialspecialpages-edit">' . $link . '</p>';
+}
index a9659b1..6f598db 100644 (file)
@@ -1367,10 +1367,6 @@ auf die bereits die erste Weiterleitung zeigen sollte.',
 'protectedtitlesempty'            => 'Zur Zeit sind mit den angegebenen Parametern keine Seiten zur Neuerstellung gesperrt.',
 'listusers'                       => 'Benutzerverzeichnis',
 'listusers-summary'               => "Diese Spezialseite listet alle registrierten Benutzer auf; die Gesamtzahl kann [[Special:Statistics|hier]] eingesehen werden. Über das Auswahlfeld ''Gruppe'' lässt sich die Abfrage auf bestimmte Benutzergruppen einschränken.",
-'specialpages'                    => 'Spezialseiten',
-'specialpages-summary'            => 'Diese Seite bietet einen Überblick aller Spezialseiten. Diese werden automatisch generiert und können nicht bearbeitet werden.',
-'spheading'                       => 'Spezialseiten für alle Benutzer',
-'restrictedpheading'              => 'Spezialseiten für Administratoren',
 'newpages'                        => 'Neue Seiten',
 'newpages-summary'                => 'Diese Spezialseite listet alle neu erstellten Seiten der letzten 30 Tage auf. Die Ausgabe kann auf einen Namensraum und/oder Benutzernamen eingeschränkt werden.',
 'newpages-username'               => 'Benutzername:',
@@ -1386,6 +1382,81 @@ auf die bereits die erste Weiterleitung zeigen sollte.',
 'pager-newer-n'                   => '{{PLURAL:$1|nächster|nächste $1}}',
 'pager-older-n'                   => '{{PLURAL:$1|vorheriger|vorherige $1}}',
 
+# Special:Specialpages
+'specialpages'         => 'Spezialseiten',
+'specialpages-summary' => 'Diese Seite bietet einen Überblick aller Spezialseiten.',
+'specialpages-other'   => 'Weitere Spezialseiten für alle Benutzer',
+'restrictedpheading'   => 'Spezialseiten für Benutzer mit erweiterten Rechten',
+'specialpages-edit'    => 'Diese Seite bearbeiten',
+'specialpages-tpl'     => '
+<!-- Format: pro Zeile ein kanonischer (englischer) Spezialseitenname:
+* special:specialpagename
+Alle anderen Zeilen werden als normaler (Wiki)Text ausgewertet -->
+== Allgemeine Listen ==
+:special:Allpages
+: special:Prefixindex
+;special:Categories
+* special:Disambiguations
+* special:Listredirects
+
+== Wartungslisten ==
+* special:Mostcategories
+* special:Fewestrevisions
+* special:Mostrevisions
+* special:BrokenRedirects
+* special:Deadendpages
+* special:DoubleRedirects
+* special:Longpages
+* special:Mostlinkedcategories
+* special:Mostimages
+* special:Mostlinked
+* special:Mostlinkedtemplates
+* special:Popularpages
+* special:Ancientpages
+* special:Lonelypages
+* special:Shortpages
+* special:Withoutinterwiki
+* special:Protectedpages
+* special:Protectedtitles
+* special:Uncategorizedcategories
+* special:Uncategorizedimages
+* special:Uncategorizedpages
+* special:Uncategorizedtemplates
+* special:Unusedcategories
+* special:Unusedimages
+* special:Unusedtemplates
+
+== Werkzeuge ==
+* special:Export
+* special:Filepath
+* special:MIMEsearch
+* special:Randompage
+* special:Randomredirect
+* special:Search
+* special:Upload
+
+== Logbücher und Informationen ==
+* special:Ipblocklist
+* special:Booksources
+* special:Imagelist
+* special:Log
+* special:Newpages
+* special:Newimages
+* special:Recentchanges
+* special:Statistics
+* special:Allmessages
+* special:Contributions
+* special:Listusers
+* special:Version
+* special:Wantedcategories
+* special:Wantedpages
+* special:Whatlinkshere
+
+== Persönliche Seiten ==
+* special:Preferences
+* special:Watchlist
+* special:Userlogin',
+
 # Book sources
 'booksources'               => 'ISBN-Suche',
 'booksources-summary'       => 'Auf dieser Spezialseite kannst du eine ISBN eingeben und erhältst dann eine Liste mit Onlinekatalogen und Bezugsmöglichkeiten zur gesuchten ISBN. Bindestriche oder Leerzeichen zwischen den Ziffern spielen für die Suche keine Rolle.',
index 8a37f91..eab1b9d 100644 (file)
@@ -1697,10 +1697,6 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''\$7''
 'protectedtitlesempty'            => 'No titles are currently protected with these parameters.',
 'listusers'                       => 'User list',
 'listusers-summary'               => '', # only translate this message to other languages if you have to change it
-'specialpages'                    => 'Special pages',
-'specialpages-summary'            => '', # only translate this message to other languages if you have to change it
-'spheading'                       => 'Special pages for all users',
-'restrictedpheading'              => 'Restricted special pages',
 'newpages'                        => 'New pages',
 'newpages-summary'                => '', # only translate this message to other languages if you have to change it
 'newpages-username'               => 'Username:',
@@ -1715,6 +1711,81 @@ The [http://meta.wikimedia.org/wiki/Help:Job_queue job queue] length is '''\$7''
 'pager-newer-n'                   => '{{PLURAL:$1|newer 1|newer $1}}',
 'pager-older-n'                   => '{{PLURAL:$1|older 1|older $1}}',
 
+# Special:Specialpages
+'specialpages'         => 'Special pages',
+'specialpages-summary' => '', # only translate this message to other languages if you have to change it
+'specialpages-other'   => 'More special pages for all users',
+'restrictedpheading'   => 'Restricted special pages',
+'specialpages-edit'    => 'Edit this page',
+'specialpages-tpl'     => '
+<!-- Format: per line one canonical (english) special page name:
+* special:specialpagename
+All other lines are rendered as normal (wiki)text -->
+== General page lists ==
+* special:Allpages
+* special:Prefixindex
+* special:Categories
+* special:Disambiguations
+* special:Listredirects
+
+== Maintenance page lists ==
+* special:Mostcategories
+* special:Fewestrevisions
+* special:Mostrevisions
+* special:BrokenRedirects
+* special:Deadendpages
+* special:DoubleRedirects
+* special:Longpages
+* special:Mostlinkedcategories
+* special:Mostimages
+* special:Mostlinked
+* special:Mostlinkedtemplates
+* special:Popularpages
+* special:Ancientpages
+* special:Lonelypages
+* special:Shortpages
+* special:Withoutinterwiki
+* special:Protectedpages
+* special:Protectedtitles
+* special:Uncategorizedcategories
+* special:Uncategorizedimages
+* special:Uncategorizedpages
+* special:Uncategorizedtemplates
+* special:Unusedcategories
+* special:Unusedimages
+* special:Unusedtemplates
+
+== Tools ==
+* special:Export
+* special:Filepath
+* special:MIMEsearch
+* special:Randompage
+* special:Randomredirect
+* special:Search
+* special:Upload
+
+== Logs and information ==
+* special:Ipblocklist
+* special:Booksources
+* special:Imagelist
+* special:Log
+* special:Newpages
+* special:Newimages
+* special:Recentchanges
+* special:Statistics
+* special:Allmessages
+* special:Contributions
+* special:Listusers
+* special:Version
+* special:Wantedcategories
+* special:Wantedpages
+* special:Whatlinkshere
+
+== Personal pages ==
+* special:Preferences
+* special:Watchlist
+* special:Userlogin',
+
 # Book sources
 'booksources'               => 'Book sources',
 'booksources-summary'       => '', # only translate this message to other languages if you have to change it
@@ -3072,5 +3143,4 @@ You can also [[Special:Watchlist/edit|use the standard editor]].',
 Images are shown in full resolution, other file types are started with their associated program directly.
 
 Enter the file name without the "{{ns:image}}:" prefix.',
-
 );
index 5009ea1..cca89de 100644 (file)
@@ -1106,10 +1106,6 @@ $wgMessageStructure = array(
                'protectedtitlesempty',
                'listusers',
                'listusers-summary',
-               'specialpages',
-               'specialpages-summary',
-               'spheading',
-               'restrictedpheading',
                'newpages',
                'newpages-summary',
                'newpages-username',
@@ -1124,6 +1120,13 @@ $wgMessageStructure = array(
                'pager-newer-n',
                'pager-older-n',
        ),
+       'specialspecialpages' => array(
+               'specialpages',
+               'specialpages-summary',
+               'specialpages-other',
+               'restrictedpheading',
+               'specialpages-tpl',
+       ),
        'booksources' => array(
                'booksources',
                'booksources-summary',
@@ -2449,6 +2452,7 @@ XHTML id names.",
        'withoutinterwiki'    => '',
        'fewestrevisions'     => '',
        'specialpages'        => 'Miscellaneous special pages',
+       'specialspecialpages' => 'Special:Specialpages',
        'booksources'         => 'Book sources',
        'specialpages2'       => '',
        'logpages'            => 'Special:Log',