Merge "Fixing dump tests for non-wikitext in NS_MAIN."
[lhc/web/wiklou.git] / skins / CologneBlue.php
index 723278d..17487f4 100644 (file)
@@ -43,7 +43,14 @@ class SkinCologneBlue extends SkinTemplate {
                $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
                $out->addModuleStyles( 'skins.cologneblue' );
        }
-
+       
+       /**
+        * Override langlink formatting behavior not to uppercase the language names.
+        * See otherLanguages() in CologneBlueTemplate.
+        */
+       function formatLanguageName( $name ) {
+               return $name;
+       }
 }
 
 class CologneBlueTemplate extends BaseTemplate {
@@ -62,109 +69,47 @@ class CologneBlueTemplate extends BaseTemplate {
        /**
         * Language/charset variant links for classic-style skins
         * @return string
+        *
+        * @fixed
         */
        function variantLinks() {
-               $s = '';
-
-               /* show links to different language variants */
-               global $wgDisableLangConversion, $wgLang;
-
-               $title = $this->getSkin()->getTitle();
-               $lang = $title->getPageLanguage();
-               $variants = $lang->getVariants();
-
-               if ( !$wgDisableLangConversion && sizeof( $variants ) > 1
-                       && !$title->isSpecialPage() ) {
-                       foreach ( $variants as $code ) {
-                               $varname = $lang->getVariantname( $code );
-
-                               if ( $varname == 'disable' ) {
-                                       continue;
-                               }
-                               $s = $wgLang->pipeList( array(
-                                       $s,
-                                       '<a href="' . htmlspecialchars( $title->getLocalURL( 'variant=' . $code ) ) . '" lang="' . $code . '" hreflang="' . $code .  '">' . htmlspecialchars( $varname ) . '</a>'
-                               ) );
-                       }
-               }
-
-               return $s;
-       }
-
-       /**
-        * Compatibility for extensions adding functionality through tabs.
-        * Eventually these old skins should be replaced with SkinTemplate-based
-        * versions, sigh...
-        * @return string
-        * @todo Exterminate! ...that, and replace it with normal SkinTemplate stuff
-        */
-       function extensionTabLinks() {
-               $tabs = array();
-               $out = '';
                $s = array();
-               wfRunHooks( 'SkinTemplateTabs', array( $this->getSkin(), &$tabs ) );
-               foreach ( $tabs as $tab ) {
-                       $s[] = Xml::element( 'a',
-                               array( 'href' => $tab['href'] ),
-                               $tab['text'] );
-               }
 
-               if ( count( $s ) ) {
-                       global $wgLang;
+               $variants = $this->data['content_navigation']['variants'];
 
-                       $out = wfMessage( 'pipe-separator' )->escaped();
-                       $out .= $wgLang->pipeList( $s );
+               foreach ( $variants as $key => $link ) {
+                       $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
                }
 
-               return $out;
+               return $this->getSkin()->getLanguage()->pipeList( $s );
        }
        
+       // @fixed
        function otherLanguages() {
-               global $wgOut, $wgLang, $wgHideInterlanguageLinks;
-
+               global $wgHideInterlanguageLinks;
                if ( $wgHideInterlanguageLinks ) {
-                       return '';
-               }
-
-               $a = $wgOut->getLanguageLinks();
-
-               if ( 0 == count( $a ) ) {
-                       return '';
+                       return "";
                }
 
-               $s = wfMessage( 'otherlanguages' )->text() . wfMessage( 'colon-separator' )->text();
-               $first = true;
-
-               if ( $wgLang->isRTL() ) {
-                       $s .= '<span dir="ltr">';
+               // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
+               // not to capitalize the language names.
+               $language_urls = $this->data['language_urls'];
+               if ( empty( $language_urls ) ) {
+                       return "";
                }
 
-               foreach ( $a as $l ) {
-                       if ( !$first ) {
-                               $s .= wfMessage( 'pipe-separator' )->escaped();
-                       }
-
-                       $first = false;
-
-                       $nt = Title::newFromText( $l );
-                       $text = Language::fetchLanguageName( $nt->getInterwiki() );
-
-                       $s .= Html::element( 'a',
-                               array( 'href' => $nt->getFullURL(), 'title' => $nt->getText(), 'class' => "external" ),
-                               $text == '' ? $l : $text );
-               }
-
-               if ( $wgLang->isRTL() ) {
-                       $s .= '</span>';
+               $s = array();
+               foreach ( $language_urls as $key => $data ) {
+                       $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
                }
 
-               return $s;
+               return wfMessage( 'otherlanguages' )->text()
+                       . wfMessage( 'colon-separator' )->text()
+                       . $this->getSkin()->getLanguage()->pipeList( $s );
        }
 
        // @fixed
        function pageTitleLinks() {
-               global $wgLang;
-               
                $s = array();
                $footlinks = $this->getFooterLinks();
                
@@ -172,67 +117,17 @@ class CologneBlueTemplate extends BaseTemplate {
                        $s[] = $this->data[$item];
                }
                
-               return $wgLang->pipeList( $s );
-       }
-
-       function printableLink() {
-               global $wgOut, $wgRequest, $wgLang;
-
-               $s = array();
-
-               if ( !$wgOut->isPrintable() ) {
-                       $printurl = htmlspecialchars( $this->getSkin()->getTitle()->getLocalUrl(
-                               $wgRequest->appendQueryValue( 'printable', 'yes', true ) ) );
-                       $s[] = "<a href=\"$printurl\" rel=\"alternate\">"
-                               . wfMessage( 'printableversion' )->text() . '</a>';
-               }
-
-               if ( $wgOut->isSyndicated() ) {
-                       foreach ( $wgOut->getSyndicationLinks() as $format => $link ) {
-                               $feedurl = htmlspecialchars( $link );
-                               $s[] = "<a href=\"$feedurl\" rel=\"alternate\" type=\"application/{$format}+xml\""
-                                               . " class=\"feedlink\">" . wfMessage( "feed-$format" )->escaped() . "</a>";
-                       }
-               }
-               return $wgLang->pipeList( $s );
-       }
-
-       /**
-        * Gets the h1 element with the page title.
-        * @return string
-        */
-       function pageTitle() {
-               global $wgOut;
-               $s = '<h1 class="pagetitle"><span dir="auto">' . $wgOut->getPageTitle() . '</span></h1>';
-               return $s;
-               }
-
-       function pageSubtitle() {
-               global $wgOut;
-
-               $sub = $wgOut->getSubtitle();
-
-               if ( $sub == '' ) {
-                       global $wgExtraSubtitle;
-                       $sub = wfMessage( 'tagline' )->parse() . $wgExtraSubtitle;
-               }
-
-               $subpages = $this->getSkin()->subPageSubtitle();
-               $sub .= !empty( $subpages ) ? "</p><p class='subpages'>$subpages" : '';
-               $s = "<p class='subtitle'>{$sub}</p>\n";
-
-               return $s;
+               return $this->getSkin()->getLanguage()->pipeList( $s );
        }
 
        function bottomLinks() {
-               global $wgOut, $wgUser;
                $sep = wfMessage( 'pipe-separator' )->escaped() . "\n";
 
                $s = '';
-               if ( $wgOut->isArticleRelated() ) {
+               if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
                        $element[] = '<strong>' . $this->editThisPage() . '</strong>';
 
-                       if ( $wgUser->isLoggedIn() ) {
+                       if ( $this->getSkin()->getUser()->isLoggedIn() ) {
                                $element[] = $this->watchThisPage();
                        }
 
@@ -266,15 +161,15 @@ class CologneBlueTemplate extends BaseTemplate {
                                $s .= "\n<br />";
 
                                // Delete/protect/move links for privileged users
-                               if ( $wgUser->isAllowed( 'delete' ) ) {
+                               if ( $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
                                        $s .= $this->deleteThisPage();
                                }
 
-                               if ( $wgUser->isAllowed( 'protect' ) ) {
+                               if ( $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
                                        $s .= $sep . $this->protectThisPage();
                                }
 
-                               if ( $wgUser->isAllowed( 'move' ) ) {
+                               if ( $this->getSkin()->getUser()->isAllowed( 'move' ) ) {
                                        $s .= $sep . $this->moveThisPage();
                                }
                        }
@@ -286,9 +181,7 @@ class CologneBlueTemplate extends BaseTemplate {
        }
 
        function editThisPage() {
-               global $wgOut;
-
-               if ( !$wgOut->isArticleRelated() ) {
+               if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
                        $s = wfMessage( 'protectedpage' )->text();
                } else {
                        $title = $this->getSkin()->getTitle();
@@ -312,12 +205,10 @@ class CologneBlueTemplate extends BaseTemplate {
        }
 
        function deleteThisPage() {
-               global $wgUser, $wgRequest;
-
-               $diff = $wgRequest->getVal( 'diff' );
+               $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
                $title = $this->getSkin()->getTitle();
 
-               if ( $title->getArticleID() && ( !$diff ) && $wgUser->isAllowed( 'delete' ) ) {
+               if ( $title->getArticleID() && ( !$diff ) && $this->getSkin()->getUser()->isAllowed( 'delete' ) ) {
                        $t = wfMessage( 'deletethispage' )->text();
 
                        $s = Linker::linkKnown(
@@ -334,12 +225,10 @@ class CologneBlueTemplate extends BaseTemplate {
        }
 
        function protectThisPage() {
-               global $wgUser, $wgRequest;
-
-               $diff = $wgRequest->getVal( 'diff' );
+               $diff = $this->getSkin()->getRequest()->getVal( 'diff' );
                $title = $this->getSkin()->getTitle();
 
-               if ( $title->getArticleID() && ( ! $diff ) && $wgUser->isAllowed( 'protect' ) ) {
+               if ( $title->getArticleID() && ( ! $diff ) && $this->getSkin()->getUser()->isAllowed( 'protect' ) ) {
                        if ( $title->isProtected() ) {
                                $text = wfMessage( 'unprotectthispage' )->text();
                                $query = array( 'action' => 'unprotect' );
@@ -362,24 +251,22 @@ class CologneBlueTemplate extends BaseTemplate {
        }
 
        function watchThisPage() {
-               global $wgOut, $wgUser;
-
                // Cache
                $title = $this->getSkin()->getTitle();
 
-               if ( $wgOut->isArticleRelated() ) {
-                       if ( $wgUser->isWatched( $title ) ) {
+               if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
+                       if ( $this->getSkin()->getUser()->isWatched( $title ) ) {
                                $text = wfMessage( 'unwatchthispage' )->text();
                                $query = array(
                                        'action' => 'unwatch',
-                                       'token' => UnwatchAction::getUnwatchToken( $title, $wgUser ),
+                                       'token' => UnwatchAction::getUnwatchToken( $title, $this->getSkin()->getUser() ),
                                );
                                $id = 'mw-unwatch-link';
                        } else {
                                $text = wfMessage( 'watchthispage' )->text();
                                $query = array(
                                        'action' => 'watch',
-                                       'token' => WatchAction::getWatchToken( $title, $wgUser ),
+                                       'token' => WatchAction::getWatchToken( $title, $this->getSkin()->getUser() ),
                                );
                                $id = 'mw-watch-link';
                        }
@@ -442,9 +329,7 @@ class CologneBlueTemplate extends BaseTemplate {
        }
 
        function watchPageLinksLink() {
-               global $wgOut;
-
-               if ( !$wgOut->isArticleRelated() ) {
+               if ( !$this->getSkin()->getOutput()->isArticleRelated() ) {
                        return wfMessage( 'parentheses', wfMessage( 'notanarticle' )->text() )->escaped();
                } else {
                        return Linker::linkKnown(
@@ -508,95 +393,102 @@ class CologneBlueTemplate extends BaseTemplate {
        
        /**
         * @return string
+        * 
+        * @fixed
         */
        function beforeContent() {
-               $mainPageObj = Title::newMainPage();
-
-               $s = "\n<div id='content'>\n";
                ob_start();
 ?>
-<div id="topbar">
-       <p id="sitetitle">
-               <a href="<?php echo htmlspecialchars( $mainPageObj->getLocalURL() ) ?>">
-                       <?php echo wfMessage( 'sitetitle' )->escaped() ?>
-               </a>
-       </p>
-       <p id="sitesub">
-               <?php echo wfMessage( 'sitesubtitle' )->escaped() ?>
-       </p>
-       
-       <p id="syslinks">
-               <span><?php echo $this->sysLinks() ?></span>
-       </p>
-       <div id="linkcollection">
-               <div id="langlinks"><?php echo str_replace( '<br />', '', $this->otherLanguages() ) ?></div>
-               <?php echo $this->getSkin()->getCategories() ?>
-               <div id="titlelinks"><?php echo $this->pageTitleLinks() ?></div>
-               <?php if ( $this->data['newtalk'] ) { ?>
-               <div class="usermessage"><strong><?php echo $this->data['newtalk'] ?></strong></div>
-               <?php } ?>
+<div id="content">
+       <div id="topbar">
+               <p id="sitetitle">
+                       <a href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
+                               <?php echo wfMessage( 'sitetitle' )->escaped() ?>
+                       </a>
+               </p>
+               <p id="sitesub"><?php echo wfMessage( 'sitesubtitle' )->escaped() ?></p>
+               
+               <div id="toplinks">
+                       <p id="syslinks"><?php echo $this->sysLinks() ?></p>
+                       <p id="variantlinks"><?php echo $this->variantLinks() ?></p>
+               </div>
+               <div id="linkcollection">
+                       <div id="langlinks"><?php echo str_replace( '<br />', '', $this->otherLanguages() ) ?></div>
+                       <?php echo $this->getSkin()->getCategories() ?>
+                       <div id="titlelinks"><?php echo $this->pageTitleLinks() ?></div>
+                       <?php if ( $this->data['newtalk'] ) { ?>
+                       <div class="usermessage"><strong><?php echo $this->data['newtalk'] ?></strong></div>
+                       <?php } ?>
+               </div>
        </div>
-</div>
+       <div id="article">
+               <?php if ( $this->getSkin()->getSiteNotice() ) { ?>
+               <div id="siteNotice"><?php echo $this->getSkin()->getSiteNotice() ?></div>
+               <?php } ?>
+               <h1 id="firstHeading"><span dir="auto"><?php echo $this->data['title'] ?></span></h1>
+               <?php if ( $this->translator->translate( 'tagline' ) ) { ?>
+               <p class="tagline"><?php echo htmlspecialchars( $this->translator->translate( 'tagline' ) ) ?></p>
+               <?php } ?>
+               <?php if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?>
+               <p class="subtitle"><?php echo $this->getSkin()->getOutput()->getSubtitle() ?></p>
+               <?php } ?>
+               <?php if ( $this->getSkin()->subPageSubtitle() ) { ?>
+               <p class="subpages"><?php echo $this->getSkin()->subPageSubtitle() ?></p>
+               <?php } ?>
 <?php
-               $s .= ob_get_contents();
+               $s = ob_get_contents();
                ob_end_clean();
                
-               $s .= "\n<div id='article'>";
-
-               $notice = $this->getSkin()->getSiteNotice();
-               if( $notice ) {
-                       $s .= "\n<div id='siteNotice'>$notice</div>\n";
-               }
-               $s .= $this->pageTitle();
-               $s .= $this->pageSubtitle() . "\n";
                return $s;
        }
 
        /**
         * @return string
+        * 
+        * @fixed
         */
-       function afterContent(){
-               $s = "\n</div>\n";
-
-               $s .= "\n<div id='footer'>";
-
-               $s .= $this->bottomLinks();
-               $s .= $this->getSkin()->getLanguage()->pipeList( array(
-                       "\n<br />" . Linker::linkKnown(
-                               Title::newMainPage()
-                       ),
+       function afterContent() {
+               ob_start();
+?>
+       </div>
+       <div id='footer'>
+<?php
+               // Page-related links
+               echo $this->bottomLinks();
+               echo "\n<br />";
+               
+               // Footer and second searchbox
+               echo $this->getSkin()->getLanguage()->pipeList( array(
+                       $this->getSkin()->mainPageLink(),
                        $this->getSkin()->aboutLink(),
-                       $this->searchForm( 'afterContent' )
+                       $this->searchForm( 'footer' )
                ) );
+               echo "\n<br />";
                
-               $s .= "\n<br />";
+               // Standard footer info
                $footlinks = $this->getFooterLinks();
                if ( $footlinks['info'] ) {
                        foreach ( $footlinks['info'] as $item ) {
-                               $s .= $this->data[$item] . ' ';
+                               echo $this->data[$item] . ' ';
                        }
                }
+?>
+       </div>
+</div>
+<?php echo $this->quickBar() ?>
+<?php
+               $s = ob_get_contents();
+               ob_end_clean();
 
-               $s .= "\n</div>\n</div>\n";
-
-               $s .= $this->quickBar();
                return $s;
        }
 
        /**
         * @return string
+        * 
+        * @fixed
         */
        function sysLinks() {
-               $li = SpecialPage::getTitleFor( 'Userlogin' );
-               $lo = SpecialPage::getTitleFor( 'Userlogout' );
-
-               $rt = $this->getSkin()->getTitle()->getPrefixedURL();
-               if ( 0 == strcasecmp( urlencode( $lo ), $rt ) ) {
-                       $q = array();
-               } else {
-                       $q = array( 'returnto' => $rt );
-               }
-
                $s = array(
                        $this->getSkin()->mainPageLink(),
                        Linker::linkKnown(
@@ -611,30 +503,13 @@ class CologneBlueTemplate extends BaseTemplate {
                                Title::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
                                wfMessage( 'faq' )->text()
                        ),
-                       Linker::specialLink( 'Specialpages' )
                );
 
-               /* show links to different language variants */
-               if( $this->variantLinks() ) {
-                       $s[] = $this->variantLinks();
-               }
-               if( $this->extensionTabLinks() ) {
-                       $s[] = $this->extensionTabLinks();
-               }
-               if ( $this->data['loggedin'] ) {
-                       $s[] = Linker::linkKnown(
-                               $lo,
-                               wfMessage( 'logout' )->text(),
-                               array(),
-                               $q
-                       );
-               } else {
-                       $s[] = Linker::linkKnown(
-                               $li,
-                               wfMessage( 'login' )->text(),
-                               array(),
-                               $q
-                       );
+               $personalUrls = $this->getPersonalTools();
+               foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
+                       if ( $personalUrls[$key] ) {
+                               $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
+                       }
                }
 
                return $this->getSkin()->getLanguage()->pipeList( $s );
@@ -714,6 +589,9 @@ class CologneBlueTemplate extends BaseTemplate {
                                        
                                        // Personal tools ("My pages")
                                        $bar['qbmyoptions'] = $this->getPersonalTools();
+                                       foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
+                                               $bar['qbmyoptions'][$key] = false;
+                                       }
                                        
                                        $additions_done = true;
                                }
@@ -781,17 +659,17 @@ class CologneBlueTemplate extends BaseTemplate {
                $search = $this->getSkin()->getRequest()->getText( 'search' );
                $action = $this->data['searchaction'];
                $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
-               if( $which == 'afterContent' ) {
+               if( $which == 'footer' ) {
                        $s .= wfMessage( 'qbfind' )->text() . ": ";
                }
 
                $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
                        . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
-                       . ($which == 'afterContent' ? " " : "<br />")
+                       . ($which == 'footer' ? " " : "<br />")
                        . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
 
                if( $wgUseTwoButtonsSearchForm ) {
-                       $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'search' )->escaped() . "\" />\n";
+                       $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
                } else {
                        $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
                }