http://www.mediawiki.org/wiki/Special:Code/MediaWiki/83600
Revision: 83600 Author: catrope Date: 2011-03-09 18:55:54 +0000 (Wed, 09 Mar 2011) Log Message: ----------- 1.17wmf1: Merge Vector edit section links module plus required ClickTracking changes: r83056, r83057, r83226, r83546, r83547, r83548, r83560 Modified Paths: -------------- branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php branches/wmf/1.17wmf1/extensions/Vector/Vector.php Added Paths: ----------- branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit-faded.png branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit.png Modified: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php =================================================================== --- branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php 2011-03-09 18:28:09 UTC (rev 83599) +++ branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.hooks.php 2011-03-09 18:55:54 UTC (rev 83600) @@ -152,4 +152,48 @@ $dbw->commit(); return $db_status; } + + public static function editPageShowEditFormFields( $editPage, $output ) { + global $wgRequest; + + // Add clicktracking fields to form, if given + $session = $wgRequest->getVal( 'clicktrackingsession' ); + $event = $wgRequest->getVal( 'clicktrackingevent' ); + if ( $session !== null && $event !== null ) { + $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingsession', $session ); + $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingevent', $event ); + } + + return true; + } + + public static function articleSave( $editpage ) { + self::trackRequest( 'save-attempt' ); + return true; + } + + public static function articleSaveComplete( $article, $user, $text, $summary, $minoredit, + $watchthis, $sectionanchor, $flags, $revision, $status, $baseRevId, $redirect ) { + self::trackRequest( 'save-complete' ); + return true; + } + + protected static function trackRequest( $info ) { + global $wgRequest; + + $session = $wgRequest->getVal( 'clicktrackingsession' ); + $event = $wgRequest->getVal( 'clicktrackingevent' ); + if ( $session !== null && $event !== null ) { + $params = new FauxRequest( array( + 'action' => 'clicktracking', + 'eventid' => $event, + 'token' => $session, + 'additional' => $info, + ) ); + $api = new ApiMain( $params, true ); + $api->execute(); + } + + return true; + } } Modified: branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php =================================================================== --- branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php 2011-03-09 18:28:09 UTC (rev 83599) +++ branches/wmf/1.17wmf1/extensions/ClickTracking/ClickTracking.php 2011-03-09 18:55:54 UTC (rev 83600) @@ -50,6 +50,10 @@ $wgHooks['MakeGlobalVariablesScript'][] = 'ClickTrackingHooks::makeGlobalVariablesScript'; $wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables'; +$wgHooks['EditPage::showEditForm:fields'][] = 'ClickTrackingHooks::editPageShowEditFormFields'; +$wgHooks['ArticleSave'][] = 'ClickTrackingHooks::articleSave'; +$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::articleSaveComplete'; + // API modules $wgAPIModules['clicktracking'] = 'ApiClickTracking'; $wgAPIModules['specialclicktracking'] = 'ApiSpecialClickTracking'; Modified: branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php =================================================================== --- branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php 2011-03-09 18:28:09 UTC (rev 83599) +++ branches/wmf/1.17wmf1/extensions/Vector/Vector.hooks.php 2011-03-09 18:55:54 UTC (rev 83600) @@ -52,10 +52,29 @@ 'footercleanup' => array( 'modules' => array( 'ext.vector.footerCleanup' ), ), + 'sectioneditlinks' => array( + 'modules' => array( 'ext.vector.sectionEditLinks' ), + 'configurations' => array( + 'wgVectorSectionEditLinksBucketTest', + 'wgVectorSectionEditLinksLotteryOdds', + ), + 'requirements' => array( + 'vector-noexperiments' => false, + ), + ), 'simplesearch' => array( 'requirements' => array( 'vector-simplesearch' => true, 'disablesuggest' => false ), 'modules' => array( 'ext.vector.simpleSearch' ), ), + 'experiments' => array( + 'preferences' => array( + 'vector-noexperiments' => array( + 'type' => 'toggle', + 'label-message' => 'vector-noexperiments-preference', + 'section' => 'rendering/advancedrendering', + ), + ), + ), ); /* Protected Static Methods */ Modified: branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php =================================================================== --- branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php 2011-03-09 18:28:09 UTC (rev 83599) +++ branches/wmf/1.17wmf1/extensions/Vector/Vector.i18n.php 2011-03-09 18:55:54 UTC (rev 83600) @@ -21,6 +21,7 @@ 'vector-editwarning-preference' => 'Warn me when I leave an edit page with unsaved changes', 'vector-simplesearch-search' => 'Search', 'vector-simplesearch-containing' => 'containing...', + 'vector-noexperiments-preference' => 'Exclude me from feature experiments', ); /** Message documentation (Message documentation) Modified: branches/wmf/1.17wmf1/extensions/Vector/Vector.php =================================================================== --- branches/wmf/1.17wmf1/extensions/Vector/Vector.php 2011-03-09 18:28:09 UTC (rev 83599) +++ branches/wmf/1.17wmf1/extensions/Vector/Vector.php 2011-03-09 18:55:54 UTC (rev 83600) @@ -22,6 +22,7 @@ 'editwarning' => array( 'global' => false, 'user' => true ), 'expandablesearch' => array( 'global' => false, 'user' => false ), 'footercleanup' => array( 'global' => false, 'user' => false ), + 'sectioneditlinks' => array( 'global' => false, 'user' => false ), 'simplesearch' => array( 'global' => false, 'user' => true ), ); @@ -33,6 +34,12 @@ // Force the new version $wgCollapsibleNavForceNewVersion = false; +// Enable bucket testing for new version of section edit links +$wgVectorSectionEditLinksBucketTest = false; +// Percentage of users who's use of section edit links will be tracked - half of which will see the +// new section edit links - default 5% +$wgVectorSectionEditLinksLotteryOdds = 5; + /* Setup */ $wgExtensionCredits['other'][] = array( @@ -93,6 +100,13 @@ 'scripts' => 'ext.vector.footerCleanup.js', 'styles' => 'ext.vector.footerCleanup.css', ), + 'ext.vector.sectionEditLinks' => $vectorResourceTemplate + array( + 'scripts' => 'ext.vector.sectionEditLinks.js', + 'styles' => 'ext.vector.sectionEditLinks.css', + 'dependencies' => array( + 'jquery.cookie', + ), + ), 'ext.vector.simpleSearch' => $vectorResourceTemplate + array( 'scripts' => 'ext.vector.simpleSearch.js', 'messages' => array( Copied: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css (from rev 83056, trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.css) =================================================================== --- branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css (rev 0) +++ branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.css 2011-03-09 18:55:54 UTC (rev 83600) @@ -0,0 +1,13 @@ +span.vector-editLink { + float: none; + display: inline-block; +} +span.vector-editLink a { + padding-left: 18px; + background-image: url(images/edit-faded.png); + background-position: left top; + background-repeat: no-repeat; +} +span.vector-editLink a:hover { + background-image: url(images/edit.png); +} Copied: branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js (from rev 83056, trunk/extensions/Vector/modules/ext.vector.sectionEditLinks.js) =================================================================== --- branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js (rev 0) +++ branches/wmf/1.17wmf1/extensions/Vector/modules/ext.vector.sectionEditLinks.js 2011-03-09 18:55:54 UTC (rev 83600) @@ -0,0 +1,64 @@ +/* + * Section Edit Links for Vector + */ +( function( $, mw ) { + +if ( mw.config.get( 'wgVectorSectionEditLinksBucketTest', false ) ) { + var bucket = $.cookie( 'ext.vector.sectionEditLinks-bucket' ); + if ( bucket === null ) { + // Percentage chance of being tracked + var odds = Math.min( 100, Math.max( 0, + Number( mw.config.get( 'wgVectorSectionEditLinksLotteryOdds', 0 ) ) + ) ); + // 0 = not tracked, 1 = tracked with old version, 2 = tracked with new version + bucket = ( Math.random() * 100 ) < odds ? Number( Math.random() < 0.5 ) + 1 : 0; + $.cookie( 'ext.vector.sectionEditLinks-bucket', bucket ); + // If we are going to track this person from now on, let's also track which bucket we put + // them into and when + if ( bucket > 0 && 'trackActionWithInfo' in $ ) { + $.trackActionWithInfo( 'ext.vector.sectionEditLinks-bucket', bucket ); + } + } +} +if ( bucket ) { + // Transform the targets of section edit links to route through the click tracking API + $( 'span.editsection a' ).each( function() { + var session = $.cookie( 'clicktracking-session' ); + var editUrl = $( this ).attr( 'href' ); + editUrl += ( editUrl.indexOf( '?' ) >= 0 ? '&' : '?' ) + $.param( { + 'clicktrackingsession': session, + 'clicktrackingevent': 'ext.vector.sectionEditLinks-bucket' + bucket + '-save' + } ); + $(this).attr( 'href', mediaWiki.config.get( 'wgScriptPath' ) + '/api.php?' + $.param( { + 'action': 'clicktracking', + 'eventid': 'ext.vector.sectionEditLinks-bucket' + bucket + '-click', + 'token': session, + 'redirectto': editUrl + } ) ); + } ); + if ( bucket == 2 ) { + // Move the link over to be next to the heading text and style it with an icon + $( 'span.mw-headline' ).each( function() { + $(this) + .after( + $( '<span class="editsection vector-editLink"></span>' ) + .append( + $(this) + .prev( 'span.editsection' ) + .find( 'a' ) + .each( function() { + var text = $(this).text(); + $(this).text( + text.substr( 0, 1 ).toUpperCase() + text.substr( 1 ) + ); + } ) + .detach() + ) + ) + .prev( 'span.editsection' ) + .remove(); + } ); + } +} + +} )( jQuery, mediaWiki ); Copied: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit-faded.png (from rev 83057, trunk/extensions/Vector/modules/images/edit-faded.png) =================================================================== (Binary files differ) Copied: branches/wmf/1.17wmf1/extensions/Vector/modules/images/edit.png (from rev 83057, trunk/extensions/Vector/modules/images/edit.png) =================================================================== (Binary files differ) _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs