MediaWiki  master
CologneBlue.php
Go to the documentation of this file.
00001 <?php
00025 if( !defined( 'MEDIAWIKI' ) ) {
00026         die( -1 );
00027 }
00028 
00033 class SkinCologneBlue extends SkinTemplate {
00034         var $skinname = 'cologneblue', $stylename = 'cologneblue',
00035                 $template = 'CologneBlueTemplate';
00036         var $useHeadElement = true;
00037 
00041         function setupSkinUserCss( OutputPage $out ){
00042                 $out->addModuleStyles( 'mediawiki.legacy.shared' );
00043                 $out->addModuleStyles( 'mediawiki.legacy.oldshared' );
00044                 $out->addModuleStyles( 'skins.cologneblue' );
00045         }
00046 
00051         function formatLanguageName( $name ) {
00052                 return $name;
00053         }
00054 }
00055 
00056 class CologneBlueTemplate extends BaseTemplate {
00057         function execute() {
00058                 // Suppress warnings to prevent notices about missing indexes in $this->data
00059                 wfSuppressWarnings();
00060                 $this->html( 'headelement' );
00061                 echo $this->beforeContent();
00062                 $this->html( 'bodytext' );
00063                 echo "\n";
00064                 echo $this->afterContent();
00065                 $this->html( 'dataAfterContent' );
00066                 $this->printTrail();
00067                 echo "\n</body></html>";
00068                 wfRestoreWarnings();
00069         }
00070 
00077         function variantLinks() {
00078                 $s = array();
00079 
00080                 $variants = $this->data['content_navigation']['variants'];
00081 
00082                 foreach ( $variants as $key => $link ) {
00083                         $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) );
00084                 }
00085 
00086                 return $this->getSkin()->getLanguage()->pipeList( $s );
00087         }
00088 
00089         // @fixed
00090         function otherLanguages() {
00091                 global $wgHideInterlanguageLinks;
00092                 if ( $wgHideInterlanguageLinks ) {
00093                         return "";
00094                 }
00095 
00096                 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue
00097                 // not to capitalize the language names.
00098                 $language_urls = $this->data['language_urls'];
00099                 if ( empty( $language_urls ) ) {
00100                         return "";
00101                 }
00102 
00103                 $s = array();
00104                 foreach ( $language_urls as $key => $data ) {
00105                         $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) );
00106                 }
00107 
00108                 return wfMessage( 'otherlanguages' )->text()
00109                         . wfMessage( 'colon-separator' )->text()
00110                         . $this->getSkin()->getLanguage()->pipeList( $s );
00111         }
00112 
00113         // @fixed
00114         function pageTitleLinks() {
00115                 $s = array();
00116                 $footlinks = $this->getFooterLinks();
00117 
00118                 foreach ( $footlinks['places'] as $item ) {
00119                         $s[] = $this->data[$item];
00120                 }
00121 
00122                 return $this->getSkin()->getLanguage()->pipeList( $s );
00123         }
00124 
00135         function processBottomLink( $key, $navlink, $message=null ) {
00136                 if ( !$navlink ) {
00137                         // Empty navlinks might be passed.
00138                         return null;
00139                 }
00140 
00141                 if ( $message ) {
00142                         $navlink['text'] = wfMessage( $message )->escaped();
00143                 }
00144 
00145                 return $this->makeListItem( $key, $this->processNavlinkForDocument( $navlink ), array( 'tag' => 'span' ) );
00146         }
00147 
00148         // @fixed
00149         function bottomLinks() {
00150                 $toolbox = $this->getToolbox();
00151                 $content_nav = $this->data['content_navigation'];
00152 
00153                 $lines = array();
00154 
00155                 if ( $this->getSkin()->getOutput()->isArticleRelated() ) {
00156                         // First row. Regular actions.
00157                         $element = array();
00158 
00159                         $editLinkMessage = $this->getSkin()->getTitle()->exists() ? 'editthispage' : 'create-this-page';
00160                         $element[] = $this->processBottomLink( 'edit', $content_nav['views']['edit'], $editLinkMessage );
00161                         $element[] = $this->processBottomLink( 'viewsource', $content_nav['views']['viewsource'], 'viewsource' );
00162 
00163                         $element[] = $this->processBottomLink( 'watch', $content_nav['actions']['watch'], 'watchthispage' );
00164                         $element[] = $this->processBottomLink( 'unwatch', $content_nav['actions']['unwatch'], 'unwatchthispage' );
00165 
00166                         $element[] = $this->talkLink();
00167 
00168                         $element[] = $this->processBottomLink( 'history', $content_nav['views']['history'], 'history' );
00169                         $element[] = $this->processBottomLink( 'info', $toolbox['info'] );
00170                         $element[] = $this->processBottomLink( 'whatlinkshere', $toolbox['whatlinkshere'] );
00171                         $element[] = $this->processBottomLink( 'recentchangeslinked', $toolbox['recentchangeslinked'] );
00172 
00173                         $element[] = $this->processBottomLink( 'contributions', $toolbox['contributions'] );
00174                         $element[] = $this->processBottomLink( 'emailuser', $toolbox['emailuser'] );
00175 
00176                         $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
00177 
00178 
00179                         // Second row. Privileged actions.
00180                         $element = array();
00181 
00182                         $element[] = $this->processBottomLink( 'delete', $content_nav['actions']['delete'], 'deletethispage' );
00183                         $element[] = $this->processBottomLink( 'undelete', $content_nav['actions']['undelete'], 'undeletethispage' );
00184 
00185                         $element[] = $this->processBottomLink( 'protect', $content_nav['actions']['protect'], 'protectthispage' );
00186                         $element[] = $this->processBottomLink( 'unprotect', $content_nav['actions']['unprotect'], 'unprotectthispage' );
00187 
00188                         $element[] = $this->processBottomLink( 'move', $content_nav['actions']['move'], 'movethispage' );
00189 
00190                         $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) );
00191 
00192 
00193                         // Third row. Language links.
00194                         $lines[] = $this->otherLanguages();
00195                 }
00196 
00197                 return implode( array_filter( $lines ), "<br />\n" ) . "<br />\n";
00198         }
00199 
00200         // @fixed
00201         function talkLink() {
00202                 $title = $this->getSkin()->getTitle();
00203 
00204                 if ( $title->getNamespace() == NS_SPECIAL ) {
00205                         // No discussion links for special pages
00206                         return "";
00207                 }
00208 
00209                 $companionTitle = $title->isTalkPage() ? $title->getSubjectPage() : $title->getTalkPage();
00210                 $companionNamespace = $companionTitle->getNamespace();
00211 
00212                 // TODO these messages appear to only be used by CologneBlue and legacy skins,
00213                 // kill and replace with something more sensibly named?
00214                 $nsToMessage = array(
00215                         NS_MAIN => 'articlepage',
00216                         NS_USER => 'userpage',
00217                         NS_PROJECT => 'projectpage',
00218                         NS_FILE => 'imagepage',
00219                         NS_MEDIAWIKI => 'mediawikipage',
00220                         NS_TEMPLATE => 'templatepage',
00221                         NS_HELP => 'viewhelppage',
00222                         NS_CATEGORY => 'categorypage',
00223                         NS_FILE => 'imagepage',
00224                 );
00225 
00226                 // Find out the message to use for link text. Use either the array above or,
00227                 // for non-talk pages, a generic "discuss this" message.
00228                 // Default is the same as for main namespace.
00229                 if ( isset( $nsToMessage[$companionNamespace] ) ) {
00230                         $message = $nsToMessage[$companionNamespace];
00231                 } else {
00232                         $message = $companionTitle->isTalkPage() ? 'talkpage' : 'articlepage';
00233                 }
00234 
00235                 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones.
00236                 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805)
00237                 $key = $companionTitle->getNamespaceKey( '' );
00238                 if ( $companionTitle->isTalkPage() ) {
00239                         $key = ( $key == 'main' ? 'talk' : $key . "_talk" );
00240                 }
00241 
00242                 // Use the regular navigational link, but replace its text. Everything else stays unmodified.
00243                 $namespacesLinks = $this->data['content_navigation']['namespaces'];
00244                 return $this->processBottomLink( $message,  $namespacesLinks[$key], $message );
00245         }
00246 
00256         function processNavlinkForDocument( $navlink, $idPrefix='cb-' ) {
00257                 if ( $navlink['id'] ) {
00258                         $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation
00259                         $navlink['tooltiponly'] = true; // but no accesskeys
00260 
00261                         // mangle or remove the id
00262                         if ( $idPrefix === false ) {
00263                                 unset( $navlink['id'] );
00264                         } else {
00265                                 $navlink['id'] =  $idPrefix . $navlink['id'];
00266                         }
00267                 }
00268 
00269                 return $navlink;
00270         }
00271 
00277         function beforeContent() {
00278                 ob_start();
00279 ?>
00280 <div id="content">
00281         <div id="topbar">
00282                 <p id="sitetitle">
00283                         <a href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>">
00284                                 <?php echo wfMessage( 'sitetitle' )->escaped() ?>
00285                         </a>
00286                 </p>
00287                 <p id="sitesub"><?php echo wfMessage( 'sitesubtitle' )->escaped() ?></p>
00288                 <div id="toplinks">
00289                         <p id="syslinks"><?php echo $this->sysLinks() ?></p>
00290                         <p id="variantlinks"><?php echo $this->variantLinks() ?></p>
00291                 </div>
00292                 <div id="linkcollection">
00293                         <div id="langlinks"><?php echo str_replace( '<br />', '', $this->otherLanguages() ) ?></div>
00294                         <?php echo $this->getSkin()->getCategories() ?>
00295                         <div id="titlelinks"><?php echo $this->pageTitleLinks() ?></div>
00296                         <?php if ( $this->data['newtalk'] ) { ?>
00297                         <div class="usermessage"><strong><?php echo $this->data['newtalk'] ?></strong></div>
00298                         <?php } ?>
00299                 </div>
00300         </div>
00301         <div id="article">
00302                 <?php if ( $this->getSkin()->getSiteNotice() ) { ?>
00303                 <div id="siteNotice"><?php echo $this->getSkin()->getSiteNotice() ?></div>
00304                 <?php } ?>
00305                 <h1 id="firstHeading"><span dir="auto"><?php echo $this->data['title'] ?></span></h1>
00306                 <?php if ( $this->translator->translate( 'tagline' ) ) { ?>
00307                 <p class="tagline"><?php echo htmlspecialchars( $this->translator->translate( 'tagline' ) ) ?></p>
00308                 <?php } ?>
00309                 <?php if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?>
00310                 <p class="subtitle"><?php echo $this->getSkin()->getOutput()->getSubtitle() ?></p>
00311                 <?php } ?>
00312                 <?php if ( $this->getSkin()->subPageSubtitle() ) { ?>
00313                 <p class="subpages"><?php echo $this->getSkin()->subPageSubtitle() ?></p>
00314                 <?php } ?>
00315 <?php
00316                 $s = ob_get_contents();
00317                 ob_end_clean();
00318 
00319                 return $s;
00320         }
00321 
00327         function afterContent() {
00328                 ob_start();
00329 ?>
00330         </div>
00331         <div id='footer'>
00332 <?php
00333                 // Page-related links
00334                 echo $this->bottomLinks();
00335                 echo "\n<br />";
00336 
00337                 // Footer and second searchbox
00338                 echo $this->getSkin()->getLanguage()->pipeList( array(
00339                         $this->getSkin()->mainPageLink(),
00340                         $this->getSkin()->aboutLink(),
00341                         $this->searchForm( 'footer' )
00342                 ) );
00343                 echo "\n<br />";
00344 
00345                 // Standard footer info
00346                 $footlinks = $this->getFooterLinks();
00347                 if ( $footlinks['info'] ) {
00348                         foreach ( $footlinks['info'] as $item ) {
00349                                 echo $this->data[$item] . ' ';
00350                         }
00351                 }
00352 ?>
00353         </div>
00354 </div>
00355 <?php echo $this->quickBar() ?>
00356 <?php
00357                 $s = ob_get_contents();
00358                 ob_end_clean();
00359 
00360                 return $s;
00361         }
00362 
00368         function sysLinks() {
00369                 $s = array(
00370                         $this->getSkin()->mainPageLink(),
00371                         Linker::linkKnown(
00372                                 Title::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ),
00373                                 wfMessage( 'about' )->text()
00374                         ),
00375                         Linker::linkKnown(
00376                                 Title::newFromText( wfMessage( 'helppage' )->inContentLanguage()->text() ),
00377                                 wfMessage( 'help' )->text()
00378                         ),
00379                         Linker::linkKnown(
00380                                 Title::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ),
00381                                 wfMessage( 'faq' )->text()
00382                         ),
00383                 );
00384 
00385                 $personalUrls = $this->getPersonalTools();
00386                 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
00387                         if ( $personalUrls[$key] ) {
00388                                 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) );
00389                         }
00390                 }
00391 
00392                 return $this->getSkin()->getLanguage()->pipeList( $s );
00393         }
00394 
00403         function sidebarAdditions( $bar ) {
00404                 // "This page" and "Edit" menus
00405                 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'],
00406                 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose.
00407                 // We also don't use $...['variants'], these are displayed in the top menu.
00408                 $content_navigation = $this->data['content_navigation'];
00409                 $qbpageoptions = array_merge(
00410                         $content_navigation['namespaces'],
00411                         array(
00412                                 'history' => $content_navigation['views']['history'],
00413                                 'watch' => $content_navigation['actions']['watch'],
00414                                 'unwatch' => $content_navigation['actions']['unwatch'],
00415                         )
00416                 );
00417                 $content_navigation['actions']['watch'] = null;
00418                 $content_navigation['actions']['unwatch'] = null;
00419                 $qbedit = array_merge(
00420                         array(
00421                                 'edit' => $content_navigation['views']['edit'],
00422                                 'addsection' => $content_navigation['views']['addsection'],
00423                         ),
00424                         $content_navigation['actions']
00425                 );
00426 
00427                 // Personal tools ("My pages")
00428                 $qbmyoptions = $this->getPersonalTools();
00429                 foreach ( array ( 'logout', 'createaccount', 'login', 'anonlogin' ) as $key ) {
00430                         $qbmyoptions[$key] = null;
00431                 }
00432 
00433                 $bar['qbedit'] = $qbedit;
00434                 $bar['qbpageoptions'] = $qbpageoptions;
00435                 $bar['qbmyoptions'] = $qbmyoptions;
00436 
00437                 return $bar;
00438         }
00439 
00448         function quickBar() {
00449                 // Massage the sidebar. We want to:
00450                 // * place SEARCH at the beginning
00451                 // * add new portlets before TOOLBOX (or at the end, if it's missing)
00452                 // * remove LANGUAGES (langlinks are displayed elsewhere)
00453                 $orig_bar = $this->data['sidebar'];
00454                 $bar = array();
00455                 $hasToolbox = false;
00456 
00457                 // Always display search first
00458                 $bar['SEARCH'] = true;
00459                 // Copy everything except for langlinks, inserting new items before toolbox
00460                 foreach ( $orig_bar as $heading => $data ) {
00461                         if ( $heading == 'TOOLBOX' ) {
00462                                 // Insert the stuff
00463                                 $bar = $this->sidebarAdditions( $bar );
00464                                 $hasToolbox = true;
00465                         }
00466 
00467                         if ( $heading != 'LANGUAGES' ) {
00468                                 $bar[$heading] = $data;
00469                         }
00470                 }
00471                 // If toolbox is missing, add our items at the end
00472                 if ( !$hasToolbox ) {
00473                         $bar = $this->sidebarAdditions( $bar );
00474                 }
00475 
00476 
00477                 // Fill out special sidebar items with content
00478                 $orig_bar = $bar;
00479                 $bar = array();
00480                 foreach ( $orig_bar as $heading => $data ) {
00481                         if ( $heading == 'SEARCH' ) {
00482                                 $bar['qbfind'] = $this->searchForm( 'sidebar' );
00483                         } elseif ( $heading == 'TOOLBOX' ) {
00484                                 $bar['toolbox'] = $this->getToolbox();
00485                         } elseif ( $heading == 'navigation' ) {
00486                                 // Use the navigation heading from standard sidebar as the "browse" section
00487                                 $bar['qbbrowse'] = $data;
00488                         } else {
00489                                 $bar[$heading] = $data;
00490                         }
00491                 }
00492 
00493 
00494                 // Output the sidebar
00495                 $s = "<div id='quickbar'>\n";
00496 
00497                 foreach ( $bar as $heading => $data ) {
00498                         $headingMsg = wfMessage( $heading );
00499                         $headingHTML = "<h6>" . ( $headingMsg->exists() ? $headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h6>";
00500                         $portletId = Sanitizer::escapeId( "p-$heading" );
00501                         $listHTML = "";
00502 
00503                         if ( is_array( $data ) ) {
00504                                 // $data is an array of links
00505                                 foreach ( $data as $key => $link ) {
00506                                         // Can be empty due to how the sidebar additions are done
00507                                         if ( $link ) {
00508                                                 $listHTML .= $this->makeListItem( $key, $link );
00509                                         }
00510                                 }
00511                                 if ( $listHTML ) {
00512                                         $listHTML = "<ul>$listHTML</ul>";
00513                                 }
00514                         } else {
00515                                 // $data is a HTML <ul>-list string
00516                                 $listHTML = $data;
00517                         }
00518 
00519                         if ( $listHTML ) {
00520                                 $s .= "<div class=\"portlet\" id=\"$portletId\">\n$headingHTML\n$listHTML\n</div>\n";
00521                         }
00522                 }
00523 
00524                 $s .= "</div>\n";
00525                 return $s;
00526         }
00527 
00534         function searchForm( $which ) {
00535                 global $wgUseTwoButtonsSearchForm;
00536 
00537                 $search = $this->getSkin()->getRequest()->getText( 'search' );
00538                 $action = $this->data['searchaction'];
00539                 $s = "<form id=\"searchform-" . htmlspecialchars($which) . "\" method=\"get\" class=\"inline\" action=\"$action\">";
00540                 if( $which == 'footer' ) {
00541                         $s .= wfMessage( 'qbfind' )->text() . ": ";
00542                 }
00543 
00544                 $s .= "<input type='text' class=\"mw-searchInput\" name=\"search\" size=\"14\" value=\""
00545                         . htmlspecialchars( substr( $search, 0, 256 ) ) . "\" />"
00546                         . ($which == 'footer' ? " " : "<br />")
00547                         . "<input type='submit' class=\"searchButton\" name=\"go\" value=\"" . wfMessage( 'searcharticle' )->escaped() . "\" />";
00548 
00549                 if( $wgUseTwoButtonsSearchForm ) {
00550                         $s .= " <input type='submit' class=\"searchButton\" name=\"fulltext\" value=\"" . wfMessage( 'searchbutton' )->escaped() . "\" />\n";
00551                 } else {
00552                         $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n";
00553                 }
00554 
00555                 $s .= '</form>';
00556 
00557                 return $s;
00558         }
00559 }