r52808 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52807‎ | r52808 | r52809 >
Date:22:43, 6 July 2009
Author:tparscal
Status:ok
Tags:
Comment:
Resolves improperly named XML ids on the namespace tabs, as well as fixes up some nastyness in the Title object
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/skins/Vector.php (modified) (history)

Diff [purge]

Index: trunk/phase3/skins/Vector.php
@@ -79,11 +79,8 @@
8080 $isTalk = $this->mTitle->isTalkPage();
8181
8282 // Generates XML IDs from namespace names
83 - $subjectId = $wgContLang->lc($wgCanonicalNamespaceNames[MWNamespace::getSubject($this->mTitle->getNamespace())]);
 83+ $subjectId = $this->mTitle->getNamespaceKey( '' );
8484
85 - if ( $subjectId == '' ) {
86 - $subjectId = 'main';
87 - }
8885 if ( $subjectId == 'main' ) {
8986 $talkId = 'talk';
9087 } else {
@@ -95,9 +92,11 @@
9693 $links['namespaces'][$subjectId] = $this->tabAction(
9794 $subjectPage, 'vector-namespace-' . $subjectId, !$isTalk, '', true
9895 );
 96+ $links['namespaces'][$subjectId]['context'] = 'subject';
9997 $links['namespaces'][$talkId] = $this->tabAction(
10098 $talkPage, 'vector-namespace-talk', $isTalk, '', true
10199 );
 100+ $links['namespaces'][$talkId]['context'] = 'talk';
102101
103102 // Adds view view link
104103 if ( $this->mTitle->exists() ) {
@@ -374,8 +373,12 @@
375374 $nav = $this->skin->buildNavigationUrls();
376375 foreach ( $nav as $section => $links ) {
377376 foreach ( $links as $key => $link ) {
 377+ $insert = '';
 378+ if ( isset( $link['context'] ) && $link['context'] == 'subject' ) {
 379+ $insert = 'nstab-';
 380+ }
378381 $nav[$section][$key]['attributes'] =
379 - ' id="' . Sanitizer::escapeId( "ca-$key" ) . '"';
 382+ ' id="' . Sanitizer::escapeId( "ca-{$insert}{$key}" ) . '"';
380383 if ( $nav[$section][$key]['class'] ) {
381384 $nav[$section][$key]['attributes'] .=
382385 ' class="' . htmlspecialchars( $link['class'] ) . '"';
@@ -390,10 +393,10 @@
391394 in_array( $key, array( 'edit', 'watch', 'unwatch' ) )
392395 ) {
393396 $nav[$section][$key]['key'] =
394 - $this->skin->tooltip( "ca-$key" );
 397+ $this->skin->tooltip( "ca-{$insert}{$key}" );
395398 } else {
396399 $nav[$section][$key]['key'] =
397 - $this->skin->tooltipAndAccesskey( "ca-$key" );
 400+ $this->skin->tooltipAndAccesskey( "ca-{$insert}{$key}" );
398401 }
399402 }
400403 }
Index: trunk/phase3/includes/Title.php
@@ -3521,40 +3521,29 @@
35223522 * Generate strings used for xml 'id' names in monobook tabs
35233523 * @return \type{\string} XML 'id' name
35243524 */
3525 - public function getNamespaceKey() {
3526 - global $wgContLang;
3527 - switch ($this->getNamespace()) {
3528 - case NS_MAIN:
3529 - case NS_TALK:
3530 - return 'nstab-main';
3531 - case NS_USER:
3532 - case NS_USER_TALK:
3533 - return 'nstab-user';
3534 - case NS_MEDIA:
3535 - return 'nstab-media';
3536 - case NS_SPECIAL:
3537 - return 'nstab-special';
3538 - case NS_PROJECT:
3539 - case NS_PROJECT_TALK:
3540 - return 'nstab-project';
3541 - case NS_FILE:
3542 - case NS_FILE_TALK:
3543 - return 'nstab-image';
3544 - case NS_MEDIAWIKI:
3545 - case NS_MEDIAWIKI_TALK:
3546 - return 'nstab-mediawiki';
3547 - case NS_TEMPLATE:
3548 - case NS_TEMPLATE_TALK:
3549 - return 'nstab-template';
3550 - case NS_HELP:
3551 - case NS_HELP_TALK:
3552 - return 'nstab-help';
3553 - case NS_CATEGORY:
3554 - case NS_CATEGORY_TALK:
3555 - return 'nstab-category';
3556 - default:
3557 - return 'nstab-' . $wgContLang->lc( $this->getSubjectNsText() );
 3525+ public function getNamespaceKey( $prepend = 'nstab-' ) {
 3526+ global $wgContLang, $wgCanonicalNamespaceNames;
 3527+ // Gets the subject namespace if this title
 3528+ $namespace = MWNamespace::getSubject( $this->getNamespace() );
 3529+ // Checks if cononical namespace name exists for namespace
 3530+ if ( isset( $wgCanonicalNamespaceNames[$namespace] ) ) {
 3531+ // Uses canonical namespace name
 3532+ $namespaceKey = $wgCanonicalNamespaceNames[$namespace];
 3533+ } else {
 3534+ // Uses text of namespace
 3535+ $namespaceKey = $this->getSubjectNsText();
35583536 }
 3537+ // Makes namespace key lowercase
 3538+ $namespaceKey = $wgContLang->lc( $namespaceKey );
 3539+ // Uses main
 3540+ if ( $namespaceKey == '' ) {
 3541+ $namespaceKey = 'main';
 3542+ }
 3543+ // Changes file to image for backwards compatibility
 3544+ if ( $namespaceKey == 'file' ) {
 3545+ $namespaceKey = 'image';
 3546+ }
 3547+ return $prepend . $namespaceKey;
35593548 }
35603549
35613550 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r53399Merging UI fixes from trunk (acaifix tag), first batch:...brion15:17, 17 July 2009

Status & tagging log