Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php |
— | — | @@ -12,10 +12,9 @@ |
13 | 13 | private $top_results = 10; |
14 | 14 | private $normalize_top_results = false; |
15 | 15 | private $normalize_results = false; |
16 | | - private $minimum_date = '20090815'; //YYYYMMDD (+1 for today) |
17 | 16 | private $end_timeframe = '20090902'; |
| 17 | + private static $minimum_date = '20090815'; //YYYYMMDD (+1 for today) |
18 | 18 | |
19 | | - |
20 | 19 | private static $userTypes = array("basic" => 0, "intermediate" => 1, "expert" => 2); |
21 | 20 | private $user_defs = array(); |
22 | 21 | |
— | — | @@ -137,7 +136,7 @@ |
138 | 137 | //$wgOut->addHTML($this->buildControlBox()); |
139 | 138 | |
140 | 139 | $wgOut->addHTML($this->buildChartDialog()); |
141 | | - $wgOut->addHTML($this->buildUserDefDialog()); |
| 140 | + $wgOut->addHTML($this->buildUserDefBlankDialog()); |
142 | 141 | |
143 | 142 | } |
144 | 143 | |
— | — | @@ -236,6 +235,80 @@ |
237 | 236 | } |
238 | 237 | |
239 | 238 | |
| 239 | + function buildUserDefBlankDialog(){ |
| 240 | + $control = ""; |
| 241 | + $control .= Xml::openElement("div", array("id" => "user_def_dialog", "class" => "dialog")); |
| 242 | + |
| 243 | + //currently editing...----| |
| 244 | + $control .= Xml::openElement("form", array("id" => "user_definition_form", "class" => "user_def_form")); |
| 245 | + $control .= Xml::openElement("fieldset", array("id" => "user_def_alter_fieldset")); |
| 246 | + $control .= Xml::openElement("legend", array("id" => "user_def_alter_legend")); |
| 247 | + $control .= wfMsg( "editing" ); |
| 248 | + $control .= Xml::closeElement("legend"); |
| 249 | + |
| 250 | + //[] anonymous users? |
| 251 | + $control .= Xml::openElement("div", array("id" => "anon_users_div", "class" => "checkbox_div control_div")); |
| 252 | + $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "anon_users_checkbox", "class" => "user_def_checkbox")); |
| 253 | + $control .= Xml::closeElement("input"); |
| 254 | + $control .= wfMsg("anon-users"); |
| 255 | + $control .= Xml::closeElement("div"); |
| 256 | + |
| 257 | + // ---------------- |
| 258 | + $control .= Xml::openElement("hr"); |
| 259 | + $control .= Xml::closeElement("hr"); |
| 260 | + $control .= Xml::openElement("div", array("id" => "contrib_opts_container")); |
| 261 | + |
| 262 | + // [] users with contributions [>=V] [n ] |
| 263 | + $control .= Xml::openElement("div", array("id" => "total_users_contrib_div", "class" => "checkbox_div control_div")); |
| 264 | + $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_checkbox", "class" => "user_def_checkbox")); |
| 265 | + $control .= Xml::closeElement("input"); |
| 266 | + $control .= wfMsg("user-contribs"); |
| 267 | + |
| 268 | + |
| 269 | + $control .= Xml::closeElement("div"); |
| 270 | + |
| 271 | + // [] contributions in timespan 1 |
| 272 | + $control .= Xml::openElement("div", array("id" => "contrib_span_1_div", "class" => "checkbox_div control_div")); |
| 273 | + |
| 274 | + $control .= Xml::openElement("div", array("id" => "contrib_span_1_text_div", "class" => "checkbox_div")); |
| 275 | + $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_1_checkbox", "class" => "user_def_checkbox")); |
| 276 | + $control .= Xml::closeElement("input"); |
| 277 | + $control .= wfMsg("user-span") . " 1"; |
| 278 | + $control .= Xml::closeElement("div"); |
| 279 | + $control .= Xml::closeElement("div"); |
| 280 | + |
| 281 | + // [] contributions in timespan 2 |
| 282 | + $control .= Xml::openElement("div", array("id" => "contrib_span_2_div", "class" => "checkbox_div control_div")); |
| 283 | + |
| 284 | + $control .= Xml::openElement("div", array("id" => "contrib_span_2_text_div", "class" => "checkbox_div")); |
| 285 | + $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_2_checkbox", "class" => "user_def_checkbox")); |
| 286 | + $control .= Xml::closeElement("input"); |
| 287 | + $control .= wfMsg("user-span") . " 2"; |
| 288 | + $control .= Xml::closeElement("div"); |
| 289 | + $control .= Xml::closeElement("div"); |
| 290 | + |
| 291 | + // [] contributions in timespan 3 |
| 292 | + $control .= Xml::openElement("div", array("id" => "contrib_span_3_div", "class" => "checkbox_div control_div")); |
| 293 | + |
| 294 | + $control .= Xml::openElement("div", array("id" => "contrib_span_3_text_div", "class" => "checkbox_div")); |
| 295 | + $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_3_checkbox", "class" => "user_def_checkbox")); |
| 296 | + $control .= Xml::closeElement("input"); |
| 297 | + $control .= wfMsg("user-span") . " 3"; |
| 298 | + $control .= Xml::closeElement("div"); |
| 299 | + $control .= Xml::closeElement("div"); |
| 300 | + |
| 301 | + |
| 302 | + |
| 303 | + |
| 304 | + $control .= Xml::closeElement("div");//close contrib opts |
| 305 | + |
| 306 | + $control .= Xml::closeElement("fieldset"); |
| 307 | + $control .= Xml::closeElement("form"); |
| 308 | + $control .= Xml::closeElement("div"); |
| 309 | + return $control; |
| 310 | + } |
| 311 | + |
| 312 | + |
240 | 313 | function buildUserDefDialog(){ |
241 | 314 | $control = ""; |
242 | 315 | $control .= Xml::openElement("div", array("id" => "user_def_dialog", "class" => "dialog")); |
— | — | @@ -385,7 +458,7 @@ |
386 | 459 | $control .= Xml::closeElement("td"); |
387 | 460 | |
388 | 461 | $control .= Xml::openElement("td", array("id" => "start_date_textarea")); |
389 | | - $control .= Xml::openElement("input", array("type" => "text", "id" => "start_date", "class" => "date_range_input")); |
| 462 | + $control .= Xml::openElement("input", array("type" => "text", "id" => "start_date", "class" => "date_range_input", "value" => self::$minimum_date)); |
390 | 463 | $control .= Xml::closeElement("input"); |
391 | 464 | $control .= Xml::closeElement("td"); |
392 | 465 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -30,8 +30,17 @@ |
31 | 31 | return true; |
32 | 32 | } |
33 | 33 | |
| 34 | + /** |
| 35 | + * Make sure the table exists for parser tests |
| 36 | + * @param $tables |
| 37 | + * @return unknown_type |
| 38 | + */ |
| 39 | + public static function parserTestTables( &$tables ) { |
| 40 | + $tables[] = 'click_tracking'; |
| 41 | + $tables[] = 'click_tracking_events'; |
| 42 | + return true; |
| 43 | + } |
34 | 44 | |
35 | | - |
36 | 45 | /* |
37 | 46 | * check to see if user is throttled |
38 | 47 | */ |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.js |
— | — | @@ -1,9 +1,35 @@ |
2 | 2 | (function($) { |
| 3 | + /* Very limited JSON encoder */ |
| 4 | + $.json_encode = function (js_obj){ |
| 5 | + var returnstr = "{ "; |
| 6 | + |
| 7 | + //trailing commas and json don't mix |
| 8 | + var propertynum = 0; |
| 9 | + for(property in js_obj){ |
| 10 | + if(propertynum > 0){ |
| 11 | + returnstr +=", "; |
| 12 | + } |
| 13 | + returnstr += "\"" + property + "\"" + " : "; |
| 14 | + if(typeof js_obj[property] == 'object'){ |
| 15 | + returnstr += $.json_encode(js_obj[property]); |
| 16 | + } |
| 17 | + else{ |
| 18 | + returnstr += "\"" + js_obj[property] + "\" "; |
| 19 | + } |
| 20 | + propertynum++; |
| 21 | + } |
| 22 | + |
| 23 | + returnstr+= " }"; |
| 24 | + return returnstr; |
| 25 | + }; |
3 | 26 | |
| 27 | + |
| 28 | + |
4 | 29 | $.renderUserDefDialogWith = function (userDef, defName){ |
5 | 30 | //change name |
6 | 31 | $("#user_def_alter_legend").text($("#user_def_alter_legend").data("defaultChangeText") + " " + defName); |
7 | 32 | $("#user_def_alter_legend").data("currentlyEditing", defName); |
| 33 | + console.dir(userDef); |
8 | 34 | |
9 | 35 | var setContribs = function(conditionArray, contribName){ |
10 | 36 | |
— | — | @@ -25,6 +51,7 @@ |
26 | 52 | initialDiv.append(textDiv); |
27 | 53 | |
28 | 54 | var i=0; |
| 55 | + console.dir(conditionArray); |
29 | 56 | for( var condition in conditionArray){ |
30 | 57 | i++; |
31 | 58 | conditionDiv = $("<div>").attr("id", contribName + "_range_" + i + "_div"); |
— | — | @@ -44,7 +71,7 @@ |
45 | 72 | cOpt1 = $("<option>").attr("id", contribName+"_"+i+"_lt"); |
46 | 73 | cOpt1.addClass("number_select_ltgt_opt"); |
47 | 74 | cOpt1.attr("value", "lt"); |
48 | | - cOpt1.text("<"); |
| 75 | + cOpt1.text("<"); |
49 | 76 | if(condition["operation"] == "<"){ |
50 | 77 | cOpt1.attr("selected", true); |
51 | 78 | } |
— | — | @@ -53,7 +80,7 @@ |
54 | 81 | cOpt2 = $("<option>").attr("id", contribName+"_"+i+"_gt"); |
55 | 82 | cOpt2.addClass("number_select_ltgt_opt"); |
56 | 83 | cOpt2.attr("value", "gt"); |
57 | | - cOpt2.text(">"); |
| 84 | + cOpt2.text(">"); |
58 | 85 | if(condition["operation"] == ">"){ |
59 | 86 | cOpt2.attr("selected", true); |
60 | 87 | } |
— | — | @@ -61,7 +88,7 @@ |
62 | 89 | cOpt3 = $("<option>").attr("id", contribName+"_"+i+"_lteq"); |
63 | 90 | cOpt3.addClass("number_select_ltgt_opt"); |
64 | 91 | cOpt3.attr("value", "lteq"); |
65 | | - cOpt3.text("<="); |
| 92 | + cOpt3.text("<="); |
66 | 93 | if(condition["operation"] == "<="){ |
67 | 94 | cOpt3.attr("selected", true); |
68 | 95 | } |
— | — | @@ -69,7 +96,7 @@ |
70 | 97 | cOpt4 = $("<option>").attr("id", contribName+"_"+i+"_gteq"); |
71 | 98 | cOpt4.addClass("number_select_ltgt_opt"); |
72 | 99 | cOpt4.attr("value", "gteq"); |
73 | | - cOpt4.text(">="); |
| 100 | + cOpt4.text(">="); |
74 | 101 | if(condition["operation"] == ">="){ |
75 | 102 | cOpt4.attr("selected", true); |
76 | 103 | } |
— | — | @@ -99,7 +126,7 @@ |
100 | 127 | $("#anon_users_checkbox").attr('checked', anon); |
101 | 128 | |
102 | 129 | //clear out old contents |
103 | | - $("#contrib_opts_container").clear(); |
| 130 | + $("#contrib_opts_container").empty(); |
104 | 131 | |
105 | 132 | var setup_set_contribs = function(contribName){ |
106 | 133 | var current_contribs = userDef[contribName]; |
— | — | @@ -214,7 +241,7 @@ |
215 | 242 | $j.post( wgScriptPath + '/api.php', |
216 | 243 | { 'action': 'specialclicktracking', 'format': 'json', |
217 | 244 | 'eventid': $("#chart_img").data( "eventid" ), 'increment': $("#chart_increment").val(), |
218 | | - 'startdate': start_date, 'enddate':end_date, 'userdefs': wgClickTrackUserDefs } , processChartJSON, "json"); |
| 245 | + 'startdate': start_date, 'enddate':end_date, 'userdefs': $.json_encode(wgClickTrackUserDefs) } , processChartJSON, "json"); |
219 | 246 | }; |
220 | 247 | |
221 | 248 | |
— | — | @@ -357,6 +384,21 @@ |
358 | 385 | $("#user_def_dialog").dialog({ autoOpen: true, width: 400 }); |
359 | 386 | $("#user_def_alter_legend").data("defaultChangeText", $("#user_def_alter_legend").text()); |
360 | 387 | |
| 388 | + |
| 389 | + //CHANGE USER/INTERMEDIATE/EXPERT DIALOGS |
| 390 | + var loadHeaderInfo = function(headerName){ |
| 391 | + $("#" + headerName + "_header").css("cursor", "pointer"); |
| 392 | + $("#" + headerName + "_header").click(function(){ |
| 393 | + $.renderUserDefDialogWith (wgClickTrackUserDefs[headerName], headerName); |
| 394 | + $("#user_def_dialog").dialog('open'); |
| 395 | + }); |
| 396 | + }; //headername |
| 397 | + |
| 398 | + |
| 399 | + loadHeaderInfo("beginner"); |
| 400 | + loadHeaderInfo("intermediate"); |
| 401 | + loadHeaderInfo("expert"); |
| 402 | + |
361 | 403 | }; |
362 | 404 | |
363 | 405 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiSpecialClickTracking.php |
— | — | @@ -15,6 +15,9 @@ |
16 | 16 | */ |
17 | 17 | public function execute(){ |
18 | 18 | |
| 19 | + $file = fopen("/Users/nimishgautam/logs/PHPLOG.txt", "a"); |
| 20 | + |
| 21 | + |
19 | 22 | $params = $this->extractRequestParams(); |
20 | 23 | $this->validateParams( $params ); |
21 | 24 | $event_id = $params['eventid']; |
— | — | @@ -23,6 +26,10 @@ |
24 | 27 | $increment = $params['increment']; |
25 | 28 | $userDefString = $params['userdefs']; |
26 | 29 | |
| 30 | + fwrite($file, var_export($_REQUEST, true) . "\n\n"); |
| 31 | + fwrite($file, var_export($params, true). "\n\n"); |
| 32 | + fclose($file); |
| 33 | + |
27 | 34 | $click_data = array(); |
28 | 35 | try{ |
29 | 36 | $click_data = SpecialClickTracking::getChartData($event_id, $startdate, $enddate, $increment, $userDefString); |
— | — | @@ -84,6 +91,7 @@ |
85 | 92 | 'startdate' => 'start date for data in YYYYMMDD format', |
86 | 93 | 'enddate' =>'end date for the data in YYYYMMDD format', |
87 | 94 | 'increment' => 'increment interval (in days) for data points', |
| 95 | + 'userdefs' => 'JSON object to encode user definitions' |
88 | 96 | ); |
89 | 97 | } |
90 | 98 | |
— | — | @@ -109,7 +117,9 @@ |
110 | 118 | ApiBase::PARAM_TYPE => 'integer', |
111 | 119 | ApiBase::PARAM_MIN => 1, |
112 | 120 | ApiBase::PARAM_MAX => 365 //1 year |
113 | | - ) |
| 121 | + ), |
| 122 | + 'userdefs' => array ( |
| 123 | + ApiBase::PARAM_TYPE => 'string') |
114 | 124 | ); |
115 | 125 | } |
116 | 126 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | // Hooked functions |
53 | 53 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema'; |
54 | 54 | $wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS'; |
| 55 | +$wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables'; |
55 | 56 | |
56 | 57 | // Set up the new API module |
57 | 58 | $wgAPIModules['clicktracking'] = 'ApiClickTracking'; |