In LockServerDaemon:
[lhc/web/wiklou.git] / skins / CologneBlue.php
index 1ff2cca..c5b3b11 100644 (file)
@@ -15,40 +15,75 @@ if( !defined( 'MEDIAWIKI' ) ) {
  * @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';
-       }
+       /**
+        * @param $out OutputPage
+        */
+       function setupSkinUserCss( OutputPage $out ){
+               parent::setupSkinUserCss( $out );
+               $out->addModuleStyles( 'skins.cologneblue' );
+
+               $qb = $this->qbSetting();
+               $rules = array();
 
-       function getSkinName() {
-               return 'cologneblue';
+               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' );
        }
 
+}
+
+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 .= '<td class="top" align="left" valign="middle" nowrap="nowrap">';
-               $s .= '<a href="' . $mainPageObj->escapeLocalURL() . '">';
+               $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 align="right">';
+               $s .= '</td><td class="top-linkcollection">';
 
                $s .= '<font size="-1"><span id="langlinks">';
                $s .= str_replace( '<br />', '', $this->otherLanguages() );
-               $cat = $this->getCategoryLinks();
-               if( $cat ) {
-                       $s .= "<br />$cat\n";
-               }
+
+               $s .= $this->getSkin()->getCategories();
+
                $s .= '<br />' . $this->pageTitleLinks();
                $s .= '</span></font>';
 
