MediaWiki
REL1_23
|
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 parent::setupSkinUserCss( $out ); 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 00075 function variantLinks() { 00076 $s = array(); 00077 00078 $variants = $this->data['content_navigation']['variants']; 00079 00080 foreach ( $variants as $key => $link ) { 00081 $s[] = $this->makeListItem( $key, $link, array( 'tag' => 'span' ) ); 00082 } 00083 00084 return $this->getSkin()->getLanguage()->pipeList( $s ); 00085 } 00086 00087 function otherLanguages() { 00088 global $wgHideInterlanguageLinks; 00089 if ( $wgHideInterlanguageLinks ) { 00090 return ""; 00091 } 00092 00093 $html = ''; 00094 00095 // We override SkinTemplate->formatLanguageName() in SkinCologneBlue 00096 // not to capitalize the language names. 00097 $language_urls = $this->data['language_urls']; 00098 if ( !empty( $language_urls ) ) { 00099 $s = array(); 00100 foreach ( $language_urls as $key => $data ) { 00101 $s[] = $this->makeListItem( $key, $data, array( 'tag' => 'span' ) ); 00102 } 00103 00104 $html = wfMessage( 'otherlanguages' )->text() 00105 . wfMessage( 'colon-separator' )->text() 00106 . $this->getSkin()->getLanguage()->pipeList( $s ); 00107 } 00108 00109 $html .= $this->renderAfterPortlet( 'lang' ); 00110 00111 return $html; 00112 } 00113 00117 protected function renderAfterPortlet( $name ) { 00118 $content = ''; 00119 wfRunHooks( 'BaseTemplateAfterPortlet', array( $this, $name, &$content ) ); 00120 00121 $html = $content !== '' ? "<div class='after-portlet after-portlet-$name'>$content</div>" : ''; 00122 00123 return $html; 00124 } 00125 00126 function pageTitleLinks() { 00127 $s = array(); 00128 $footlinks = $this->getFooterLinks(); 00129 00130 foreach ( $footlinks['places'] as $item ) { 00131 $s[] = $this->data[$item]; 00132 } 00133 00134 return $this->getSkin()->getLanguage()->pipeList( $s ); 00135 } 00136 00146 function processBottomLink( $key, $navlink, $message = null ) { 00147 if ( !$navlink ) { 00148 // Empty navlinks might be passed. 00149 return null; 00150 } 00151 00152 if ( $message ) { 00153 $navlink['text'] = wfMessage( $message )->escaped(); 00154 } 00155 00156 return $this->makeListItem( $key, $this->processNavlinkForDocument( $navlink ), array( 'tag' => 'span' ) ); 00157 } 00158 00159 function bottomLinks() { 00160 $toolbox = $this->getToolbox(); 00161 $content_nav = $this->data['content_navigation']; 00162 00163 $lines = array(); 00164 00165 if ( $this->getSkin()->getOutput()->isArticleRelated() ) { 00166 // First row. Regular actions. 00167 $element = array(); 00168 00169 $editLinkMessage = $this->getSkin()->getTitle()->exists() ? 'editthispage' : 'create-this-page'; 00170 $element[] = $this->processBottomLink( 'edit', $content_nav['views']['edit'], $editLinkMessage ); 00171 $element[] = $this->processBottomLink( 'viewsource', $content_nav['views']['viewsource'], 'viewsource' ); 00172 00173 $element[] = $this->processBottomLink( 'watch', $content_nav['actions']['watch'], 'watchthispage' ); 00174 $element[] = $this->processBottomLink( 'unwatch', $content_nav['actions']['unwatch'], 'unwatchthispage' ); 00175 00176 $element[] = $this->talkLink(); 00177 00178 $element[] = $this->processBottomLink( 'history', $content_nav['views']['history'], 'history' ); 00179 $element[] = $this->processBottomLink( 'info', $toolbox['info'] ); 00180 $element[] = $this->processBottomLink( 'whatlinkshere', $toolbox['whatlinkshere'] ); 00181 $element[] = $this->processBottomLink( 'recentchangeslinked', $toolbox['recentchangeslinked'] ); 00182 00183 $element[] = $this->processBottomLink( 'contributions', $toolbox['contributions'] ); 00184 $element[] = $this->processBottomLink( 'emailuser', $toolbox['emailuser'] ); 00185 00186 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) ); 00187 00188 // Second row. Privileged actions. 00189 $element = array(); 00190 00191 $element[] = $this->processBottomLink( 'delete', $content_nav['actions']['delete'], 'deletethispage' ); 00192 $element[] = $this->processBottomLink( 'undelete', $content_nav['actions']['undelete'], 'undeletethispage' ); 00193 00194 $element[] = $this->processBottomLink( 'protect', $content_nav['actions']['protect'], 'protectthispage' ); 00195 $element[] = $this->processBottomLink( 'unprotect', $content_nav['actions']['unprotect'], 'unprotectthispage' ); 00196 00197 $element[] = $this->processBottomLink( 'move', $content_nav['actions']['move'], 'movethispage' ); 00198 00199 $lines[] = $this->getSkin()->getLanguage()->pipeList( array_filter( $element ) ); 00200 00201 // Third row. Language links. 00202 $lines[] = $this->otherLanguages(); 00203 } 00204 00205 return implode( array_filter( $lines ), "<br />\n" ) . "<br />\n"; 00206 } 00207 00208 function talkLink() { 00209 $title = $this->getSkin()->getTitle(); 00210 00211 if ( $title->getNamespace() == NS_SPECIAL ) { 00212 // No discussion links for special pages 00213 return ""; 00214 } 00215 00216 $companionTitle = $title->isTalkPage() ? $title->getSubjectPage() : $title->getTalkPage(); 00217 $companionNamespace = $companionTitle->getNamespace(); 00218 00219 // TODO these messages are only be used by CologneBlue, 00220 // kill and replace with something more sensibly named? 00221 $nsToMessage = array( 00222 NS_MAIN => 'articlepage', 00223 NS_USER => 'userpage', 00224 NS_PROJECT => 'projectpage', 00225 NS_FILE => 'imagepage', 00226 NS_MEDIAWIKI => 'mediawikipage', 00227 NS_TEMPLATE => 'templatepage', 00228 NS_HELP => 'viewhelppage', 00229 NS_CATEGORY => 'categorypage', 00230 NS_FILE => 'imagepage', 00231 ); 00232 00233 // Find out the message to use for link text. Use either the array above or, 00234 // for non-talk pages, a generic "discuss this" message. 00235 // Default is the same as for main namespace. 00236 if ( isset( $nsToMessage[$companionNamespace] ) ) { 00237 $message = $nsToMessage[$companionNamespace]; 00238 } else { 00239 $message = $companionTitle->isTalkPage() ? 'talkpage' : 'articlepage'; 00240 } 00241 00242 // Obviously this can't be reasonable and just return the key for talk namespace, only for content ones. 00243 // Thus we have to mangle it in exactly the same way SkinTemplate does. (bug 40805) 00244 $key = $companionTitle->getNamespaceKey( '' ); 00245 if ( $companionTitle->isTalkPage() ) { 00246 $key = ( $key == 'main' ? 'talk' : $key . "_talk" ); 00247 } 00248 00249 // Use the regular navigational link, but replace its text. Everything else stays unmodified. 00250 $namespacesLinks = $this->data['content_navigation']['namespaces']; 00251 return $this->processBottomLink( $message, $namespacesLinks[$key], $message ); 00252 } 00253 00263 function processNavlinkForDocument( $navlink, $idPrefix = 'cb-' ) { 00264 if ( $navlink['id'] ) { 00265 $navlink['single-id'] = $navlink['id']; // to allow for tooltip generation 00266 $navlink['tooltiponly'] = true; // but no accesskeys 00267 00268 // mangle or remove the id 00269 if ( $idPrefix === false ) { 00270 unset( $navlink['id'] ); 00271 } else { 00272 $navlink['id'] = $idPrefix . $navlink['id']; 00273 } 00274 } 00275 00276 return $navlink; 00277 } 00278 00282 function beforeContent() { 00283 ob_start(); 00284 ?> 00285 <div id="content"> 00286 <div id="topbar"> 00287 <p id="sitetitle" role="banner"> 00288 <a href="<?php echo htmlspecialchars( $this->data['nav_urls']['mainpage']['href'] ) ?>"> 00289 <?php echo wfMessage( 'sitetitle' )->escaped() ?> 00290 </a> 00291 </p> 00292 <p id="sitesub"><?php echo wfMessage( 'sitesubtitle' )->escaped() ?></p> 00293 <div id="linkcollection" role="navigation"> 00294 <div id="langlinks"><?php echo str_replace( '<br />', '', $this->otherLanguages() ) ?></div> 00295 <?php echo $this->getSkin()->getCategories() ?> 00296 <div id="titlelinks"><?php echo $this->pageTitleLinks() ?></div> 00297 <?php if ( $this->data['newtalk'] ) { ?> 00298 <div class="usermessage"><strong><?php echo $this->data['newtalk'] ?></strong></div> 00299 <?php } ?> 00300 </div> 00301 </div> 00302 <div id="article" class="mw-body" role="main"> 00303 <?php if ( $this->getSkin()->getSiteNotice() ) { ?> 00304 <div id="siteNotice"><?php echo $this->getSkin()->getSiteNotice() ?></div> 00305 <?php } ?> 00306 <h1 id="firstHeading" lang="<?php 00307 $this->data['pageLanguage'] = $this->getSkin()->getTitle()->getPageViewLanguage()->getHtmlCode(); 00308 $this->text( 'pageLanguage' ); 00309 ?>"><span dir="auto"><?php echo $this->data['title'] ?></span></h1> 00310 <?php if ( $this->translator->translate( 'tagline' ) ) { ?> 00311 <p class="tagline"><?php echo htmlspecialchars( $this->translator->translate( 'tagline' ) ) ?></p> 00312 <?php } ?> 00313 <?php if ( $this->getSkin()->getOutput()->getSubtitle() ) { ?> 00314 <p class="subtitle"><?php echo $this->getSkin()->getOutput()->getSubtitle() ?></p> 00315 <?php } ?> 00316 <?php if ( $this->getSkin()->subPageSubtitle() ) { ?> 00317 <p class="subpages"><?php echo $this->getSkin()->subPageSubtitle() ?></p> 00318 <?php } ?> 00319 <?php 00320 $s = ob_get_contents(); 00321 ob_end_clean(); 00322 00323 return $s; 00324 } 00325 00329 function afterContent() { 00330 ob_start(); 00331 ?> 00332 </div> 00333 <div id="footer"> 00334 <div id="footer-navigation" role="navigation"> 00335 <?php 00336 // Page-related links 00337 echo $this->bottomLinks(); 00338 echo "\n<br />"; 00339 00340 // Footer and second searchbox 00341 echo $this->getSkin()->getLanguage()->pipeList( array( 00342 $this->getSkin()->mainPageLink(), 00343 $this->getSkin()->aboutLink(), 00344 $this->searchForm( 'footer' ) 00345 ) ); 00346 ?> 00347 </div> 00348 <div id="footer-info" role="contentinfo"> 00349 <?php 00350 // Standard footer info 00351 $footlinks = $this->getFooterLinks(); 00352 if ( $footlinks['info'] ) { 00353 foreach ( $footlinks['info'] as $item ) { 00354 echo $this->data[$item] . ' '; 00355 } 00356 } 00357 ?> 00358 </div> 00359 </div> 00360 </div> 00361 <div id="mw-navigation"> 00362 <h2><?php echo wfMessage( 'navigation-heading' )->escaped() ?></h2> 00363 <div id="toplinks" role="navigation"> 00364 <p id="syslinks"><?php echo $this->sysLinks() ?></p> 00365 <p id="variantlinks"><?php echo $this->variantLinks() ?></p> 00366 </div> 00367 <?php echo $this->quickBar() ?> 00368 </div> 00369 <?php 00370 $s = ob_get_contents(); 00371 ob_end_clean(); 00372 00373 return $s; 00374 } 00375 00379 function sysLinks() { 00380 $s = array( 00381 $this->getSkin()->mainPageLink(), 00382 Linker::linkKnown( 00383 Title::newFromText( wfMessage( 'aboutpage' )->inContentLanguage()->text() ), 00384 wfMessage( 'about' )->text() 00385 ), 00386 Linker::makeExternalLink( 00387 Skin::makeInternalOrExternalUrl( wfMessage( 'helppage' )->inContentLanguage()->text() ), 00388 wfMessage( 'help' )->text(), 00389 false 00390 ), 00391 Linker::linkKnown( 00392 Title::newFromText( wfMessage( 'faqpage' )->inContentLanguage()->text() ), 00393 wfMessage( 'faq' )->text() 00394 ), 00395 ); 00396 00397 $personalUrls = $this->getPersonalTools(); 00398 foreach ( array( 'logout', 'createaccount', 'login' ) as $key ) { 00399 if ( $personalUrls[$key] ) { 00400 $s[] = $this->makeListItem( $key, $personalUrls[$key], array( 'tag' => 'span' ) ); 00401 } 00402 } 00403 00404 return $this->getSkin()->getLanguage()->pipeList( $s ); 00405 } 00406 00413 function sidebarAdditions( $bar ) { 00414 // "This page" and "Edit" menus 00415 // We need to do some massaging here... we reuse all of the items, except for $...['views']['view'], 00416 // as $...['namespaces']['main'] and $...['namespaces']['talk'] together serve the same purpose. 00417 // We also don't use $...['variants'], these are displayed in the top menu. 00418 $content_navigation = $this->data['content_navigation']; 00419 $qbpageoptions = array_merge( 00420 $content_navigation['namespaces'], 00421 array( 00422 'history' => $content_navigation['views']['history'], 00423 'watch' => $content_navigation['actions']['watch'], 00424 'unwatch' => $content_navigation['actions']['unwatch'], 00425 ) 00426 ); 00427 $content_navigation['actions']['watch'] = null; 00428 $content_navigation['actions']['unwatch'] = null; 00429 $qbedit = array_merge( 00430 array( 00431 'edit' => $content_navigation['views']['edit'], 00432 'addsection' => $content_navigation['views']['addsection'], 00433 ), 00434 $content_navigation['actions'] 00435 ); 00436 00437 // Personal tools ("My pages") 00438 $qbmyoptions = $this->getPersonalTools(); 00439 foreach ( array( 'logout', 'createaccount', 'login', ) as $key ) { 00440 $qbmyoptions[$key] = null; 00441 } 00442 00443 // Use the closest reasonable name 00444 $bar['cactions'] = $qbedit; 00445 $bar['pageoptions'] = $qbpageoptions; // this is a non-standard portlet name, but nothing fits 00446 $bar['personal'] = $qbmyoptions; 00447 00448 return $bar; 00449 } 00450 00457 function quickBar() { 00458 // Massage the sidebar. We want to: 00459 // * place SEARCH at the beginning 00460 // * add new portlets before TOOLBOX (or at the end, if it's missing) 00461 // * remove LANGUAGES (langlinks are displayed elsewhere) 00462 $orig_bar = $this->data['sidebar']; 00463 $bar = array(); 00464 $hasToolbox = false; 00465 00466 // Always display search first 00467 $bar['SEARCH'] = true; 00468 // Copy everything except for langlinks, inserting new items before toolbox 00469 foreach ( $orig_bar as $heading => $data ) { 00470 if ( $heading == 'TOOLBOX' ) { 00471 // Insert the stuff 00472 $bar = $this->sidebarAdditions( $bar ); 00473 $hasToolbox = true; 00474 } 00475 00476 if ( $heading != 'LANGUAGES' ) { 00477 $bar[$heading] = $data; 00478 } 00479 } 00480 // If toolbox is missing, add our items at the end 00481 if ( !$hasToolbox ) { 00482 $bar = $this->sidebarAdditions( $bar ); 00483 } 00484 00485 // Fill out special sidebar items with content 00486 $orig_bar = $bar; 00487 $bar = array(); 00488 foreach ( $orig_bar as $heading => $data ) { 00489 if ( $heading == 'SEARCH' ) { 00490 $bar['search'] = $this->searchForm( 'sidebar' ); 00491 } elseif ( $heading == 'TOOLBOX' ) { 00492 $bar['tb'] = $this->getToolbox(); 00493 } else { 00494 $bar[$heading] = $data; 00495 } 00496 } 00497 00498 // Output the sidebar 00499 // CologneBlue uses custom messages for some portlets, but we should keep the ids for consistency 00500 $idToMessage = array( 00501 'search' => 'qbfind', 00502 'navigation' => 'qbbrowse', 00503 'tb' => 'toolbox', 00504 'cactions' => 'qbedit', 00505 'personal' => 'qbmyoptions', 00506 'pageoptions' => 'qbpageoptions', 00507 ); 00508 00509 $s = "<div id='quickbar'>\n"; 00510 00511 foreach ( $bar as $heading => $data ) { 00512 $portletId = Sanitizer::escapeId( "p-$heading" ); 00513 $headingMsg = wfMessage( $idToMessage[$heading] ? $idToMessage[$heading] : $heading ); 00514 $headingHTML = "<h3>" . ( $headingMsg->exists() ? $headingMsg->escaped() : htmlspecialchars( $heading ) ) . "</h3>"; 00515 $listHTML = ""; 00516 00517 if ( is_array( $data ) ) { 00518 // $data is an array of links 00519 foreach ( $data as $key => $link ) { 00520 // Can be empty due to how the sidebar additions are done 00521 if ( $link ) { 00522 $listHTML .= $this->makeListItem( $key, $link ); 00523 } 00524 } 00525 if ( $listHTML ) { 00526 $listHTML = "<ul>$listHTML</ul>"; 00527 } 00528 } else { 00529 // $data is a HTML <ul>-list string 00530 $listHTML = $data; 00531 } 00532 00533 if ( $listHTML ) { 00534 $role = ( $heading == 'search' ) ? 'search' : 'navigation'; 00535 $s .= "<div class=\"portlet\" id=\"$portletId\" role=\"$role\">\n$headingHTML\n$listHTML\n</div>\n"; 00536 } 00537 00538 $s .= $this->renderAfterPortlet( $heading ); 00539 } 00540 00541 $s .= "</div>\n"; 00542 return $s; 00543 } 00544 00549 function searchForm( $which ) { 00550 global $wgUseTwoButtonsSearchForm; 00551 00552 $search = $this->getSkin()->getRequest()->getText( 'search' ); 00553 $action = $this->data['searchaction']; 00554 $s = "<form id=\"searchform-" . htmlspecialchars( $which ) . "\" method=\"get\" class=\"inline\" action=\"$action\">"; 00555 if ( $which == 'footer' ) { 00556 $s .= wfMessage( 'qbfind' )->text() . ": "; 00557 } 00558 00559 $s .= $this->makeSearchInput( array( 'class' => 'mw-searchInput', 'type' => 'text', 'size' => '14' ) ); 00560 $s .= ( $which == 'footer' ? " " : "<br />" ); 00561 $s .= $this->makeSearchButton( 'go', array( 'class' => 'searchButton' ) ); 00562 00563 if ( $wgUseTwoButtonsSearchForm ) { 00564 $s .= $this->makeSearchButton( 'fulltext', array( 'class' => 'searchButton' ) ); 00565 } else { 00566 $s .= '<div><a href="' . $action . '" rel="search">' . wfMessage( 'powersearch-legend' )->escaped() . "</a></div>\n"; 00567 } 00568 00569 $s .= '</form>'; 00570 00571 return $s; 00572 } 00573 }