Remove hard coding of pipe separators in skins. Use Language::pipeList as much as...
[lhc/web/wiklou.git] / skins / CologneBlue.php
index 20ed3b4..c650cbe 100644 (file)
@@ -1,36 +1,34 @@
 <?php
 /**
- * See skin.doc
+ * See docs/skin.txt
  *
  * @todo document
- * @package MediaWiki
- * @subpackage Skins
+ * @file
+ * @ingroup Skins
  */
 
 if( !defined( 'MEDIAWIKI' ) )
-       die();
+       die( -1 );
 
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Skins
+ * @ingroup Skins
  */
 class SkinCologneBlue extends Skin {
 
        function getStylesheet() {
-               return "common/cologneblue.css";
+               return 'common/cologneblue.css';
        }
        function getSkinName() {
                return "cologneblue";
        }
 
        function doBeforeContent() {
-               global $wgUser, $wgOut, $wgTitle, $wgSiteNotice;
 
                $s = "";
                $qb = $this->qbSetting();
                $mainPageObj = Title::newMainPage();
-               
+
                $s .= "\n<div id='content'>\n<div id='topbar'>" .
                  "<table width='100%' border='0' cellspacing='0' cellpadding='8'><tr>";
 
@@ -47,7 +45,7 @@ class SkinCologneBlue extends Skin {
                $s .= "</td><td align='right'>" ;
 
                $s .= "<font size='-1'><span id='langlinks'>" ;
-               $s .= str_replace ( "<br>" , "" , $this->otherLanguages() );
+               $s .= str_replace ( "<br />" , "" , $this->otherLanguages() );
                $cat = $this->getCategoryLinks();
                if( $cat ) $s .= "<br />$cat\n";
                $s .= "<br />" . $this->pageTitleLinks();
@@ -57,8 +55,9 @@ class SkinCologneBlue extends Skin {
 
                $s .= "\n</div>\n<div id='article'>";
 
-               if( $wgSiteNotice ) {
-                       $s .= "\n<div id='siteNotice'>$wgSiteNotice</div>\n";
+               $notice = wfGetSiteNotice();
+               if( $notice ) {
+                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
                $s .= $this->pageTitle();
                $s .= $this->pageSubtitle() . "\n";
@@ -67,7 +66,7 @@ class SkinCologneBlue extends Skin {
 
        function doAfterContent()
        {
-               global $wgUser, $wgOut;
+               global $wgOut, $wgLang;
 
                $s = "\n</div><br clear='all' />\n";
 
@@ -81,9 +80,11 @@ class SkinCologneBlue extends Skin {
                $s .= "<td class='bottom' align='center' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $this->makeKnownLink( wfMsgForContent( "mainpage" ) ) . " | "
-                 . $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();
 
@@ -96,10 +97,9 @@ class SkinCologneBlue extends Skin {
                if ( 0 != $qb ) { $s .= $this->quickBar(); }
                return $s;
        }
-       function doGetUserStyles()
-       {
-               global $wgUser, $wgOut, $wgStyleSheetPath;
-               $s = '';
+
+       function reallyGenerateUserStylesheet() {
+               $s = parent::reallyGenerateUserStylesheet();
                $qb = $this->qbSetting();
 
                if ( 2 == $qb ) { # Right
@@ -108,58 +108,63 @@ class SkinCologneBlue extends Skin {
                } else if ( 1 == $qb ) {
                        $s .= "#quickbar { position: absolute; left: 4px; }\n" .
                          "#article { margin-left: 148px; margin-right: 4px; }\n";
-               } else if ( 3 == $qb ) { # Floating
+               } else if ( 3 == $qb ) { # Floating left
                        $s .= "#quickbar { position:absolute; left:4px } \n" .
                          "#topbar { margin-left: 148px }\n" .
                          "#article { margin-left:148px; margin-right: 4px; } \n" .
                          "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;} \n"; # Hides from IE
+               } else if ( 4 == $qb ) { # Floating right
+                       $s .= "#quickbar { position: fixed; right: 4px; } \n" .
+                         "#topbar { margin-right: 148px }\n" .
+                         "#article { margin-right: 148px; margin-left: 4px; } \n" .
+                         "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;} \n"; # Hides from IE
                }
-               $s .= parent::doGetUserStyles();
                return $s;
        }
-       function sysLinks()
-       {
-               global $wgUser, $wgContLang, $wgTitle;
+
+       function sysLinks() {
+               global $wgUser, $wgLang, $wgContLang, $wgTitle;
                $li = $wgContLang->specialPage("Userlogin");
                $lo = $wgContLang->specialPage("Userlogout");
 
                $rt = $wgTitle->getPrefixedURL();
                if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
                        $q = "";
-               } else { 
-                       $q = "returnto={$rt}"; 
+               } else {
+                       $q = "returnto={$rt}";
                }
-               
-               $s = "" .
-                 $this->makeKnownLink( wfMsgForContent( "mainpage" ), wfMsg( "mainpage" ) )
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) )
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "helppage" ), wfMsg( "help" ) )
-                 . " | " .
-                 $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") )
-                 . " | " .
-                 $this->specialLink( "specialpages" ) . " | ";
-
-               if ( $wgUser->getID() )
-               {
-                       $s .=  $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
+
+               $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 */
+               if( $this->variantLinks() ) {
+                       $s[] = $this->variantLinks();
                }
-               else
-               {
-                       $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
+               if( $this->extensionTabLinks() ) {
+                       $s[] = $this->extensionTabLinks();
+               }
+               if ( $wgUser->isLoggedIn() ) {
+                       $s[] = $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
+               } else {
+                       $s[] = $this->makeKnownLink( $li, wfMsg( "login" ), $q );
                }
 
-               return $s;
+               return $wgLang->pipeList( $s );
        }
 
        /**
         * Compute the sidebar
-        * @private
+        * @access private
         */
        function quickBar()
        {
-               global $wgOut, $wgTitle, $wgUser, $wgLang, $wgContLang, $wgDisableUploads, $wgNavigationLinks;
+               global $wgOut, $wgTitle, $wgUser, $wgLang, $wgContLang, $wgEnableUploads;
 
                $tns=$wgTitle->getNamespace();
 
@@ -171,11 +176,17 @@ class SkinCologneBlue extends Skin {
 
                $s .= $this->menuHead( "qbbrowse" );
 
-               foreach ( $wgNavigationLinks as $link ) {
-                       $msg = wfMsgForContent( $link['href'] );
-                       if ( $msg != '-' ) {
-                               $s .= '<a href="' . $this->makeInternalOrExternalUrl( $msg ) . '">' .
-                                       wfMsg( $link['text'] ) . '</a>' . $sep;
+               # Use the first heading from the Monobook sidebar as the "browse" section
+               $bar = $this->buildSidebar();
+               unset( $bar['SEARCH'] );
+               unset( $bar['LANGUAGES'] );
+               unset( $bar['TOOLBOX'] );
+               $browseLinks = reset( $bar );
+
+               foreach ( $browseLinks as $link ) {
+                       if ( $link['text'] != '-' ) {
+                               $s .= "<a href=\"{$link['href']}\">" .
+                                       htmlspecialchars( $link['text'] ) . '</a>' . $sep;
                        }
                }
 
@@ -185,7 +196,7 @@ class SkinCologneBlue extends Skin {
 
                        $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) );
 
-                       if ( 0 != $wgUser->getID() ) {
+                       if( $wgUser->isLoggedIn() ) {
                                $s .= $sep . $this->moveThisPage();
                        }
                        if ( $wgUser->isAllowed('delete') ) {
@@ -204,9 +215,9 @@ class SkinCologneBlue extends Skin {
 
                        $s .= $this->menuHead( "qbpageoptions" );
                        $s .= $this->talkLink()
-                         . $sep . $this->commentLink() 
+                         . $sep . $this->commentLink()
                          . $sep . $this->printableLink();
-                       if ( 0 != $wgUser->getID() ) {
+                       if ( $wgUser->isLoggedIn() ) {
                                $s .= $sep . $this->watchThisPage();
                        }
 
@@ -216,8 +227,8 @@ class SkinCologneBlue extends Skin {
                          . $this->historyLink()
                          . $sep . $this->whatLinksHere()
                          . $sep . $this->watchPageLinksLink();
-                         
-                       if ( Namespace::getUser() == $tns || Namespace::getTalk(Namespace::getUser()) == $tns ) {
+
+                       if( $tns == NS_USER || $tns == NS_USER_TALK ) {
                                $id=User::idFromName($wgTitle->getText());
                                if ($id != 0) {
                                        $s .= $sep . $this->userContribsLink();
@@ -230,19 +241,20 @@ class SkinCologneBlue extends Skin {
                }
 
                $s .= $this->menuHead( "qbmyoptions" );
-               if ( 0 != $wgUser->getID() ) {
+               if ( $wgUser->isLoggedIn() ) {
                        $name = $wgUser->getName();
-                       $tl = $this->makeKnownLink( $wgContLang->getNsText(
-                         Namespace::getTalk( Namespace::getUser() ) ) . ":{$name}",
-                         wfMsg( "mytalk" ) );
-                       if ( 0 != $wgUser->getNewtalk() ) { $tl .= " *"; }
+                       $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
+                               wfMsg( 'mytalk' ) );
+                       if ( $wgUser->getNewtalk() ) {
+                               $tl .= " *";
+                       }
 
-                       $s .= $this->makeKnownLink( $wgContLang->getNsText(
-                         Namespace::getUser() ) . ":{$name}", wfMsg( "mypage" ) )
+                       $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
+                               wfMsg( "mypage" ) )
                          . $sep . $tl
                          . $sep . $this->specialLink( "watchlist" )
-                         . $sep . $this->makeKnownLink( $wgContLang->specialPage( "Contributions" ),
-                               wfMsg( "mycontris" ), "target=" . wfUrlencode($wgUser->getName() ) )            
+                         . $sep . $this->makeKnownLinkObj( SpecialPage::getSafeTitleFor( "Contributions", $wgUser->getName() ),
+                               wfMsg( "mycontris" ) )
                          . $sep . $this->specialLink( "preferences" )
                          . $sep . $this->specialLink( "userlogout" );
                } else {
@@ -250,11 +262,10 @@ class SkinCologneBlue extends Skin {
                }
 
                $s .= $this->menuHead( "qbspecialpages" )
-                 . $this->specialLink( "newpages" ) 
-                 . $sep . $this->specialLink( "imagelist" ) 
-                 . $sep . $this->specialLink( "statistics" ) 
-                 . $sep . $this->bugReportsLink();
-               if ( 0 != $wgUser->getID() && !$wgDisableUploads ) {
+                 . $this->specialLink( "newpages" )
+                 . $sep . $this->specialLink( "listfiles" )
+                 . $sep . $this->specialLink( "statistics" );
+               if ( $wgUser->isLoggedIn() && $wgEnableUploads ) {
                        $s .= $sep . $this->specialLink( "upload" );
                }
                global $wgSiteSupportPage;
@@ -262,8 +273,10 @@ class SkinCologneBlue extends Skin {
                        $s .= $sep."<a href=\"".htmlspecialchars($wgSiteSupportPage)."\" class =\"internal\">"
                              .wfMsg( "sitesupport" )."</a>";
                }
-               
-               $s .= $sep . $this->makeKnownLink( $wgContLang->specialPage( "Specialpages" ), wfMsg("moredotdotdot") );
+
+               $s .= $sep . $this->makeKnownLinkObj(
+                       SpecialPage::getTitleFor( 'Specialpages' ),
+                       wfMsg( 'moredotdotdot' ) );
 
                $s .= $sep . "\n</div>\n";
                return $s;
@@ -277,19 +290,29 @@ class SkinCologneBlue extends Skin {
 
        function searchForm( $label = "" )
        {
-               global $wgRequest;
+               global $wgRequest, $wgUseTwoButtonsSearchForm;
 
                $search = $wgRequest->getText( 'search' );
                $action = $this->escapeSearchLink();
-               $s = "<form id=\"search\" method=\"get\" class=\"inline\" action=\"$action\">";
+               $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
                if ( "" != $label ) { $s .= "{$label}: "; }
 
-               $s .= "<input type='text' name=\"search\" size='14' value=\""
-                 . htmlspecialchars(substr($search,0,256)) . "\" />"
-                 . "<br /><input type='submit' name=\"go\" value=\"" . htmlspecialchars( wfMsg( "go" ) ) . "\" /> <input type='submit' name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( "search" ) ) . "\" /></form>";
+               $s .= "<input type='text' id=\"searchInput{$this->searchboxes}\" class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
+                 . htmlspecialchars(substr($search,0,256)) . "\" /><br />"
+                 . "<input type='submit' id=\"searchGoButton{$this->searchboxes}\" class=\"searchButton\" name=\"go\" value=\"" . htmlspecialchars( wfMsg( "searcharticle" ) ) . "\" />";
+
+               if ($wgUseTwoButtonsSearchForm) 
+                       $s .= "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( "search" ) ) . "\" />\n";
+               else
+                       $s .= '<div><a href="$action" rel="search">' . wfMsg ('powersearch-legend') . "</a></div>\n";
+               
+               $s .= '</form>';
+
+               // Ensure unique id's for search boxes made after the first
+               $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
 
                return $s;
        }
 }
 
-?>
+