Index: trunk/extensions/ApprovedRevs/ApprovedRevs.i18n.php |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | 'approvedrevs-approvedandlatest' => 'This is the approved revision of this page, as well as being the most recent.', |
31 | 31 | 'approvedrevs-viewlatest' => 'View most recent revision.', |
32 | 32 | 'approvedrevs-blankpageshown' => 'No revision has been approved for this page.', |
| 33 | + 'approvedrevs-editwarning' => 'Please note that you are now editing the latest revision of this page, which is not the approved one shown by default.', |
33 | 34 | 'approvedpages' => 'Approved pages', |
34 | 35 | 'approvedrevs-approvedpages-docu' => 'The following are the pages in the wiki that have an approved revision.', |
35 | 36 | 'unapprovedpages' => 'Unapproved pages', |
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.php |
— | — | @@ -46,7 +46,10 @@ |
47 | 47 | $wgHooks['ArticleFromTitle'][] = 'ApprovedRevsHooks::showApprovedRevision'; |
48 | 48 | $wgHooks['ArticleAfterFetchContent'][] = 'ApprovedRevsHooks::showBlankIfUnapproved'; |
49 | 49 | $wgHooks['DisplayOldSubtitle'][] = 'ApprovedRevsHooks::setSubtitle'; |
50 | | -$wgHooks['SkinTemplateNavigation'][] = 'ApprovedRevsHooks::changeEditLink'; |
| 50 | +// it's 'SkinTemplateNavigation' for the Vector skin, 'SkinTemplateTabs' for |
| 51 | +// most other skins |
| 52 | +$wgHooks['SkinTemplateTabs'][] = 'ApprovedRevsHooks::changeEditLink'; |
| 53 | +$wgHooks['SkinTemplateNavigation'][] = 'ApprovedRevsHooks::changeEditLinkVector'; |
51 | 54 | $wgHooks['PageHistoryBeforeList'][] = 'ApprovedRevsHooks::storeApprovedRevisionForHistoryPage'; |
52 | 55 | $wgHooks['PageHistoryLineEnding'][] = 'ApprovedRevsHooks::addApprovalLink'; |
53 | 56 | $wgHooks['UnknownAction'][] = 'ApprovedRevsHooks::setAsApproved'; |
— | — | @@ -58,6 +61,8 @@ |
59 | 62 | $wgHooks['ParserBeforeTidy'][] = 'ApprovedRevsHooks::handleMagicWords'; |
60 | 63 | $wgHooks['AdminLinks'][] = 'ApprovedRevsHooks::addToAdminLinks'; |
61 | 64 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ApprovedRevsHooks::describeDBSchema'; |
| 65 | +$wgHooks['EditPage::showEditForm:initial'][] = 'ApprovedRevsHooks::addWarningToEditPage'; |
| 66 | +$wgHooks['sfHTMLBeforeForm'][] = 'ApprovedRevsHooks::addWarningToSFForm'; |
62 | 67 | |
63 | 68 | // logging |
64 | 69 | $wgLogTypes['approval'] = 'approval'; |
Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php |
— | — | @@ -147,8 +147,46 @@ |
148 | 148 | $wgOut->setSubtitle( $text ); |
149 | 149 | return false; |
150 | 150 | } |
151 | | - |
| 151 | + |
152 | 152 | /** |
| 153 | + * Add a warning to the top of the 'edit' page if the approved |
| 154 | + * revision is not the same as the latest one, so that users don't |
| 155 | + * get confused, since they'll be seeing the latest one. |
| 156 | + */ |
| 157 | + public static function addWarningToEditPage( &$editPage ) { |
| 158 | + // only show the warning if it's not an old revision |
| 159 | + global $wgRequest; |
| 160 | + if ( $wgRequest->getCheck( 'oldid' ) ) { |
| 161 | + return true; |
| 162 | + } |
| 163 | + $title = $editPage->getArticle()->getTitle(); |
| 164 | + $approvedRevID = ApprovedRevs::getApprovedRevID( $title ); |
| 165 | + $latestRevID = $title->getLatestRevID(); |
| 166 | + if ( ! empty( $approvedRevID ) && $approvedRevID != $latestRevID ) { |
| 167 | + global $wgOut; |
| 168 | + $wgOut->addHTML( '<p><strong>' . wfMsg( 'approvedrevs-editwarning' ) . "</strong></p>\n" ); |
| 169 | + } |
| 170 | + return true; |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * Same as addWarningToEditPage(), but for the Semantic Foms |
| 175 | + * 'edit with form' tab |
| 176 | + */ |
| 177 | + public static function addWarningToSFForm( &$pageName, &$preFormHTML ) { |
| 178 | + // The title could be obtained via $pageName in theory - the |
| 179 | + // problem is that, pre-SF 2.0.2, that variable wasn't set |
| 180 | + // correctly. |
| 181 | + global $wgTitle; |
| 182 | + $approvedRevID = ApprovedRevs::getApprovedRevID( $wgTitle ); |
| 183 | + $latestRevID = $wgTitle->getLatestRevID(); |
| 184 | + if ( ! empty( $approvedRevID ) && $approvedRevID != $latestRevID ) { |
| 185 | + $preFormHTML .= '<p><strong>' . wfMsg( 'approvedrevs-editwarning' ) . "</strong></p>\n"; |
| 186 | + } |
| 187 | + return true; |
| 188 | + } |
| 189 | + |
| 190 | + /** |
153 | 191 | * If user is looking at a revision through a main 'view' URL (no |
154 | 192 | * revision specified), have the 'edit' tab link to the basic |
155 | 193 | * 'action=edit' URL (i.e., the latest revision), no matter which |
— | — | @@ -163,17 +201,28 @@ |
164 | 202 | // the URL is the same regardless of whether the tab |
165 | 203 | // is 'edit' or 'view source', but the "action" is |
166 | 204 | // different |
167 | | - if ( array_key_exists( 'edit', $contentActions['views'] ) ) { |
168 | | - $contentActions['views']['edit']['href'] = $skin->getTitle()->getLocalUrl( array( 'action' => 'edit' ) ); |
| 205 | + if ( array_key_exists( 'edit', $contentActions ) ) { |
| 206 | + $contentActions['edit']['href'] = $skin->getTitle()->getLocalUrl( array( 'action' => 'edit' ) ); |
169 | 207 | } |
170 | | - if ( array_key_exists( 'viewsource', $contentActions['views'] ) ) { |
171 | | - $contentActions['views']['viewsource']['href'] = $skin->getTitle()->getLocalUrl( array( 'action' => 'edit' ) ); |
| 208 | + if ( array_key_exists( 'viewsource', $contentActions ) ) { |
| 209 | + $contentActions['viewsource']['href'] = $skin->getTitle()->getLocalUrl( array( 'action' => 'edit' ) ); |
172 | 210 | } |
173 | 211 | } |
174 | 212 | return true; |
175 | 213 | } |
176 | 214 | |
177 | 215 | /** |
| 216 | + * Same as changedEditLink(), but only for the Vector skin (and |
| 217 | + * related skins). |
| 218 | + */ |
| 219 | + static function changeEditLinkVector( &$skin, &$links ) { |
| 220 | + // the old '$content_actions' array is thankfully just a |
| 221 | + // sub-array of this one |
| 222 | + self::changeEditLink( $skin, $links['views'] ); |
| 223 | + return true; |
| 224 | + } |
| 225 | + |
| 226 | + /** |
178 | 227 | * Store the approved revision ID, if any, directly in the object |
179 | 228 | * for this article - this is called so that a query to the database |
180 | 229 | * can be made just once for every view of a history page, instead |
— | — | @@ -321,7 +370,7 @@ |
322 | 371 | */ |
323 | 372 | static function setTranscludedPageRev( $parser, &$title, &$skip, &$id ) { |
324 | 373 | $revision_id = ApprovedRevs::getApprovedRevID( $title ); |
325 | | - if ( !is_null( $revision_id ) ) { |
| 374 | + if ( ! empty( $revision_id ) ) { |
326 | 375 | $id = $revision_id; |
327 | 376 | } |
328 | 377 | return true; |