Remove hard coding of pipe separators in skins. Use Language::pipeList as much as...
authorSiebrand Mazeland <siebrand@users.mediawiki.org>
Mon, 9 Feb 2009 16:24:03 +0000 (16:24 +0000)
committerSiebrand Mazeland <siebrand@users.mediawiki.org>
Mon, 9 Feb 2009 16:24:03 +0000 (16:24 +0000)
includes/Skin.php
skins/CologneBlue.php
skins/Standard.php

index 5d2f037..c6b40e9 100644 (file)
@@ -940,20 +940,20 @@ END;
        function doAfterContent() { return "</div></div>"; }
 
        function pageTitleLinks() {
-               global $wgOut, $wgTitle, $wgUser, $wgRequest;
+               global $wgOut, $wgTitle, $wgUser, $wgRequest, $wgLang;
 
                $oldid = $wgRequest->getVal( 'oldid' );
                $diff = $wgRequest->getVal( 'diff' );
                $action = $wgRequest->getText( 'action' );
 
-               $s = $this->printableLink();
+               $s[] = $this->printableLink();
                $disclaimer = $this->disclaimerLink(); # may be empty
                if( $disclaimer ) {
-                       $s .= ' | ' . $disclaimer;
+                       $s[] = $disclaimer;
                }
                $privacy = $this->privacyLink(); # may be empty too
                if( $privacy ) {
-                       $s .= ' | ' . $privacy;
+                       $s[] = $privacy;
                }
 
                if ( $wgOut->isArticleRelated() ) {
@@ -963,12 +963,12 @@ END;
                                if( $image ) {
                                        $link = htmlspecialchars( $image->getURL() );
                                        $style = $this->getInternalLinkAttributes( $link, $name );
-                                       $s .= " | <a href=\"{$link}\"{$style}>{$name}</a>";
+                                       $s[] = "<a href=\"{$link}\"{$style}>{$name}</a>";
                                }
                        }
                }
                if ( 'history' == $action || isset( $diff ) || isset( $oldid ) ) {
-                       $s .= ' | ' . $this->makeKnownLinkObj( $wgTitle,
+                       $s[] .= $this->makeKnownLinkObj( $wgTitle,
                                        wfMsg( 'currentrev' ) );
                }
 
@@ -978,7 +978,7 @@ END;
                        if( !$wgTitle->equals( $wgUser->getTalkPage() ) ) {
                                $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessageslink' ), 'redirect=no' );
                                $dl = $this->makeKnownLinkObj( $wgUser->getTalkPage(), wfMsgHtml( 'newmessagesdifflink' ), 'diff=cur' );
-                               $s.= ' | <strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
+                               $s[] = '<strong>'. wfMsg( 'youhavenewmessages', $tl, $dl ) . '</strong>';
                                # disable caching
                                $wgOut->setSquidMaxage(0);
                                $wgOut->enableClientCache(false);
@@ -987,9 +987,9 @@ END;
 
                $undelete = $this->getUndeleteLink();
                if( !empty( $undelete ) ) {
-                       $s .= ' | '.$undelete;
+                       $s[] = $undelete;
                }
-               return $s;
+               return $wgLang->pipeList( $s );
        }
 
        function getUndeleteLink() {
@@ -1012,18 +1012,18 @@ END;
        }
 
        function printableLink() {
-               global $wgOut, $wgFeedClasses, $wgRequest;
+               global $wgOut, $wgFeedClasses, $wgRequest, $wgLang;
 
                $printurl = $wgRequest->escapeAppendQuery( 'printable=yes' );
 
-               $s = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
+               $s[] = "<a href=\"$printurl\" rel=\"alternate\">" . wfMsg( 'printableversion' ) . '</a>';
                if( $wgOut->isSyndicated() ) {
                        foreach( $wgFeedClasses as $format => $class ) {
                                $feedurl = $wgRequest->escapeAppendQuery( "feed=$format" );
-                               $s .= " | <a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\" class=\"feedlink\">{$format}</a>";
+                               $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\" class=\"feedlink\">{$format}</a>";
                        }
                }
-               return $s;
+               return $wgLang->pipeList( $s );
        }
 
        function pageTitle() {
@@ -1068,7 +1068,7 @@ END;
                                                $getlink = $this->makeKnownLinkObj( $linkObj, htmlspecialchars( $display ) );
                                                $c++;
                                                if ($c>1) {
-                                                       $subpages .= ' | ';
+                                                       $subpages .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
                                                } else  {
                                                        $subpages .= '&lt; ';
                                                }
@@ -1131,16 +1131,21 @@ END;
                        $ret .= $this->link( $wgUser->getUserPage(),
                                htmlspecialchars( $wgUser->getName() ) );
                        $ret .= " ($talkLink)<br />";
-                       $ret .= $this->link(
-                               SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
-                               array(), array( 'returnto' => $returnTo )
-                       );
-                       $ret .= ' | ' . $this->specialLink( 'preferences' );
-               }
-               $ret .= ' | ' . $this->link(
-                       Title::newFromText( wfMsgForContent( 'helppage' ) ),
-                       wfMsg( 'help' )
-               );
+                       $ret .= $wgLang->pipeList( array(
+                               $this->link(
+                                       SpecialPage::getTitleFor( 'Userlogout' ), wfMsg( 'logout' ),
+                                       array(), array( 'returnto' => $returnTo )
+                               ),
+                               $this->specialLink( 'preferences' ),
+                       ) );
+               }
+               $ret = $wgLang->pipeList( array(
+                       $ret,
+                       $this->link(
+                               Title::newFromText( wfMsgForContent( 'helppage' ) ),
+                               wfMsg( 'help' )
+                       ),
+               ) );
 
                return $ret;
        }
