Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -855,37 +855,28 @@ |
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | | - * Modifies an array of action links, as used by SkinTemplateNavigation and |
| 859 | + * Modify an array of action links, as used by SkinTemplateNavigation and |
860 | 860 | * SkinTemplateTabs, to inlude flagged revs UI elements |
861 | 861 | */ |
862 | 862 | public function setActionTabs( $skin, &$actions ) { |
863 | 863 | global $wgRequest, $wgUser, $wgFlaggedRevTabs; |
864 | 864 | |
865 | | - // Gets the title of the subject page |
866 | 865 | $title = $this->parent->getTitle()->getSubjectPage(); |
867 | | - // Checks if page is not a reviewable page |
868 | 866 | if ( !FlaggedRevs::isPageReviewable( $title ) || !$title->exists() ) { |
869 | | - // Exits, since only reviewable pages need these tabs |
| 867 | + // Exit, since only reviewable pages need these tabs |
870 | 868 | return true; |
871 | 869 | } |
872 | | - // Checks if... |
| 870 | + // Check if we should show a stabilization tab |
873 | 871 | if ( |
874 | | - // This page is not a talk page |
875 | 872 | !$skin->mTitle->isTalkPage() && |
876 | | - // User is allowed to stablize pages |
877 | 873 | $wgUser->isAllowed( 'stablesettings' ) && |
878 | | - // Actions is an array |
879 | 874 | is_array( $actions ) && |
880 | | - // A protect tab does not exist |
881 | 875 | !isset( $actions['protect'] ) && |
882 | | - // An unprotect tab does not exist |
883 | 876 | !isset( $actions['unprotect'] ) |
884 | 877 | ) { |
885 | | - // Loads messages for stabilization UI |
886 | 878 | wfLoadExtensionMessages( 'Stabilization' ); |
887 | | - // Gets the title of the Stabilization special page |
888 | 879 | $stableTitle = SpecialPage::getTitleFor( 'Stabilization' ); |
889 | | - // Adds default tab to actions |
| 880 | + // Add a tab |
890 | 881 | $actions['default'] = array( |
891 | 882 | 'class' => false, |
892 | 883 | 'text' => wfMsg( 'stabilization-tab' ), |
— | — | @@ -894,77 +885,54 @@ |
895 | 886 | ) |
896 | 887 | ); |
897 | 888 | } |
898 | | - // Exit |
899 | 889 | return true; |
900 | 890 | } |
901 | 891 | |
902 | 892 | /** |
903 | | - * Modifies an array of view links, as used by SkinTemplateNavigation and |
| 893 | + * Modify an array of view links, as used by SkinTemplateNavigation and |
904 | 894 | * SkinTemplateTabs, to inlude flagged revs UI elements |
905 | 895 | */ |
906 | 896 | public function setViewTabs( $skin, &$views ) { |
907 | 897 | global $wgRequest, $wgUser, $wgFlaggedRevTabs; |
908 | 898 | |
909 | | - // Gets the title of the subject page |
910 | 899 | $title = $this->parent->getTitle()->getSubjectPage(); |
911 | | - // Gets the value of the action parameter, defaulting to view |
912 | 900 | $action = $wgRequest->getVal( 'action', 'view' ); |
913 | | - // Gets the article instance of the page |
914 | 901 | $fa = FlaggedArticle::getTitleInstance( $title ); |
915 | | - // Checks if article is not reviewable or the UI should be hidden |
916 | 902 | if ( !$fa->isReviewable() || $this->limitedUI() ) { |
917 | | - // Exits |
| 903 | + // Exit, since this isn't a reviewable page or the UI is hidden |
918 | 904 | return true; |
919 | 905 | } |
920 | | - // Gets the stable revision |
921 | 906 | $srev = $this->getStableRev( $action == 'rollback' ? FR_MASTER : 0 ); |
922 | | - // Checks if no stable revision exists |
923 | 907 | if( is_null( $srev ) ) { |
924 | | - // Exits |
| 908 | + // Exit, since no stable revision exists |
925 | 909 | return true; |
926 | 910 | } |
927 | | - // Loads messages for flagged revisions UI |
928 | 911 | wfLoadExtensionMessages( 'FlaggedRevs' ); |
929 | | - // Creates article object from title |
930 | 912 | $article = new Article( $title ); |
931 | | - // Gets the status of whether the article is the stable revision |
932 | 913 | $synced = FlaggedRevs::stableVersionIsSynced( $srev, $article ); |
933 | | - // Checks if this page is not a talk page and not the stable version |
934 | 914 | if ( !$skin->mTitle->isTalkPage() && !$synced ) { |
935 | | - // Checks if there's an edit tab |
936 | 915 | if ( isset( $views['edit'] ) ) { |
937 | | - // Checks if we should show the stable version by default |
938 | 916 | if ( $this->showStableByDefault() ) { |
939 | | - // Changes the label of the edit button |
940 | 917 | $views['edit']['text'] = wfMsg('revreview-edit'); |
941 | 918 | } |
942 | | - // Checks if revision overriding is OK |
943 | 919 | if ( $this->pageOverride() ) { |
944 | | - // Changes the href of the edit tab |
945 | 920 | $views['edit']['href'] = $title->getLocalUrl( 'action=edit' ); |
946 | 921 | } |
947 | 922 | } |
948 | | - // Checks if there's a viewsource tab |
949 | 923 | if ( isset( $views['viewsource'] ) ) { |
950 | | - // Checks if we should show the stable version by default |
951 | 924 | if ( $this->showStableByDefault() ) { |
952 | | - // Changes the label of the viewsource button |
953 | 925 | $views['viewsource']['text'] = wfMsg('revreview-source'); |
954 | 926 | } |
955 | | - // Checks if revision overriding is OK |
956 | 927 | if ( $this->pageOverride() ) { |
957 | | - // Changes the href of the viewsource tab |
958 | 928 | $views['viewsource']['href'] = $title->getLocalUrl( 'action=edit' ); |
959 | 929 | } |
960 | 930 | } |
961 | 931 | } |
962 | | - // Checks if flagged revisions tabs should not be shown or the page is |
963 | | - // already the most current revision |
964 | | - if( !$wgFlaggedRevTabs || $synced ) { |
965 | | - // Exits |
| 932 | + if ( !$wgFlaggedRevTabs || $synced ) { |
| 933 | + // Exit, since either the flagged revisions tabs should not be shown |
| 934 | + // or the page is already the most current revision |
966 | 935 | return true; |
967 | 936 | } |
968 | | - // Create set of tabs to be created |
969 | 937 | $tabs = array( |
970 | 938 | 'stable' => array( |
971 | 939 | 'text' => wfMsg( 'revreview-stable' ), |
— | — | @@ -977,44 +945,36 @@ |
978 | 946 | 'class' => '' |
979 | 947 | ), |
980 | 948 | ); |
981 | | - // Checks if revision overriding is OK and we are at the stable version |
982 | 949 | if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) { |
| 950 | + // We are looking a the stable version |
983 | 951 | $tabs['stable']['class'] = 'selected'; |
984 | 952 | } |
985 | | - // Checks if... |
986 | 953 | elseif ( |
987 | | - // This is a view or edit page |
988 | 954 | ( self::isViewAction( $action ) || $action == 'edit' ) && |
989 | | - // This is not a talk page |
990 | 955 | !$skin->mTitle->isTalkPage() |
991 | 956 | ) { |
992 | 957 | // We are looking at the current revision or in edit mode |
993 | 958 | $tabs['current']['class'] = 'selected'; |
994 | 959 | } |
995 | | - // Loops over each action tab |
996 | 960 | $first = true; |
997 | 961 | $newViews = array(); |
998 | 962 | foreach ( $views as $tabAction => $data ) { |
999 | | - // Checks if this is the first tab |
1000 | 963 | if ( $first ) { |
1001 | 964 | if( $synced ) { |
1002 | | - // Appends old tab to new tabs, thus keeping the first one |
| 965 | + // Use existing first tabs when synced |
1003 | 966 | $newViews[$tabAction] = $data; |
1004 | 967 | } else { |
1005 | | - // Appends new tabs, thus replacing the first one |
| 968 | + // Use split current and stable tabs when not synced |
1006 | 969 | $newViews['stable'] = $tabs['stable']; |
1007 | 970 | $newViews['current'] = $tabs['current']; |
1008 | 971 | } |
1009 | | - // Marks first as false |
1010 | 972 | $first = false; |
1011 | 973 | } else { |
1012 | | - // Appends old tab to new tabs |
1013 | 974 | $newViews[$tabAction] = $data; |
1014 | 975 | } |
1015 | 976 | } |
1016 | 977 | // Replaces old tabs with new tabs |
1017 | 978 | $views = $newViews; |
1018 | | - // Exits |
1019 | 979 | return true; |
1020 | 980 | } |
1021 | 981 | |