r41825 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41824‎ | r41825 | r41826 >
Date:01:33, 8 October 2008
Author:dale
Status:old
Tags:
Comment:
capture stats updates
Modified paths:
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.i18n.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/playerStats.js (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/playerStats.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php
@@ -32,18 +32,22 @@
3333 case 'Survey':
3434 //check if
3535 $this->do_survey_forum();
36 - break;
 36+ break;
3737 case '':default:
38 - $this->do_stats_page();
 38+ if($wgRequest->getVal('action')=='submit'){
 39+ $this->do_submit();
 40+ }else{
 41+ $this->do_stats_page();
 42+ }
3943 break;
4044 }
4145 }
4246 function do_stats_page(){
4347 global $wgOut, $wgRequest;
4448 $wgOut->addHTML( " $this->req_param stats output will go here, with a link to a full report once its available");
45 - }
 49+ }
4650 function do_survey_forum(){
47 - global $wgOut, $psEmbedAry, $wgTitle;
 51+ global $wgOut, $psEmbedAry, $wgTitle, $wgUser,$wgEnableParserCache, $wgParser, $wgScript;
4852 $wgOut->addHTML ( wfMsg('ps_survey_description'));
4953
5054 //select the embed ary element:
@@ -51,7 +55,8 @@
5256 foreach($psEmbedAry as $embed){
5357 $tw+=$embed['weight'];
5458 }
55 - $selected_val = rand(0, $tw);
 59+ $selected_val = rand(1, $tw);
 60+ $tw=0;
5661 foreach($psEmbedAry as $embed){
5762 $tw+=$embed['weight'];
5863 if($tw>=$selected_val){
@@ -60,38 +65,130 @@
6166 }
6267 $embed_code='';
6368 if(isset($embed['html_code'])){
 69+ //run the stats (if not internal oggPlay)
 70+ $this->runJS_Stats();
6471 $embed_code=$embed['html_code'];
65 - }else if(isset($embed['wiki_code'])){
66 - $embed_code=$embed['wiki_code'];
 72+ }else if(isset($embed['wiki_code'])){
 73+ $popts = new ParserOptions;
 74+ $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts);
 75+ $embed_code = $parserOutput->getText();
6776 }
 77+ //print "EMBED C: $embed_code \n";
6878 //$q = 'action='.$this->action;
6979 #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
70 - $action = $wgTitle->escapeLocalURL( $q );
 80+ //$action = $wgScript.'?title='.$wgTitle->getDBKey() . '/Thanks';
 81+ $action = $wgTitle->getLocalURL('action=submit');
 82+ $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey);
 83+ $enUserHash = Xml::encodeJsVar( $jsUserHash );
7184 //work with "embed"
 85+
 86+
