In LockServerDaemon:
[lhc/web/wiklou.git] / skins / CologneBlue.php
index f3806dc..c5b3b11 100644 (file)
@@ -1,61 +1,97 @@
 <?php
 /**
- * See docs/skin.txt
+ * Cologne Blue: A nicer-looking alternative to Standard.
  *
  * @todo document
  * @file
  * @ingroup Skins
  */
 
-if( !defined( 'MEDIAWIKI' ) )
+if( !defined( 'MEDIAWIKI' ) ) {
        die( -1 );
+}
 
 /**
  * @todo document
  * @ingroup Skins
  */
-class SkinCologneBlue extends Skin {
+class SkinCologneBlue extends SkinLegacy {
+       var $skinname = 'cologneblue', $stylename = 'cologneblue',
+               $template = 'CologneBlueTemplate';
 
-       function getStylesheet() {
-               return 'common/cologneblue.css';
-       }
-       function getSkinName() {
-               return "cologneblue";
+       /**
+        * @param $out OutputPage
+        */
+       function setupSkinUserCss( OutputPage $out ){
+               parent::setupSkinUserCss( $out );
+               $out->addModuleStyles( 'skins.cologneblue' );
+
+               $qb = $this->qbSetting();
+               $rules = array();
+
+               if ( 2 == $qb ) { # Right
+                       $rules[] = "/* @noflip */#quickbar { position: absolute; right: 4px; }";
+                       $rules[] = "/* @noflip */#article { margin-left: 4px; margin-right: 148px; }";
+                       $rules[] = "/* @noflip */#footer { margin-right: 152px; }";
+               } elseif ( 1 == $qb ) {
+                       $rules[] = "/* @noflip */#quickbar { position: absolute; left: 4px; }";
+                       $rules[] = "/* @noflip */#article { margin-left: 148px; margin-right: 4px; }";
+                       $rules[] = "/* @noflip */#footer { margin-left: 152px; }";
+               } elseif ( 3 == $qb ) { # Floating left
+                       $rules[] = "/* @noflip */#quickbar { position:absolute; left:4px }";
+                       $rules[] = "/* @noflip */#topbar { margin-left: 148px }";
+                       $rules[] = "/* @noflip */#article { margin-left:148px; margin-right: 4px; }";
+                       $rules[] = "/* @noflip */body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto; bottom:4px;}"; # Hides from IE
+                       $rules[] = "/* @noflip */#footer { margin-left: 152px; }";
+               } elseif ( 4 == $qb ) { # Floating right
+                       $rules[] = "/* @noflip */#quickbar { position: fixed; right: 4px; }";
+                       $rules[] = "/* @noflip */#topbar { margin-right: 148px }";
+                       $rules[] = "/* @noflip */#article { margin-right: 148px; margin-left: 4px; }";
+                       $rules[] = "/* @noflip */body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto; bottom:4px;}"; # Hides from IE
+                       $rules[] = "/* @noflip */#footer { margin-right: 152px; }";
+               }
+               $style = implode( "\n", $rules );
+               $out->addInlineStyle( $style, 'flip' );
        }
 
-       function doBeforeContent() {
+}
 
-               $s = "";
-               $qb = $this->qbSetting();
+class CologneBlueTemplate extends LegacyTemplate {
+
+       /**
+        * @return string
+        */
+       function doBeforeContent() {
                $mainPageObj = Title::newMainPage();
 
-               $s .= "\n<div id='content'>\n<div id='topbar'>" .
-                 "<table width='100%' border='0' cellspacing='0' cellpadding='8'><tr>";
+               $s = "\n<div id='content'>\n<div id='topbar'>" .
+                 '<table width="100%" border="0" cellspacing="0" cellpadding="8"><tr>';
 
-               $s .= "<td class='top' align='left' valign='middle' nowrap='nowrap'>";
-               $s .= "<a href=\"" . $mainPageObj->escapeLocalURL() . "\">";
-               $s .= "<span id='sitetitle'>" . wfMsg( "sitetitle" ) . "</span></a>";
+               $s .= '<td class="top" nowrap="nowrap">';
+               $s .= '<a href="' . htmlspecialchars( $mainPageObj->getLocalURL() ) . '">';
+               $s .= '<span id="sitetitle">' . wfMsg( 'sitetitle' ) . '</span></a>';
 
-               $s .= "</td><td class='top' align='right' valign='bottom' width='100%'>";
+               $s .= '</td><td class="top" id="top-syslinks" width="100%">';
                $s .= $this->sysLinks();
-               $s .= "</td></tr><tr><td valign='top'>";
+               $s .= '</td></tr><tr><td class="top-subheader">';
+
+               $s .= '<font size="-1"><span id="sitesub">';
+               $s .= htmlspecialchars( wfMsg( 'sitesubtitle' ) ) . '</span></font>';
+               $s .= '</td><td class="top-linkcollection">';
+
+               $s .= '<font size="-1"><span id="langlinks">';
+               $s .= str_replace( '<br />', '', $this->otherLanguages() );
 
-               $s .= "<font size='-1'><span id='sitesub'>";
-               $s .= htmlspecialchars( wfMsg( "sitesubtitle" ) ) . "</span></font>";
-               $s .= "</td><td align='right'>" ;
+               $s .= $this->getSkin()->getCategories();
 
-               $s .= "<font size='-1'><span id='langlinks'>" ;
-               $s .= str_replace ( "<br />" , "" , $this->otherLanguages() );
-               $cat = $this->getCategoryLinks();
-               if( $cat ) $s .= "<br />$cat\n";
-               $s .= "<br />" . $this->pageTitleLinks();
-               $s .= "</span></font>";
+               $s .= '<br />' . $this->pageTitleLinks();
+               $s .= '</span></font>';
 
                $s .= "</td></tr></table>\n";
 
                $s .= "\n</div>\n<div id='article'>";
 
-               $notice = wfGetSiteNotice();
+               $notice = $this->getSkin()->getSiteNotice();
                if( $notice ) {
                        $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
@@ -64,174 +100,191 @@ class SkinCologneBlue extends Skin {
                return $s;
        }
 
-       function doAfterContent()
-       {
-               global $wgOut;
-
+       /**
+        * @return string
+        */
+       function doAfterContent(){
                $s = "\n</div><br clear='all' />\n";
 
                $s .= "\n<div id='footer'>";
-               $s .= "<table width='98%' border='0' cellspacing='0'><tr>";
+               $s .= '<table width="98%" border="0" cellspacing="0"><tr>';
 
-               $qb = $this->qbSetting();
-               if ( 1 == $qb || 3 == $qb ) { # Left
-                       $s .= $this->getQuickbarCompensator();
-               }
-               $s .= "<td class='bottom' align='center' valign='top'>";
+               $s .= '<td class="bottom">';
 
                $s .= $this->bottomLinks();
-               $s .= "\n<br />" . $this->makeKnownLinkObj( Title::newMainPage() ) . " | "
-                 . $this->aboutLink() . " | "
-                 . $this->searchForm( wfMsg( "qbfind" ) );
+               $s .= $this->getSkin()->getLanguage()->pipeList( array(
+                       "\n<br />" . Linker::link(
+                               Title::newMainPage(),
+                               null,
+                               array(),
+                               array(),
+                               array( 'known', 'noclasses' )
+                       ),
+                       $this->getSkin()->aboutLink(),
+                       $this->searchForm( wfMsg( 'qbfind' ) )
+               ) );
 
                $s .= "\n<br />" . $this->pageStats();
 
-               $s .= "</td>";
-               if ( 2 == $qb ) { # Right
-                       $s .= $this->getQuickbarCompensator();
-               }
+               $s .= '</td>';
                $s .= "</tr></table>\n</div>\n</div>\n";
 
-               if ( 0 != $qb ) { $s .= $this->quickBar(); }
-               return $s;
-       }
-
-       function reallyGenerateUserStylesheet() {
-               $s = parent::reallyGenerateUserStylesheet();
-               $qb = $this->qbSetting();
-
-               if ( 2 == $qb ) { # Right
-                       $s .= "#quickbar { position: absolute; right: 4px; }\n" .
-                         "#article { margin-left: 4px; margin-right: 148px; }\n";
-               } else if ( 1 == $qb ) {
-                       $s .= "#quickbar { position: absolute; left: 4px; }\n" .
-                         "#article { margin-left: 148px; margin-right: 4px; }\n";
-               } 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
+               if ( $this->getSkin()->qbSetting() != 0 ) {
+                       $s .= $this->quickBar();
                }
                return $s;
        }
 
+       /**
+        * @return string
+        */
        function sysLinks() {
-               global $wgUser, $wgContLang, $wgTitle;
-               $li = $wgContLang->specialPage("Userlogin");
-               $lo = $wgContLang->specialPage("Userlogout");
+               $li = SpecialPage::getTitleFor( 'Userlogin' );
+               $lo = SpecialPage::getTitleFor( 'Userlogout' );
 
-               $rt = $wgTitle->getPrefixedURL();
+               $rt = $this->getSkin()->getTitle()->getPrefixedURL();
                if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
-                       $q = "";
+                       $q = array();
                } else {
-                       $q = "returnto={$rt}";
+                       $q = array( '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->getSkin()->mainPageLink(),
+                       Linker::linkKnown(
+                               Title::newFromText( wfMsgForContent( 'aboutpage' ) ),
+                               wfMsg( 'about' )
+                       ),
+                       Linker::linkKnown(
+                               Title::newFromText( wfMsgForContent( 'helppage' ) ),
+                               wfMsg( 'help' )
+                       ),
+                       Linker::linkKnown(
+                               Title::newFromText( wfMsgForContent( 'faqpage' ) ),
+                               wfMsg( 'faq' )
+                       ),
+                       Linker::specialLink( 'Specialpages' )
+               );
 
                /* show links to different language variants */
-               $s .= $this->variantLinks();
-               $s .= $this->extensionTabLinks();
-               
-               $s .= " | ";
-               if ( $wgUser->isLoggedIn() ) {
-                       $s .=  $this->makeKnownLink( $lo, wfMsg( "logout" ), $q );
+               if( $this->variantLinks() ) {
+                       $s[] = $this->variantLinks();
+               }
+               if( $this->extensionTabLinks() ) {
+                       $s[] = $this->extensionTabLinks();
+               }
+               if ( $this->data['loggedin'] ) {
+                       $s[] = Linker::linkKnown(
+                               $lo,
+                               wfMsg( 'logout' ),
+                               array(),
+                               $q
+                       );
                } else {
-                       $s .=  $this->makeKnownLink( $li, wfMsg( "login" ), $q );
+                       $s[] = Linker::linkKnown(
+                               $li,
+                               wfMsg( 'login' ),
+                               array(),
+                               $q
+                       );
                }
 
-               return $s;
+               return $this->getSkin()->getLanguage()->pipeList( $s );
        }
 
        /**
         * Compute the sidebar
         * @access private
+        *
+        * @return string
         */
-       function quickBar()
-       {
-               global $wgOut, $wgTitle, $wgUser, $wgLang, $wgContLang, $wgEnableUploads;
-
-               $tns=$wgTitle->getNamespace();
-
+       function quickBar(){
                $s = "\n<div id='quickbar'>";
 
-               $sep = "<br />";
-               $s .= $this->menuHead( "qbfind" );
+               $sep = '<br />';
+               $s .= $this->menuHead( 'qbfind' );
                $s .= $this->searchForm();
 
-               $s .= $this->menuHead( "qbbrowse" );
+               $s .= $this->menuHead( 'qbbrowse' );
 
                # Use the first heading from the Monobook sidebar as the "browse" section
-               $bar = $this->buildSidebar();
+               $bar = $this->getSkin()->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;
+               $barnumber = 1;
+               foreach ( $bar as $heading => $browseLinks ) {
+                       if ( $barnumber > 1 ) {
+                               $headingMsg = wfMessage( $heading );
+                               if ( $headingMsg->exists() ) {
+                                       $h = $headingMsg->text();
+                               } else {
+                                       $h = $heading;
+                               }
+                               $s .= "\n<h6>" . htmlspecialchars( $h ) . "</h6>";
+                       }
+                       if( is_array( $browseLinks ) ) {
+                               foreach ( $browseLinks as $link ) {
+                                       if ( $link['text'] != '-' ) {
+                                               $s .= "<a href=\"{$link['href']}\">" .
+                                                       htmlspecialchars( $link['text'] ) . '</a>' . $sep;
+                                       }
+                               }
                        }
+                       $barnumber++;
                }
 
-               if ( $wgOut->isArticle() ) {
-                       $s .= $this->menuHead( "qbedit" );
-                       $s .= "<strong>" . $this->editThisPage() . "</strong>";
+               $user = $this->getSkin()->getUser();
 
-                       $s .= $sep . $this->makeKnownLink( wfMsgForContent( "edithelppage" ), wfMsg( "edithelp" ) );
+               if ( $this->data['isarticle'] ) {
+                       $s .= $this->menuHead( 'qbedit' );
+                       $s .= '<strong>' . $this->editThisPage() . '</strong>';
 
-                       if( $wgUser->isLoggedIn() ) {
+                       $s .= $sep . Linker::linkKnown(
+                               Title::newFromText( wfMsgForContent( 'edithelppage' ) ),
+                               wfMsg( 'edithelp' )
+                       );
+
+                       if( $this->data['loggedin'] ) {
                                $s .= $sep . $this->moveThisPage();
                        }
-                       if ( $wgUser->isAllowed('delete') ) {
+                       if ( $user->isAllowed( 'delete' ) ) {
                                $dtp = $this->deleteThisPage();
-                               if ( "" != $dtp ) {
+                               if ( $dtp != '' ) {
                                        $s .= $sep . $dtp;
                                }
                        }
-                       if ( $wgUser->isAllowed('protect') ) {
+                       if ( $user->isAllowed( 'protect' ) ) {
                                $ptp = $this->protectThisPage();
-                               if ( "" != $ptp ) {
+                               if ( $ptp != '' ) {
                                        $s .= $sep . $ptp;
                                }
                        }
                        $s .= $sep;
 
-                       $s .= $this->menuHead( "qbpageoptions" );
+                       $s .= $this->menuHead( 'qbpageoptions' );
                        $s .= $this->talkLink()
-                         . $sep . $this->commentLink()
-                         . $sep . $this->printableLink();
-                       if ( $wgUser->isLoggedIn() ) {
+                                       . $sep . $this->commentLink()
+                                       . $sep . $this->printableLink();
+                       if ( $this->data['loggedin'] ) {
                                $s .= $sep . $this->watchThisPage();
                        }
 
                        $s .= $sep;
 
-                       $s .= $this->menuHead("qbpageinfo")
-                         . $this->historyLink()
-                         . $sep . $this->whatLinksHere()
-                         . $sep . $this->watchPageLinksLink();
+                       $s .= $this->menuHead( 'qbpageinfo' )
+                                       . $this->historyLink()
+                                       . $sep . $this->whatLinksHere()
+                                       . $sep . $this->watchPageLinksLink();
 
-                       if( $tns == NS_USER || $tns == NS_USER_TALK ) {
-                               $id=User::idFromName($wgTitle->getText());
-                               if ($id != 0) {
+                       $title = $this->getSkin()->getTitle();
+                       $tns = $title->getNamespace();
+                       if ( $tns == NS_USER || $tns == NS_USER_TALK ) {
+                               $id = User::idFromName( $title->getText() );
+                               if( $id != 0 ) {
                                        $s .= $sep . $this->userContribsLink();
-                                       if( $this->showEmailUser( $id ) ) {
+                                       if( $this->getSkin()->showEmailUser( $id ) ) {
                                                $s .= $sep . $this->emailUserLink();
                                        }
                                }
@@ -239,67 +292,100 @@ class SkinCologneBlue extends Skin {
                        $s .= $sep;
                }
 
-               $s .= $this->menuHead( "qbmyoptions" );
-               if ( $wgUser->isLoggedIn() ) {
-                       $name = $wgUser->getName();
-                       $tl = $this->makeKnownLinkObj( $wgUser->getTalkPage(),
-                               wfMsg( 'mytalk' ) );
-                       if ( $wgUser->getNewtalk() ) {
-                               $tl .= " *";
+               $s .= $this->menuHead( 'qbmyoptions' );
+               if ( $this->data['loggedin'] ) {
+                       $tl = Linker::link(
+                               $user->getTalkPage(),
+                               wfMsg( 'mytalk' ),
+                               array(),
+                               array(),
+                               array( 'known', 'noclasses' )
+                       );
+                       if ( $user->getNewtalk() ) {
+                               $tl .= ' *';
                        }
 
-                       $s .= $this->makeKnownLinkObj( $wgUser->getUserPage(),
-                               wfMsg( "mypage" ) )
-                         . $sep . $tl
-                         . $sep . $this->specialLink( "watchlist" )
-                         . $sep . $this->makeKnownLinkObj( SpecialPage::getSafeTitleFor( "Contributions", $wgUser->getName() ),
-                               wfMsg( "mycontris" ) )
-                         . $sep . $this->specialLink( "preferences" )
-                         . $sep . $this->specialLink( "userlogout" );
+                       $s .= Linker::link(
+                                       $user->getUserPage(),
+                                       wfMsg( 'mypage' ),
+                                       array(),
+                                       array(),
+                                       array( 'known', 'noclasses' )
+                               ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
+                                       . $sep .
+                               Linker::link(
+                                       SpecialPage::getSafeTitleFor( 'Contributions', $user->getName() ),
+                                       wfMsg( 'mycontris' ),
+                                       array(),
+                                       array(),
+                                       array( 'known', 'noclasses' )
+                               ) . $sep . Linker::specialLink( 'Preferences' )
+                               . $sep . Linker::specialLink( 'Userlogout' );
                } else {
-                       $s .= $this->specialLink( "userlogin" );
+                       $s .= Linker::specialLink( 'Userlogin' );
                }
 
-               $s .= $this->menuHead( "qbspecialpages" )
-                 . $this->specialLink( "newpages" )
-                 . $sep . $this->specialLink( "imagelist" )
-                 . $sep . $this->specialLink( "statistics" );
-               if ( $wgUser->isLoggedIn() && $wgEnableUploads ) {
-                       $s .= $sep . $this->specialLink( "upload" );
+               $s .= $this->menuHead( 'qbspecialpages' )
+                       . Linker::specialLink( 'Newpages' )
+                       . $sep . Linker::specialLink( 'Listfiles' )
+                       . $sep . Linker::specialLink( 'Statistics' );
+               if( UploadBase::isEnabled() && UploadBase::isAllowed( $user ) === true ) {
+                       $s .= $sep . $this->getUploadLink();
                }
+
                global $wgSiteSupportPage;
-               if( $wgSiteSupportPage) {
-                       $s .= $sep."<a href=\"".htmlspecialchars($wgSiteSupportPage)."\" class =\"internal\">"
-                             .wfMsg( "sitesupport" )."</a>";
+
+               if( $wgSiteSupportPage ) {
+                       $s .= $sep . '<a href="' . htmlspecialchars( $wgSiteSupportPage ) . '" class="internal">'
+                                       . wfMsg( 'sitesupport' ) . '</a>';
                }
 
-               $s .= $sep . $this->makeKnownLinkObj(
+               $s .= $sep . Linker::link(
                        SpecialPage::getTitleFor( 'Specialpages' ),
-                       wfMsg( 'moredotdotdot' ) );
+                       wfMsg( 'moredotdotdot' ),
+                       array(),
+                       array(),
+                       array( 'known', 'noclasses' )
+               );
 
                $s .= $sep . "\n</div>\n";
                return $s;
        }
 
-       function menuHead( $key )
-       {
+       /**
+        * @param $key string
+        * @return string
+        */
+       function menuHead( $key ) {
                $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
                return $s;
        }
 
-       function searchForm( $label = "" )
-       {
-               global $wgRequest;
+       /**
+        * @param $label string
+        * @return string
+        */
+       function searchForm( $label = '' ) {
+               global $wgUseTwoButtonsSearchForm;
 
-               $search = $wgRequest->getText( 'search' );
-               $action = $this->escapeSearchLink();
+               $search = $this->getSkin()->getRequest()->getText( 'search' );
+               $action = $this->data['searchaction'];
                $s = "<form id=\"searchform{$this->searchboxes}\" method=\"get\" class=\"inline\" action=\"$action\">";
-               if ( "" != $label ) { $s .= "{$label}: "; }
+               if( $label != '' ) {
+                       $s .= "{$label}: ";
+               }
 
                $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>";
+                       . 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;
@@ -307,5 +393,3 @@ class SkinCologneBlue extends Skin {
                return $s;
        }
 }
-
-