| Index: trunk/phase3/includes/SkinTemplate.php |
| — | — | @@ -789,6 +789,9 @@ |
| 790 | 790 | |
| 791 | 791 | wfProfileIn( __METHOD__ ); |
| 792 | 792 | |
| | 793 | + $title = $this->getRelevantTitle(); // Display tabs for the relevant title rather than always the title itself |
| | 794 | + $onPage = $title->equals($this->mTitle); |
| | 795 | + |
| 793 | 796 | $content_navigation = array( |
| 794 | 797 | 'namespaces' => array(), |
| 795 | 798 | 'views' => array(), |
| — | — | @@ -800,23 +803,23 @@ |
| 801 | 804 | $action = $wgRequest->getVal( 'action', 'view' ); |
| 802 | 805 | $section = $wgRequest->getVal( 'section' ); |
| 803 | 806 | |
| 804 | | - $userCanRead = $this->mTitle->userCanRead(); |
| | 807 | + $userCanRead = $title->userCanRead(); |
| 805 | 808 | $skname = $this->skinname; |
| 806 | 809 | |
| 807 | 810 | $preventActiveTabs = false; |
| 808 | 811 | wfRunHooks( 'SkinTemplatePreventOtherActiveTabs', array( &$this, &$preventActiveTabs ) ); |
| 809 | 812 | |
| 810 | 813 | // Checks if page is some kind of content |
| 811 | | - if( $this->iscontent ) { |
| | 814 | + if( $this->mTitle->getNamespace() != NS_SPECIAL ) { |
| 812 | 815 | // Gets page objects for the related namespaces |
| 813 | | - $subjectPage = $this->mTitle->getSubjectPage(); |
| 814 | | - $talkPage = $this->mTitle->getTalkPage(); |
| | 816 | + $subjectPage = $title->getSubjectPage(); |
| | 817 | + $talkPage = $title->getTalkPage(); |
| 815 | 818 | |
| 816 | 819 | // Determines if this is a talk page |
| 817 | | - $isTalk = $this->mTitle->isTalkPage(); |
| | 820 | + $isTalk = $title->isTalkPage(); |
| 818 | 821 | |
| 819 | 822 | // Generates XML IDs from namespace names |
| 820 | | - $subjectId = $this->mTitle->getNamespaceKey( '' ); |
| | 823 | + $subjectId = $title->getNamespaceKey( '' ); |
| 821 | 824 | |
| 822 | 825 | if ( $subjectId == 'main' ) { |
| 823 | 826 | $talkId = 'talk'; |
| — | — | @@ -835,11 +838,11 @@ |
| 836 | 839 | $content_navigation['namespaces'][$talkId]['context'] = 'talk'; |
| 837 | 840 | |
| 838 | 841 | // Adds view view link |
| 839 | | - if ( $this->mTitle->exists() && $userCanRead ) { |
| | 842 | + if ( $title->exists() && $userCanRead ) { |
| 840 | 843 | $content_navigation['views']['view'] = $this->tabAction( |
| 841 | 844 | $isTalk ? $talkPage : $subjectPage, |
| 842 | 845 | !wfEmptyMsg( "$skname-view-view" ) ? "$skname-view-view" : 'view', |
| 843 | | - ( $action == 'view' ), '', true |
| | 846 | + ( $onPage && $action == 'view' ), '', true |
| 844 | 847 | ); |
| 845 | 848 | $content_navigation['views']['view']['redundant'] = true; // signal to hide this from simple content_actions |
| 846 | 849 | } |
| — | — | @@ -849,12 +852,12 @@ |
| 850 | 853 | // Checks if user can... |
| 851 | 854 | if ( |
| 852 | 855 | // read and edit the current page |
| 853 | | - $userCanRead && $this->mTitle->quickUserCan( 'edit' ) && |
| | 856 | + $userCanRead && $title->quickUserCan( 'edit' ) && |
| 854 | 857 | ( |
| 855 | 858 | // if it exists |
| 856 | | - $this->mTitle->exists() || |
| | 859 | + $title->exists() || |
| 857 | 860 | // or they can create one here |
| 858 | | - $this->mTitle->quickUserCan( 'create' ) |
| | 861 | + $title->quickUserCan( 'create' ) |
| 859 | 862 | ) |
| 860 | 863 | ) { |
| 861 | 864 | // Builds CSS class for talk page links |
| — | — | @@ -862,15 +865,16 @@ |
| 863 | 866 | |
| 864 | 867 | // Determines if we're in edit mode |
| 865 | 868 | $selected = ( |
| | 869 | + $onPage && |
| 866 | 870 | ( $action == 'edit' || $action == 'submit' ) && |
| 867 | 871 | ( $section != 'new' ) |
| 868 | 872 | ); |
| 869 | | - $msgKey = $this->mTitle->exists() || ( $this->mTitle->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $this->mTitle->getText() ) ) ? |
| | 873 | + $msgKey = $title->exists() || ( $title->getNamespace() == NS_MEDIAWIKI && !wfEmptyMsg( $title->getText() ) ) ? |
| 870 | 874 | "edit" : "create"; |
| 871 | 875 | $content_navigation['views']['edit'] = array( |
| 872 | 876 | 'class' => ( $selected ? 'selected' : '' ) . $isTalkClass, |
| 873 | 877 | 'text' => wfMessageFallback( "$skname-view-$msgKey", $msgKey )->plain(), |
| 874 | | - 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ), |
| | 878 | + 'href' => $title->getLocalURL( $this->editUrlOptions() ), |
| 875 | 879 | 'primary' => true, // don't collapse this in vector |
| 876 | 880 | ); |
| 877 | 881 | // Checks if this is a current rev of talk page and we should show a new |
| — | — | @@ -883,17 +887,17 @@ |
| 884 | 888 | $content_navigation['views']['addsection'] = array( |
| 885 | 889 | 'class' => $section == 'new' ? 'selected' : false, |
| 886 | 890 | 'text' => wfMessageFallback( "$skname-action-addsection", 'addsection' )->plain(), |
| 887 | | - 'href' => $this->mTitle->getLocalURL( 'action=edit§ion=new' ) |
| | 891 | + 'href' => $title->getLocalURL( 'action=edit§ion=new' ) |
| 888 | 892 | ); |
| 889 | 893 | } |
| 890 | 894 | } |
| 891 | 895 | // Checks if the page has some kind of viewable content |
| 892 | | - } elseif ( $this->mTitle->hasSourceText() && $userCanRead ) { |
| | 896 | + } elseif ( $title->hasSourceText() && $userCanRead ) { |
| 893 | 897 | // Adds view source view link |
| 894 | 898 | $content_navigation['views']['viewsource'] = array( |
| 895 | | - 'class' => ( $action == 'edit' ) ? 'selected' : false, |
| | 899 | + 'class' => ( $onPage && $action == 'edit' ) ? 'selected' : false, |
| 896 | 900 | 'text' => wfMessageFallback( "$skname-action-viewsource", 'viewsource' )->plain(), |
| 897 | | - 'href' => $this->mTitle->getLocalURL( $this->editUrlOptions() ), |
| | 901 | + 'href' => $title->getLocalURL( $this->editUrlOptions() ), |
| 898 | 902 | 'primary' => true, // don't collapse this in vector |
| 899 | 903 | ); |
| 900 | 904 | } |
| — | — | @@ -902,24 +906,24 @@ |
| 903 | 907 | wfProfileIn( __METHOD__ . '-live' ); |
| 904 | 908 | |
| 905 | 909 | // Checks if the page exists |
| 906 | | - if ( $this->mTitle->exists() && $userCanRead ) { |
| | 910 | + if ( $title->exists() && $userCanRead ) { |
| 907 | 911 | // Adds history view link |
| 908 | 912 | $content_navigation['views']['history'] = array( |
| 909 | | - 'class' => ( $action == 'history' ) ? 'selected' : false, |
| | 913 | + 'class' => ( $onPage && $action == 'history' ) ? 'selected' : false, |
| 910 | 914 | 'text' => wfMessageFallback( "$skname-view-history", 'history_short' )->plain(), |
| 911 | | - 'href' => $this->mTitle->getLocalURL( 'action=history' ), |
| | 915 | + 'href' => $title->getLocalURL( 'action=history' ), |
| 912 | 916 | 'rel' => 'archives', |
| 913 | 917 | ); |
| 914 | 918 | |
| 915 | 919 | if( $wgUser->isAllowed( 'delete' ) ) { |
| 916 | 920 | $content_navigation['actions']['delete'] = array( |
| 917 | | - 'class' => ( $action == 'delete' ) ? 'selected' : false, |
| | 921 | + 'class' => ( $onPage && $action == 'delete' ) ? 'selected' : false, |
| 918 | 922 | 'text' => wfMessageFallback( "$skname-action-delete", 'delete' )->plain(), |
| 919 | | - 'href' => $this->mTitle->getLocalURL( 'action=delete' ) |
| | 923 | + 'href' => $title->getLocalURL( 'action=delete' ) |
| 920 | 924 | ); |
| 921 | 925 | } |
| 922 | | - if ( $this->mTitle->quickUserCan( 'move' ) ) { |
| 923 | | - $moveTitle = SpecialPage::getTitleFor( 'Movepage', $this->thispage ); |
| | 926 | + if ( $title->quickUserCan( 'move' ) ) { |
| | 927 | + $moveTitle = SpecialPage::getTitleFor( 'Movepage', $title->getPrefixedDBkey() ); |
| 924 | 928 | $content_navigation['actions']['move'] = array( |
| 925 | 929 | 'class' => $this->mTitle->isSpecial( 'Movepage' ) ? 'selected' : false, |
| 926 | 930 | 'text' => wfMessageFallback( "$skname-action-move", 'move' )->plain(), |
| — | — | @@ -927,37 +931,37 @@ |
| 928 | 932 | ); |
| 929 | 933 | } |
| 930 | 934 | |
| 931 | | - if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| 932 | | - $mode = !$this->mTitle->isProtected() ? 'protect' : 'unprotect'; |
| | 935 | + if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| | 936 | + $mode = !$title->isProtected() ? 'protect' : 'unprotect'; |
| 933 | 937 | $content_navigation['actions'][$mode] = array( |
| 934 | | - 'class' => ( $action == $mode ) ? 'selected' : false, |
| | 938 | + 'class' => ( $onPage && $action == $mode ) ? 'selected' : false, |
| 935 | 939 | 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(), |
| 936 | | - 'href' => $this->mTitle->getLocalURL( "action=$mode" ) |
| | 940 | + 'href' => $title->getLocalURL( "action=$mode" ) |
| 937 | 941 | ); |
| 938 | 942 | } |
| 939 | 943 | } else { |
| 940 | 944 | // article doesn't exist or is deleted |
| 941 | 945 | if ( $wgUser->isAllowed( 'deletedhistory' ) ) { |
| 942 | | - $n = $this->mTitle->isDeleted(); |
| | 946 | + $n = $title->isDeleted(); |
| 943 | 947 | if( $n ) { |
| 944 | 948 | $undelTitle = SpecialPage::getTitleFor( 'Undelete' ); |
| 945 | 949 | // If the user can't undelete but can view deleted history show them a "View .. deleted" tab instead |
| 946 | 950 | $msgKey = $wgUser->isAllowed( 'undelete' ) ? 'undelete' : 'viewdeleted'; |
| 947 | 951 | $content_navigation['actions']['undelete'] = array( |
| 948 | | - 'class' => false, |
| | 952 | + 'class' => $this->mTitle->isSpecial( 'Undelete' ) ? 'selected' : false, |
| 949 | 953 | 'text' => wfMessageFallback( "$skname-action-$msgKey", "{$msgKey}_short" ) |
| 950 | 954 | ->params( $wgLang->formatNum( $n ) )->text(), |
| 951 | | - 'href' => $undelTitle->getLocalURL( array( 'target' => $this->thispage ) ) |
| | 955 | + 'href' => $undelTitle->getLocalURL( array( 'target' => $title->getPrefixedDBkey() ) ) |
| 952 | 956 | ); |
| 953 | 957 | } |
| 954 | 958 | } |
| 955 | 959 | |
| 956 | | - if ( $this->mTitle->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| 957 | | - $mode = !$this->mTitle->getRestrictions( 'create' ) ? 'protect' : 'unprotect'; |
| | 960 | + if ( $title->getNamespace() !== NS_MEDIAWIKI && $wgUser->isAllowed( 'protect' ) ) { |
| | 961 | + $mode = !$title->getRestrictions( 'create' ) ? 'protect' : 'unprotect'; |
| 958 | 962 | $content_navigation['actions'][$mode] = array( |
| 959 | | - 'class' => ( $action == $mode ) ? 'selected' : false, |
| | 963 | + 'class' => ( $onPage && $action == $mode ) ? 'selected' : false, |
| 960 | 964 | 'text' => wfMessageFallback( "$skname-action-$mode", $mode )->plain(), |
| 961 | | - 'href' => $this->mTitle->getLocalURL( "action=$mode" ) |
| | 965 | + 'href' => $title->getLocalURL( "action=$mode" ) |
| 962 | 966 | ); |
| 963 | 967 | } |
| 964 | 968 | } |
| — | — | @@ -974,11 +978,11 @@ |
| 975 | 979 | * a change to that procedure these messages will have to remain as |
| 976 | 980 | * the global versions. |
| 977 | 981 | */ |
| 978 | | - $mode = $this->mTitle->userIsWatching() ? 'unwatch' : 'watch'; |
| | 982 | + $mode = $title->userIsWatching() ? 'unwatch' : 'watch'; |
| 979 | 983 | $content_navigation['actions'][$mode] = array( |
| 980 | | - 'class' => ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false, |
| | 984 | + 'class' => $onPage && ( $action == 'watch' || $action == 'unwatch' ) ? 'selected' : false, |
| 981 | 985 | 'text' => wfMsg( $mode ), // uses 'watch' or 'unwatch' message |
| 982 | | - 'href' => $this->mTitle->getLocalURL( 'action=' . $mode ) |
| | 986 | + 'href' => $title->getLocalURL( 'action=' . $mode ) |
| 983 | 987 | ); |
| 984 | 988 | } |
| 985 | 989 | |
| — | — | @@ -1014,7 +1018,7 @@ |
| 1015 | 1019 | $content_navigation['variants'][] = array( |
| 1016 | 1020 | 'class' => ( $code == $preferred ) ? 'selected' : false, |
| 1017 | 1021 | 'text' => $varname, |
| 1018 | | - 'href' => $this->mTitle->getLocalURL( '', $code ) |
| | 1022 | + 'href' => $title->getLocalURL( '', $code ) |
| 1019 | 1023 | ); |
| 1020 | 1024 | } |
| 1021 | 1025 | } |
| — | — | @@ -1179,10 +1183,10 @@ |
| 1180 | 1184 | ); |
| 1181 | 1185 | } |
| 1182 | 1186 | |
| 1183 | | - if( $this->mTitle->getNamespace() == NS_USER || $this->mTitle->getNamespace() == NS_USER_TALK ) { |
| 1184 | | - $rootUser = strtok( $this->mTitle->getText(), '/' ); |
| 1185 | | - $id = User::idFromName( $rootUser ); |
| 1186 | | - $ip = User::isIP( $rootUser ); |
| | 1187 | + if ( $user = $this->getRelevantUser() ) { |
| | 1188 | + $id = $user->getID(); |
| | 1189 | + $ip = $user->isAnon(); |
| | 1190 | + $rootUser = $user->getName(); |
| 1187 | 1191 | } else { |
| 1188 | 1192 | $id = 0; |
| 1189 | 1193 | $ip = false; |
| Index: trunk/phase3/includes/specials/SpecialUndelete.php |
| — | — | @@ -649,6 +649,7 @@ |
| 650 | 650 | } |
| 651 | 651 | if ( $this->mTarget !== '' ) { |
| 652 | 652 | $this->mTargetObj = Title::newFromURL( $this->mTarget ); |
| | 653 | + $wgUser->getSkin()->setRelevantTitle( $this->mTargetObj ); |
| 653 | 654 | } else { |
| 654 | 655 | $this->mTargetObj = null; |
| 655 | 656 | } |
| Index: trunk/phase3/includes/specials/SpecialLog.php |
| — | — | @@ -106,6 +106,11 @@ |
| 107 | 107 | # Set title and add header |
| 108 | 108 | $loglist->showHeader( $pager->getType() ); |
| 109 | 109 | |
| | 110 | + # Set relevant user |
| | 111 | + if ( $pager->getUser() ) { |
| | 112 | + $wgUser->getSkin()->setRelevantUser( User::newFromName( $pager->getUser() ) ); |
| | 113 | + } |
| | 114 | + |
| 110 | 115 | # Show form options |
| 111 | 116 | $loglist->showOptions( $pager->getType(), $pager->getUser(), $pager->getPage(), $pager->getPattern(), |
| 112 | 117 | $pager->getYear(), $pager->getMonth(), $pager->getFilterParams(), $opts->getValue( 'tagfilter' ) ); |
| Index: trunk/phase3/includes/specials/SpecialContributions.php |
| — | — | @@ -78,6 +78,10 @@ |
| 79 | 79 | $target = $nt->getText(); |
| 80 | 80 | $wgOut->setSubtitle( $this->contributionsSub( $nt, $id ) ); |
| 81 | 81 | $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsgExt( 'contributions-title', array( 'parsemag' ),$target ) ) ); |
| | 82 | + $user = User::newFromName( $target, false ); |
| | 83 | + if ( is_object($user) ) { |
| | 84 | + $wgUser->getSkin()->setRelevantUser( $user ); |
| | 85 | + } |
| 82 | 86 | } else { |
| 83 | 87 | $wgOut->setSubtitle( wfMsgHtml( 'sp-contributions-newbies-sub') ); |
| 84 | 88 | $wgOut->setHTMLTitle( wfMsg( 'pagetitle', wfMsg( 'sp-contributions-newbies-title' ) ) ); |
| Index: trunk/phase3/includes/specials/SpecialBlockip.php |
| — | — | @@ -123,6 +123,9 @@ |
| 124 | 124 | |
| 125 | 125 | $titleObj = SpecialPage::getTitleFor( 'Blockip' ); |
| 126 | 126 | $user = User::newFromName( $this->BlockAddress ); |
| | 127 | + if ( is_object( $user ) || User::isIP( $this->BlockAddress ) ) { |
| | 128 | + $wgUser->getSkin()->setRelevantUser( is_object($user) ? $user : User::newFromName( $this->BlockAddress, false ) ); |
| | 129 | + } |
| 127 | 130 | |
| 128 | 131 | $alreadyBlocked = false; |
| 129 | 132 | $otherBlockedMsgs = array(); |
| Index: trunk/phase3/includes/specials/SpecialMovepage.php |
| — | — | @@ -109,6 +109,7 @@ |
| 110 | 110 | |
| 111 | 111 | $wgOut->setPagetitle( wfMsg( 'move-page', $this->oldTitle->getPrefixedText() ) ); |
| 112 | 112 | $wgOut->setSubtitle( wfMsg( 'move-page-backlink', $oldTitleLink ) ); |
| | 113 | + $skin->setRelevantTitle( $this->oldTitle ); |
| 113 | 114 | |
| 114 | 115 | $newTitle = $this->newTitle; |
| 115 | 116 | |
| Index: trunk/phase3/includes/Skin.php |
| — | — | @@ -27,6 +27,8 @@ |
| 28 | 28 | protected $skinname = 'standard'; |
| 29 | 29 | // @todo Fixme: should be protected :-\ |
| 30 | 30 | var $mTitle = null; |
| | 31 | + protected $mRelevantTitle = null; |
| | 32 | + protected $mRelevantUser = null; |
| 31 | 33 | |
| 32 | 34 | /** Constructor, call parent constructor */ |
| 33 | 35 | function __construct() { |
| — | — | @@ -366,6 +368,66 @@ |
| 367 | 369 | } |
| 368 | 370 | |
| 369 | 371 | /** |
| | 372 | + * Set the "relevant" title |
| | 373 | + * @see self::getRelevantTitle() |
| | 374 | + * @param $t Title object to use |
| | 375 | + */ |
| | 376 | + public function setRelevantTitle( $t ) { |
| | 377 | + $this->mRelevantTitle = $t; |
| | 378 | + } |
| | 379 | + |
| | 380 | + /** |
| | 381 | + * Return the "relevant" title. |
| | 382 | + * A "relevant" title is not necessarily the actual title of the page. |
| | 383 | + * Special pages like Special:MovePage use set the page they are acting on |
| | 384 | + * as their "relevant" title, this allows the skin system to display things |
| | 385 | + * such as content tabs which belong to to that page instead of displaying |
| | 386 | + * a basic special page tab which has almost no meaning. |
| | 387 | + */ |
| | 388 | + public function getRelevantTitle() { |
| | 389 | + if ( isset($this->mRelevantTitle) ) { |
| | 390 | + return $this->mRelevantTitle; |
| | 391 | + } |
| | 392 | + return $this->mTitle; |
| | 393 | + } |
| | 394 | + |
| | 395 | + /** |
| | 396 | + * Set the "relevant" user |
| | 397 | + * @see self::getRelevantUser() |
| | 398 | + * @param $u User object to use |
| | 399 | + */ |
| | 400 | + public function setRelevantUser( $u ) { |
| | 401 | + $this->mRelevantUser = $u; |
| | 402 | + } |
| | 403 | + |
| | 404 | + /** |
| | 405 | + * Return the "relevant" user. |
| | 406 | + * A "relevant" user is similar to a relevant title. Special pages like |
| | 407 | + * Special:Contributions mark the user which they are relevant to so that |
| | 408 | + * things like the toolbox can display the information they usually are only |
| | 409 | + * able to display on a user's userpage and talkpage. |
| | 410 | + */ |
| | 411 | + public function getRelevantUser() { |
| | 412 | + if ( isset($this->mRelevantUser) ) { |
| | 413 | + return $this->mRelevantUser; |
| | 414 | + } |
| | 415 | + $title = $this->getRelevantTitle(); |
| | 416 | + if( $title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK ) { |
| | 417 | + $rootUser = strtok( $title->getText(), '/' ); |
| | 418 | + if ( User::isIP( $rootUser ) ) { |
| | 419 | + $this->mRelevantUser = User::newFromName( $rootUser, false ); |
| | 420 | + } else { |
| | 421 | + $user = User::newFromName( $rootUser ); |
| | 422 | + if ( $user->isLoggedIn() ) { |
| | 423 | + $this->mRelevantUser = $user; |
| | 424 | + } |
| | 425 | + } |
| | 426 | + return $this->mRelevantUser; |
| | 427 | + } |
| | 428 | + return null; |
| | 429 | + } |
| | 430 | + |
| | 431 | + /** |
| 370 | 432 | * Outputs the HTML generated by other functions. |
| 371 | 433 | * @param $out Object: instance of OutputPage |
| 372 | 434 | */ |