r111589 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111588‎ | r111589 | r111590 >
Date:22:41, 15 February 2012
Author:bsitu
Status:ok
Tags:
Comment:
add clickTracking to save attempt, remove redundant functions and add comments
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,25 +66,13 @@
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;
7770
78 - if ( $wgRequest->getVal( 'fromacw' ) ) {
79 - self::clickTracking( 'created-from-article-creation', $title );
80 - }
81 - }
82 -
8371 /**
8472 * Tracking code that calls ClickTracking
8573 * @param $event string the event name
8674 * @param $title Object
8775 */
88 - private static function clickTracking( $event, $title ) {
 76+ public static function clickTracking( $event, $title ) {
8977 // check if ClickTracking API is enabled
9078 if ( !self::trackingEnabled() ) {
9179 return;
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.php
@@ -31,6 +31,7 @@
3232 $wgHooks['SpecialSearchCreateLink'][] = 'ArticleCreationHooks::SpecialSearchCreateLink';
3333 $wgHooks['EditPage::showEditForm:fields'][] = 'ArticleCreationHooks::pushTrackingFieldsToEdit';
3434 $wgHooks['ArticleSaveComplete'][] = 'ArticleCreationHooks::trackEditSuccess';
 35+$wgHooks['EditPage::attemptSave'][] = 'ArticleCreationHooks::trackEditAttempt';
3536
3637 $wgHooks['ResourceLoaderGetConfigVars'][] = 'ArticleCreationHooks::resourceLoaderGetConfigVars';
3738
Index: trunk/extensions/ArticleCreationWorkflow/ArticleCreationWorkflow.hooks.php
@@ -6,6 +6,7 @@
77 * Redirect users to a page specified by returnto upon successful account creation
88 * @param $welcome_creation_msg - string
99 * @param $injected_html - html string
 10+ * @return bool
1011 */
1112 public static function BeforeWelcomeCreation( &$welcome_creation_msg, &$injected_html ) {
1213 global $wgRequest, $wgOut;
@@ -26,7 +27,8 @@
2728
2829 /**
2930 * If the edit page is coming from red link, redirect users to article-non-existing page
30 - * @param $editPage - Object
 31+ * @param $editPage EditPage
 32+ * @return bool
3133 */
3234 public static function AlternateEdit( $editPage ) {
3335 global $wgRequest, $wgOut;
@@ -46,6 +48,8 @@
4749
4850 /**
4951 * Customized html that shows an article doesn't exist
 52+ * @param $article Article
 53+ * @return bool
5054 */
5155 public static function BeforeDisplayNoArticleText( $article ) {
5256 global $wgOut;
@@ -80,6 +84,9 @@
8185
8286 /**
8387 * Alter 'Create' Link behavior in search result page
 88+ * @param $title Title
 89+ * @param $params array
 90+ * @return bool
8491 */
8592 public static function SpecialSearchCreateLink( $title, &$params ) {
8693 global $wgOut, $wgHooks;
@@ -109,9 +116,9 @@
110117
111118 return true;
112119 }
113 -
 120+
114121 /**
115 - * Tracks successful edits
 122+ * Tracks successful save from article creation workflow
116123 *
117124 * @see http://www.mediawiki.org/wiki/Manual:Hooks/ArticleSaveComplete
118125 * @param $article WikiPage
@@ -130,7 +137,30 @@
131138 public static function trackEditSuccess( &$article, &$user, $text,
132139 $summary, $minoredit, $watchthis, $sectionanchor, &$flags,
133140 $revision, &$status, $baseRevId /*, &$redirect */ ) { // $redirect not passed in 1.18wmf1
134 - ArticleCreationUtil::trackCompleteSave( $article->getTitle() );
 141+
 142+ global $wgRequest;
 143+
 144+ if ( $wgRequest->getVal( 'fromacw' ) ) {
 145+ ArticleCreationUtil::clickTracking( 'created-from-article-creation', $article->getTitle() );
 146+ }
 147+
135148 return true;
136149 }
 150+
 151+ /**
 152+ * Tracks save attempt from article creation workflow
 153+ *
 154+ * @see http://www.mediawiki.org/wiki/Manual:Hooks/EditPage::attemptSave
 155+ * @param $editpage EditPage
 156+ * @return bool
 157+ */
 158+ public static function trackEditAttempt( $editpage ) {
 159+ global $wgRequest;
 160+
 161+ if ( $wgRequest->getVal( 'fromacw' ) ) {
 162+ ArticleCreationUtil::clickTracking( 'attempt-save-from-article-creation', $editpage->getArticle()->getTitle() );
 163+ }
 164+
 165+ return true;
 166+ }
137167 }

Status & tagging log