@@ -1179,23 +1184,29 @@ END;
 
        function topLinks() {
                global $wgOut;
-               $sep = " |\n";
 
-               $s = $this->mainPageLink() . $sep
-                 . $this->specialLink( 'recentchanges' );
+               $s = array(
+                       $this->mainPageLink(),
+                       $this->specialLink( 'recentchanges' )
+               );
 
                if ( $wgOut->isArticleRelated() ) {
-                       $s .=  $sep . $this->editThisPage()
-                         . $sep . $this->historyLink();
+                       $s[] = $this->editThisPage();
+                       $s[] = $this->historyLink();
                }
                # Many people don't like this dropdown box
-               #$s .= $sep . $this->specialPagesList();
+               #$s[] = $this->specialPagesList();
 
-               $s .= $this->variantLinks();
+               if( $this->variantLinks() ) {
+                       $s = $this->variantLinks();
+               }
 
-               $s .= $this->extensionTabLinks();
+               if( $this->extensionTabLinks() ) {
+                       $s[] = $this->extensionTabLinks();
+               }
 
-               return $s;
+               // FIXME: Is using Language::pipeList impossible here? Do not quite understand the use of the newline
+               return implode( $s, wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n" );
        }
 
        /**
@@ -1206,14 +1217,23 @@ END;
         */
        function extensionTabLinks() {
                $tabs = array();
-               $s = '';
+               $out = '';
+               $s = array();
                wfRunHooks( 'SkinTemplateTabs', array( $this, &$tabs ) );
                foreach( $tabs as $tab ) {
-                       $s .= ' | ' . Xml::element( 'a',
+                       $s[] = Xml::element( 'a',
                                array( 'href' => $tab['href'] ),
                                $tab['text'] );
                }
-               return $s;
+
+               if( count( $s ) ) {
+                       global $wgLang;
+
+                       $out = wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+                       $out .= $wgLang->pipeList( $s );
+               }
+
+               return $out;
        }
 
        /**
@@ -1223,14 +1243,14 @@ END;
        function variantLinks() {
                $s = '';
                /* show links to different language variants */
-               global $wgDisableLangConversion, $wgContLang, $wgTitle;
+               global $wgDisableLangConversion, $wgLang, $wgContLang, $wgTitle;
                $variants = $wgContLang->getVariants();
                if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
                        foreach( $variants as $code ) {
                                $varname = $wgContLang->getVariantname( $code );
                                if( $varname == 'disable' )
                                        continue;
-                               $s .= ' | <a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>';
+                               $s = $wgLang->pipeList( array( $s, '<a href="' . $wgTitle->escapeLocalUrl( 'variant=' . $code ) . '">' . htmlspecialchars( $varname ) . '</a>' ) );
                        }
                }
                return $s;
@@ -1238,21 +1258,21 @@ END;
 
        function bottomLinks() {
                global $wgOut, $wgUser, $wgTitle, $wgUseTrackbacks;
-               $sep = " |\n";
+               $sep = wfMsgExt( 'pipe-separator' , 'escapenoentities' ) . "\n";
 
                $s = '';
                if ( $wgOut->isArticleRelated() ) {
-                       $s .= '<strong>' . $this->editThisPage() . '</strong>';
+                       $element[] = '<strong>' . $this->editThisPage() . '</strong>';
                        if ( $wgUser->isLoggedIn() ) {
-                               $s .= $sep . $this->watchThisPage();
+                               $element[] = $this->watchThisPage();
                        }
-                       $s .= $sep . $this->talkLink()
-                         . $sep . $this->historyLink()
-                         . $sep . $this->whatLinksHere()
-                         . $sep . $this->watchPageLinksLink();
+                       $element[] = $this->talkLink();
+                       $element[] = $this->historyLink();
+                       $element[] = $this->whatLinksHere();
+                       $element[] = $this->watchPageLinksLink();
 
                        if ($wgUseTrackbacks)
-                               $s .= $sep . $this->trackbackLink();
+                               $element[] = $this->trackbackLink();
 
                        if ( $wgTitle->getNamespace() == NS_USER
                            || $wgTitle->getNamespace() == NS_USER_TALK )
@@ -1262,12 +1282,15 @@ END;
                                $ip=User::isIP($wgTitle->getText());
 
                                if($id || $ip) { # both anons and non-anons have contri list
-                                       $s .= $sep . $this->userContribsLink();
+                                       $element[] = $this->userContribsLink();
                                }
                                if( $this->showEmailUser( $id ) ) {
-                                       $s .= $sep . $this->emailUserLink();
+                                       $element[] = $this->emailUserLink();
                                }
                        }
+                       
+                       $s = implode( $element, $sep );
+
                        if ( $wgTitle->getArticleId() ) {
                                $s .= "\n<br />";
                                if($wgUser->isAllowed('delete')) { $s .= $this->deleteThisPage(); }
@@ -1276,6 +1299,7 @@ END;
                        }
                        $s .= "<br />\n" . $this->otherLanguages();
                }
+
                return $s;
        }
 
