Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -703,15 +703,20 @@ |
704 | 704 | */ |
705 | 705 | function pageOverride() { |
706 | 706 | global $wgTitle, $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgUser, $wgRequest, $action; |
707 | | - // This only applies to content pages |
| 707 | + // This only applies to viewing content pages |
708 | 708 | if( $action !='view' || !$wgTitle->isContentPage() ) return; |
709 | | - // If $wgFlaggedRevsAnonOnly is set to false, stable version are only requested explicitly |
| 709 | + // Does not apply to diffs/old revisions |
| 710 | + if( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') ) return; |
| 711 | + // Does the stable version override the current one? |
710 | 712 | if( $wgFlaggedRevsOverride ) { |
711 | | - return !( ($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) || $wgRequest->getVal('oldid') || |
712 | | - $wgRequest->getVal('diff') || $wgRequest->getIntOrNull('stable')===0 ); |
| 713 | + // If $wgFlaggedRevsAnonOnly is set to false, stable version are only requested explicitly |
| 714 | + if( $wgFlaggedRevsAnonOnly && $wgUser->isAnon() ) { |
| 715 | + return !( $wgRequest->getIntOrNull('stable')===0 ); |
| 716 | + } else { |
| 717 | + return ( $wgRequest->getIntOrNull('stable')===1 ); |
| 718 | + } |
713 | 719 | } else { |
714 | | - return !( $wgRequest->getVal('oldid') || $wgRequest->getVal('diff') || |
715 | | - $wgRequest->getIntOrNull('stable') !==1 ); |
| 720 | + return !( $wgRequest->getIntOrNull('stable') !==1 ); |
716 | 721 | } |
717 | 722 | } |
718 | 723 | |
— | — | @@ -894,100 +899,103 @@ |
895 | 900 | |
896 | 901 | function setCurrentTab( &$sktmp, &$content_actions ) { |
897 | 902 | global $wgRequest, $wgFlaggedRevsAnonOnly, $wgFlaggedRevsOverride, $wgUser, $action; |
898 | | - |
899 | 903 | // Get the subject page |
900 | 904 | $title = $sktmp->mTitle->getSubjectPage(); |
901 | 905 | // Non-content pages cannot be validated |
902 | 906 | if( !$title->isContentPage() || !$title->exists() ) return; |
903 | 907 | $article = new Article( $title ); |
904 | | - // If we are viewing a page normally, and it was overrode |
| 908 | + // If we are viewing a page normally, and it was overridden, |
905 | 909 | // change the edit tab to a "current revision" tab |
906 | | - if( !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) || !$wgFlaggedRevsOverride ) { |
907 | | - $tfrev = $this->getOverridingRev( $article ); |
908 | | - // No quality revs? Find the last reviewed one |
909 | | - if( !is_object($tfrev) ) return; |
910 | | - // Note that revisions may not be set to override for users |
911 | | - if( $this->pageOverride() ) { |
912 | | - # Remove edit option altogether |
913 | | - unset( $content_actions['edit']); |
914 | | - unset( $content_actions['viewsource']); |
915 | | - $new_actions = array(); $counter = 0; |
916 | | - # Straighten out order |
917 | | - foreach( $content_actions as $tab_action => $data ) { |
918 | | - if( $counter==1 ) { |
919 | | - # Set the tab AFTER the main tab is set |
920 | | - if( $wgFlaggedRevsOverride ) { |
921 | | - $new_actions['current'] = array( |
922 | | - 'class' => '', |
923 | | - 'text' => wfMsg('revreview-current'), |
924 | | - 'href' => $title->getLocalUrl( 'stable=0' ) |
925 | | - ); |
926 | | - } else { |
927 | | - $new_actions['stable'] = array( |
928 | | - 'class' => 'selected', |
929 | | - 'text' => wfMsg('revreview-stable'), |
930 | | - 'href' => $title->getLocalUrl( 'stable=1' ) |
931 | | - ); |
932 | | - } |
| 910 | + $tfrev = $this->getOverridingRev( $article ); |
| 911 | + // No quality revs? Find the last reviewed one |
| 912 | + if( !is_object($tfrev) ) return; |
| 913 | + // Note that revisions may not be set to override for users |
| 914 | + if( $this->pageOverride() ) { |
| 915 | + # Remove edit option altogether |
| 916 | + unset( $content_actions['edit']); |
| 917 | + unset( $content_actions['viewsource']); |
| 918 | + $new_actions = array(); $counter = 0; |
| 919 | + # Straighten out order |
| 920 | + foreach( $content_actions as $tab_action => $data ) { |
| 921 | + if( $counter==1 ) { |
| 922 | + # Set the tab AFTER the main tab is set |
| 923 | + if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 924 | + $new_actions['current'] = array( |
| 925 | + 'class' => '', |
| 926 | + 'text' => wfMsg('revreview-current'), |
| 927 | + 'href' => $title->getLocalUrl( 'stable=0' ) |
| 928 | + ); |
| 929 | + } else { |
| 930 | + # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
| 931 | + # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
| 932 | + $new_actions['stable'] = array( |
| 933 | + 'class' => 'selected', |
| 934 | + 'text' => wfMsg('revreview-stable'), |
| 935 | + 'href' => $title->getLocalUrl( 'stable=1' ) |
| 936 | + ); |
933 | 937 | } |
934 | | - $new_actions[$tab_action] = $data; |
935 | | - $counter++; |
936 | | - } |
937 | | - # Reset static array |
938 | | - $content_actions = $new_actions; |
939 | | - } else if( $action != 'view' || $wgRequest->getVal('oldid') || $sktmp->mTitle->isTalkPage() ) { |
940 | | - // We are looking at the talk page |
941 | | - $new_actions = array(); $counter = 0; |
942 | | - # Straighten out order |
943 | | - foreach( $content_actions as $tab_action => $data ) { |
944 | | - if( $counter==1 ) { |
945 | | - # Set the tab AFTER the main tab is set |
946 | | - if( $wgFlaggedRevsOverride ) { |
947 | | - $new_actions['current'] = array( |
948 | | - 'class' => '', |
949 | | - 'text' => wfMsg('revreview-current'), |
950 | | - 'href' => $title->getLocalUrl( 'stable=0' ) |
951 | | - ); |
952 | | - } else { |
953 | | - $new_actions['stable'] = array( |
954 | | - 'class' => '', |
955 | | - 'text' => wfMsg('revreview-stable'), |
956 | | - 'href' => $title->getLocalUrl( 'stable=1' ) |
957 | | - ); |
958 | | - } |
| 938 | + } |
| 939 | + $new_actions[$tab_action] = $data; |
| 940 | + $counter++; |
| 941 | + } |
| 942 | + # Reset static array |
| 943 | + $content_actions = $new_actions; |
| 944 | + } else if( $action !='view' || $wgRequest->getVal('oldid') || $sktmp->mTitle->isTalkPage() ) { |
| 945 | + // We are looking at the talk page or diffs/hist/oldids |
| 946 | + $new_actions = array(); $counter = 0; |
| 947 | + # Straighten out order |
| 948 | + foreach( $content_actions as $tab_action => $data ) { |
| 949 | + if( $counter==1 ) { |
| 950 | + # Set the tab AFTER the main tab is set |
| 951 | + if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 952 | + $new_actions['current'] = array( |
| 953 | + 'class' => '', |
| 954 | + 'text' => wfMsg('revreview-current'), |
| 955 | + 'href' => $title->getLocalUrl( 'stable=0' ) |
| 956 | + ); |
| 957 | + } else { |
| 958 | + # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
| 959 | + # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
| 960 | + $new_actions['stable'] = array( |
| 961 | + 'class' => '', |
| 962 | + 'text' => wfMsg('revreview-stable'), |
| 963 | + 'href' => $title->getLocalUrl( 'stable=1' ) |
| 964 | + ); |
959 | 965 | } |
960 | | - $new_actions[$tab_action] = $data; |
961 | | - $counter++; |
962 | | - } |
963 | | - # Reset static array |
964 | | - $content_actions = $new_actions; |
965 | | - } else { |
966 | | - // We are looking at the current revision/history/diffs ect... |
967 | | - $new_actions = array(); $counter = 0; |
968 | | - # Straighten out order |
969 | | - foreach( $content_actions as $tab_action => $data ) { |
970 | | - if( $counter==1 ) { |
971 | | - # Set the tab AFTER the main tab is set |
972 | | - if( $wgFlaggedRevsOverride ) { |
973 | | - $new_actions['current'] = array( |
974 | | - 'class' => 'selected', |
975 | | - 'text' => wfMsg('revreview-current'), |
976 | | - 'href' => $title->getLocalUrl( 'stable=0' ) |
977 | | - ); |
978 | | - } else { |
979 | | - $new_actions['stable'] = array( |
980 | | - 'class' => '', |
981 | | - 'text' => wfMsg('revreview-stable'), |
982 | | - 'href' => $title->getLocalUrl( 'stable=1' ) |
983 | | - ); |
984 | | - } |
985 | | - } |
986 | | - $new_actions[$tab_action] = $data; |
987 | | - $counter++; |
988 | | - } |
989 | | - # Reset static array |
990 | | - $content_actions = $new_actions; |
991 | | - } |
| 966 | + } |
| 967 | + $new_actions[$tab_action] = $data; |
| 968 | + $counter++; |
| 969 | + } |
| 970 | + # Reset static array |
| 971 | + $content_actions = $new_actions; |
| 972 | + } else { |
| 973 | + // We are looking at the current revision |
| 974 | + $new_actions = array(); $counter = 0; |
| 975 | + # Straighten out order |
| 976 | + foreach( $content_actions as $tab_action => $data ) { |
| 977 | + if( $counter==1 ) { |
| 978 | + # Set the tab AFTER the main tab is set |
| 979 | + if( $wgFlaggedRevsOverride && !($wgFlaggedRevsAnonOnly && !$wgUser->isAnon()) ) { |
| 980 | + $new_actions['current'] = array( |
| 981 | + 'class' => 'selected', |
| 982 | + 'text' => wfMsg('revreview-current'), |
| 983 | + 'href' => $title->getLocalUrl( 'stable=0' ) |
| 984 | + ); |
| 985 | + } else { |
| 986 | + # Add 'stable' tab if either $wgFlaggedRevsOverride is off, |
| 987 | + # or this is a user viewing the page with $wgFlaggedRevsAnonOnly on |
| 988 | + $new_actions['stable'] = array( |
| 989 | + 'class' => '', |
| 990 | + 'text' => wfMsg('revreview-stable'), |
| 991 | + 'href' => $title->getLocalUrl( 'stable=1' ) |
| 992 | + ); |
| 993 | + } |
| 994 | + } |
| 995 | + $new_actions[$tab_action] = $data; |
| 996 | + $counter++; |
| 997 | + } |
| 998 | + # Reset static array |
| 999 | + $content_actions = $new_actions; |
992 | 1000 | } |
993 | 1001 | } |
994 | 1002 | |