@@ -56,7 +91,7 @@ class SkinCologneBlue extends Skin {
 
                $s .= "\n</div>\n<div id='article'>";
 
-               $notice = wfGetSiteNotice();
+               $notice = $this->getSkin()->getSiteNotice();
                if( $notice ) {
                        $s .= "\n<div id='siteNotice'>$notice</div>\n";
                }
@@ -65,83 +100,49 @@ class SkinCologneBlue extends Skin {
                return $s;
        }
 
+       /**
+        * @return string
+        */
        function doAfterContent(){
-               global $wgLang;
-
                $s = "\n</div><br clear='all' />\n";
 
                $s .= "\n<div id='footer'>";
                $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 .= $wgLang->pipeList( array(
-                       "\n<br />" . $this->link(
+               $s .= $this->getSkin()->getLanguage()->pipeList( array(
+                       "\n<br />" . Linker::link(
                                Title::newMainPage(),
                                null,
                                array(),
                                array(),
                                array( 'known', 'noclasses' )
                        ),
-                       $this->aboutLink(),
+                       $this->getSkin()->aboutLink(),
                        $this->searchForm( wfMsg( 'qbfind' ) )
                ) );
 
                $s .= "\n<br />" . $this->pageStats();
 
                $s .= '</td>';
-               if ( 2 == $qb ) { # Right
-                       $s .= $this->getQuickbarCompensator();
-               }
                $s .= "</tr></table>\n</div>\n</div>\n";
 
-               if ( 0 != $qb ) {
+               if ( $this->getSkin()->qbSetting() != 0 ) {
                        $s .= $this->quickBar();
                }
                return $s;
        }
 
-       function setupSkinUserCss( OutputPage $out ){
-               global $wgContLang;
-               $qb = $this->qbSetting();
-               $rules = array();
-
-               if ( 2 == $qb ) { # Right
-                       $rules[] = "#quickbar { position: absolute; right: 4px; }";
-                       $rules[] = "#article { margin-left: 4px; margin-right: 148px; }";
-               } elseif ( 1 == $qb ) {
-                       $rules[] = "#quickbar { position: absolute; left: 4px; }";
-                       $rules[] = "#article { margin-left: 148px; margin-right: 4px; }";
-               } elseif ( 3 == $qb ) { # Floating left
-                       $rules[] = "#quickbar { position:absolute; left:4px }";
-                       $rules[] = "#topbar { margin-left: 148px }";
-                       $rules[] = "#article { margin-left:148px; margin-right: 4px; }";
-                       $rules[] = "body>#quickbar { position:fixed; left:4px; top:4px; overflow:auto ;bottom:4px;}"; # Hides from IE
-               } elseif ( 4 == $qb ) { # Floating right
-                       $rules[] = "#quickbar { position: fixed; right: 4px; }";
-                       $rules[] = "#topbar { margin-right: 148px }";
-                       $rules[] = "#article { margin-right: 148px; margin-left: 4px; }";
-                       $rules[] = "body>#quickbar { position: fixed; right: 4px; top: 4px; overflow: auto ;bottom:4px;}"; # Hides from IE
-               }
-               $style = implode( "\n", $rules );
-               if ( $wgContLang->getDir() === 'rtl' ) {
-                       $style = CSSJanus::transform( $style, true, false );
-               }
-               $out->addInlineStyle( $style );
-               parent::setupSkinUserCss( $out );
-       }
-
+       /**
+        * @return string
+        */
        function sysLinks() {
-               global $wgUser, $wgLang;
                $li = SpecialPage::getTitleFor( 'Userlogin' );
                $lo = SpecialPage::getTitleFor( 'Userlogout' );
 
-               $rt = $this->mTitle->getPrefixedURL();
+               $rt = $this->getSkin()->getTitle()->getPrefixedURL();
                if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
                        $q = array();
                } else {
@@ -149,20 +150,20 @@ class SkinCologneBlue extends Skin {
                }
 
                $s = array(
-                       $this->mainPageLink(),
-                       $this->linkKnown(
+                       $this->getSkin()->mainPageLink(),
+                       Linker::linkKnown(
                                Title::newFromText( wfMsgForContent( 'aboutpage' ) ),
                                wfMsg( 'about' )
                        ),
-                       $this->linkKnown(
+                       Linker::linkKnown(
                                Title::newFromText( wfMsgForContent( 'helppage' ) ),
                                wfMsg( 'help' )
                        ),
-                       $this->linkKnown(
+                       Linker::linkKnown(
                                Title::newFromText( wfMsgForContent( 'faqpage' ) ),
                                wfMsg( 'faq' )
                        ),
-                       $this->specialLink( 'Specialpages' )
+                       Linker::specialLink( 'Specialpages' )
                );
 
                /* show links to different language variants */
@@ -172,15 +173,15 @@ class SkinCologneBlue extends Skin {
                if( $this->extensionTabLinks() ) {
                        $s[] = $this->extensionTabLinks();
                }
-               if ( $wgUser->isLoggedIn() ) {
-                       $s[] = $this->linkKnown(
+               if ( $this->data['loggedin'] ) {
+                       $s[] = Linker::linkKnown(
                                $lo,
                                wfMsg( 'logout' ),
                                array(),
                                $q
                        );
                } else {
-                       $s[] = $this->linkKnown(
+                       $s[] = Linker::linkKnown(
                                $li,
                                wfMsg( 'login' ),
                                array(),
@@ -188,18 +189,16 @@ class SkinCologneBlue extends Skin {
                        );
                }
 
-               return $wgLang->pipeList( $s );
+               return $this->getSkin()->getLanguage()->pipeList( $s );
        }
 
        /**
         * Compute the sidebar
         * @access private
+        *
+        * @return string
         */
        function quickBar(){
-               global $wgOut, $wgUser;
-
-               $tns = $this->mTitle->getNamespace();
-
                $s = "\n<div id='quickbar'>";
 
                $sep = '<br />';
@@ -209,38 +208,54 @@ class SkinCologneBlue extends Skin {
                $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() ) {
+               $user = $this->getSkin()->getUser();
+
+               if ( $this->data['isarticle'] ) {
                        $s .= $this->menuHead( 'qbedit' );
                        $s .= '<strong>' . $this->editThisPage() . '</strong>';
 
-                       $s .= $sep . $this->linkKnown(
+                       $s .= $sep . Linker::linkKnown(
                                Title::newFromText( wfMsgForContent( 'edithelppage' ) ),
                                wfMsg( 'edithelp' )
                        );
 
-                       if( $wgUser->isLoggedIn() ) {
+                       if( $this->data['loggedin'] ) {
                                $s .= $sep . $this->moveThisPage();
                        }
-                       if ( $wgUser->isAllowed( 'delete' ) ) {
+                       if ( $user->isAllowed( 'delete' ) ) {
                                $dtp = $this->deleteThisPage();
                                if ( $dtp != '' ) {
                                        $s .= $sep . $dtp;
                                }
                        }
-                       if ( $wgUser->isAllowed( 'protect' ) ) {
+                       if ( $user->isAllowed( 'protect' ) ) {
                                $ptp = $this->protectThisPage();
                                if ( $ptp != '' ) {
                                        $s .= $sep . $ptp;
@@ -252,7 +267,7 @@ class SkinCologneBlue extends Skin {
                        $s .= $this->talkLink()
                                        . $sep . $this->commentLink()
                                        . $sep . $this->printableLink();
-                       if ( $wgUser->isLoggedIn() ) {
+                       if ( $this->data['loggedin'] ) {
                                $s .= $sep . $this->watchThisPage();
                        }
 
@@ -263,11 +278,13 @@ class SkinCologneBlue extends Skin {
                                        . $sep . $this->whatLinksHere()
                                        . $sep . $this->watchPageLinksLink();
 
-                       if( $tns == NS_USER || $tns == NS_USER_TALK ) {
-                               $id = User::idFromName( $this->mTitle->getText() );
+                       $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();
                                        }
                                }
@@ -276,43 +293,43 @@ class SkinCologneBlue extends Skin {
                }
 
                $s .= $this->menuHead( 'qbmyoptions' );
-               if ( $wgUser->isLoggedIn() ) {
-                       $tl = $this->link(
-                               $wgUser->getTalkPage(),
+               if ( $this->data['loggedin'] ) {
+                       $tl = Linker::link(
+                               $user->getTalkPage(),
                                wfMsg( 'mytalk' ),
                                array(),
                                array(),
                                array( 'known', 'noclasses' )
                        );
-                       if ( $wgUser->getNewtalk() ) {
+                       if ( $user->getNewtalk() ) {
                                $tl .= ' *';
                        }
 
-                       $s .= $this->link(
-                                       $wgUser->getUserPage(),
+                       $s .= Linker::link(
+                                       $user->getUserPage(),
                                        wfMsg( 'mypage' ),
                                        array(),
                                        array(),
                                        array( 'known', 'noclasses' )
-                               ) . $sep . $tl . $sep . $this->specialLink( 'Watchlist' )
+                               ) . $sep . $tl . $sep . Linker::specialLink( 'Watchlist' )
                                        . $sep .
-                               $this->link(
-                                       SpecialPage::getSafeTitleFor( 'Contributions', $wgUser->getName() ),
+                               Linker::link(
+                                       SpecialPage::getSafeTitleFor( 'Contributions', $user->getName() ),
                                        wfMsg( 'mycontris' ),
                                        array(),
                                        array(),
                                        array( 'known', 'noclasses' )
-                               ) . $sep . $this->specialLink( 'Preferences' )
-                               . $sep . $this->specialLink( 'Userlogout' );
+                               ) . $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( 'Listfiles' )
-                       . $sep . $this->specialLink( 'Statistics' );
-               if( UploadBase::isEnabled() && UploadBase::isAllowed( $wgUser ) === true ) {
+                       . Linker::specialLink( 'Newpages' )
+                       . $sep . Linker::specialLink( 'Listfiles' )
+                       . $sep . Linker::specialLink( 'Statistics' );
+               if( UploadBase::isEnabled() && UploadBase::isAllowed( $user ) === true ) {
                        $s .= $sep . $this->getUploadLink();
                }
 
@@ -323,7 +340,7 @@ class SkinCologneBlue extends Skin {
                                        . wfMsg( 'sitesupport' ) . '</a>';
                }
 
-               $s .= $sep . $this->link(
+               $s .= $sep . Linker::link(
                        SpecialPage::getTitleFor( 'Specialpages' ),
                        wfMsg( 'moredotdotdot' ),
                        array(),
@@ -335,16 +352,24 @@ class SkinCologneBlue extends Skin {
                return $s;
        }
 
+       /**
+        * @param $key string
+        * @return string
+        */
        function menuHead( $key ) {
                $s = "\n<h6>" . wfMsg( $key ) . "</h6>";
                return $s;
        }
 
+       /**
+        * @param $label string
+        * @return string
+        */
        function searchForm( $label = '' ) {
-               global $wgRequest, $wgUseTwoButtonsSearchForm;
+               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}: ";