r57253 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57252‎ | r57253 | r57254 >
Date:21:20, 1 October 2009
Author:nimishg
Status:deferred (Comments)
Tags:
Comment:
Added clicktracking to parse tables testing
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ApiSpecialClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php
@@ -12,10 +12,9 @@
1313 private $top_results = 10;
1414 private $normalize_top_results = false;
1515 private $normalize_results = false;
16 - private $minimum_date = '20090815'; //YYYYMMDD (+1 for today)
1716 private $end_timeframe = '20090902';
 17+ private static $minimum_date = '20090815'; //YYYYMMDD (+1 for today)
1818
19 -
2019 private static $userTypes = array("basic" => 0, "intermediate" => 1, "expert" => 2);
2120 private $user_defs = array();
2221
@@ -137,7 +136,7 @@
138137 //$wgOut->addHTML($this->buildControlBox());
139138
140139 $wgOut->addHTML($this->buildChartDialog());
141 - $wgOut->addHTML($this->buildUserDefDialog());
 140+ $wgOut->addHTML($this->buildUserDefBlankDialog());
142141
143142 }
144143
@@ -236,6 +235,80 @@
237236 }
238237
239238
 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+
240313 function buildUserDefDialog(){
241314 $control = "";
242315 $control .= Xml::openElement("div", array("id" => "user_def_dialog", "class" => "dialog"));
@@ -385,7 +458,7 @@
386459 $control .= Xml::closeElement("td");
387460
388461 $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));
390463 $control .= Xml::closeElement("input");
391464 $control .= Xml::closeElement("td");
392465
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -30,8 +30,17 @@
3131 return true;
3232 }
3333
 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+ }
3444
35 -
3645 /*
3746 * check to see if user is throttled
3847 */
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.js
@@ -1,9 +1,35 @@
22 (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+ };
326
 27+
 28+
429 $.renderUserDefDialogWith = function (userDef, defName){
530 //change name
631 $("#user_def_alter_legend").text($("#user_def_alter_legend").data("defaultChangeText") + " " + defName);
732 $("#user_def_alter_legend").data("currentlyEditing", defName);
 33+ console.dir(userDef);
834
935 var setContribs = function(conditionArray, contribName){
1036
@@ -25,6 +51,7 @@
2652 initialDiv.append(textDiv);
2753
2854 var i=0;
 55+ console.dir(conditionArray);
2956 for( var condition in conditionArray){
3057 i++;
3158 conditionDiv = $("<div>").attr("id", contribName + "_range_" + i + "_div");
@@ -44,7 +71,7 @@
4572 cOpt1 = $("<option>").attr("id", contribName+"_"+i+"_lt");
4673 cOpt1.addClass("number_select_ltgt_opt");
4774 cOpt1.attr("value", "lt");
48 - cOpt1.text("&lt;");
 75+ cOpt1.text("<");
4976 if(condition["operation"] == "<"){
5077 cOpt1.attr("selected", true);
5178 }
@@ -53,7 +80,7 @@
5481 cOpt2 = $("<option>").attr("id", contribName+"_"+i+"_gt");
5582 cOpt2.addClass("number_select_ltgt_opt");
5683 cOpt2.attr("value", "gt");
57 - cOpt2.text("&gt;");
 84+ cOpt2.text(">");
5885 if(condition["operation"] == ">"){
5986 cOpt2.attr("selected", true);
6087 }
@@ -61,7 +88,7 @@
6289 cOpt3 = $("<option>").attr("id", contribName+"_"+i+"_lteq");
6390 cOpt3.addClass("number_select_ltgt_opt");
6491 cOpt3.attr("value", "lteq");
65 - cOpt3.text("&lt;=");
 92+ cOpt3.text("<=");
6693 if(condition["operation"] == "<="){
6794 cOpt3.attr("selected", true);
6895 }
@@ -69,7 +96,7 @@
7097 cOpt4 = $("<option>").attr("id", contribName+"_"+i+"_gteq");
7198 cOpt4.addClass("number_select_ltgt_opt");
7299 cOpt4.attr("value", "gteq");
73 - cOpt4.text("&gt;=");
 100+ cOpt4.text(">=");
74101 if(condition["operation"] == ">="){
75102 cOpt4.attr("selected", true);
76103 }
@@ -99,7 +126,7 @@
100127 $("#anon_users_checkbox").attr('checked', anon);
101128
102129 //clear out old contents
103 - $("#contrib_opts_container").clear();
 130+ $("#contrib_opts_container").empty();
104131
105132 var setup_set_contribs = function(contribName){
106133 var current_contribs = userDef[contribName];
@@ -214,7 +241,7 @@
215242 $j.post( wgScriptPath + '/api.php',
216243 { 'action': 'specialclicktracking', 'format': 'json',
217244 '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");
219246 };
220247
221248
@@ -357,6 +384,21 @@
358385 $("#user_def_dialog").dialog({ autoOpen: true, width: 400 });
359386 $("#user_def_alter_legend").data("defaultChangeText", $("#user_def_alter_legend").text());
360387
 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+
361403 };
362404
363405
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiSpecialClickTracking.php
@@ -15,6 +15,9 @@
1616 */
1717 public function execute(){
1818
 19+ $file = fopen("/Users/nimishgautam/logs/PHPLOG.txt", "a");
 20+
 21+
1922 $params = $this->extractRequestParams();
2023 $this->validateParams( $params );
2124 $event_id = $params['eventid'];
@@ -23,6 +26,10 @@
2427 $increment = $params['increment'];
2528 $userDefString = $params['userdefs'];
2629
 30+ fwrite($file, var_export($_REQUEST, true) . "\n\n");
 31+ fwrite($file, var_export($params, true). "\n\n");
 32+ fclose($file);
 33+
2734 $click_data = array();
2835 try{
2936 $click_data = SpecialClickTracking::getChartData($event_id, $startdate, $enddate, $increment, $userDefString);
@@ -84,6 +91,7 @@
8592 'startdate' => 'start date for data in YYYYMMDD format',
8693 'enddate' =>'end date for the data in YYYYMMDD format',
8794 'increment' => 'increment interval (in days) for data points',
 95+ 'userdefs' => 'JSON object to encode user definitions'
8896 );
8997 }
9098
@@ -109,7 +117,9 @@
110118 ApiBase::PARAM_TYPE => 'integer',
111119 ApiBase::PARAM_MIN => 1,
112120 ApiBase::PARAM_MAX => 365 //1 year
113 - )
 121+ ),
 122+ 'userdefs' => array (
 123+ ApiBase::PARAM_TYPE => 'string')
114124 );
115125 }
116126
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php
@@ -51,6 +51,7 @@
5252 // Hooked functions
5353 $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema';
5454 $wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS';
 55+$wgHooks['ParserTestTables'][] = 'ClickTrackingHooks::parserTestTables';
5556
5657 // Set up the new API module
5758 $wgAPIModules['clicktracking'] = 'ApiClickTracking';

Comments

#Comment by Siebrand (talk | contribs)   21:25, 1 October 2009
+		$file = fopen("/Users/nimishgautam/logs/PHPLOG.txt", "a");

Is there more debug code in here that shouldn't have been committed?

#Comment by Nimish Gautam (talk | contribs)   21:57, 1 October 2009

Holy crap! Excellent catch, I commited the wrong versions of some files...fixed in r57257

#Comment by Siebrand (talk | contribs)   13:34, 2 October 2009

Thanks. Resetting state to new.

Status & tagging log