Index: trunk/extensions/Translate/tag/PageTranslationHooks.php |
— | — | @@ -569,4 +569,63 @@ |
570 | 570 | |
571 | 571 | return true; |
572 | 572 | } |
| 573 | + |
| 574 | + public static function replaceSubtitle( &$subpages, $skin, $out ) { |
| 575 | + global $wgOut, $wgUser; |
| 576 | + if ( $out === null ) $out = $wgOut; |
| 577 | + if ( $skin === null ) $skin = $wgUser->getSkin(); |
| 578 | + |
| 579 | + if ( !TranslatablePage::isTranslationPage( $out->getTitle() ) |
| 580 | + && !TranslatablePage::isSourcePage( $out->getTitle() ) ) { |
| 581 | + return true; |
| 582 | + } |
| 583 | + |
| 584 | + // Copied from Skin::subPageSubtitle() |
| 585 | + if ( $out->isArticle() && MWNamespace::hasSubpages( $out->getTitle()->getNamespace() ) ) { |
| 586 | + $ptext = $out->getTitle()->getPrefixedText(); |
| 587 | + if ( preg_match( '/\//', $ptext ) ) { |
| 588 | + $links = explode( '/', $ptext ); |
| 589 | + array_pop( $links ); |
| 590 | + // Also pop of one extra for language code is needed |
| 591 | + if ( TranslatablePage::isTranslationPage( $out->getTitle() ) ) { |
| 592 | + array_pop( $links ); |
| 593 | + } |
| 594 | + $c = 0; |
| 595 | + $growinglink = ''; |
| 596 | + $display = ''; |
| 597 | + |
| 598 | + foreach ( $links as $link ) { |
| 599 | + $growinglink .= $link; |
| 600 | + $display .= $link; |
| 601 | + $linkObj = Title::newFromText( $growinglink ); |
| 602 | + |
| 603 | + if ( is_object( $linkObj ) && $linkObj->exists() ) { |
| 604 | + $getlink = $skin->linkKnown( |
| 605 | + SpecialPage::getTitleFor( 'MyLanguage', $growinglink ), |
| 606 | + htmlspecialchars( $display ) |
| 607 | + ); |
| 608 | + |
| 609 | + $c++; |
| 610 | + |
| 611 | + if ( $c > 1 ) { |
| 612 | + $subpages .= wfMsgExt( 'pipe-separator', 'escapenoentities' ); |
| 613 | + } else { |
| 614 | + // This one is stupid imho, doesn't work with chihuahua |
| 615 | + //$subpages .= '< '; |
| 616 | + } |
| 617 | + |
| 618 | + $subpages .= $getlink; |
| 619 | + $display = ''; |
| 620 | + } else { |
| 621 | + $display .= '/'; |
| 622 | + } |
| 623 | + $growinglink .= '/'; |
| 624 | + } |
| 625 | + } |
| 626 | + return false; |
| 627 | + } |
| 628 | + |
| 629 | + return true; |
| 630 | + } |
| 631 | + |
573 | 632 | } |
Index: trunk/extensions/Translate/Translate.php |
— | — | @@ -615,6 +615,9 @@ |
616 | 616 | |
617 | 617 | // Custom move page that can move all the associated pages too |
618 | 618 | $wgHooks['SpecialPage_initList'][] = 'PageTranslationHooks::replaceMovePage'; |
| 619 | + |
| 620 | + // Replace subpage logic behaviour |
| 621 | + $wgHooks['SkinSubPageSubtitle'][] = 'PageTranslationHooks::replaceSubtitle'; |
619 | 622 | } |
620 | 623 | } |
621 | 624 | |