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