r53185 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53184‎ | r53185 | r53186 >
Date:18:37, 13 July 2009
Author:tparscal
Status:ok
Tags:
Comment:
Reduced the level of detail in comments as per Tim Starling's request.
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -855,37 +855,28 @@
856856 }
857857
858858 /**
859 - * Modifies an array of action links, as used by SkinTemplateNavigation and
 859+ * Modify an array of action links, as used by SkinTemplateNavigation and
860860 * SkinTemplateTabs, to inlude flagged revs UI elements
861861 */
862862 public function setActionTabs( $skin, &$actions ) {
863863 global $wgRequest, $wgUser, $wgFlaggedRevTabs;
864864
865 - // Gets the title of the subject page
866865 $title = $this->parent->getTitle()->getSubjectPage();
867 - // Checks if page is not a reviewable page
868866 if ( !FlaggedRevs::isPageReviewable( $title ) || !$title->exists() ) {
869 - // Exits, since only reviewable pages need these tabs
 867+ // Exit, since only reviewable pages need these tabs
870868 return true;
871869 }
872 - // Checks if...
 870+ // Check if we should show a stabilization tab
873871 if (
874 - // This page is not a talk page
875872 !$skin->mTitle->isTalkPage() &&
876 - // User is allowed to stablize pages
877873 $wgUser->isAllowed( 'stablesettings' ) &&
878 - // Actions is an array
879874 is_array( $actions ) &&
880 - // A protect tab does not exist
881875 !isset( $actions['protect'] ) &&
882 - // An unprotect tab does not exist
883876 !isset( $actions['unprotect'] )
884877 ) {
885 - // Loads messages for stabilization UI
886878 wfLoadExtensionMessages( 'Stabilization' );
887 - // Gets the title of the Stabilization special page
888879 $stableTitle = SpecialPage::getTitleFor( 'Stabilization' );
889 - // Adds default tab to actions
 880+ // Add a tab
890881 $actions['default'] = array(
891882 'class' => false,
892883 'text' => wfMsg( 'stabilization-tab' ),
@@ -894,77 +885,54 @@
895886 )
896887 );
897888 }
898 - // Exit
899889 return true;
900890 }
901891
902892 /**
903 - * Modifies an array of view links, as used by SkinTemplateNavigation and
 893+ * Modify an array of view links, as used by SkinTemplateNavigation and
904894 * SkinTemplateTabs, to inlude flagged revs UI elements
905895 */
906896 public function setViewTabs( $skin, &$views ) {
907897 global $wgRequest, $wgUser, $wgFlaggedRevTabs;
908898
909 - // Gets the title of the subject page
910899 $title = $this->parent->getTitle()->getSubjectPage();
911 - // Gets the value of the action parameter, defaulting to view
912900 $action = $wgRequest->getVal( 'action', 'view' );
913 - // Gets the article instance of the page
914901 $fa = FlaggedArticle::getTitleInstance( $title );
915 - // Checks if article is not reviewable or the UI should be hidden
916902 if ( !$fa->isReviewable() || $this->limitedUI() ) {
917 - // Exits
 903+ // Exit, since this isn't a reviewable page or the UI is hidden
918904 return true;
919905 }
920 - // Gets the stable revision
921906 $srev = $this->getStableRev( $action == 'rollback' ? FR_MASTER : 0 );
922 - // Checks if no stable revision exists
923907 if( is_null( $srev ) ) {
924 - // Exits
 908+ // Exit, since no stable revision exists
925909 return true;
926910 }
927 - // Loads messages for flagged revisions UI
928911 wfLoadExtensionMessages( 'FlaggedRevs' );
929 - // Creates article object from title
930912 $article = new Article( $title );
931 - // Gets the status of whether the article is the stable revision
932913 $synced = FlaggedRevs::stableVersionIsSynced( $srev, $article );
933 - // Checks if this page is not a talk page and not the stable version
934914 if ( !$skin->mTitle->isTalkPage() && !$synced ) {
935 - // Checks if there's an edit tab
936915 if ( isset( $views['edit'] ) ) {
937 - // Checks if we should show the stable version by default
938916 if ( $this->showStableByDefault() ) {
939 - // Changes the label of the edit button
940917 $views['edit']['text'] = wfMsg('revreview-edit');
941918 }
942 - // Checks if revision overriding is OK
943919 if ( $this->pageOverride() ) {
944 - // Changes the href of the edit tab
945920 $views['edit']['href'] = $title->getLocalUrl( 'action=edit' );
946921 }
947922 }
948 - // Checks if there's a viewsource tab
949923 if ( isset( $views['viewsource'] ) ) {
950 - // Checks if we should show the stable version by default
951924 if ( $this->showStableByDefault() ) {
952 - // Changes the label of the viewsource button
953925 $views['viewsource']['text'] = wfMsg('revreview-source');
954926 }
955 - // Checks if revision overriding is OK
956927 if ( $this->pageOverride() ) {
957 - // Changes the href of the viewsource tab
958928 $views['viewsource']['href'] = $title->getLocalUrl( 'action=edit' );
959929 }
960930 }
961931 }
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
966935 return true;
967936 }
968 - // Create set of tabs to be created
969937 $tabs = array(
970938 'stable' => array(
971939 'text' => wfMsg( 'revreview-stable' ),
@@ -977,44 +945,36 @@
978946 'class' => ''
979947 ),
980948 );
981 - // Checks if revision overriding is OK and we are at the stable version
982949 if ( $this->pageOverride() || $wgRequest->getVal( 'stableid' ) ) {
 950+ // We are looking a the stable version
983951 $tabs['stable']['class'] = 'selected';
984952 }
985 - // Checks if...
986953 elseif (
987 - // This is a view or edit page
988954 ( self::isViewAction( $action ) || $action == 'edit' ) &&
989 - // This is not a talk page
990955 !$skin->mTitle->isTalkPage()
991956 ) {
992957 // We are looking at the current revision or in edit mode
993958 $tabs['current']['class'] = 'selected';
994959 }
995 - // Loops over each action tab
996960 $first = true;
997961 $newViews = array();
998962 foreach ( $views as $tabAction => $data ) {
999 - // Checks if this is the first tab
1000963 if ( $first ) {
1001964 if( $synced ) {
1002 - // Appends old tab to new tabs, thus keeping the first one
 965+ // Use existing first tabs when synced
1003966 $newViews[$tabAction] = $data;
1004967 } else {
1005 - // Appends new tabs, thus replacing the first one
 968+ // Use split current and stable tabs when not synced
1006969 $newViews['stable'] = $tabs['stable'];
1007970 $newViews['current'] = $tabs['current'];
1008971 }
1009 - // Marks first as false
1010972 $first = false;
1011973 } else {
1012 - // Appends old tab to new tabs
1013974 $newViews[$tabAction] = $data;
1014975 }
1015976 }
1016977 // Replaces old tabs with new tabs
1017978 $views = $newViews;
1018 - // Exits
1019979 return true;
1020980 }
1021981

Status & tagging log