r83548 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83547‎ | r83548 | r83549 >
Date:22:01, 8 March 2011
Author:tparscal
Status:ok
Tags:
Comment:
Added edit tracking
* If clicktrackingsession and clicktrackingevent are detected in the edit page URL, hidden form fields are shown
* If clicktrackingsession and clicktrackingevent are detected in an edit page save, click tracking logs it
Modified paths:
  • /trunk/extensions/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/ClickTracking/ClickTracking.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php
@@ -152,4 +152,48 @@
153153 $dbw->commit();
154154 return $db_status;
155155 }
 156+
 157+ public static function editPageShowEditFormFields( $editPage, $output ) {
 158+ global $wgRequest;
 159+
 160+ // Add clicktracking fields to form, if given
 161+ $session = $wgRequest->getVal( 'clicktrackingsession' );
 162+ $event = $wgRequest->getVal( 'clicktrackingevent' );
 163+ if ( $session !== null && $event !== null ) {
 164+ $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingsession', $session );
 165+ $editPage->editFormTextAfterContent .= Html::hidden( 'clicktrackingevent', $event );
 166+ }
 167+
 168+ return true;
 169+ }
 170+
 171+ public static function articleSave( $editpage ) {
 172+ self::trackRequest( 'save-attempt' );
 173+ return true;
 174+ }
 175+
 176+ public static function articleSaveComplete( $article, $user, $text, $summary, $minoredit,
 177+ $watchthis, $sectionanchor, $flags, $revision, $status, $baseRevId, $redirect ) {
 178+ self::trackRequest( 'save-complete' );
 179+ return true;
 180+ }
 181+
 182+ protected static function trackRequest( $info ) {
 183+ global $wgRequest;
 184+
 185+ $session = $wgRequest->getVal( 'clicktrackingsession' );
 186+ $event = $wgRequest->getVal( 'clicktrackingevent' );
 187+ if ( $session !== null && $event !== null ) {
 188+ $params = new FauxRequest( array(
 189+ 'action' => 'clicktracking',
 190+ 'eventid' => $event,
 191+ 'token' => $session,
 192+ 'additional' => $info,
 193+ ) );
 194+ $api = new ApiMain( $params, true );
 195+ $api->execute();
 196+ }
 197+
 198+ return true;
 199+ }
156200 }
Index: trunk/extensions/ClickTracking/ClickTracking.php
@@ -50,6 +50,10 @@
5151 $wgHooks['MakeGlobalVariablesScript'][] = 'ClickTrackingHooks::makeGlobalVariablesScript';
5252 $wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables';
5353
 54+$wgHooks['EditPage::showEditForm:fields'][] = 'ClickTrackingHooks::editPageShowEditFormFields';
 55+$wgHooks['ArticleSave'][] = 'ClickTrackingHooks::articleSave';
 56+$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::articleSaveComplete';
 57+
5458 // API modules
5559 $wgAPIModules['clicktracking'] = 'ApiClickTracking';
5660 $wgAPIModules['specialclicktracking'] = 'ApiSpecialClickTracking';

Follow-up revisions

RevisionCommit summaryAuthorDate
r836001.17wmf1: Merge Vector edit section links module plus required ClickTracking ...catrope18:55, 9 March 2011

Status & tagging log