Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -13,6 +13,7 @@ |
14 | 14 | private static $doOutput = false; |
15 | 15 | private static $messages = array(); |
16 | 16 | private static $variables = array(); |
| 17 | + private static $literalVariables = array(); |
17 | 18 | private static $styles = array(); |
18 | 19 | private static $styleFiles = array( |
19 | 20 | 'base_sets' => array( |
— | — | @@ -128,6 +129,14 @@ |
129 | 130 | self::$variables[$key] = |
130 | 131 | "var {$escapedVariableKey} = '{$escapedVariableValue}';"; |
131 | 132 | } |
| 133 | + |
| 134 | + //literal variables, ie ones we do not want escaped as strings |
| 135 | + foreach( self::$literalVariables as $key => $value){ |
| 136 | + $escapedVariableValue = Xml::escapeJsString( $value ); |
| 137 | + $escapedVariableKey = Xml::escapeJsString( $key ); |
| 138 | + self::$variables[$key] = |
| 139 | + "var {$escapedVariableKey} = {$escapedVariableValue};"; |
| 140 | + } |
132 | 141 | if ( count( self::$variables ) > 0 ) { |
133 | 142 | $out->addScript( |
134 | 143 | Xml::tags( |
— | — | @@ -216,11 +225,19 @@ |
217 | 226 | } |
218 | 227 | |
219 | 228 | /** |
220 | | - * Adds internationalized message definitions to the document for access |
221 | | - * via javascript using the gM() function |
222 | | - * @param array $messages Key names of messages to load |
| 229 | + * Adds variables that will be turned into global variables in JS |
| 230 | + * @param $variables array of "name" => "value" |
223 | 231 | */ |
224 | 232 | public static function addVariables( $variables ) { |
225 | 233 | self::$variables = array_merge( self::$variables, $variables ); |
226 | 234 | } |
| 235 | + |
| 236 | + /** |
| 237 | + * Adds variables that will be turned into global variables in JS, but not escaped as strings |
| 238 | + * @param $variables array of "name" => "value" |
| 239 | + */ |
| 240 | + public static function addLiteralVariables( $variables ) { |
| 241 | + self::$literalVariables = array_merge( self::$literalVariables, $variables ); |
| 242 | + } |
| 243 | + |
227 | 244 | } |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php |
— | — | @@ -0,0 +1,24 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Special:ClickTracking |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +class SpecialClickTracking extends SpecialPage { |
| 11 | + function __construct() { |
| 12 | + parent::__construct( 'ClickTracking' ); |
| 13 | + wfLoadExtensionMessages( 'ClickTracking' ); |
| 14 | + } |
| 15 | + |
| 16 | + function execute( $par ) { |
| 17 | + global $wgOut; |
| 18 | + $this->setHeaders(); |
| 19 | + $wgOut->setPageTitle( wfMsg( 'clicktracking-title' ) ); |
| 20 | + |
| 21 | + } |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +} |
\ No newline at end of file |
Property changes on: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 26 | + native |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -59,7 +59,11 @@ |
60 | 60 | UsabilityInitiativeHooks::addScript( 'ClickTracking/ClickTracking.js' ); |
61 | 61 | UsabilityInitiativeHooks::addVariables( |
62 | 62 | array( |
63 | | - 'wgTrackingToken' => ClickTrackingHooks::get_session_id(), |
| 63 | + 'wgTrackingToken' => ClickTrackingHooks::get_session_id() |
| 64 | + ) |
| 65 | + ); |
| 66 | + UsabilityInitiativeHooks::addLiteralVariables( |
| 67 | + array( |
64 | 68 | 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled() |
65 | 69 | ) |
66 | 70 | ); |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | (function($) { |
3 | 3 | |
4 | | - if(wgClickTrackingIsThrottled == 'false'){ |
| 4 | + if(!wgClickTrackingIsThrottled){ |
5 | 5 | // creates 'track action' function to call the clicktracking API and send the ID |
6 | 6 | $.trackAction = function ( id ){ |
7 | 7 | $j.post( wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken } ); |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.alias.php |
— | — | @@ -0,0 +1,13 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Special page aliases for Usability Initiative ClickTracking extension |
| 5 | + * |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
| 8 | + */ |
| 9 | + |
| 10 | +$aliases = array(); |
| 11 | + |
| 12 | +$aliases['en'] = array( |
| 13 | + 'ClickTracking' => array( 'ClickTracking' ), |
| 14 | +); |
Property changes on: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.alias.php |
___________________________________________________________________ |
Name: svn:eol-style |
1 | 15 | + native |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.i18n.php |
— | — | @@ -13,7 +13,8 @@ |
14 | 14 | */ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'clicktracking' => 'Usability Initiative click tracking', |
17 | | - 'clicktracking-desc' => 'Click tracking, intended for tracking events that do not cause a page refresh' |
| 17 | + 'clicktracking-desc' => 'Click tracking, intended for tracking events that do not cause a page refresh', |
| 18 | + 'clicktracking-title' => 'Aggregated user clicks' |
18 | 19 | ); |
19 | 20 | |
20 | 21 | /** Message documentation (Message documentation) |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php |
— | — | @@ -47,11 +47,22 @@ |
48 | 48 | $dir = dirname( __FILE__ ) . '/'; |
49 | 49 | $wgAutoloadClasses['ClickTrackingHooks'] = $dir . 'ClickTracking.hooks.php'; |
50 | 50 | $wgAutoloadClasses['ApiClickTracking'] = $dir . 'ApiClickTracking.php'; |
| 51 | +$wgAutoloadClasses['SpecialClickTracking'] = $dir . 'SpecialClickTracking.php'; |
51 | 52 | |
| 53 | + |
52 | 54 | // Hooked functions |
53 | 55 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema'; |
54 | 56 | $wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::storeNewContrib'; |
55 | 57 | $wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS'; |
56 | 58 | |
57 | 59 | // Set up the new API module |
58 | | -$wgAPIModules['clicktracking'] = 'ApiClickTracking'; |
\ No newline at end of file |
| 60 | +$wgAPIModules['clicktracking'] = 'ApiClickTracking'; |
| 61 | + |
| 62 | +//Special page setup |
| 63 | +$wgSpecialPages['ClickTracking'] = 'SpecialClickTracking'; |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | +// Adds Internationalized Messages |
| 68 | +$wgExtensionMessagesFiles['ClickTracking'] = $dir . 'ClickTracking.i18n.php'; |
| 69 | +$wgExtensionAliasesFiles['ClickTracking'] = $dir . 'ClickTracking.alias.php'; |
\ No newline at end of file |