r111521 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111520‎ | r111521 | r111522 >
Date:01:54, 15 February 2012
Author:bsitu
Status:ok
Tags:
Comment:
Adding clickTracking for articles created from Article Creation Workflow
Modified paths:
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php (modified) (history)
  • /trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationUtil.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ArticleCreationWorkflow/includes/ArticleCreationUtil.php
@@ -66,7 +66,19 @@
6767
6868 self::clickTracking( $event, Title::newFromText( $par ) );
6969 }
 70+
 71+ /**
 72+ * Track pages created from article creation
 73+ * @param $title Title
 74+ */
 75+ public static function TrackCompleteSave( $title ) {
 76+ global $wgRequest;
7077
 78+ if ( $wgRequest->getVal( 'fromacw' ) ) {
 79+ self::clickTracking( 'created-from-article-creation', $title );
 80+ }
 81+ }
 82+
7183 /**
7284 * Tracking code that calls ClickTracking
7385 * @param $event string the event name
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php
@@ -29,6 +29,8 @@
3030 $wgHooks['BeforeWelcomeCreation'][] = 'ArticleCreationHooks::BeforeWelcomeCreation';
3131 $wgHooks['AlternateEdit'][] = 'ArticleCreationHooks::AlternateEdit';
3232 $wgHooks['SpecialSearchCreateLink'][] = 'ArticleCreationHooks::SpecialSearchCreateLink';
 33+$wgHooks['EditPage::showEditForm:fields'][] = 'ArticleCreationHooks::pushTrackingFieldsToEdit';
 34+$wgHooks['ArticleSaveComplete'][] = 'ArticleCreationHooks::trackEditSuccess';
3335
3436 $wgHooks['ResourceLoaderGetConfigVars'][] = 'ArticleCreationHooks::resourceLoaderGetConfigVars';
3537
@@ -168,8 +170,8 @@
169171
170172 $wgArticleCreationConfig = array(
171173 'action-url' => array(
172 - 'draft' => '{{SCRIPT}}?title=User:{{USER}}/{{PAGE}}&action=edit',
173 - 'create' => '{{SCRIPT}}?title={{PAGE}}&action=edit',
 174+ 'draft' => '{{SCRIPT}}?title=User:{{USER}}/{{PAGE}}&action=edit&fromacw=1',
 175+ 'create' => '{{SCRIPT}}?title={{PAGE}}&action=edit&fromacw=1',
174176 'login' => '{{SCRIPT}}?title=Special:Userlogin&returnto=Special:ArticleCreationLanding/{{PAGE}}&returntoquery=' . urlencode( 'fromlogin=1' ),
175177 'signup' => '{{SCRIPT}}?title=Special:Userlogin/signup&returnto=Special:ArticleCreationLanding/{{PAGE}}&returntoquery=' . urlencode( 'fromsignup=1' ),
176178 'request' => 'http://google.com/?q={{PAGE}}'
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php
@@ -93,4 +93,44 @@
9494 return true;
9595 }
9696
 97+ /**
 98+ * Pushes the tracking fields into the edit page
 99+ * @see http://www.mediawiki.org/wiki/Manual:Hooks/EditPage::showEditForm:fields
 100+ * @param $editPage EditPage
 101+ * @param $output OutputPage
 102+ * @return bool
 103+ */
 104+ public static function pushTrackingFieldsToEdit( $editPage, $output ) {
 105+ $fromacw = $output->getRequest()->getVal( 'fromacw' );
 106+
 107+ if ( $fromacw ) {
 108+ $editPage->editFormTextAfterContent .= Html::hidden( 'fromacw', '1' );
 109+ }
 110+
 111+ return true;
 112+ }
 113+
 114+ /**
 115+ * Tracks successful edits
 116+ *
 117+ * @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleSaveComplete
 118+ * @param $article WikiPage
 119+ * @param $user
 120+ * @param $text
 121+ * @param $summary
 122+ * @param $minoredit
 123+ * @param $watchthis
 124+ * @param $sectionanchor
 125+ * @param $flags
 126+ * @param $revision
 127+ * @param $status
 128+ * @param $baseRevId
 129+ * @return bool
 130+ */
 131+ public static function trackEditSuccess( &$article, &$user, $text,
 132+ $summary, $minoredit, $watchthis, $sectionanchor, &$flags,
 133+ $revision, &$status, $baseRevId /*, &$redirect */ ) { // $redirect not passed in 1.18wmf1
 134+ ArticleCreationUtil::trackCompleteSave( $article->getTitle() );
 135+ return true;
 136+ }
97137 }

Status & tagging log