Index: trunk/extensions/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -152,4 +152,48 @@ |
153 | 153 | $dbw->commit(); |
154 | 154 | return $db_status; |
155 | 155 | } |
| 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 | + } |
156 | 200 | } |
Index: trunk/extensions/ClickTracking/ClickTracking.php |
— | — | @@ -50,6 +50,10 @@ |
51 | 51 | $wgHooks['MakeGlobalVariablesScript'][] = 'ClickTrackingHooks::makeGlobalVariablesScript'; |
52 | 52 | $wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables'; |
53 | 53 | |
| 54 | +$wgHooks['EditPage::showEditForm:fields'][] = 'ClickTrackingHooks::editPageShowEditFormFields'; |
| 55 | +$wgHooks['ArticleSave'][] = 'ClickTrackingHooks::articleSave'; |
| 56 | +$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::articleSaveComplete'; |
| 57 | + |
54 | 58 | // API modules |
55 | 59 | $wgAPIModules['clicktracking'] = 'ApiClickTracking'; |
56 | 60 | $wgAPIModules['specialclicktracking'] = 'ApiSpecialClickTracking'; |