7287 //output table with flash and or video embed:
7388 $wgOut->addHTML( <<<EOT
 89+<p>
7490 <table>
7591 <tr>
76 - <td>
 92+ <td valign="top">
 93+ $embed_code
 94+ </td>
 95+ <td valign="top">
 96+ <form id="ps_editform" name="ps_editform" method="post" action="{$action}" enctype="multipart/form-data">
 97+ <input type="hidden" name="uh" value={$enUserHash}>
 98+EOT
 99+ );
 100+ //output questions:
 101+ $wgOut->addHTML( wfMsg('ps_could_play') );
 102+ //yes no with expand
 103+ $wgOut->addHTML( '<br><input type="radio" name="ps_could_play" value="yes"
 104+ onclick="document.getElementById(\'ps_could_not_play\').style.display = \'none\';">'.
 105+ wfMsg('ps_play_yes') .'<br>
 106+ <input type="radio" name="ps_could_play" value="no"
 107+ onclick="document.getElementById(\'ps_could_not_play\').style.display = \'inline\';">'.
 108+ wfMsg('ps_play_no').'<p>
 109+ <div id="ps_could_not_play" style="display:none;">
 110+ '.wfMsg('ps_problem_checkoff').'
 111+ <table border="0" cellspacing="0" cellpadding="0">
 112+ <tr>
 113+ <td><input type="checkbox" name="ps_no_video" value="1"></td>
 114+ <td>'.wfMsg('ps_no_video').' </td>
 115+ </tr>
 116+ <tr>
 117+ <tr>
 118+ <td><input type="checkbox" name="ps_jumpy_playback" value="1"></td>
 119+ <td>'.wfMsg('ps_jumpy_playback').' </td>
 120+ </tr>
 121+ <tr>
 122+ <td><input type="checkbox" name="ps_bad_sync" value="1"></td>
 123+ <td>'.wfMsg('ps_bad_sync').' </td>
 124+ </tr>
 125+ <tr>
 126+ <td><input type="checkbox" name="ps_no_sound" value="1"></td>
 127+ <td>'.wfMsg('ps_no_sound').'</td>
 128+ </tr>
 129+ </table>
 130+ '.wfMsg('ps_problems_desc').'<br><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br>
 131+ </div>
 132+ '.wfMsg('ps_would_install') . '<br>'.
 133+ '<input type="radio" name="ps_would_install" value="yes">'.wfMsg('ps_yes_install').'<br>'.
 134+ '<input type="radio" name="ps_would_install" value="no">'.wfMsg('ps_no_install').'<br>'
 135+);
 136+ //if ie output switch check:
 137+ if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$_SERVER['HTTP_USER_AGENT'],$matched)) {
 138+ $wgOut->addHTML( '<br>'.
 139+ wfMsg('ps_would_switch') .'<br>'.
 140+ '<input type="radio" name="ps_would_switch" value="yes">'.wfMsg('ps_yes_switch').'<br>'.
 141+ '<input type="radio" name="ps_would_switch" value="no">'.wfMsg('ps_no_install').'<br>'
 142+ );
 143+ }
 144+ $wgOut->addHTML( '<br>'. wfMsg('ps_your_email').'<br>'.
 145+ '<input type="text" name="ps_your_email" size="30" maxlength="200"><p>'.
 146+ wfMsg('ps_privacy'). '<br>'.
 147+ '<input type="submit" value="'.wfMsg('ps_submit_survey').'">'
 148+ );
 149+
 150+ $wgOut->addHTML('
 151+ </form>
77152 </td>
78 - <td>
79 - <form id="editform" name="editform" method="post" action="$action" enctype="multipart/form-data">
80 - form goes here
81 - </form>
82 - </td>
83153 </tr>
84 -</table>
85 -
 154+</table>');
 155+ }
 156+ function do_submit(){
 157+ global $wgRequest;
 158+ print_r($wgRequest);
 159+ //print "NO VIDEO: "
 160+ $insAry = array(
 161+ 'user_hash' => $wgRequest->getVal('uh'),
 162+
 163+ 'ps_could_play' => ( $wgRequest->getVal('ps_could_play')=='' )?0:1,
 164+ 'ps_jumpy_playback' => ( $wgRequest->getVal('ps_jumpy_playback')=='' )?0:1,
 165+ 'ps_no_video' => ( $wgRequest->getVal('ps_no_video')=='' )?0:1,
 166+ 'ps_bad_sync' => ( $wgRequest->getVal('ps_bad_sync')=='' )?0:1,
 167+ 'ps_no_sound' => ( $wgRequest->getVal('ps_no_sound')=='' )?0:1,
 168+
 169+ 'ps_would_install' => ( $wgRequest->getVal('ps_would_install')=='no' )?0:1,
 170+
 171+ 'ps_your_email' => htmlspecialchars( $wgRequest->getVal('ps_your_email' ) ),
 172+ 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal('ps_problems_desc' ) )
 173+ );
 174+ if( $wgRequest->getVal('ps_would_switch')!='')
 175+ $insAry['ps_would_switch'] = ( $wgRequest->getVal('ps_would_switch')=='yes')?1:0;
 176+
 177+ print_r($insAry);
 178+ }
 179+ /* to run the stats in cases where we are not using oggHanndler to play*/
 180+ function runJS_Stats(){
 181+ global $wgOut, $wgScriptPath;
 182+ $scriptPath = OggHandler::getMyScriptPath();
 183+ //include the javascript and do the stats
 184+ $wgOut->addHTML( <<<EOT
 185+ <script type="text/javascript" src="$scriptPath/OggPlayer.js"></script>
 186+ <script type="text/javascript" src="$wgScriptPath/extensions/PlayerStatsGrabber/playerStats.js"></script>
 187+ <script type="text/javascript">
 188+ wgOggPlayer.doStats();
 189+ </script>
86190 EOT
87 - );
88 - $o='';
89 - $o.='<td>'.$embed_code.'</td>';
90 - $o.='<td>';
91 -
92 - $o.='</td>';
93 - $o.='</tr></table>';
 191+);
