Fix regression -- wfMkdirParents() started whining if target directory existed, inste...
[lhc/web/wiklou.git] / skins / CologneBlue.php
index 88d1e6d..b066a1a 100644 (file)
@@ -1,36 +1,36 @@
 <?php
 /**
- * See skin.doc
+ * See skin.txt
  *
  * @todo document
- * @package MediaWiki
- * @subpackage Skins
+ * @addtogroup Skins
  */
 
 if( !defined( 'MEDIAWIKI' ) )
-       die();
+       die( -1 );
 
 /**
  * @todo document
- * @package MediaWiki
- * @subpackage Skins
+ * @addtogroup Skins
  */
 class SkinCologneBlue extends Skin {
 
+       private $searchboxes = '';
+       // How many search boxes have we made?  Avoid duplicate id's.
+
        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 +47,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 +57,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 +68,7 @@ class SkinCologneBlue extends Skin {
 
        function doAfterContent()
        {
-               global $wgUser, $wgOut;
+               global $wgOut;
 
                $s = "\n</div><br clear='all' />\n";
 
@@ -81,7 +82,7 @@ class SkinCologneBlue extends Skin {
                $s .= "<td class='bottom' align='center' valign='top'>";
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $this->makeKnownLink( wfMsgForContent( "mainpage" ) ) . " | "
+               $s .= "\n<br />" . $this->makeKnownLinkObj( Title::newMainPage() ) . " | "
                  . $this->aboutLink() . " | "
                  . $this->searchForm( wfMsg( "qbfind" ) );
 
@@ -96,9 +97,9 @@ class SkinCologneBlue extends Skin {
                if ( 0 != $qb ) { $s .= $this->quickBar(); }
                return $s;
        }
-       function doGetUserStyles()
-       {
-               global $wgUser, $wgOut, $wgStyleSheetPath;
+
+       function doGetUserStyles() {
+               global $wgOut;
                $s = parent::doGetUserStyles();
                $qb = $this->qbSetting();
 
@@ -108,16 +109,21 @@ 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
                }
                return $s;
        }
-       function sysLinks()
-       {
+
+       function sysLinks() {
                global $wgUser, $wgContLang, $wgTitle;
                $li = $wgContLang->specialPage("Userlogin");
                $lo = $wgContLang->specialPage("Userlogout");
@@ -125,12 +131,12 @@ class SkinCologneBlue extends Skin {
                $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->mainPageLink()
                  . " | " .
                  $this->makeKnownLink( wfMsgForContent( "aboutpage" ), wfMsg( "about" ) )
                  . " | " .
@@ -138,42 +144,29 @@ class SkinCologneBlue extends Skin {
                  . " | " .
                  $this->makeKnownLink( wfMsgForContent( "faqpage" ), wfMsg("faq") )
                  . " | " .
-                 $this->specialLink( "specialpages" ) . " | ";
+                 $this->specialLink( "specialpages" );
 
-               if ( $wgUser->getID() )
-               {
+               /* show links to different language variants */
+               $s .= $this->variantLinks();
+               $s .= $this->extensionTabLinks();
+               
+               $s .= " | ";
+               if ( $wgUser->isLoggedIn() ) {
                        $s .=  $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
-               }
-               else
-               {
+               } else {
                        $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
                }
 
-               /* show links to different language variants */
-               global $wgDisableLangConversion;
-               $variants = $wgContLang->getVariants();
-               if( !$wgDisableLangConversion && sizeof( $variants ) > 1 ) {
-                       $actstr = '';
-                       foreach( $variants as $code ) {
-                               $varname = $wgContLang->getVariantname( $code );
-                               if( $varname == 'disable' )
-                                       continue;
-                               $s .= ' | <a href="' . $wgTitle->getLocalUrl( 'variant=' . $code ) . '">' . $varname . '</a>';
-                       }
-               }
-
-
-
                return $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();
 
@@ -185,12 +178,14 @@ class SkinCologneBlue extends Skin {
 
                $s .= $this->menuHead( "qbbrowse" );
 
-               foreach ( $wgNavigationLinks as $link ) {
-                       $msg = wfMsgForContent( $link['href'] );
-                       $text = wfMsg( $link['text'] );
-                       if ( $msg != '-' && $text != '-' ) {
-                               $s .= '<a href="' . $this->makeInternalOrExternalUrl( $msg ) . '">' .
-                                       htmlspecialchars( $text ) . '</a>' . $sep;
+               # Use the first heading from the Monobook sidebar as the "browse" section
+               $bar = $this->buildSidebar();
+               $browseLinks = reset( $bar );
+
+               foreach ( $browseLinks as $link ) {
+                       if ( $link['text'] != '-' ) {
+                               $s .= "<a href=\"{$link['href']}\">" .
+                                       htmlspecialchars( $link['text'] ) . '</a>' . $sep;
                        }
                }
 
@@ -200,7 +195,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') ) {
@@ -219,9 +214,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();
                        }
 
@@ -231,8 +226,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();
@@ -245,19 +240,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 {
@@ -265,11 +261,11 @@ class SkinCologneBlue extends Skin {
                }
 
                $s .= $this->menuHead( "qbspecialpages" )
-                 . $this->specialLink( "newpages" ) 
-                 . $sep . $this->specialLink( "imagelist" ) 
-                 . $sep . $this->specialLink( "statistics" ) 
+                 . $this->specialLink( "newpages" )
+                 . $sep . $this->specialLink( "imagelist" )
+                 . $sep . $this->specialLink( "statistics" )
                  . $sep . $this->bugReportsLink();
-               if ( 0 != $wgUser->getID() && !$wgDisableUploads ) {
+               if ( $wgUser->isLoggedIn() && $wgEnableUploads ) {
                        $s .= $sep . $this->specialLink( "upload" );
                }
                global $wgSiteSupportPage;
@@ -277,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;
@@ -296,12 +294,16 @@ class SkinCologneBlue extends Skin {
 
                $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" ) ) . "\" />"
+                 . "<input type='submit' id=\"mw-searchButton{$this->searchboxes}\" class=\"searchButton\" name=\"fulltext\" value=\"" . htmlspecialchars( wfMsg( "search" ) ) . "\" /></form>";
+
+               // Ensure unique id's for search boxes made after the first
+               $this->searchboxes = $this->searchboxes == '' ? 2 : $this->searchboxes + 1;
 
                return $s;
        }