Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php |
— | — | @@ -3,183 +3,188 @@ |
4 | 4 | if ( !defined( 'MEDIAWIKI' ) ) die(); |
5 | 5 | |
6 | 6 | class SpecialPlayerStatsGrabber extends SpecialPage { |
7 | | - var $action=''; |
8 | | - function SpecialPlayerStatsGrabber() { |
9 | | - SpecialPage::SpecialPage("PlayerStatsGrabber"); |
10 | | - wfLoadExtensionMessages('PlayerStatsGrabber'); |
11 | | - } |
12 | | - //used for page title |
13 | | - function getDescription(){ |
14 | | - switch($this->req_param){ |
15 | | - case 'Survey': |
16 | | - return wfMsg('ps_take_video_survey'); |
17 | | - break; |
18 | | - case '': |
19 | | - default: |
20 | | - return wfMsg('playerstatsgrabber'); |
21 | | - break; |
22 | | - } |
23 | | - } |
24 | | - function execute( $par ) { |
25 | | - global $wgRequest, $wgOut; |
26 | | - $this->req_param = $par; |
27 | | - print $wgRequest->getText('param'); |
28 | | - //set the header: |
29 | | - $this->setHeaders(); |
30 | | - |
31 | | - //do the page: |
32 | | - switch($this->req_param){ |
33 | | - case 'Survey': |
34 | | - //check if |
35 | | - $this->do_survey_forum(); |
36 | | - break; |
37 | | - case '':default: |
38 | | - if($wgRequest->getVal('action')=='submit'){ |
39 | | - $this->do_submit(); |
40 | | - }else{ |
41 | | - $this->do_stats_page(); |
42 | | - } |
43 | | - break; |
44 | | - } |
45 | | - } |
46 | | - function do_stats_page(){ |
47 | | - global $wgOut, $wgRequest; |
48 | | - $wgOut->addHTML( " $this->req_param stats output will go here, with a link to a full report once its available"); |
49 | | - } |
50 | | - function do_survey_forum(){ |
51 | | - global $wgOut, $psEmbedAry, $wgTitle, $wgUser,$wgEnableParserCache, $wgParser, $wgScript; |
52 | | - $wgOut->addHTML ( wfMsg('ps_survey_description')); |
53 | | - |
54 | | - //select the embed ary element: |
55 | | - $tw=0; |
56 | | - foreach($psEmbedAry as $embed){ |
57 | | - $tw+=$embed['weight']; |
58 | | - } |
59 | | - $selected_val = rand(1, $tw); |
60 | | - $tw=0; |
61 | | - foreach($psEmbedAry as $embed){ |
62 | | - $tw+=$embed['weight']; |
63 | | - if($tw>=$selected_val){ |
64 | | - break; |
65 | | - } |
66 | | - } |
67 | | - $embed_code=''; |
68 | | - if(isset($embed['html_code'])){ |
69 | | - //run the stats (if not internal oggPlay) |
70 | | - $this->runJS_Stats(); |
71 | | - $embed_code=$embed['html_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(); |
76 | | - } |
77 | | - //print "EMBED C: $embed_code \n"; |
78 | | - //$q = 'action='.$this->action; |
79 | | - #if ( "no" == $redirect ) { $q .= "&redirect=no"; } |
80 | | - //$action = $wgScript.'?title='.$wgTitle->getDBKey() . '/Thanks'; |
81 | | - $action = $wgTitle->getLocalURL('action=submit'); |
82 | | - $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey); |
83 | | - $enUserHash = Xml::encodeJsVar( $jsUserHash ); |
84 | | - //work with "embed" |
85 | | - |
86 | | - |
87 | | - //output table with flash and or video embed: |
88 | | - $wgOut->addHTML( <<<EOT |
| 7 | + var $action = ''; |
| 8 | + function SpecialPlayerStatsGrabber() { |
| 9 | + SpecialPage::SpecialPage( "PlayerStatsGrabber" ); |
| 10 | + wfLoadExtensionMessages( 'PlayerStatsGrabber' ); |
| 11 | + } |
| 12 | + // used for page title |
| 13 | + function getDescription() { |
| 14 | + switch( $this->req_param ) { |
| 15 | + case 'Survey': |
| 16 | + return wfMsg( 'ps_take_video_survey' ); |
| 17 | + break; |
| 18 | + case '': |
| 19 | + default: |
| 20 | + return wfMsg( 'playerstatsgrabber' ); |
| 21 | + break; |
| 22 | + } |
| 23 | + } |
| 24 | + |
| 25 | + function execute( $par ) { |
| 26 | + global $wgRequest, $wgOut; |
| 27 | + $this->req_param = $par; |
| 28 | + print $wgRequest->getText( 'param' ); |
| 29 | + // set the header: |
| 30 | + $this->setHeaders(); |
| 31 | + |
| 32 | + // do the page: |
| 33 | + switch( $this->req_param ) { |
| 34 | + case 'Survey': |
| 35 | + // check if |
| 36 | + $this->do_survey_forum(); |
| 37 | + break; |
| 38 | + case '':default: |
| 39 | + if ( $wgRequest->getVal( 'action' ) == 'submit' ) { |
| 40 | + $this->do_submit(); |
| 41 | + } else { |
| 42 | + $this->do_stats_page(); |
| 43 | + } |
| 44 | + break; |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + function do_stats_page() { |
| 49 | + global $wgOut, $wgRequest; |
| 50 | + $wgOut->addHTML( " $this->req_param stats output will go here, with a link to a full report once its available" ); |
| 51 | + } |
| 52 | + |
| 53 | + function do_survey_forum() { |
| 54 | + global $wgOut, $psEmbedAry, $wgTitle, $wgUser, $wgEnableParserCache, $wgParser, $wgScript; |
| 55 | + $wgOut->addHTML ( wfMsg( 'ps_survey_description' ) ); |
| 56 | + |
| 57 | + // select the embed ary element: |
| 58 | + $tw = 0; |
| 59 | + foreach ( $psEmbedAry as $embed ) { |
| 60 | + $tw += $embed['weight']; |
| 61 | + } |
| 62 | + $selected_val = rand( 1, $tw ); |
| 63 | + $tw = 0; |
| 64 | + foreach ( $psEmbedAry as $embed ) { |
| 65 | + $tw += $embed['weight']; |
| 66 | + if ( $tw >= $selected_val ) { |
| 67 | + break; |
| 68 | + } |
| 69 | + } |
| 70 | + |
| 71 | + $embed_code = ''; |
| 72 | + |
| 73 | + if ( isset( $embed['html_code'] ) ) { |
| 74 | + // run the stats (if not internal oggPlay) |
| 75 | + $this->runJS_Stats(); |
| 76 | + $embed_code = $embed['html_code']; |
| 77 | + } else if ( isset( $embed['wiki_code'] ) ) { |
| 78 | + $popts = new ParserOptions; |
| 79 | + $parserOutput = $wgParser->parse( $embed['wiki_code'], $wgTitle, $popts ); |
| 80 | + $embed_code = $parserOutput->getText(); |
| 81 | + } |
| 82 | + // print "EMBED C: $embed_code \n"; |
| 83 | + // $q = 'action='.$this->action; |
| 84 | + # if ( "no" == $redirect ) { $q .= "&redirect=no"; } |
| 85 | + // $action = $wgScript.'?title='.$wgTitle->getDBKey() . '/Thanks'; |
| 86 | + $action = $wgTitle->getLocalURL( 'action=submit' ); |
| 87 | + $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey ); |
| 88 | + $enUserHash = Xml::encodeJsVar( $jsUserHash ); |
| 89 | + // work with "embed" |
| 90 | + |
| 91 | + |
| 92 | + // output table with flash and or video embed: |
| 93 | + $wgOut->addHTML( <<<EOT |
89 | 94 | <p> |
90 | 95 | <table> |
91 | 96 | <tr> |
92 | 97 | <td valign="top"> |
93 | 98 | $embed_code |
94 | | - </td> |
| 99 | + </td> |
95 | 100 | <td valign="top"> |
96 | | - <form id="ps_editform" name="ps_editform" method="post" action="{$action}" enctype="multipart/form-data"> |
| 101 | + <form id="ps_editform" name="ps_editform" method="post" action="{$action}" enctype="multipart/form-data"> |
97 | 102 | <input type="hidden" name="uh" value={$enUserHash}> |
98 | 103 | EOT |
99 | 104 | ); |
100 | | - //output questions: |
101 | | - $wgOut->addHTML( wfMsg('ps_could_play') ); |
102 | | - //yes no with expand |
| 105 | + // output questions: |
| 106 | + $wgOut->addHTML( wfMsg( 'ps_could_play' ) ); |
| 107 | + // yes no with expand |
103 | 108 | $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 | + onclick="document.getElementById(\'ps_could_not_play\').style.display = \'none\';">' . |
| 110 | + wfMsg( 'ps_play_yes' ) . '<br> |
| 111 | + <input type="radio" name="ps_could_play" value="no" |
| 112 | + onclick="document.getElementById(\'ps_could_not_play\').style.display = \'inline\';">' . |
| 113 | + wfMsg( 'ps_play_no' ) . '<p> |
109 | 114 | <div id="ps_could_not_play" style="display:none;"> |
110 | | - '.wfMsg('ps_problem_checkoff').' |
| 115 | + ' . wfMsg( 'ps_problem_checkoff' ) . ' |
111 | 116 | <table border="0" cellspacing="0" cellpadding="0"> |
112 | 117 | <tr> |
113 | 118 | <td><input type="checkbox" name="ps_no_video" value="1"></td> |
114 | | - <td>'.wfMsg('ps_no_video').' </td> |
| 119 | + <td>' . wfMsg( 'ps_no_video' ) . ' </td> |
115 | 120 | </tr> |
116 | 121 | <tr> |
117 | 122 | <tr> |
118 | 123 | <td><input type="checkbox" name="ps_jumpy_playback" value="1"></td> |
119 | | - <td>'.wfMsg('ps_jumpy_playback').' </td> |
| 124 | + <td>' . wfMsg( 'ps_jumpy_playback' ) . ' </td> |
120 | 125 | </tr> |
121 | | - <tr> |
| 126 | + <tr> |
122 | 127 | <td><input type="checkbox" name="ps_bad_sync" value="1"></td> |
123 | | - <td>'.wfMsg('ps_bad_sync').' </td> |
124 | | - </tr> |
| 128 | + <td>' . wfMsg( 'ps_bad_sync' ) . ' </td> |
| 129 | + </tr> |
125 | 130 | <tr> |
126 | 131 | <td><input type="checkbox" name="ps_no_sound" value="1"></td> |
127 | | - <td>'.wfMsg('ps_no_sound').'</td> |
| 132 | + <td>' . wfMsg( 'ps_no_sound' ) . '</td> |
128 | 133 | </tr> |
129 | | - </table> |
130 | | - '.wfMsg('ps_problems_desc').'<br><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br> |
| 134 | + </table> |
| 135 | + ' . wfMsg( 'ps_problems_desc' ) . '<br><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br> |
131 | 136 | </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').'">' |
| 137 | + ' . wfMsg( 'ps_would_install' ) . '<br>' . |
| 138 | + '<input type="radio" name="ps_would_install" value="yes">' . wfMsg( 'ps_yes_install' ) . '<br>' . |
| 139 | + '<input type="radio" name="ps_would_install" value="no">' . wfMsg( 'ps_no_install' ) . '<br>' |
| 140 | +); |
| 141 | + // if ie output switch check: |
| 142 | + if ( preg_match( '|MSIE ([0-9].[0-9]{1,2})|', $_SERVER['HTTP_USER_AGENT'], $matched ) ) { |
| 143 | + $wgOut->addHTML( '<br>' . |
| 144 | + wfMsg( 'ps_would_switch' ) . '<br>' . |
| 145 | + '<input type="radio" name="ps_would_switch" value="yes">' . wfMsg( 'ps_yes_switch' ) . '<br>' . |
| 146 | + '<input type="radio" name="ps_would_switch" value="no">' . wfMsg( 'ps_no_install' ) . '<br>' |
| 147 | + ); |
| 148 | + } |
| 149 | + $wgOut->addHTML( '<br>' . wfMsg( 'ps_your_email' ) . '<br>' . |
| 150 | + '<input type="text" name="ps_your_email" size="30" maxlength="200"><p>' . |
| 151 | + wfMsg( 'ps_privacy' ) . '<br>' . |
| 152 | + '<input type="submit" value="' . wfMsg( 'ps_submit_survey' ) . '">' |
148 | 153 | ); |
149 | | - |
150 | | - $wgOut->addHTML(' |
| 154 | + |
| 155 | + $wgOut->addHTML( ' |
151 | 156 | </form> |
152 | 157 | </td> |
153 | 158 | </tr> |
154 | | -</table>'); |
| 159 | +</table>' ); |
155 | 160 | } |
156 | | - function do_submit(){ |
| 161 | + function do_submit() { |
157 | 162 | 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' ) ) |
| 163 | + print_r( $wgRequest ); |
| 164 | + // print "NO VIDEO: " |
| 165 | + $insAry = array( |
| 166 | + 'user_hash' => $wgRequest->getVal( 'uh' ), |
| 167 | + |
| 168 | + 'ps_could_play' => ( $wgRequest->getVal( 'ps_could_play' ) == '' ) ? 0:1, |
| 169 | + 'ps_jumpy_playback' => ( $wgRequest->getVal( 'ps_jumpy_playback' ) == '' ) ? 0:1, |
| 170 | + 'ps_no_video' => ( $wgRequest->getVal( 'ps_no_video' ) == '' ) ? 0:1, |
| 171 | + 'ps_bad_sync' => ( $wgRequest->getVal( 'ps_bad_sync' ) == '' ) ? 0:1, |
| 172 | + 'ps_no_sound' => ( $wgRequest->getVal( 'ps_no_sound' ) == '' ) ? 0:1, |
| 173 | + |
| 174 | + 'ps_would_install' => ( $wgRequest->getVal( 'ps_would_install' ) == 'no' ) ? 0:1, |
| 175 | + |
| 176 | + 'ps_your_email' => htmlspecialchars( $wgRequest->getVal( 'ps_your_email' ) ), |
| 177 | + 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal( 'ps_problems_desc' ) ) |
173 | 178 | ); |
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); |
| 179 | + if ( $wgRequest->getVal( 'ps_would_switch' ) != '' ) |
| 180 | + $insAry['ps_would_switch'] = ( $wgRequest->getVal( 'ps_would_switch' ) == 'yes' ) ? 1:0; |
| 181 | + |
| 182 | + print_r( $insAry ); |
178 | 183 | } |
179 | 184 | /* to run the stats in cases where we are not using oggHanndler to play*/ |
180 | | - function runJS_Stats(){ |
| 185 | + function runJS_Stats() { |
181 | 186 | global $wgOut, $wgScriptPath; |
182 | 187 | $scriptPath = OggHandler::getMyScriptPath(); |
183 | | - //include the javascript and do the stats |
| 188 | + // include the javascript and do the stats |
184 | 189 | $wgOut->addHTML( <<<EOT |
185 | 190 | <script type="text/javascript" src="$scriptPath/OggPlayer.js"></script> |
186 | 191 | <script type="text/javascript" src="$wgScriptPath/extensions/PlayerStatsGrabber/playerStats.js"></script> |
— | — | @@ -188,7 +193,5 @@ |
189 | 194 | </script> |
190 | 195 | EOT |
191 | 196 | ); |
192 | | - } |
| 197 | + } |
193 | 198 | } |
194 | | - |
195 | | -?> |
\ No newline at end of file |
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.i18n.php |
— | — | @@ -3,33 +3,33 @@ |
4 | 4 | |
5 | 5 | $messages['en'] = array( |
6 | 6 | 'playerstatsgrabber' => 'Player stats survey', |
7 | | - 'ps_take_video_survey'=> 'Video playback survey', |
8 | | - 'ps_survey_description'=> 'This survey will help improve support for rich media. |
| 7 | + 'ps_take_video_survey' => 'Video playback survey', |
| 8 | + 'ps_survey_description' => 'This survey will help improve support for rich media. |
9 | 9 | 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, there were issues or it did not play', |
| 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, there were issues or it did not play', |
13 | 13 | |
14 | 14 | 'ps_problem_checkoff' => 'Please mark any of the following problems if they occurred:', |
15 | 15 | |
16 | 16 | 'ps_no_video' => 'No video played back at all', |
17 | | - 'ps_jumpy_playback' =>' Jumping playback (the video played,, then paused then played)', |
| 17 | + 'ps_jumpy_playback' => ' Jumping playback (the video played,, then paused then played)', |
18 | 18 | 'ps_no_sound' => 'No audio, (my computer volume is on, but I hear no audio for this video)', |
19 | 19 | 'ps_bad_sync' => 'Audio was out of sync with the video', |
20 | 20 | |
21 | 21 | 'ps_problems_desc' => 'Please describe any additional issues below (optional):', |
22 | 22 | |
23 | | - 'ps_would_install' =>'Would you install an additional plug-in to view videos on this wiki?', |
24 | | - 'ps_no_install' =>'No, I would not install an additional plug-in', |
25 | | - 'ps_yes_install' =>'Yes, I would install an additional plug-in', |
| 23 | + 'ps_would_install' => 'Would you install an additional plug-in to view videos on this wiki?', |
| 24 | + 'ps_no_install' => 'No, I would not install an additional plug-in', |
| 25 | + 'ps_yes_install' => 'Yes, I would install an additional plug-in', |
26 | 26 | |
27 | | - 'ps_would_switch' =>'You appear to be running Internet Explorer. |
| 27 | + 'ps_would_switch' => 'You appear to be running Internet Explorer. |
28 | 28 | Would you consider installing a different browser to improve your media experience on this wiki?', |
29 | | - 'ps_yes_switch' =>'Yes, I would switch browsers', |
30 | | - 'ps_no_switch' =>'No, I would switch browsers', |
| 29 | + 'ps_yes_switch' => 'Yes, I would switch browsers', |
| 30 | + 'ps_no_switch' => 'No, I would switch browsers', |
31 | 31 | |
32 | | - 'ps_your_email' =>'Your email address (optional)', |
33 | | - 'ps_submit_survey' =>'Submit survey', |
34 | | - 'ps_privacy' =>'Privacy link or note goes here', |
35 | | - 'ps_thanks' =>'Thank you for participating in this video survey', |
| 32 | + 'ps_your_email' => 'Your email address (optional)', |
| 33 | + 'ps_submit_survey' => 'Submit survey', |
| 34 | + 'ps_privacy' => 'Privacy link or note goes here', |
| 35 | + 'ps_thanks' => 'Thank you for participating in this video survey', |
36 | 36 | ); |
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php |
— | — | @@ -1,121 +1,120 @@ |
2 | 2 | <?php |
3 | 3 | /* |
4 | | - * simple stats output and gather for oggPlay and a "sample page" |
5 | | - */ |
| 4 | + * simple stats output and gather for oggPlay and a "sample page" |
| 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')) { |
9 | | - echo <<<EOT |
| 8 | +if ( !defined( 'MEDIAWIKI' ) ) { |
| 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 | | - exit( 1 ); |
| 13 | + exit( 1 ); |
14 | 14 | } |
15 | 15 | /* |
16 | 16 | * config values |
17 | 17 | */ |
18 | 18 | |
19 | | -//embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1) |
20 | | -//flash embed coode (the raw html that gets outputed to the browers) |
| 19 | +// embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1) |
| 20 | +// flash embed coode (the raw html that gets outputed to the browers) |
21 | 21 | $psEmbedAry = array( |
22 | | - array( 'embed_type'=>'flash', |
23 | | - 'source_type'=>'youtube', |
24 | | - 'name'=>'Sample Youtube Embed', |
25 | | - 'weight'=>1, |
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>' |
| 22 | + array( |
| 23 | + 'embed_type' => 'flash', |
| 24 | + 'source_type' => 'youtube', |
| 25 | + 'name' => 'Sample Youtube Embed', |
| 26 | + 'weight' => 1, |
| 27 | + '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>' |
27 | 28 | ), |
28 | | - array( 'embed_type' =>'ogg', |
29 | | - 'name'=>'Sample oggPlay Embed', |
30 | | - 'weight'=>1, |
31 | | - 'wiki_code' =>'[[Image:Sample_fish.ogg]]' |
| 29 | + array( |
| 30 | + 'embed_type' => 'ogg', |
| 31 | + 'name' => 'Sample oggPlay Embed', |
| 32 | + 'weight' => 1, |
| 33 | + 'wiki_code' => '[[Image:Sample_fish.ogg]]' |
32 | 34 | ) |
33 | 35 | ); |
34 | 36 | |
35 | | - |
36 | | - |
37 | 37 | /* |
38 | 38 | * end config |
39 | 39 | */ |
40 | 40 | |
41 | | -$wgExtensionMessagesFiles['PlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber.i18n.php'; |
42 | | -$wgAutoloadClasses['SpecialPlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber_body.php'; |
43 | | -$wgSpecialPages['PlayerStatsGrabber'] = array( 'SpecialPlayerStatsGrabber' ); |
44 | | - |
| 41 | +$wgExtensionMessagesFiles['PlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber.i18n.php'; |
| 42 | +$wgAutoloadClasses['SpecialPlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber_body.php'; |
| 43 | +$wgSpecialPages['PlayerStatsGrabber'] = array( 'SpecialPlayerStatsGrabber' ); |
| 44 | + |
45 | 45 | $wgSpecialPageGroups['PlayerStatsGrabber'] = 'wiki'; // like Special:Statistics |
46 | 46 | |
47 | | -//add ajax hook to accept the status input: |
| 47 | +// add ajax hook to accept the status input: |
48 | 48 | $wgAjaxExportList[] = 'mw_push_player_stats'; |
49 | 49 | |
50 | 50 | $wgExtensionCredits['media'][] = array( |
51 | 51 | 'name' => 'PlayerStats', |
52 | 52 | 'author' => 'Michael Dale', |
53 | | - 'svn-date' => '$LastChangedDate: 2008-08-06 07:18:43 -0700 (Wed, 06 Aug 2008) $', |
| 53 | + 'svn-date' => '$LastChangedDate: 2008-08-06 07:18:43 -0700 (Wed, 06 Aug 2008) $', |
54 | 54 | 'svn-revision' => '$LastChangedRevision: 38715 $', |
55 | 55 | 'url' => 'http://www.mediawiki.org/wiki/Extension:PlayerStats', |
56 | | - 'description' => 'PlayerStats and survey for monitoring theora support relative to flash' |
| 56 | + 'description' => 'PlayerStats and survey for monitoring theora support relative to flash' |
57 | 57 | ); |
58 | 58 | |
59 | | - |
60 | 59 | /* |
61 | 60 | * does a player stats request.. returns the "db key" |
62 | | - * (lets people fill out survay after playing clip) |
63 | | - * or |
64 | | - * (ties survay page data to detection) |
| 61 | + * (lets people fill out survay after playing clip) |
| 62 | + * or |
| 63 | + * (ties survay page data to detection) |
65 | 64 | */ |
66 | | -function mw_push_player_stats(){ |
67 | | - global $wgRequest; |
68 | | - //do the insert into the userPlayerStats table: |
| 65 | +function mw_push_player_stats() { |
| 66 | + global $wgRequest; |
| 67 | + // do the insert into the userPlayerStats table: |
69 | 68 | $dbr =& wfGetDB( DB_READ ); |
70 | | - if( $wgRequest->getVal('cb')=='' |
71 | | - || $wgRequest->getVal('cb_inx')=='' |
72 | | - || $wgRequest->getVal('uh')==''){ |
73 | | - //output error: |
| 69 | + if ( $wgRequest->getVal( 'cb' ) == '' |
| 70 | + || $wgRequest->getVal( 'cb_inx' ) == '' |
| 71 | + || $wgRequest->getVal( 'uh' ) == '' ) { |
| 72 | + // output error: |
74 | 73 | return 'error: missing param for json callback'; |
75 | | - } |
76 | | - if(!isset($wgRequest->data['cs'])|| !is_array($wgRequest->data['cs'])){ |
77 | | - $wgRequest->data['cs']=array(); |
78 | 74 | } |
79 | | - //set up insert array: |
| 75 | + if ( !isset( $wgRequest->data['cs'] ) || !is_array( $wgRequest->data['cs'] ) ) { |
| 76 | + $wgRequest->data['cs'] = array(); |
| 77 | + } |
| 78 | + // set up insert array: |
80 | 79 | $insAry = array( |
81 | | - 'user_hash' => $wgRequest->getVal('uh'), |
82 | | - 'b_user_agent' => $wgRequest->getVal('b_user_agent'), |
83 | | - 'b_name' => $wgRequest->getVal('b_name'), |
84 | | - 'b_version' => $wgRequest->getVal('b_version'), |
85 | | - 'b_os' => $wgRequest->getVal('b_os'), |
86 | | - 'flash_version' => $wgRequest->getVal('fv'), |
87 | | - 'java_version' => $wgRequest->getVal('jv'), |
88 | | - 'html5_video_enabled'=>(in_array('videoElement', $wgRequest->data['cs'] ))?true:false, |
89 | | - 'java_enabled' => ( in_array('cortado', $wgRequest->data['cs'] ) )?true:false, |
90 | | - 'totem_enabled' => ( in_array('totem', $wgRequest->data['cs'] ) )?true:false, |
91 | | - 'flash_enabled' =>( in_array('flash', $wgRequest->data['cs'] ) )?true:false, |
92 | | - 'quicktime_enabled' =>( in_array( array('quicktime-mozilla','quicktime-activex'), |
93 | | - $wgRequest->data['cs'] ) |
94 | | - )?true:false, |
95 | | - 'vlc_enabled' =>( in_array( array('vlc-mozilla', 'vlc-activex'), |
96 | | - $wgRequest->data['cs'] ) |
97 | | - )?true:false, |
98 | | - 'mplayer_enabled' =>( in_array( 'mplayerplug-in', |
99 | | - $wgRequest->data['cs'] ) |
100 | | - )?true:false |
101 | | - ); |
102 | | - //check for user hash (don't collect multiple times for the same user) |
103 | | - //$user_hash = |
104 | | - $insert_id = $dbr->selectField('player_stats_log', 'id', |
105 | | - array( 'user_hash'=>$wgRequest->getVal('uh') ), |
106 | | - 'mw_push_player_stats::Select User Hash'); |
107 | | - //last_insert_id |
108 | | - if( $insert_id ){ |
109 | | - //for now don't insert repeates |
110 | | - }else{ |
| 80 | + 'user_hash' => $wgRequest->getVal( 'uh' ), |
| 81 | + 'b_user_agent' => $wgRequest->getVal( 'b_user_agent' ), |
| 82 | + 'b_name' => $wgRequest->getVal( 'b_name' ), |
| 83 | + 'b_version' => $wgRequest->getVal( 'b_version' ), |
| 84 | + 'b_os' => $wgRequest->getVal( 'b_os' ), |
| 85 | + 'flash_version' => $wgRequest->getVal( 'fv' ), |
| 86 | + 'java_version' => $wgRequest->getVal( 'jv' ), |
| 87 | + 'html5_video_enabled' => ( in_array( 'videoElement', $wgRequest->data['cs'] ) ) ? true:false, |
| 88 | + 'java_enabled' => ( in_array( 'cortado', $wgRequest->data['cs'] ) ) ? true:false, |
| 89 | + 'totem_enabled' => ( in_array( 'totem', $wgRequest->data['cs'] ) ) ? true:false, |
| 90 | + 'flash_enabled' => ( in_array( 'flash', $wgRequest->data['cs'] ) ) ? true:false, |
| 91 | + 'quicktime_enabled' => ( in_array( array( 'quicktime-mozilla', 'quicktime-activex' ), |
| 92 | + $wgRequest->data['cs'] ) |
| 93 | + ) ? true:false, |
| 94 | + 'vlc_enabled' => ( in_array( array( 'vlc-mozilla', 'vlc-activex' ), |
| 95 | + $wgRequest->data['cs'] ) |
| 96 | + ) ? true:false, |
| 97 | + 'mplayer_enabled' => ( in_array( 'mplayerplug-in', |
| 98 | + $wgRequest->data['cs'] ) |
| 99 | + ) ? true:false |
| 100 | + ); |
| 101 | + // check for user hash (don't collect multiple times for the same user) |
| 102 | + // $user_hash = |
| 103 | + $insert_id = $dbr->selectField( 'player_stats_log', 'id', |
| 104 | + array( 'user_hash' => $wgRequest->getVal( 'uh' ) ), |
| 105 | + 'mw_push_player_stats::Select User Hash' ); |
| 106 | + // last_insert_id |
| 107 | + if ( $insert_id ) { |
| 108 | + // for now don't insert repeates |
| 109 | + } else { |
111 | 110 | $dbw =& wfGetDB( DB_WRITE ); |
112 | | - $dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats:Insert'); |
| 111 | + $dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats:Insert' ); |
113 | 112 | $insert_id = $dbw->insertId(); |
114 | 113 | $dbw->commit(); |
115 | 114 | } |
116 | 115 | header( 'Content-Type: text/javascript' ); |
117 | | - return htmlspecialchars( $wgRequest->getVal('cb') ). '(' .PhpArrayToJsObject_Recurse( |
118 | | - array( |
119 | | - 'cb_inx' => htmlspecialchars( $wgRequest->getVal('cb_inx') ), |
| 116 | + return htmlspecialchars( $wgRequest->getVal( 'cb' ) ) . '(' . PhpArrayToJsObject_Recurse( |
| 117 | + array( |
| 118 | + 'cb_inx' => htmlspecialchars( $wgRequest->getVal( 'cb_inx' ) ), |
120 | 119 | 'id' => $insert_id |
121 | 120 | ) |
122 | 121 | ) . ');'; |
— | — | @@ -123,47 +122,48 @@ |
124 | 123 | |
125 | 124 | /* |
126 | 125 | * @@todo should use API json output wrappers |
127 | | - */ |
128 | | -if( ! function_exists('php2jsObj') ){ |
| 126 | + */ |
| 127 | +if ( ! function_exists( 'php2jsObj' ) ) { |
129 | 128 | function php2jsObj( $array, $objName = 'mv_result' ) |
130 | 129 | { |
131 | 130 | return $objName . ' = ' . phpArrayToJsObject_Recurse( $array ) . ";\n"; |
132 | 131 | } |
133 | 132 | } |
134 | | -if( ! function_exists('PhpArrayToJsObject_Recurse') ){ |
| 133 | +if ( ! function_exists( 'PhpArrayToJsObject_Recurse' ) ) { |
135 | 134 | function PhpArrayToJsObject_Recurse( $array ) { |
136 | | - // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes). |
137 | | - if ( ! is_array( $array ) && !is_object( $array ) ) { |
138 | | - // Handle null specially: otherwise it becomes "". |
139 | | - if ( $array === null ) |
140 | | - { |
141 | | - return 'null'; |
142 | | - } |
143 | | - return '"' . javascript_escape( $array ) . '"'; |
144 | | - } |
145 | | - // Open this JS object. |
146 | | - $retVal = "{"; |
147 | | - // Output all key/value pairs as "$key" : $value |
148 | | - // * Output a JS object (using recursion), if $value is a PHP array. |
149 | | - // * Output the value in quotes, if $value is not an array (see above). |
150 | | - $first = true; |
151 | | - foreach ( $array as $key => $value ) { |
152 | | - // Add a comma before all but the first pair. |
153 | | - if ( ! $first ) { |
154 | | - $retVal .= ', '; |
155 | | - } |
156 | | - $first = false; |
157 | | - // Quote $key if it's a string. |
158 | | - if ( is_string( $key ) ) { |
159 | | - $key = '"' . $key . '"'; |
160 | | - } |
161 | | - $retVal .= $key . ' : ' . PhpArrayToJsObject_Recurse( $value ); |
162 | | - } |
163 | | - // Close and return the JS object. |
164 | | - return $retVal . "}"; |
| 135 | + // Base case of recursion: when the passed value is not a PHP array, just output it (in quotes). |
| 136 | + if ( ! is_array( $array ) && !is_object( $array ) ) { |
| 137 | + // Handle null specially: otherwise it becomes "". |
| 138 | + if ( $array === null ) |
| 139 | + { |
| 140 | + return 'null'; |
| 141 | + } |
| 142 | + return '"' . javascript_escape( $array ) . '"'; |
| 143 | + } |
| 144 | + // Open this JS object. |
| 145 | + $retVal = "{"; |
| 146 | + // Output all key/value pairs as "$key" : $value |
| 147 | + // * Output a JS object (using recursion), if $value is a PHP array. |
| 148 | + // * Output the value in quotes, if $value is not an array (see above). |
| 149 | + $first = true; |
| 150 | + foreach ( $array as $key => $value ) { |
| 151 | + // Add a comma before all but the first pair. |
| 152 | + if ( ! $first ) { |
| 153 | + $retVal .= ', '; |
| 154 | + } |
| 155 | + $first = false; |
| 156 | + // Quote $key if it's a string. |
| 157 | + if ( is_string( $key ) ) { |
| 158 | + $key = '"' . $key . '"'; |
| 159 | + } |
| 160 | + $retVal .= $key . ' : ' . PhpArrayToJsObject_Recurse( $value ); |
| 161 | + } |
| 162 | + // Close and return the JS object. |
| 163 | + return $retVal . "}"; |
165 | 164 | } |
166 | 165 | } |
167 | | -if( ! function_exists('javascript_escape')){ |
| 166 | + |
| 167 | +if ( ! function_exists( 'javascript_escape' ) ) { |
168 | 168 | function javascript_escape( $val ) { |
169 | 169 | // first strip /r |
170 | 170 | $val = str_replace( "\r", '', $val ); |
— | — | @@ -172,5 +172,3 @@ |
173 | 173 | $val ); |
174 | 174 | } |
175 | 175 | } |
176 | | - |
177 | | -?> |
\ No newline at end of file |
Index: trunk/extensions/PlayerStatsGrabber/playerStats.js |
— | — | @@ -1,6 +1,6 @@ |
2 | | -//wgServerOveride: leave empty to use the current server |
3 | | -// (else provide the absolute url to index.php of the wiki you are recording stats to) |
4 | | -var wgServerOveride = ""; |
| 2 | +//wgServerOveride: leave empty to use the current server |
| 3 | +// (else provide the absolute url to index.php of the wiki you are recording stats to) |
| 4 | +var wgServerOveride = ""; |
5 | 5 | var global_req_cb = new Array();//the global request callback array |
6 | 6 | |
7 | 7 | /*parseUri class:*/ |
— | — | @@ -13,59 +13,59 @@ |
14 | 14 | this.doStats(); |
15 | 15 | }, |
16 | 16 | doStats:function() { |
17 | | - //make sure we ran detect: |
| 17 | + //make sure we ran detect: |
18 | 18 | if (!this.detectionDone) { |
19 | 19 | this.detect(); |
20 | 20 | } |
21 | | - |
22 | | - //build our request url: |
| 21 | + |
| 22 | + //build our request url: |
23 | 23 | if( wgServerOveride!="" ){ |
24 | 24 | url= wgServerOveride; |
25 | 25 | }else{ |
26 | 26 | url = wgServer +((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript); |
27 | 27 | } |
28 | | - url += "?action=ajax&rs=mw_push_player_stats"; |
29 | | - |
30 | | - //detect windows media player ( direct show filters could be installed) |
31 | | - if ( navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && |
| 28 | + url += "?action=ajax&rs=mw_push_player_stats"; |
| 29 | + |
| 30 | + //detect windows media player ( direct show filters could be installed) |
| 31 | + if ( navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && |
32 | 32 | navigator.mimeTypes["video/x-ms-wm"].enabledPlugin){ |
33 | 33 | this.clientSupports['ms_video']; |
34 | 34 | } |
35 | 35 | //@@todo research if we can detect if MS video support a given codec |
36 | | - |
| 36 | + |
37 | 37 | //detect flash support |
38 | 38 | if( FlashDetect.installed ) |
39 | | - this.clientSupports['flash']=true; |
40 | | - |
| 39 | + this.clientSupports['flash']=true; |
| 40 | + |
41 | 41 | var j=0; |
42 | 42 | for(var i in this.clientSupports){ |
43 | 43 | url+='&cs[]='+encodeURIComponent(i); |
44 | 44 | j++; |
45 | 45 | } |
46 | | - |
| 46 | + |
47 | 47 | //get the flash version: |
48 | 48 | url+='&fv='+ encodeURIComponent( FlashDetect.raw ); |
49 | | - |
50 | | - |
51 | | - //detect java version if possible: (ie not IE with default security) |
| 49 | + |
| 50 | + |
| 51 | + //detect java version if possible: (ie not IE with default security) |
52 | 52 | if( javaDetect.version ){ |
53 | 53 | url+= '&jv='+ encodeURIComponent ( javaDetect.version ); |
54 | 54 | } |
55 | | - |
56 | | - //add some additional params seperated out to enum keys: |
57 | | - url+= '&b_user_agent=' +encodeURIComponent( navigator.userAgent ); |
| 55 | + |
| 56 | + //add some additional params seperated out to enum keys: |
| 57 | + url+= '&b_user_agent=' +encodeURIComponent( navigator.userAgent ); |
58 | 58 | url+= '&b_name=' + encodeURIComponent( BrowserDetect.browser ) ; |
59 | 59 | url+= '&b_version=' + encodeURIComponent( BrowserDetect.version ); |
60 | | - url+= '&b_os=' + encodeURIComponent( BrowserDetect.OS ) ; |
61 | | - |
| 60 | + url+= '&b_os=' + encodeURIComponent( BrowserDetect.OS ) ; |
| 61 | + |
62 | 62 | //and finaly add the user hash: |
63 | 63 | url+='&uh=' + encodeURIComponent ( wgOggPlayer.userHash ); |
64 | | - |
65 | | - //now send out our stats update (run via javascript include to support remote servers: |
| 64 | + |
| 65 | + //now send out our stats update (run via javascript include to support remote servers: |
66 | 66 | do_request ( url, function( responseObj ){ |
67 | 67 | wg_ran_stats( responseObj ); |
68 | | - }); |
69 | | - } |
| 68 | + }); |
| 69 | + } |
70 | 70 | } |
71 | 71 | //extend the OggHandler object for stats collection |
72 | 72 | for(i in wgOggPlayer){ |
— | — | @@ -77,9 +77,9 @@ |
78 | 78 | function wg_ran_stats(responseObj){ |
79 | 79 | js_log('did stats with id:' + responseObj['id']); |
80 | 80 | } |
81 | | -/* |
| 81 | +/* |
82 | 82 | * a few utily functions |
83 | | - * to enable cross site requests via json: |
| 83 | + * to enable cross site requests via json: |
84 | 84 | */ |
85 | 85 | function loadExternalJs(url){ |
86 | 86 | js_log('load js: '+ url); |
— | — | @@ -104,7 +104,7 @@ |
105 | 105 | } |
106 | 106 | function js_log(string){ |
107 | 107 | if( window.console ){ |
108 | | - console.log(string); |
| 108 | + console.log(string); |
109 | 109 | }else{ |
110 | 110 | /* |
111 | 111 | * IE and non-firebug debug: |
— | — | @@ -127,20 +127,20 @@ |
128 | 128 | javaEnabled: false, |
129 | 129 | version: false, |
130 | 130 | init:function(){ |
131 | | - if (typeof navigator != 'undefined' && typeof navigator.javaEnabled != 'undefined'){ |
| 131 | + if (typeof navigator != 'undefined' && typeof navigator.javaEnabled != 'undefined'){ |
132 | 132 | this.javaEnabled = navigator.javaEnabled(); |
133 | 133 | }else{ |
134 | 134 | this.javaEnabled = 'unknown'; |
135 | 135 | } |
136 | 136 | if (navigator.javaEnabled() && typeof java != 'undefined') |
137 | | - this.version = java.lang.System.getProperty("java.version"); |
138 | | - //try to get the IE version of java (not likely to work with default security setting) |
| 137 | + this.version = java.lang.System.getProperty("java.version"); |
| 138 | + //try to get the IE version of java (not likely to work with default security setting) |
139 | 139 | if( wgOggPlayer.msie ){ |
140 | 140 | var shell; |
141 | 141 | try { |
142 | 142 | // Create WSH(WindowsScriptHost) shell, available on Windows only |
143 | 143 | shell = new ActiveXObject("WScript.Shell"); |
144 | | - |
| 144 | + |
145 | 145 | if (shell != null) { |
146 | 146 | // Read JRE version from Window Registry |
147 | 147 | try { |
Index: trunk/extensions/PlayerStatsGrabber/playerStats.sql |
— | — | @@ -35,4 +35,3 @@ |
36 | 36 | PRIMARY KEY (`id`), |
37 | 37 | KEY `user_hash` (`user_hash`) |
38 | 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ; |
39 | | - |