94192 }
95193 }
96194
97 -
98195 ?>
\ No newline at end of file
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.i18n.php
@@ -5,19 +5,33 @@
66 'playerstatsgrabber' => 'Player Stats Survey',
77 'ps_take_video_survey'=> 'Video Playback Survey',
88 'ps_survey_description'=>
9 - 'This Survey will help wikipedia improve support for rich media. Please follow the on-screen instructions:',
10 - 'ps_could_play'=>'When you clicked "play", did the video playback?',
11 - 'ps_sound'=>'Did you have your volume up, and did you hear sound? ',
12 - 'ps_problems_desc'=>'If you experienced any problems playing the video, mark what applies.
13 - If you need more space use the other text field.',
14 - 'ps_problem_jumpy_playback'=>' Jumping playback (the video played then paused then played)',
15 - 'ps_problem_bad_sync' => 'audio was out of sync with the video',
 9+ 'This Survey will help wikipedia improve support for rich media. Please answer the following questions:',
 10+ 'ps_could_play'=>'When you clicked "play", did the video playback perfectly with audio?',
 11+ 'ps_play_yes' =>'Yes, the clip played perfectly',
 12+ 'ps_play_no' =>'No, had issues or did not play',
 13+
 14+ 'ps_problem_checkoff' => 'Please mark any of the following problems if they occurred:',
 15+
 16+ 'ps_no_video' => 'No Video played back at all',
 17+ 'ps_jumpy_playback' =>' Jumping playback (the video played then paused then played)',
 18+ 'ps_no_sound' => 'No Audio, (My Computer Volume is ON but I hear no audio for this video)',
 19+ 'ps_bad_sync' => 'Audio was out of sync with the video',
 20+
 21+ 'ps_problems_desc' => 'Please describe any additional issues bellow (optional):',
 22+
1623 'ps_would_install' =>'As a Wikipedia user, would you install an additional plug-in to view
17 -video on Wikipedia?',
18 - 'ps_would_switch' =>'As a Wikipedia user, would you consider installing a different browser to improve your experience on Wikipedia?',
 24+videos on Wikipedia?',
 25+ 'ps_no_install' =>'No, I would not install additional plug-in',
 26+ 'ps_yes_install' =>'Yes, I would install an additional plug-in',
 27+
 28+ 'ps_would_switch' =>'You appear to be running Internet Explore. As a Wikipedia user, would you consider installing a different browser to improve your media experience on Wikipedia?',
 29+ 'ps_yes_switch' =>'Yes I would switch browsers',
 30+ 'ps_no_switch' =>'No I would switch browsers',
 31+
1932 'ps_your_email' =>'your email address (optional) ',
2033 'ps_submit_survey' =>'Submit Survey',
21 - 'ps_privacy' =>'Privacy note goes here'
 34+ 'ps_privacy' =>'Privacy link or note goes here',
 35+ 'ps_thanks' =>'Thank you for Participating in this Video Survey'
2236 );
2337
2438 ?>
\ No newline at end of file
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php
@@ -22,9 +22,10 @@
2323 'source_type'=>'youtube',
2424 'name'=>'Sample Youtube Embed',
2525 'weight'=>1,
26 - 'code'=>'<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/eaADQTeZRCY&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/eaADQTeZRCY&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'
 26+ 'html_code'=>'<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/eaADQTeZRCY&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/eaADQTeZRCY&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'
2727 ),
28 - array( 'embed_type' =>'local',
 28+ array( 'embed_type' =>'ogg',
 29+ 'name'=>'Sample oggPlay Embed',
2930 'weight'=>1,
3031 'wiki_code' =>'[[Image:Sample_fish.ogg]]'
3132 )
Index: trunk/extensions/PlayerStatsGrabber/playerStats.js
@@ -8,9 +8,16 @@
99
1010 //extened version of OggHandler
1111 wgExtendedOggPlayerStats = {
12 - init:function( player, params ) {
13 - //call the parent function first
 12+ init:function(player, params){
1413 this.parent_init( player, params );
 14+ this.doStats();
 15+ },
 16+ doStats:function() {
 17+ //make sure we ran detect:
 18+ if (!this.detectionDone) {
 19+ this.detect();
 20+ }
 21+
1522 //build our request url:
1623 if( wgServerOveride!="" ){
1724 url= wgServerOveride;
Index: trunk/extensions/PlayerStatsGrabber/playerStats.sql
@@ -18,3 +18,21 @@
1919 PRIMARY KEY (`id`),
2020 KEY `user_hash` (`user_hash`)
2121 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
 22+
 23+CREATE TABLE IF NOT EXISTS `player_stats_survey` (
 24+ `id` int(10) unsigned NOT NULL auto_increment,
 25+ `user_hash` char(40) collate utf8_bin NOT NULL,
 26+ `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
 27+ `ps_could_play` tinyint(1) NOT NULL,
 28+ `ps_jumpy_playback` tinyint(1) NOT NULL,
 29+ `ps_no_video` tinyint(1) NOT NULL,
 30+ `ps_bad_sync` tinyint(1) NOT NULL,
 31+ `ps_no_sound` tinyint(1) NOT NULL,
 32+ `ps_would_install` tinyint(1) NOT NULL,
 33+ `ps_would_switch` tinyint(1) NOT NULL,
 34+ `ps_your_email` varchar(200) collate utf8_bin NOT NULL,
 35+ `ps_problems_desc` text collate utf8_bin NOT NULL,
 36+ PRIMARY KEY (`id`),
 37+ KEY `user_hash` (`user_hash`)
 38+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
 39+

Status & tagging log