@@ -1657,7 +1681,7 @@ END;
                $first = true;
                if($wgContLang->isRTL()) $s .= '<span dir="LTR">';
                foreach( $a as $l ) {
-                       if ( ! $first ) { $s .= ' | '; }
+                       if ( ! $first ) { $s .= wfMsgExt( 'pipe-separator' , 'escapenoentities' ); }
                        $first = false;
 
                        $nt = Title::newFromText( $l );
index b784c55..c650cbe 100644 (file)
@@ -66,7 +66,7 @@ class SkinCologneBlue extends Skin {
 
        function doAfterContent()
        {
-               global $wgOut;
+               global $wgOut, $wgLang;
 
                $s = "\n</div><br clear='all' />\n";
 
@@ -80,9 +80,11 @@ class SkinCologneBlue extends Skin {
                $s .= "<td class='bottom' align='center' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $this->makeKnownLinkObj( Title::newMainPage() ) . " | "
-                 . $this->aboutLink() . " | "
-                 . $this->searchForm( wfMsg( "qbfind" ) );
+               $s .= $wgLang->pipeList( array(
+                       "\n<br />" . $this->makeKnownLinkObj( Title::newMainPage() ),
+                       $this->aboutLink(),
+                       $this->searchForm( wfMsg( "qbfind" ) )
+               ) );
 
                $s .= "\n<br />" . $this->pageStats();
 
@@ -121,7 +123,7 @@ class SkinCologneBlue extends Skin {
        }
 
        function sysLinks() {
-               global $wgUser, $wgContLang, $wgTitle;
+               global $wgUser, $wgLang, $wgContLang, $wgTitle;
                $li = $wgContLang->specialPage("Userlogin");
                $lo = $wgContLang->specialPage("Userlogout");
 
@@ -132,29 +134,28 @@ class SkinCologneBlue extends Skin {
                        $q = "returnto={$rt}";
                }
 
-               $s = "" .
-                 $this->mainPageLink()
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) )
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) )
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") )
-                 . " | " .
-                 $this->specialLink( "specialpages" );
+               $s = array(
+                       $this->mainPageLink(),
+                       $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) ),
+                       $this->makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) ),
+                       $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") ),
+                       $this->specialLink( "specialpages" )
+               );
 
                /* show links to different language variants */
-               $s .= $this->variantLinks();
-               $s .= $this->extensionTabLinks();
-               
-               $s .= " | ";
+               if( $this->variantLinks() ) {
+                       $s[] = $this->variantLinks();
+               }
+               if( $this->extensionTabLinks() ) {
+                       $s[] = $this->extensionTabLinks();
+               }
                if ( $wgUser->isLoggedIn() ) {
-                       $s .=  $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
+                       $s[] = $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
                } else {
-                       $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
+                       $s[] = $this->makeKnownLink( $li, wfMsg( "login" ), $q );
                }
 
-               return $s;
+               return $wgLang->pipeList( $s );
        }
 
        /**
index 1f3cab9..694bc5e 100644 (file)
@@ -82,7 +82,7 @@ class SkinStandard extends Skin {
        }
 
        function doAfterContent() {
-               global $wgContLang;
+               global $wgContLang, $wgLang;
                $fname =  'SkinStandard::doAfterContent';
                wfProfileIn( $fname );
                wfProfileIn( $fname.'-1' );
@@ -108,10 +108,11 @@ class SkinStandard extends Skin {
                $s .= "<td class='bottom' align='$l' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $this->mainPageLink()
-                 . ' | ' . $this->aboutLink()
-                 . ' | ' . $this->specialLink( 'recentchanges' )
-                 . ' | ' . $this->searchForm()
+               $s .= "\n<br />" . $wgLang->pipeList( array(
+                       $this->mainPageLink(),
+                       $this->aboutLink(),
+                       $this->specialLink( 'recentchanges' ),
+                       $this->searchForm() ) )
                  . '<br /><span id="pagestats">' . $this->pageStats() . '</span>';
 
                $s .= "</td>";