Awight has uploaded a new change for review. https://gerrit.wikimedia.org/r/195094
Change subject: WIP Start work on "detach" ...................................................................... WIP Start work on "detach" Change-Id: I4653a328d5fe3c6cd06a9fd6a91d4c9376133fb1 --- M Nonlinear.hooks.php M Nonlinear.php 2 files changed, 40 insertions(+), 9 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Nonlinear refs/changes/94/195094/1 diff --git a/Nonlinear.hooks.php b/Nonlinear.hooks.php index 148afe4..f64a3c4 100644 --- a/Nonlinear.hooks.php +++ b/Nonlinear.hooks.php @@ -1,8 +1,11 @@ <?php namespace Nonlinear; +use \Linker; +use \Revision; + class Hooks { - static function onAlternateEdit( $page ) { + public static function onAlternateEdit( $page ) { global $wgRequest; if ( $wgRequest->getVal( 'wpDraft' ) ) { @@ -11,7 +14,7 @@ return true; } - static function onShowEditFormInitial( &$page, &$out ) { + public static function onShowEditFormInitial( &$page, &$out ) { global $wgRequest; if ( $wgRequest->getVal( 'wpDraft' ) ) { @@ -29,7 +32,7 @@ return true; } - static function onEditPageBeforeEditButtons( &$page, &$buttons, &$tabindex ) { + public static function onEditPageBeforeEditButtons( &$page, &$buttons, &$tabindex ) { // TODO: core hook to check "will otherwise go live" condition. If not, then override the "save" functionality by branching /* if ( is_callable( '\\FlaggablePageView::singleton' ) ) { @@ -51,17 +54,17 @@ return true; } - static function onGetQueryInfo( $pager, &$queryInfo ) { + public static function onGetQueryInfo( $pager, &$queryInfo ) { BranchStore::alterPageHistoryQuery( $queryInfo ); return true; } - static function onPageHistoryLineEnding( $pager, $row, &$summary, $classes ) { + public static function onPageHistoryLineEnding( $pager, $row, &$summary, $classes ) { $summary = \Xml::wrapClass( $row->branch_name, "branch-label" ) . $summary; return true; } - static function onRevisionInsertComplete( $revision, $data, $flags ) { + public static function onRevisionInsertComplete( $revision, $data, $flags ) { $parentRevision = \Revision::newFromId( $revision->getParentId() ); if ( $parentRevision ) { $parentBranch = Branch::find( $parentRevision ); @@ -75,16 +78,42 @@ return true; } - static function addUi( $page, $skin ) { + public static function addUi( $page, $skin ) { if ( $page->getRequest()->getVal( 'action' ) === 'history' ) { $page->addModules( 'ext.nonlinear.historyPage.ui' ); } return true; } - static function onLoadExtensionSchemaUpdates( \DatabaseUpdater $du ) { + public static function onLoadExtensionSchemaUpdates( \DatabaseUpdater $du ) { $du->addExtensionUpdate( array( 'addTable', 'nonlinear_branch', __DIR__ . "/schema/install.sql", true ) ); return true; } + + public static function onHistoryRevisionTools( Revision $rev, &$tools ) { + # TODO: Determine whether the feature is enabled. + + $prevRev = $rev->getPrevious(); + + # TODO: We can probably do something about deleted, as well. + if ( !$rev->isDeleted( Revision::DELETED_TEXT ) + && $prevRev && !$prevRev->isDeleted( Revision::DELETED_TEXT ) + ) { + # TODO: Create tooltip for the first (=latest) line only + $tooltip = array( 'title' => wfMessage( 'tooltip-detach' )->text() ); + $detachLink = Linker::linkKnown( + $rev->getTitle(), + wfMessage( 'editdetach' )->escaped(), + $tooltip, + array( + 'action' => 'detach', + 'undoafter' => $prevRev->getId(), + 'undo' => $rev->getId() + ) + ); + + $tools[] = "<span class=\"mw-history-detach\">{$detachLink}</span>"; + } + } } diff --git a/Nonlinear.php b/Nonlinear.php index ff903fd..de4c547 100644 --- a/Nonlinear.php +++ b/Nonlinear.php @@ -11,7 +11,7 @@ 'author' => array( 'Adam Wight', ), - 'version' => '0.2.0', + 'version' => '0.3.0', 'url' => 'https://www.mediawiki.org/wiki/Extension:Nonlinear', 'descriptionmsg' => 'nonlinear-desc', ); @@ -24,6 +24,8 @@ $wgHooks['PageHistoryPager::getQueryInfo'][] = 'Nonlinear\Hooks::onGetQueryInfo'; $wgHooks['PageHistoryLineEnding'][] = 'Nonlinear\Hooks::onPageHistoryLineEnding'; +$wgHooks['HistoryRevisionTools'][] = 'Nonlinear\Hooks::onHistoryRevisionTools'; + // Disable "Save Draft" stuff for now if ( false ) { $wgHooks['AlternateEdit'][] = 'Nonlinear\Hooks::onAlternateEdit'; -- To view, visit https://gerrit.wikimedia.org/r/195094 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4653a328d5fe3c6cd06a9fd6a91d4c9376133fb1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Nonlinear Gerrit-Branch: master Gerrit-Owner: Awight <awi...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits