r41910 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r41909‎ | r41910 | r41911 >
Date:00:42, 10 October 2008
Author:dale
Status:old
Tags:
Comment:
added flowplayer support test, added reporting the requested url to the plyaback log, added consistent sample media across media types
Modified paths:
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/README (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/flow_player (added) (history)
  • /trunk/extensions/PlayerStatsGrabber/flow_player/FlowPlayerDark.swf (added) (history)
  • /trunk/extensions/PlayerStatsGrabber/flow_player/flashembed.min.js (added) (history)
  • /trunk/extensions/PlayerStatsGrabber/playerStats.js (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/playerStats.sql (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/sample_media (added) (history)
  • /trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.flv (added) (history)
  • /trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.ogg (added) (history)

Diff [purge]

Index: trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.flv
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.flv
___________________________________________________________________
Added: svn:mime-type
11 + application/octet-stream
Index: trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.ogg
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/PlayerStatsGrabber/sample_media/sample_barney.ogg
___________________________________________________________________
Added: svn:mime-type
22 + application/octet-stream
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php
@@ -3,89 +3,89 @@
44 if ( !defined( 'MEDIAWIKI' ) ) die();
55
66 class SpecialPlayerStatsGrabber extends SpecialPage {
7 - var $action = '';
 7+ var $action='';
88 function SpecialPlayerStatsGrabber() {
9 - SpecialPage::SpecialPage( "PlayerStatsGrabber" );
10 - wfLoadExtensionMessages( 'PlayerStatsGrabber' );
 9+ SpecialPage::SpecialPage("PlayerStatsGrabber");
 10+ wfLoadExtensionMessages('PlayerStatsGrabber');
1111 }
12 - // used for page title
13 - function getDescription() {
14 - switch( $this->req_param ) {
 12+ //used for page title
 13+ function getDescription(){
 14+ switch($this->req_param){
1515 case 'Survey':
16 - return wfMsg( 'ps_take_video_survey' );
 16+ return wfMsg('ps_take_video_survey');
1717 break;
1818 case '':
1919 default:
20 - return wfMsg( 'playerstatsgrabber' );
 20+ return wfMsg('playerstatsgrabber');
2121 break;
2222 }
2323 }
2424 function execute( $par ) {
2525 global $wgRequest, $wgOut;
2626 $this->req_param = $par;
27 - print $wgRequest->getText( 'param' );
28 - // set the header:
 27+ print $wgRequest->getText('param');
 28+ //set the header:
2929 $this->setHeaders();
3030
31 - // do the page:
32 - switch( $this->req_param ) {
 31+ //do the page:
 32+ switch($this->req_param){
3333 case 'Survey':
34 - // check if
 34+ //check if
3535 $this->do_survey_forum();
3636 break;
3737 case '':default:
38 - if ( $wgRequest->getVal( 'action' ) == 'submit' ) {
 38+ if($wgRequest->getVal('action')=='submit'){
3939 $this->do_submit_survey();
40 - } else if ( $wgRequest->getVal( 'action' ) == 'survey' ) {
 40+ }else if($wgRequest->getVal('action')=='survey'){
4141 $this->do_survey_forum();
42 - } else {
 42+ }else{
4343 $this->do_stats_page();
4444 }
4545 break;
4646 }
4747 }
48 - function do_stats_page() {
 48+ function do_stats_page(){
4949 global $wgOut, $wgRequest, $wgTitle;
50 - $wgOut->addWikiText( wfMsg( 'ps_stats_welcome_link' ) );
 50+ $wgOut->addWikiText( wfMsg('stats_welcome_link' ) );
5151 }
52 - function do_survey_forum() {
53 - global $wgOut, $psEmbedAry, $wgTitle, $wgUser, $wgEnableParserCache, $wgParser, $wgScript;
54 - $wgOut->addHTML ( wfMsg( 'ps_survey_description' ) );
 52+ function do_survey_forum(){
 53+ global $wgOut, $psEmbedAry, $wgTitle, $wgUser,$wgEnableParserCache, $wgParser, $wgScript;
 54+ $wgOut->addHTML ( wfMsg('ps_survey_description'));
5555
56 - // select the embed ary element:
57 - $tw = 0;
58 - foreach ( $psEmbedAry as $embed ) {
59 - $tw += $embed['weight'];
 56+ //select the embed ary element:
 57+ $tw=0;
 58+ foreach($psEmbedAry as $embed){
 59+ $tw+=$embed['weight'];
6060 }
61 - $selected_val = rand( 1, $tw );
62 - $tw = 0;
63 - foreach ( $psEmbedAry as $embed ) {
64 - $tw += $embed['weight'];
65 - if ( $tw >= $selected_val ) {
 61+ $selected_val = rand(1, $tw);
 62+ $tw=0;
 63+ foreach($psEmbedAry as $embed){
 64+ $tw+=$embed['weight'];
 65+ if($tw>=$selected_val){
6666 break;
6767 }
6868 }
69 - $embed_code = '';
70 - if ( isset( $embed['html_code'] ) ) {
71 - // run the stats (if not internal oggPlay)
 69+ $embed_code='';
 70+ if(isset($embed['html_code'])){
 71+ //run the stats (if not internal oggPlay)
7272 $this->runJS_Stats();
73 - $embed_code = $embed['html_code'];
74 - } else if ( isset( $embed['wiki_code'] ) ) {
 73+ $embed_code=$embed['html_code'];
 74+ }else if(isset($embed['wiki_code'])){
7575 $popts = new ParserOptions;
76 - $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts );
 76+ $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts);
7777 $embed_code = $parserOutput->getText();
7878 }
79 - // print "EMBED C: $embed_code \n";
80 - // $q = 'action='.$this->action;
81 - # if ( "no" == $redirect ) { $q .= "&redirect=no"; }
82 - // $action = $wgScript.'?title='.$wgTitle->getDBKey() . '/Thanks';
83 - $action = $wgTitle->getLocalURL( 'action=submit' );
84 - $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey );
 79+ //print "EMBED C: $embed_code \n";
 80+ //$q = 'action='.$this->action;
 81+ #if ( "no" == $redirect ) { $q .= "&redirect=no"; }
 82+ //$action = $wgScript.'?title='.$wgTitle->getDBKey() . '/Thanks';
 83+ $action = $wgTitle->getLocalURL('action=submit');
 84+ $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey);
8585 $enUserHash = Xml::encodeJsVar( $jsUserHash );
86 - // work with "embed"
 86+ //work with "embed"
8787 $embed_key = $embed['embed_key'];
8888
89 - // output table with flash and or video embed:
 89+ //output table with flash and or video embed:
9090 $wgOut->addHTML( <<<EOT
9191 <p>
9292 <table>
@@ -99,165 +99,169 @@
100100 <input type="hidden" name="embed_key" value="{$embed_key}">
101101 EOT
102102 );
103 - // output questions:
104 - $wgOut->addHTML( wfMsg( 'ps_could_play' ) );
105 - // yes no with expand
 103+ //output questions:
 104+ $wgOut->addHTML( wfMsg('ps_could_play') );
 105+ //yes no with expand
106106 $wgOut->addHTML( '<br><input type="radio" name="ps_could_play" value="yes"
107 - onclick="document.getElementById(\'ps_could_not_play\').style.display = \'none\';">' .
108 - wfMsg( 'ps_play_yes' ) . '<br>
 107+ onclick="document.getElementById(\'ps_could_not_play\').style.display = \'none\';">'.
 108+ wfMsg('ps_play_yes') .'<br>
109109 <input type="radio" name="ps_could_play" value="no"
110 - onclick="document.getElementById(\'ps_could_not_play\').style.display = \'inline\';">' .
111 - wfMsg( 'ps_play_no' ) . '<p>
 110+ onclick="document.getElementById(\'ps_could_not_play\').style.display = \'inline\';">'.
 111+ wfMsg('ps_play_no').'<p>
112112 <div id="ps_could_not_play" style="display:none;">
113 - ' . wfMsg( 'ps_problem_checkoff' ) . '
 113+ '.wfMsg('ps_problem_checkoff').'
114114 <table border="0" cellspacing="0" cellpadding="0">
115115 <tr>
116116 <td><input type="checkbox" name="ps_no_video" value="1"></td>
117 - <td>' . wfMsg( 'ps_no_video' ) . ' </td>
 117+ <td>'.wfMsg('ps_no_video').' </td>
118118 </tr>
119119 <tr>
120120 <tr>
121121 <td><input type="checkbox" name="ps_jumpy_playback" value="1"></td>
122 - <td>' . wfMsg( 'ps_jumpy_playback' ) . ' </td>
 122+ <td>'.wfMsg('ps_jumpy_playback').' </td>
123123 </tr>
124124 <tr>
125125 <td><input type="checkbox" name="ps_bad_sync" value="1"></td>
126 - <td>' . wfMsg( 'ps_bad_sync' ) . ' </td>
 126+ <td>'.wfMsg('ps_bad_sync').' </td>
127127 </tr>
128128 <tr>
129129 <td><input type="checkbox" name="ps_no_sound" value="1"></td>
130 - <td>' . wfMsg( 'ps_no_sound' ) . '</td>
 130+ <td>'.wfMsg('ps_no_sound').'</td>
131131 </tr>
132132 </table>
133 - ' . wfMsg( 'ps_problems_desc' ) . '<br><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br>
 133+ '.wfMsg('ps_problems_desc').'<br><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br>
134134 </div>
135 - ' . wfMsg( 'ps_would_install' ) . '<br>' .
136 - '<input type="radio" name="ps_would_install" value="yes">' . wfMsg( 'ps_yes_install' ) . '<br>' .
137 - '<input type="radio" name="ps_would_install" value="no">' . wfMsg( 'ps_no_install' ) . '<br>'
 135+ '.wfMsg('ps_would_install') . '<br>'.
 136+ '<input type="radio" name="ps_would_install" value="yes">'.wfMsg('ps_yes_install').'<br>'.
 137+ '<input type="radio" name="ps_would_install" value="no">'.wfMsg('ps_no_install').'<br>'
138138 );
139 - // if ie output switch check:
140 - if ( preg_match( '|MSIE ([0-9].[0-9]{1,2})|', $_SERVER['HTTP_USER_AGENT'], $matched ) ) {
141 - $wgOut->addHTML( '<br>' .
142 - wfMsg( 'ps_would_switch' ) . '<br>' .
143 - '<input type="radio" name="ps_would_switch" value="yes">' . wfMsg( 'ps_yes_switch' ) . '<br>' .
144 - '<input type="radio" name="ps_would_switch" value="no">' . wfMsg( 'ps_no_install' ) . '<br>'
 139+ //if ie output switch check:
 140+ if (preg_match('|MSIE ([0-9].[0-9]{1,2})|',$_SERVER['HTTP_USER_AGENT'],$matched)) {
 141+ $wgOut->addHTML( '<br>'.
 142+ wfMsg('ps_would_switch') .'<br>'.
 143+ '<input type="radio" name="ps_would_switch" value="yes">'.wfMsg('ps_yes_switch').'<br>'.
 144+ '<input type="radio" name="ps_would_switch" value="no">'.wfMsg('ps_no_install').'<br>'
145145 );
146146 }
147 - $wgOut->addHTML( '<br>' . wfMsg( 'ps_your_email' ) . '<br>' .
148 - '<input type="text" name="ps_your_email" size="30" maxlength="200"><p>' .
149 - wfMsg( 'ps_privacy' ) . '<br>' .
150 - '<input type="submit" value="' . wfMsg( 'ps_submit_survey' ) . '">'
 147+ $wgOut->addHTML( '<br>'. wfMsg('ps_your_email').'<br>'.
 148+ '<input type="text" name="ps_your_email" size="30" maxlength="200"><p>'.
 149+ wfMsg('ps_privacy'). '<br>'.
 150+ '<input type="submit" value="'.wfMsg('ps_submit_survey').'">'
151151 );
152152
153 - $wgOut->addHTML( '
 153+ $wgOut->addHTML('
154154 </form>
155155 </td>
156156 </tr>
157 -</table>' );
 157+</table>');
158158 }
159 - function do_submit_player_log() {
160 - global $wgRequest;
161 - // do the insert into the userPlayerStats table:
 159+ function do_submit_player_log(){
 160+ global $wgRequest, $psLogEveryPlayRequestPerUser;
 161+ //do the insert into the userPlayerStats table:
162162 $dbr =& wfGetDB( DB_READ );
163 - if ( $wgRequest->getVal( 'cb' ) == ''
164 - || $wgRequest->getVal( 'cb_inx' ) == ''
165 - || $wgRequest->getVal( 'uh' ) == '' ) {
166 - // output error:
 163+ if( $wgRequest->getVal('cb')==''
 164+ || $wgRequest->getVal('cb_inx')==''
 165+ || $wgRequest->getVal('uh')==''){
 166+ //output error:
167167 return 'error: missing param for json callback';
168168 }
169 - if ( !isset( $wgRequest->data['cs'] ) || !is_array( $wgRequest->data['cs'] ) ) {
170 - $wgRequest->data['cs'] = array();
 169+ if(!isset($wgRequest->data['cs'])|| !is_array($wgRequest->data['cs'])){
 170+ $wgRequest->data['cs']=array();
171171 }
172 - // set up insert array:
 172+ //set up insert array:
173173 $insAry = array(
174 - 'user_hash' => $wgRequest->getVal( 'uh' ),
175 - 'b_user_agent' => $wgRequest->getVal( 'b_user_agent' ),
176 - 'b_name' => $wgRequest->getVal( 'b_name' ),
177 - 'b_version' => $wgRequest->getVal( 'b_version' ),
178 - 'b_os' => $wgRequest->getVal( 'b_os' ),
179 - 'flash_version' => $wgRequest->getVal( 'fv' ),
180 - 'java_version' => $wgRequest->getVal( 'jv' ),
181 - 'html5_video_enabled' => ( in_array( 'videoElement', $wgRequest->data['cs'] ) ) ? true:false,
182 - 'java_enabled' => ( in_array( 'cortado', $wgRequest->data['cs'] ) ) ? true:false,
183 - 'totem_enabled' => ( in_array( 'totem', $wgRequest->data['cs'] ) ) ? true:false,
184 - 'flash_enabled' => ( in_array( 'flash', $wgRequest->data['cs'] ) ) ? true:false,
185 - 'quicktime_enabled' => ( in_array( array( 'quicktime-mozilla', 'quicktime-activex' ),
 174+ 'user_hash' => $wgRequest->getVal('uh'),
 175+ 'file_url' => $wgRequest->getVal('purl'),
 176+ 'b_user_agent' => $wgRequest->getVal('b_user_agent'),
 177+ 'b_name' => $wgRequest->getVal('b_name'),
 178+ 'b_version' => $wgRequest->getVal('b_version'),
 179+ 'b_os' => $wgRequest->getVal('b_os'),
 180+ 'flash_version' => $wgRequest->getVal('fv'),
 181+ 'java_version' => $wgRequest->getVal('jv'),
 182+ 'html5_video_enabled'=>(in_array('videoElement', $wgRequest->data['cs'] ))?true:false,
 183+ 'java_enabled' => ( in_array('cortado', $wgRequest->data['cs'] ) )?true:false,
 184+ 'totem_enabled' => ( in_array('totem', $wgRequest->data['cs'] ) )?true:false,
 185+ 'flash_enabled' =>( in_array('flash', $wgRequest->data['cs'] ) )?true:false,
 186+ 'quicktime_enabled' =>( in_array( array('quicktime-mozilla','quicktime-activex'),
186187 $wgRequest->data['cs'] )
187 - ) ? true:false,
188 - 'vlc_enabled' => ( in_array( array( 'vlc-mozilla', 'vlc-activex' ),
 188+ )?true:false,
 189+ 'vlc_enabled' =>( in_array( array('vlc-mozilla', 'vlc-activex'),
189190 $wgRequest->data['cs'] )
190 - ) ? true:false,
191 - 'mplayer_enabled' => ( in_array( 'mplayerplug-in',
 191+ )?true:false,
 192+ 'mplayer_enabled' =>( in_array( 'mplayerplug-in',
192193 $wgRequest->data['cs'] )
193 - ) ? true:false
 194+ )?true:false
194195 );
195 - // check for user hash (don't collect multiple times for the same user)
196 - // $user_hash =
197 - $insert_id = $dbr->selectField( 'player_stats_log', 'id',
198 - array( 'user_hash' => $wgRequest->getVal( 'uh' ) ),
199 - 'do_submit_player_log::Select User Hash' );
200 - // if the user_hash is not already in the db or if we are logging every request do INSERT
201 - if ( !$insert_id || $psLogEveryPlayRequestPerUser ) {
 196+ //check for user hash (don't collect multiple times for the same user)
 197+ //$user_hash =
 198+ $insert_id = $dbr->selectField('player_stats_log', 'id',
 199+ array( 'user_hash'=>$wgRequest->getVal('uh') ),
 200+ 'do_submit_player_log::Select User Hash');
 201+ //if the user_hash is not already in the db or if we are logging every request do INSERT
 202+ if( !$insert_id || $psLogEveryPlayRequestPerUser){
202203 $dbw =& wfGetDB( DB_WRITE );
203 - $dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats::Insert' );
 204+ $dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats::Insert');
204205 $insert_id = $dbw->insertId();
205206 $dbw->commit();
206207 }
207208 header( 'Content-Type: text/javascript' );
208 - return htmlspecialchars( $wgRequest->getVal( 'cb' ) ) . '(' . PhpArrayToJsObject_Recurse(
 209+ return htmlspecialchars( $wgRequest->getVal('cb') ). '(' .PhpArrayToJsObject_Recurse(
209210 array(
210 - 'cb_inx' => htmlspecialchars( $wgRequest->getVal( 'cb_inx' ) ),
 211+ 'cb_inx' => htmlspecialchars( $wgRequest->getVal('cb_inx') ),
211212 'id' => $insert_id
212213 )
213214 ) . ');';
214215 }
215 - function do_submit_survey() {
 216+ function do_submit_survey(){
216217 global $wgRequest, $wgOut;
217 - // print_r($wgRequest);
218 - // print "NO VIDEO: "
 218+ //print_r($wgRequest);
 219+ //print "NO VIDEO: "
219220 $dbr =& wfGetDB( DB_READ );
220221 $insAry = array(
221 - 'user_hash' => $wgRequest->getVal( 'uh' ),
222 - 'embed_key' => $wgRequest->getVal( 'embed_key' ),
223 - 'player_stats_log_id' => $wgRequest->getVal( 'player_stats_log_id' ),
224 -
225 - 'ps_could_play' => ( $wgRequest->getVal( 'ps_could_play' ) == '' ) ? 0:1,
226 - 'ps_jumpy_playback' => ( $wgRequest->getVal( 'ps_jumpy_playback' ) == '' ) ? 0:1,
227 - 'ps_no_video' => ( $wgRequest->getVal( 'ps_no_video' ) == '' ) ? 0:1,
228 - 'ps_bad_sync' => ( $wgRequest->getVal( 'ps_bad_sync' ) == '' ) ? 0:1,
229 - 'ps_no_sound' => ( $wgRequest->getVal( 'ps_no_sound' ) == '' ) ? 0:1,
230 -
231 - 'ps_would_install' => ( $wgRequest->getVal( 'ps_would_install' ) == 'no' ) ? 0:1,
 222+ 'user_hash' => $wgRequest->getVal('uh'),
 223+ 'embed_key' => $wgRequest->getVal('embed_key'),
 224+ 'player_stats_log_id'=> $wgRequest->getVal('player_stats_log_id'),
 225+
 226+ 'ps_jumpy_playback' => ( $wgRequest->getVal('ps_jumpy_playback' ) == '' ) ? 0:1,
 227+ 'ps_no_video' => ( $wgRequest->getVal('ps_no_video' ) == '' ) ? 0:1,
 228+ 'ps_bad_sync' => ( $wgRequest->getVal('ps_bad_sync' ) == '' ) ? 0:1,
 229+ 'ps_no_sound' => ( $wgRequest->getVal('ps_no_sound' ) == '' ) ? 0:1,
232230
233 - 'ps_your_email' => htmlspecialchars( $wgRequest->getVal( 'ps_your_email' ) ),
234 - 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal( 'ps_problems_desc' ) )
 231+ 'ps_your_email' => htmlspecialchars( $wgRequest->getVal('ps_your_email' ) ),
 232+ 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal('ps_problems_desc' ) )
235233 );
236 -
237 - if ( $wgRequest->getVal( 'ps_would_switch' ) != '' )
238 - $insAry['ps_would_switch'] = ( $wgRequest->getVal( 'ps_would_switch' ) == 'yes' ) ? 1:0;
 234+ //leave NULL if un-answered for all yes no questions: :
 235+ if( $wgRequest->getVal('ps_could_play')!='')
 236+ $insAry['ps_could_play'] = ( $wgRequest->getVal('ps_could_play')=='yes' ) ? 1:0;
 237+
 238+ if( $wgRequest->getVal('ps_would_install')!='')
 239+ $insAry['ps_would_install'] = ( $wgRequest->getVal('ps_would_install') == 'yes' ) ? 1:0;
 240+
 241+ if( $wgRequest->getVal('ps_would_switch')!='')
 242+ $insAry['ps_would_switch'] = ( $wgRequest->getVal('ps_would_switch') == 'yes') ? 1:0;
239243
240 - $user_id = $dbr->selectField( 'player_stats_survey', 'id',
241 - array( 'user_hash' => $wgRequest->getVal( 'uh' ) ),
242 - 'do_submit_survey::Select User Hash' );
 244+ $user_id = $dbr->selectField('player_stats_survey', 'id',
 245+ array( 'user_hash'=>$wgRequest->getVal('uh') ),
 246+ 'do_submit_survey::Select User Hash');
243247
244 - if ( !$user_id || $psAllowMultipleSurveysPerUser ) {
 248+ if( !$user_id || $psAllowMultipleSurveysPerUser){
245249 $dbw =& wfGetDB( DB_WRITE );
246 - $dbw->insert( 'player_stats_survey', $insAry, 'do_submit_survey::Insert' );
 250+ $dbw->insert( 'player_stats_survey', $insAry, 'do_submit_survey::Insert');
247251 $insert_id = $dbw->insertId();
248252 $dbw->commit();
249253 }
250 - if ( $user_id && !$psAllowMultipleSurveysPerUser ) {
251 - $wgOut->addHTML( wfMsg( 'ps_only_one_survey_pp' ) );
252 - } else {
253 - // return thank you page:
254 - $wgOut->addHTML( wfMsg( 'ps_thanks' ) );
255 - }
 254+ if( $user_id && !$psAllowMultipleSurveysPerUser){
 255+ $wgOut->addHTML( wfMsg('only_one_survey_pp'));
 256+ }else{
 257+ //return thank you page:
 258+ $wgOut->addHTML( wfMsg('ps_thanks') );
 259+ }
256260 }
257261 /* to run the stats in cases where we are not using oggHanndler to play*/
258 - function runJS_Stats() {
 262+ function runJS_Stats(){
259263 global $wgOut, $wgScriptPath;
260264 $scriptPath = OggHandler::getMyScriptPath();
261 - // include the javascript and do the stats
 265+ //include the javascript and do the stats
262266 $wgOut->addHTML( <<<EOT
263267 <script type="text/javascript" src="$scriptPath/OggPlayer.js"></script>
264268 <script type="text/javascript" src="$wgScriptPath/extensions/PlayerStatsGrabber/playerStats.js"></script>
Index: trunk/extensions/PlayerStatsGrabber/flow_player/FlowPlayerDark.swf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/extensions/PlayerStatsGrabber/flow_player/FlowPlayerDark.swf
___________________________________________________________________
Added: svn:mime-type
265269 + application/octet-stream
Index: trunk/extensions/PlayerStatsGrabber/flow_player/flashembed.min.js
@@ -0,0 +1,16 @@
 2+/**
 3+ * flashembed 0.31. Adobe Flash embedding script
 4+ *
 5+ * http://flowplayer.org/tools/flash-embed.html
 6+ *
 7+ * Copyright (c) 2008 Tero Piirainen (tipiirai@gmail.com)
 8+ *
 9+ * Released under the MIT License:
 10+ * http://www.opensource.org/licenses/mit-license.php
 11+ *
 12+ * >> Basically you can do anything you want but leave this header as is <<
 13+ *
 14+ * version 0.01 - 03/11/2008
 15+ * version 0.31 - Tue Jul 22 2008 06:30:31 GMT+0200 (GMT+02:00)
 16+ */
 17+function flashembed(root,userParams,flashvars){function getHTML(){var html="";if(typeof flashvars=='function'){flashvars=flashvars();}if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){html='<embed type="application/x-shockwave-flash" ';if(params.id){extend(params,{name:params.id});}for(var key in params){if(params[key]!==null){html+=[key]+'="'+params[key]+'"\n\t';}}if(flashvars){html+='flashvars=\''+concatVars(flashvars)+'\'';}html+='/>';}else{html='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" ';html+='width="'+params.width+'" height="'+params.height+'"';if(!params.id&&document.all){params.id="_"+(""+Math.random()).substring(5);}if(params.id){html+=' id="'+params.id+'"';}html+='>';html+='\n\t<param name="movie" value="'+params.src+'" />';params.id=params.src=params.width=params.height=null;for(var k in params){if(params[k]!==null){html+='\n\t<param name="'+k+'" value="'+params[k]+'" />';}}if(flashvars){html+='\n\t<param name="flashvars" value=\''+concatVars(flashvars)+'\' />';}html+="</object>";if(debug){alert(html);}}return html;}function init(name){var timer=setInterval(function(){var doc=document;var el=doc.getElementById(name);if(el){flashembed(el,userParams,flashvars);clearInterval(timer);}else if(doc&&doc.getElementsByTagName&&doc.getElementById&&doc.body){clearInterval(timer);}},13);return true;}function extend(to,from){if(from){for(key in from){if(from.hasOwnProperty(key)){to[key]=from[key];}}}}var params={src:'#',width:'100%',height:'100%',version:null,onFail:null,expressInstall:null,debug:false,bgcolor:'#ffffff',allowfullscreen:true,allowscriptaccess:'always',quality:'high',type:'application/x-shockwave-flash',pluginspage:'http://www.adobe.com/go/getflashplayer'};if(typeof userParams=='string'){userParams={src:userParams};}extend(params,userParams);var version=flashembed.getVersion();var required=params.version;var express=params.expressInstall;var debug=params.debug;if(typeof root=='string'){var el=document.getElementById(root);if(el){root=el;}else{return init(root);}}if(!root){return;}if(!required||flashembed.isSupported(required)){params.onFail=params.version=params.expressInstall=params.debug=null;root.innerHTML=getHTML();return root.firstChild;}else if(params.onFail){var ret=params.onFail.call(params,flashembed.getVersion(),flashvars);if(ret){root.innerHTML=ret;}}else if(required&&express&&flashembed.isSupported([6,65])){extend(params,{src:express});flashvars={MMredirectURL:location.href,MMplayerType:'PlugIn',MMdoctitle:document.title};root.innerHTML=getHTML();}else{if(root.innerHTML.replace(/\s/g,'')!==''){}else{root.innerHTML="<h2>Flash version "+required+" or greater is required</h2>"+"<h3>"+(version[0]>0?"Your version is "+version:"You have no flash plugin installed")+"</h3>"+"<p>Download latest version from <a href='"+params.pluginspage+"'>here</a></p>";}}function concatVars(vars){var out="";for(var key in vars){if(vars[key]){out+=[key]+'='+asString(vars[key])+'&';}}return out.substring(0,out.length-1);}function asString(obj){switch(typeOf(obj)){case'string':return'"'+obj.replace(new RegExp('(["\\\\])','g'),'\\$1')+'"';case'array':return'['+map(obj,function(el){return asString(el);}).join(',')+']';case'function':return'"function()"';case'object':var str=[];for(var prop in obj){if(obj.hasOwnProperty(prop)){str.push('"'+prop+'":'+asString(obj[prop]));}}return'{'+str.join(',')+'}';}return String(obj).replace(/\s/g," ").replace(/\'/g,"\"");}function typeOf(obj){if(obj===null||obj===undefined){return false;}var type=typeof obj;return(type=='object'&&obj.push)?'array':type;}if(window.attachEvent){window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};});}function map(arr,func){var newArr=[];for(var i in arr){if(arr.hasOwnProperty(i)){newArr[i]=func(arr[i]);}}return newArr;}return root;}if(typeof jQuery=='function'){(function($){$.fn.extend({flashembed:function(params,flashvars){return this.each(function(){flashembed(this,params,flashvars);});}});})(jQuery);}flashembed=flashembed||{};flashembed.getVersion=function(){var version=[0,0];if(navigator.plugins&&typeof navigator.plugins["Shockwave Flash"]=="object"){var _d=navigator.plugins["Shockwave Flash"].description;if(typeof _d!="undefined"){_d=_d.replace(/^.*\s+(\S+\s+\S+$)/,"$1");var _m=parseInt(_d.replace(/^(.*)\..*$/,"$1"),10);var _r=/r/.test(_d)?parseInt(_d.replace(/^.*r(.*)$/,"$1"),10):0;version=[_m,_r];}}else if(window.ActiveXObject){try{var _a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");version=[6,0];_a.AllowScriptAccess="always";}catch(ee){if(version[0]==6){return;}}try{_a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(eee){}}if(typeof _a=="object"){_d=_a.GetVariable("$version");if(typeof _d!="undefined"){_d=_d.replace(/^\S+\s+(.*)$/,"$1").split(",");version=[parseInt(_d[0],10),parseInt(_d[2],10)];}}}return version;};flashembed.isSupported=function(version){var now=flashembed.getVersion();var ret=(now[0]>version[0])||(now[0]==version[0]&&now[1]>=version[1]);return ret;};
\ No newline at end of file
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php
@@ -1,42 +1,75 @@
22 <?php
33 /*
44 * simple stats output and gather for oggPlay and a "sample page"
5 - */
 5+ */
66
77 # Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
8 -if ( !defined( 'MEDIAWIKI' ) ) {
 8+if (!defined('MEDIAWIKI')) {
99 echo <<<EOT
1010 To install my extension, put the following line in LocalSettings.php:
1111 require_once( "\$IP/extensions/MyExtension/MyExtension.php" );
1212 EOT;
1313 exit( 1 );
1414 }
 15+$psScriptPath = $wgScriptPath . '/extensions/PlayerStatsGrabber';
 16+
1517 /*
1618 * config values
1719 */
1820
19 -// $psLogEveryPlayRequestPerUser
20 -// true we log every play request
21 -// false we only log play request from different users
22 -$psLogEveryPlayRequestPerUser = false;
 21+//$psLogEveryPlayRequestPerUser
 22+//true we log every play request
 23+//false we only log play request from different users
 24+$psLogEveryPlayRequestPerUser = true;
2325
24 -// allow users to submit the suvey more than once
 26+//allow users to submit the suvey more than once
2527 $psAllowMultipleSurveysPerUser = false;
2628
27 -// embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1)
28 -// flash embed code (the raw html that gets outputted to the browsers))
29 -// embed key gets recorded to the database to identify what player was sent to the client in the survey
30 -// (you need to add it as an ENUM option)
 29+//embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1)
 30+//flash embed code (the raw html that gets outputted to the browsers))
 31+//embed key gets recorded to the database to identify what player was sent to the client in the survey
 32+//(you need to add it as an ENUM option)
 33+$flowEmbedCode=<<<EOT
 34+<script type="text/javascript" src="{$psScriptPath}/flow_player/flashembed.min.js"></script>
 35+<script type="text/javascript">
 36+ flashembed("example",
 37+ {
 38+ src:'{$psScriptPath}/flow_player/FlowPlayerDark.swf',
 39+ width: 400,
 40+ height: 320,
 41+ id:'myflash_id',
 42+ },
 43+ {
 44+ config: {
 45+ autoPlay: false,
 46+ id: 'myflash_id',
 47+ autoBuffering: true,
 48+ controlBarBackgroundColor:'0x2e8860',
 49+ initialScale: 'scale',
 50+ videoFile: '{$psScriptPath}/flow_player/sample_barney.flv'
 51+ }}
 52+ );
 53+</script>
 54+
 55+<div id="example"></div>
 56+
 57+
 58+EOT;
3159 $psEmbedAry = array(
32 - array( 'embed_key' => 'youtube',
33 - 'name' => 'Sample Youtube Embed',
34 - 'weight' => 1,
35 - '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>'
 60+ array( 'embed_key'=>'youtube',
 61+ 'name'=>'Sample Youtube Embed',
 62+ 'weight'=>1,
 63+ 'html_code'=>'<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/Ga1kC6oGT9A&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/Ga1kC6oGT9A&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>'
3664 ),
37 - array( 'embed_key' => 'oggHandler',
38 - 'name' => 'Sample oggPlay Embed',
39 - 'weight' => 1,
40 - 'wiki_code' => '[[Image:Sample_fish.ogg]]'
 65+ array( 'embed_key'=>'oggHandler',
 66+ 'name'=>'Sample oggPlay Embed',
 67+ 'weight'=>1,
 68+ 'wiki_code' =>'[[Image:Sample_barney.ogg]]'
 69+ ),
 70+ array('embed_key'=>'flowplayer',
 71+ 'name'=>'Sample oggPlay Embed',
 72+ 'weight'=>1,
 73+ 'html_code'=>$flowEmbedCode
4174 )
4275 );
4376
@@ -52,7 +85,7 @@
5386
5487 $wgSpecialPageGroups['PlayerStatsGrabber'] = 'wiki'; // like Special:Statistics
5588
56 -// add ajax hook to accept the status input:
 89+//add ajax hook to accept the status input:
5790 $wgAjaxExportList[] = 'mw_push_player_stats';
5891
5992 $wgExtensionCredits['media'][] = array(
@@ -61,7 +94,7 @@
6295 'svn-date' => '$LastChangedDate: 2008-08-06 07:18:43 -0700 (Wed, 06 Aug 2008) $',
6396 'svn-revision' => '$LastChangedRevision: 38715 $',
6497 'url' => 'http://www.mediawiki.org/wiki/Extension:PlayerStats',
65 - 'description' => 'PlayerStats and survey for monitoring theora support relative to flash'
 98+ 'description' => 'PlayerStats and survey for monitoring theora support relative to flash'
6699 );
67100
68101
@@ -71,20 +104,20 @@
72105 * or
73106 * (ties survay page data to detection)
74107 */
75 -function mw_push_player_stats() {
76 - return SpecialPlayerStatsGrabber::do_submit_player_log();
 108+function mw_push_player_stats(){
 109+ return SpecialPlayerStatsGrabber::do_submit_player_log();
77110 }
78111
79112 /*
80113 * @@todo should use API json output wrappers
81 - */
82 -if ( ! function_exists( 'php2jsObj' ) ) {
 114+ */
 115+if( ! function_exists('php2jsObj') ){
83116 function php2jsObj( $array, $objName = 'mv_result' )
84117 {
85118 return $objName . ' = ' . phpArrayToJsObject_Recurse( $array ) . ";\n";
86119 }
87120 }
88 -if ( ! function_exists( 'PhpArrayToJsObject_Recurse' ) ) {
 121+if( ! function_exists('PhpArrayToJsObject_Recurse') ){
89122 function PhpArrayToJsObject_Recurse( $array ) {
90123 // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes).
91124 if ( ! is_array( $array ) && !is_object( $array ) ) {
@@ -117,7 +150,7 @@
118151 return $retVal . "}";
119152 }
120153 }
121 -if ( ! function_exists( 'javascript_escape' ) ) {
 154+if( ! function_exists('javascript_escape')){
122155 function javascript_escape( $val ) {
123156 // first strip /r
124157 $val = str_replace( "\r", '', $val );
Index: trunk/extensions/PlayerStatsGrabber/playerStats.js
@@ -8,8 +8,10 @@
99
1010 //extened version of OggHandler
1111 wgExtendedOggPlayerStats = {
 12+ videoUrl:false,
1213 init:function(player, params){
1314 this.parent_init( player, params );
 15+ this.videoUrl = params.videoUrl;
1416 this.doStats();
1517 },
1618 doStats:function() {
@@ -57,7 +59,9 @@
5860 url+= '&b_name=' + encodeURIComponent( BrowserDetect.browser ) ;
5961 url+= '&b_version=' + encodeURIComponent( BrowserDetect.version );
6062 url+= '&b_os=' + encodeURIComponent( BrowserDetect.OS ) ;
61 -
 63+
 64+ if(this.videoUrl)
 65+ url+= '&purl='+ encodeURIComponent( this.videoUrl ) ;
6266 //and finaly add the user hash:
6367 url+='&uh=' + encodeURIComponent ( wgOggPlayer.userHash );
6468
Index: trunk/extensions/PlayerStatsGrabber/playerStats.sql
@@ -1,6 +1,7 @@
22 CREATE TABLE IF NOT EXISTS `player_stats_log` (
33 `id` int(11) unsigned NOT NULL auto_increment,
44 `time_stamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
 5+ `file_url` varchar(255) character set utf8 collate utf8_bin NOT NULL,
56 `user_hash` char(40) character set utf8 collate utf8_bin NOT NULL,
67 `html5_video_enabled` tinyint(1) default NULL,
78 `java_enabled` tinyint(1) default NULL,
@@ -19,21 +20,22 @@
2021 KEY `user_hash` (`user_hash`)
2122 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
2223
 24+
2325 CREATE TABLE IF NOT EXISTS `player_stats_survey` (
2426 `id` int(10) unsigned NOT NULL auto_increment,
2527 `user_hash` char(40) collate utf8_bin NOT NULL,
2628 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
27 - `embed_key` enum('youtube','oggHandler') collate utf8_bin default NULL,
 29+ `embed_key` enum('youtube','oggHandler','flowplayer') collate utf8_bin default NULL,
2830 `player_stats_log_id` int(11) unsigned default NULL,
29 - `ps_could_play` tinyint(1) NOT NULL,
 31+ `ps_could_play` tinyint(1) default NULL,
3032 `ps_jumpy_playback` tinyint(1) NOT NULL,
3133 `ps_no_video` tinyint(1) NOT NULL,
3234 `ps_bad_sync` tinyint(1) NOT NULL,
3335 `ps_no_sound` tinyint(1) NOT NULL,
34 - `ps_would_install` tinyint(1) NOT NULL,
35 - `ps_would_switch` tinyint(1) NOT NULL,
 36+ `ps_would_install` tinyint(1) default NULL,
 37+ `ps_would_switch` tinyint(1) default NULL,
3638 `ps_your_email` varchar(200) collate utf8_bin NOT NULL,
3739 `ps_problems_desc` text collate utf8_bin NOT NULL,
3840 PRIMARY KEY (`id`),
3941 KEY `user_hash` (`user_hash`)
40 -) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
 42+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;
\ No newline at end of file
Index: trunk/extensions/PlayerStatsGrabber/README
@@ -1,8 +1,25 @@
22 Player Stats Grabber
33
 4+==Install==
 5+
 6+add to local seettings:
 7+require( "$IP/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php" );
 8+
 9+upload sample_barney.ogg (the survey site should include oggHandler)
 10+
 11+update oggHandler config (locally)
 12+$wgPlayerStatsCollectionJs = $wgScriptPath . '/extensions/PlayerStatsGrabber/playerStats.js';
 13+
 14+run the sql:
 15+playerStats.sql
 16+
 17+
418 == Overview ==
5 -Player Stats Grabber is a simple survey and player stats collector.
 19+Player Stats Grabber is a simple survey and player stats collector.
620
 21+The survey page:
 22+Special:PlayerStatsGrabber/Survey
 23+
724 config variables:
825 $psLogEveryPlayRequestPerUser:
926 when set to true we log every play request

Status & tagging log