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 |
1 | 1 | + 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 |
2 | 2 | + application/octet-stream |
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php |
— | — | @@ -3,89 +3,89 @@ |
4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
5 | 5 | |
6 | 6 | class SpecialPlayerStatsGrabber extends SpecialPage { |
7 | | - var $action = ''; |
| 7 | + var $action=''; |
8 | 8 | function SpecialPlayerStatsGrabber() { |
9 | | - SpecialPage::SpecialPage( "PlayerStatsGrabber" ); |
10 | | - wfLoadExtensionMessages( 'PlayerStatsGrabber' ); |
| 9 | + SpecialPage::SpecialPage("PlayerStatsGrabber"); |
| 10 | + wfLoadExtensionMessages('PlayerStatsGrabber'); |
11 | 11 | } |
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){ |
15 | 15 | case 'Survey': |
16 | | - return wfMsg( 'ps_take_video_survey' ); |
| 16 | + return wfMsg('ps_take_video_survey'); |
17 | 17 | break; |
18 | 18 | case '': |
19 | 19 | default: |
20 | | - return wfMsg( 'playerstatsgrabber' ); |
| 20 | + return wfMsg('playerstatsgrabber'); |
21 | 21 | break; |
22 | 22 | } |
23 | 23 | } |
24 | 24 | function execute( $par ) { |
25 | 25 | global $wgRequest, $wgOut; |
26 | 26 | $this->req_param = $par; |
27 | | - print $wgRequest->getText( 'param' ); |
28 | | - // set the header: |
| 27 | + print $wgRequest->getText('param'); |
| 28 | + //set the header: |
29 | 29 | $this->setHeaders(); |
30 | 30 | |
31 | | - // do the page: |
32 | | - switch( $this->req_param ) { |
| 31 | + //do the page: |
| 32 | + switch($this->req_param){ |
33 | 33 | case 'Survey': |
34 | | - // check if |
| 34 | + //check if |
35 | 35 | $this->do_survey_forum(); |
36 | 36 | break; |
37 | 37 | case '':default: |
38 | | - if ( $wgRequest->getVal( 'action' ) == 'submit' ) { |
| 38 | + if($wgRequest->getVal('action')=='submit'){ |
39 | 39 | $this->do_submit_survey(); |
40 | | - } else if ( $wgRequest->getVal( 'action' ) == 'survey' ) { |
| 40 | + }else if($wgRequest->getVal('action')=='survey'){ |
41 | 41 | $this->do_survey_forum(); |
42 | | - } else { |
| 42 | + }else{ |
43 | 43 | $this->do_stats_page(); |
44 | 44 | } |
45 | 45 | break; |
46 | 46 | } |
47 | 47 | } |
48 | | - function do_stats_page() { |
| 48 | + function do_stats_page(){ |
49 | 49 | global $wgOut, $wgRequest, $wgTitle; |
50 | | - $wgOut->addWikiText( wfMsg( 'ps_stats_welcome_link' ) ); |
| 50 | + $wgOut->addWikiText( wfMsg('stats_welcome_link' ) ); |
51 | 51 | } |
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')); |
55 | 55 | |
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']; |
60 | 60 | } |
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){ |
66 | 66 | break; |
67 | 67 | } |
68 | 68 | } |
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) |
72 | 72 | $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'])){ |
75 | 75 | $popts = new ParserOptions; |
76 | | - $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts ); |
| 76 | + $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts); |
77 | 77 | $embed_code = $parserOutput->getText(); |
78 | 78 | } |
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); |
85 | 85 | $enUserHash = Xml::encodeJsVar( $jsUserHash ); |
86 | | - // work with "embed" |
| 86 | + //work with "embed" |
87 | 87 | $embed_key = $embed['embed_key']; |
88 | 88 | |
89 | | - // output table with flash and or video embed: |
| 89 | + //output table with flash and or video embed: |
90 | 90 | $wgOut->addHTML( <<<EOT |
91 | 91 | <p> |
92 | 92 | <table> |
— | — | @@ -99,165 +99,169 @@ |
100 | 100 | <input type="hidden" name="embed_key" value="{$embed_key}"> |
101 | 101 | EOT |
102 | 102 | ); |
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 |
106 | 106 | $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> |
109 | 109 | <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> |
112 | 112 | <div id="ps_could_not_play" style="display:none;"> |
113 | | - ' . wfMsg( 'ps_problem_checkoff' ) . ' |
| 113 | + '.wfMsg('ps_problem_checkoff').' |
114 | 114 | <table border="0" cellspacing="0" cellpadding="0"> |
115 | 115 | <tr> |
116 | 116 | <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> |
118 | 118 | </tr> |
119 | 119 | <tr> |
120 | 120 | <tr> |
121 | 121 | <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> |
123 | 123 | </tr> |
124 | 124 | <tr> |
125 | 125 | <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> |
127 | 127 | </tr> |
128 | 128 | <tr> |
129 | 129 | <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> |
131 | 131 | </tr> |
132 | 132 | </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> |
134 | 134 | </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>' |
138 | 138 | ); |
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>' |
145 | 145 | ); |
146 | 146 | } |
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').'">' |
151 | 151 | ); |
152 | 152 | |
153 | | - $wgOut->addHTML( ' |
| 153 | + $wgOut->addHTML(' |
154 | 154 | </form> |
155 | 155 | </td> |
156 | 156 | </tr> |
157 | | -</table>' ); |
| 157 | +</table>'); |
158 | 158 | } |
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: |
162 | 162 | $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: |
167 | 167 | return 'error: missing param for json callback'; |
168 | 168 | } |
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(); |
171 | 171 | } |
172 | | - // set up insert array: |
| 172 | + //set up insert array: |
173 | 173 | $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'), |
186 | 187 | $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'), |
189 | 190 | $wgRequest->data['cs'] ) |
190 | | - ) ? true:false, |
191 | | - 'mplayer_enabled' => ( in_array( 'mplayerplug-in', |
| 191 | + )?true:false, |
| 192 | + 'mplayer_enabled' =>( in_array( 'mplayerplug-in', |
192 | 193 | $wgRequest->data['cs'] ) |
193 | | - ) ? true:false |
| 194 | + )?true:false |
194 | 195 | ); |
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){ |
202 | 203 | $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'); |
204 | 205 | $insert_id = $dbw->insertId(); |
205 | 206 | $dbw->commit(); |
206 | 207 | } |
207 | 208 | header( 'Content-Type: text/javascript' ); |
208 | | - return htmlspecialchars( $wgRequest->getVal( 'cb' ) ) . '(' . PhpArrayToJsObject_Recurse( |
| 209 | + return htmlspecialchars( $wgRequest->getVal('cb') ). '(' .PhpArrayToJsObject_Recurse( |
209 | 210 | array( |
210 | | - 'cb_inx' => htmlspecialchars( $wgRequest->getVal( 'cb_inx' ) ), |
| 211 | + 'cb_inx' => htmlspecialchars( $wgRequest->getVal('cb_inx') ), |
211 | 212 | 'id' => $insert_id |
212 | 213 | ) |
213 | 214 | ) . ');'; |
214 | 215 | } |
215 | | - function do_submit_survey() { |
| 216 | + function do_submit_survey(){ |
216 | 217 | global $wgRequest, $wgOut; |
217 | | - // print_r($wgRequest); |
218 | | - // print "NO VIDEO: " |
| 218 | + //print_r($wgRequest); |
| 219 | + //print "NO VIDEO: " |
219 | 220 | $dbr =& wfGetDB( DB_READ ); |
220 | 221 | $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, |
232 | 230 | |
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' ) ) |
235 | 233 | ); |
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; |
239 | 243 | |
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'); |
243 | 247 | |
244 | | - if ( !$user_id || $psAllowMultipleSurveysPerUser ) { |
| 248 | + if( !$user_id || $psAllowMultipleSurveysPerUser){ |
245 | 249 | $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'); |
247 | 251 | $insert_id = $dbw->insertId(); |
248 | 252 | $dbw->commit(); |
249 | 253 | } |
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 | + } |
256 | 260 | } |
257 | 261 | /* to run the stats in cases where we are not using oggHanndler to play*/ |
258 | | - function runJS_Stats() { |
| 262 | + function runJS_Stats(){ |
259 | 263 | global $wgOut, $wgScriptPath; |
260 | 264 | $scriptPath = OggHandler::getMyScriptPath(); |
261 | | - // include the javascript and do the stats |
| 265 | + //include the javascript and do the stats |
262 | 266 | $wgOut->addHTML( <<<EOT |
263 | 267 | <script type="text/javascript" src="$scriptPath/OggPlayer.js"></script> |
264 | 268 | <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 |
265 | 269 | + 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 @@ |
2 | 2 | <?php |
3 | 3 | /* |
4 | 4 | * simple stats output and gather for oggPlay and a "sample page" |
5 | | - */ |
| 5 | + */ |
6 | 6 | |
7 | 7 | # 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')) { |
9 | 9 | echo <<<EOT |
10 | 10 | To install my extension, put the following line in LocalSettings.php: |
11 | 11 | require_once( "\$IP/extensions/MyExtension/MyExtension.php" ); |
12 | 12 | EOT; |
13 | 13 | exit( 1 ); |
14 | 14 | } |
| 15 | +$psScriptPath = $wgScriptPath . '/extensions/PlayerStatsGrabber'; |
| 16 | + |
15 | 17 | /* |
16 | 18 | * config values |
17 | 19 | */ |
18 | 20 | |
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; |
23 | 25 | |
24 | | -// allow users to submit the suvey more than once |
| 26 | +//allow users to submit the suvey more than once |
25 | 27 | $psAllowMultipleSurveysPerUser = false; |
26 | 28 | |
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; |
31 | 59 | $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>' |
36 | 64 | ), |
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 |
41 | 74 | ) |
42 | 75 | ); |
43 | 76 | |
— | — | @@ -52,7 +85,7 @@ |
53 | 86 | |
54 | 87 | $wgSpecialPageGroups['PlayerStatsGrabber'] = 'wiki'; // like Special:Statistics |
55 | 88 | |
56 | | -// add ajax hook to accept the status input: |
| 89 | +//add ajax hook to accept the status input: |
57 | 90 | $wgAjaxExportList[] = 'mw_push_player_stats'; |
58 | 91 | |
59 | 92 | $wgExtensionCredits['media'][] = array( |
— | — | @@ -61,7 +94,7 @@ |
62 | 95 | 'svn-date' => '$LastChangedDate: 2008-08-06 07:18:43 -0700 (Wed, 06 Aug 2008) $', |
63 | 96 | 'svn-revision' => '$LastChangedRevision: 38715 $', |
64 | 97 | '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' |
66 | 99 | ); |
67 | 100 | |
68 | 101 | |
— | — | @@ -71,20 +104,20 @@ |
72 | 105 | * or |
73 | 106 | * (ties survay page data to detection) |
74 | 107 | */ |
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(); |
77 | 110 | } |
78 | 111 | |
79 | 112 | /* |
80 | 113 | * @@todo should use API json output wrappers |
81 | | - */ |
82 | | -if ( ! function_exists( 'php2jsObj' ) ) { |
| 114 | + */ |
| 115 | +if( ! function_exists('php2jsObj') ){ |
83 | 116 | function php2jsObj( $array, $objName = 'mv_result' ) |
84 | 117 | { |
85 | 118 | return $objName . ' = ' . phpArrayToJsObject_Recurse( $array ) . ";\n"; |
86 | 119 | } |
87 | 120 | } |
88 | | -if ( ! function_exists( 'PhpArrayToJsObject_Recurse' ) ) { |
| 121 | +if( ! function_exists('PhpArrayToJsObject_Recurse') ){ |
89 | 122 | function PhpArrayToJsObject_Recurse( $array ) { |
90 | 123 | // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes). |
91 | 124 | if ( ! is_array( $array ) && !is_object( $array ) ) { |
— | — | @@ -117,7 +150,7 @@ |
118 | 151 | return $retVal . "}"; |
119 | 152 | } |
120 | 153 | } |
121 | | -if ( ! function_exists( 'javascript_escape' ) ) { |
| 154 | +if( ! function_exists('javascript_escape')){ |
122 | 155 | function javascript_escape( $val ) { |
123 | 156 | // first strip /r |
124 | 157 | $val = str_replace( "\r", '', $val ); |
Index: trunk/extensions/PlayerStatsGrabber/playerStats.js |
— | — | @@ -8,8 +8,10 @@ |
9 | 9 | |
10 | 10 | //extened version of OggHandler |
11 | 11 | wgExtendedOggPlayerStats = { |
| 12 | + videoUrl:false, |
12 | 13 | init:function(player, params){ |
13 | 14 | this.parent_init( player, params ); |
| 15 | + this.videoUrl = params.videoUrl; |
14 | 16 | this.doStats(); |
15 | 17 | }, |
16 | 18 | doStats:function() { |
— | — | @@ -57,7 +59,9 @@ |
58 | 60 | url+= '&b_name=' + encodeURIComponent( BrowserDetect.browser ) ; |
59 | 61 | url+= '&b_version=' + encodeURIComponent( BrowserDetect.version ); |
60 | 62 | url+= '&b_os=' + encodeURIComponent( BrowserDetect.OS ) ; |
61 | | - |
| 63 | + |
| 64 | + if(this.videoUrl) |
| 65 | + url+= '&purl='+ encodeURIComponent( this.videoUrl ) ; |
62 | 66 | //and finaly add the user hash: |
63 | 67 | url+='&uh=' + encodeURIComponent ( wgOggPlayer.userHash ); |
64 | 68 | |
Index: trunk/extensions/PlayerStatsGrabber/playerStats.sql |
— | — | @@ -1,6 +1,7 @@ |
2 | 2 | CREATE TABLE IF NOT EXISTS `player_stats_log` ( |
3 | 3 | `id` int(11) unsigned NOT NULL auto_increment, |
4 | 4 | `time_stamp` timestamp NOT NULL default CURRENT_TIMESTAMP, |
| 5 | + `file_url` varchar(255) character set utf8 collate utf8_bin NOT NULL, |
5 | 6 | `user_hash` char(40) character set utf8 collate utf8_bin NOT NULL, |
6 | 7 | `html5_video_enabled` tinyint(1) default NULL, |
7 | 8 | `java_enabled` tinyint(1) default NULL, |
— | — | @@ -19,21 +20,22 @@ |
20 | 21 | KEY `user_hash` (`user_hash`) |
21 | 22 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; |
22 | 23 | |
| 24 | + |
23 | 25 | CREATE TABLE IF NOT EXISTS `player_stats_survey` ( |
24 | 26 | `id` int(10) unsigned NOT NULL auto_increment, |
25 | 27 | `user_hash` char(40) collate utf8_bin NOT NULL, |
26 | 28 | `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, |
28 | 30 | `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, |
30 | 32 | `ps_jumpy_playback` tinyint(1) NOT NULL, |
31 | 33 | `ps_no_video` tinyint(1) NOT NULL, |
32 | 34 | `ps_bad_sync` tinyint(1) NOT NULL, |
33 | 35 | `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, |
36 | 38 | `ps_your_email` varchar(200) collate utf8_bin NOT NULL, |
37 | 39 | `ps_problems_desc` text collate utf8_bin NOT NULL, |
38 | 40 | PRIMARY KEY (`id`), |
39 | 41 | 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 @@ |
2 | 2 | Player Stats Grabber |
3 | 3 | |
| 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 | + |
4 | 18 | == 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. |
6 | 20 | |
| 21 | +The survey page: |
| 22 | +Special:PlayerStatsGrabber/Survey |
| 23 | + |
7 | 24 | config variables: |
8 | 25 | $psLogEveryPlayRequestPerUser: |
9 | 26 | when set to true we log every play request |