r63413 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r63412‎ | r63413 | r63414 >
Date:20:27, 8 March 2010
Author:ialex
Status:ok
Tags:
Comment:
* Removed some ?>
* Removed trailing spaces
Modified paths:
  • /trunk/extensions/Eval/SpecialEval.class.php (modified) (history)
  • /trunk/extensions/Eval/SpecialEval.php (modified) (history)
  • /trunk/extensions/Hanp/php-utf8/utf8.inc (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php (modified) (history)
  • /trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php (modified) (history)
  • /trunk/extensions/SlippyMap/SlippyMapExportCgiBin.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Hanp/php-utf8/utf8.inc
@@ -209,4 +209,3 @@
210210 return $dest;
211211 }
212212
213 -?>
Index: trunk/extensions/SlippyMap/SlippyMapExportCgiBin.class.php
@@ -9,13 +9,13 @@
1010
1111 /** borrowed from OpenLayers.DOTS_PER_UNIT */
1212 private static $INCHES_PER_UNIT = array (
13 - 'dd' => 4374754,
14 - 'm' => 39.3701
 13+ 'dd' => 4374754,
 14+ 'm' => 39.3701
1515 );
16 -
 16+
1717 /** borrowed from OpenLayers.DOTS_PER_INCH */
1818 private static $DOTS_PER_INCH = 72;
19 -
 19+
2020 /** pixel size in meters */
2121 private static $PIXEL_SIZE = 0.00028;
2222
@@ -74,11 +74,11 @@
7575 if ( $this->options['sphericalMercator'] ) {
7676 // Calculate bounds within a spherical mercator projection if that is what the scale is based on
7777 $mercatorCenter = self::forwardMercator( $center );
78 - $mbounds = array(
79 - $mercatorCenter[0] - $w_deg / 2,
80 - $mercatorCenter[1] - $h_deg / 2,
81 - $mercatorCenter[0] + $w_deg / 2,
82 - $mercatorCenter[1] + $h_deg / 2
 78+ $mbounds = array(
 79+ $mercatorCenter[0] - $w_deg / 2,
 80+ $mercatorCenter[1] - $h_deg / 2,
 81+ $mercatorCenter[0] + $w_deg / 2,
 82+ $mercatorCenter[1] + $h_deg / 2
8383 );
8484 $this->bounds = self::inverseMercator( $mbounds );
8585 }
@@ -94,21 +94,21 @@
9595 protected function getScaleFromResolution( $resolution ) {
9696 return $resolution * self::$INCHES_PER_UNIT[$this->options['unit']] * self::$DOTS_PER_INCH;
9797 }
98 -
 98+
9999 /**
100100 * Determines resolutions and scales based on a maximum resolution and number of zoom levels
101101 * Borrowed from OpenLayers.Layer.initResolutions
102102 */
103103 protected function initResolutionsAndScales() {
104 - $this->resolutions = array();
105 - $base = 2;
106 -
107 - for ( $i = 0; $i < $this->options['numZoomLevels']; $i++ ) {
108 - $this->resolutions[$i] = $this->options['maxResolution'] / pow( $base, $i );
 104+ $this->resolutions = array();
 105+ $base = 2;
 106+
 107+ for ( $i = 0; $i < $this->options['numZoomLevels']; $i++ ) {
 108+ $this->resolutions[$i] = $this->options['maxResolution'] / pow( $base, $i );
109109 $this->scales[$i] = $this->getScaleFromResolution( $this->resolutions[$i] );
110110 }
111111 }
112 -
 112+
113113 /**
114114 * Convert from WGS84 to spherical mercator
115115 */
@@ -116,14 +116,14 @@
117117 for ($i=0; $i<count($lonlat); $i+=2) {
118118 /* lon */
119119 $lonlat[$i] = $lonlat[$i] * (2 * M_PI * 6378137 / 2.0) / 180.0;
120 -
 120+
121121 /* lat */
122122 $lonlat[$i+1] = log(tan((90 + $lonlat[$i+1]) * M_PI / 360.0)) / (M_PI / 180.0);
123123 $lonlat[$i+1] = $lonlat[$i+1] * (2 * M_PI * 6378137 / 2.0) / 180.0;
124 - }
 124+ }
125125 return $lonlat;
126126 }
127 -
 127+
128128 /**
129129 * Convert from spherical mercator to WGS84
130130 */
@@ -131,13 +131,12 @@
132132 for ($i=0; $i<count($lonlat); $i+=2) {
133133 /* lon */
134134 $lonlat[$i] = $lonlat[$i] / ((2 * M_PI * 6378137 / 2.0) / 180.0);
135 -
 135+
136136 /* lat */
137137 $lonlat[$i+1] = $lonlat[$i+1] / ((2 * M_PI * 6378137 / 2.0) / 180.0);
138138 $lonlat[$i+1] = 180.0 / M_PI * (2 * atan(exp($lonlat[$i+1] * M_PI / 180.0)) - M_PI / 2);
139 - }
140 -
 139+ }
 140+
141141 return $lonlat;
142142 }
143143 }
144 -?>
Index: trunk/extensions/Eval/SpecialEval.class.php
@@ -156,4 +156,4 @@
157157 );
158158 }
159159 }
160 -?>
 160+
Index: trunk/extensions/Eval/SpecialEval.php
@@ -25,4 +25,3 @@
2626 $wgSpecialPages['Eval'] = 'SpecialEval';
2727 $wgAutoloadClasses['SpecialEval'] = $dir . 'SpecialEval.class.php';
2828
29 -?>
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber_body.php
@@ -26,7 +26,7 @@
2727 // print $wgRequest->getText( 'param' );
2828 // set the header:
2929 $this->setHeaders();
30 -
 30+
3131 // do the page:
3232 switch( $this->req_param ) {
3333 case 'Survey':
@@ -51,7 +51,7 @@
5252 function do_survey_forum() {
5353 global $wgOut, $psEmbedAry, $wgTitle, $wgUser, $wgEnableParserCache, $wgParser, $wgScript;
5454 $wgOut->addHTML ( wfMsg( 'ps_survey_description' ) );
55 -
 55+
5656 // select the embed ary element:
5757 $tw = 0;
5858 foreach ( $psEmbedAry as $embed ) {
@@ -85,7 +85,7 @@
8686 // work with "embed"
8787 $embed_key = $embed['embed_key'];
8888 $userToken = htmlspecialchars( $wgUser->editToken() );
89 -
 89+
9090 // output table with flash and or video embed:
9191 $wgOut->addHTML( <<<EOT
9292 <p>
@@ -107,31 +107,31 @@
108108 $wgOut->addHTML( '<br /><input type="radio" name="ps_could_play" value="yes"
109109 onclick="document.getElementById(\'ps_could_not_play\').style.display = \'none\';">' .
110110 wfMsg( 'ps_play_yes' ) . '<br />
111 - <input type="radio" name="ps_could_play" value="no"
 111+ <input type="radio" name="ps_could_play" value="no"
112112 onclick="document.getElementById(\'ps_could_not_play\').style.display = \'inline\';">' .
113113 wfMsg( 'ps_play_no' ) . '<p>
114114 <div id="ps_could_not_play" style="display:none;">
115115 ' . wfMsg( 'ps_problem_checkoff' ) . '
116 - <table border="0" cellspacing="0" cellpadding="0">
117 - <tr>
118 - <td><input type="checkbox" name="ps_no_video" value="1"></td>
119 - <td>' . wfMsg( 'ps_no_video' ) . ' </td>
120 - </tr>
121 - <tr>
122 - <tr>
123 - <td><input type="checkbox" name="ps_jumpy_playback" value="1"></td>
124 - <td>' . wfMsg( 'ps_jumpy_playback' ) . ' </td>
125 - </tr>
126 - <tr>
127 - <td><input type="checkbox" name="ps_bad_sync" value="1"></td>
128 - <td>' . wfMsg( 'ps_bad_sync' ) . ' </td>
129 - </tr>
 116+ <table border="0" cellspacing="0" cellpadding="0">
130117 <tr>
131 - <td><input type="checkbox" name="ps_no_sound" value="1"></td>
132 - <td>' . wfMsg( 'ps_no_sound' ) . '</td>
133 - </tr>
134 - </table>
135 - ' . wfMsg( 'ps_problems_desc' ) . '<br /><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br />
 118+ <td><input type="checkbox" name="ps_no_video" value="1"></td>
 119+ <td>' . wfMsg( 'ps_no_video' ) . ' </td>
 120+ </tr>
 121+ <tr>
 122+ <tr>
 123+ <td><input type="checkbox" name="ps_jumpy_playback" value="1"></td>
 124+ <td>' . wfMsg( 'ps_jumpy_playback' ) . ' </td>
 125+ </tr>
 126+ <tr>
 127+ <td><input type="checkbox" name="ps_bad_sync" value="1"></td>
 128+ <td>' . wfMsg( 'ps_bad_sync' ) . ' </td>
 129+ </tr>
 130+ <tr>
 131+ <td><input type="checkbox" name="ps_no_sound" value="1"></td>
 132+ <td>' . wfMsg( 'ps_no_sound' ) . '</td>
 133+ </tr>
 134+ </table>
 135+ ' . wfMsg( 'ps_problems_desc' ) . '<br /><textarea name="ps_problems_desc" rows="2" cols="40" MAXLENGTH="300"></textarea><br />
136136 </div>
137137 ' . wfMsg( 'ps_would_install' ) . '<br />' .
138138 '<input type="radio" name="ps_would_install" value="yes">' . wfMsg( 'ps_yes_install' ) . '<br />' .
@@ -160,7 +160,7 @@
161161 function do_submit_player_log() {
162162 global $wgRequest, $psLogEveryPlayRequestPerUser;
163163 // do the insert into the userPlayerStats table:
164 - $dbr = wfGetDB( DB_READ );
 164+ $dbr = wfGetDB( DB_READ );
165165 $cs = $wgRequest->getArray( 'cs', array() );
166166 // set up insert array:
167167 $insAry = array(
@@ -185,7 +185,7 @@
186186 $insert_id = $dbr->selectField( 'player_stats_log', 'id',
187187 array( 'user_hash' => $wgRequest->getVal( 'uh' ) ),
188188 'do_submit_player_log::Select User Hash' );
189 - // if the user_hash is not already in the db or if we are logging every request do INSERT
 189+ // if the user_hash is not already in the db or if we are logging every request do INSERT
190190 if ( !$insert_id || $psLogEveryPlayRequestPerUser ) {
191191 $dbw = wfGetDB( DB_WRITE );
192192 $dbw->insert( 'player_stats_log', $insAry, 'mw_push_player_stats::Insert' );
@@ -213,29 +213,29 @@
214214 $wgOut->addHTML ( wfMsg( 'token_suffix_mismatch' ) );
215215 return false;
216216 }
217 -
 217+
218218 // print "NO VIDEO: "
219219 $dbr = wfGetDB( DB_READ );
220220 $insAry = array(
221 - 'user_hash' => $wgRequest->getVal( 'uh' ),
 221+ 'user_hash' => $wgRequest->getVal( 'uh' ),
222222 'embed_key' => $wgRequest->getVal( 'embed_key' ),
223223 'player_stats_log_id' => $wgRequest->getVal( 'player_stats_log_id' ),
224 -
225 - 'ps_jumpy_playback' => ( $wgRequest->getVal( 'ps_jumpy_playback' ) == '' ) ? 0:1,
226 - 'ps_no_video' => ( $wgRequest->getVal( 'ps_no_video' ) == '' ) ? 0:1,
227 - 'ps_bad_sync' => ( $wgRequest->getVal( 'ps_bad_sync' ) == '' ) ? 0:1,
228 - 'ps_no_sound' => ( $wgRequest->getVal( 'ps_no_sound' ) == '' ) ? 0:1,
229224
230 - 'ps_your_email' => htmlspecialchars( $wgRequest->getVal( 'ps_your_email' ) ),
231 - 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal( 'ps_problems_desc' ) )
 225+ 'ps_jumpy_playback' => ( $wgRequest->getVal( 'ps_jumpy_playback' ) == '' ) ? 0:1,
 226+ 'ps_no_video' => ( $wgRequest->getVal( 'ps_no_video' ) == '' ) ? 0:1,
 227+ 'ps_bad_sync' => ( $wgRequest->getVal( 'ps_bad_sync' ) == '' ) ? 0:1,
 228+ 'ps_no_sound' => ( $wgRequest->getVal( 'ps_no_sound' ) == '' ) ? 0:1,
 229+
 230+ 'ps_your_email' => htmlspecialchars( $wgRequest->getVal( 'ps_your_email' ) ),
 231+ 'ps_problems_desc' => htmlspecialchars( $wgRequest->getVal( 'ps_problems_desc' ) )
232232 );
233233 // leave NULL if un-answered for all yes no questions: :
234234 if ( $wgRequest->getVal( 'ps_could_play' ) != '' )
235235 $insAry['ps_could_play'] = ( $wgRequest->getVal( 'ps_could_play' ) == 'yes' ) ? 1:0;
236 -
 236+
237237 if ( $wgRequest->getVal( 'ps_would_install' ) != '' )
238238 $insAry['ps_would_install'] = ( $wgRequest->getVal( 'ps_would_install' ) == 'yes' ) ? 1:0;
239 -
 239+
240240 if ( $wgRequest->getVal( 'ps_would_switch' ) != '' )
241241 $insAry['ps_would_switch'] = ( $wgRequest->getVal( 'ps_would_switch' ) == 'yes' ) ? 1:0;
242242
@@ -261,17 +261,15 @@
262262 global $wgOut, $wgScriptPath, $wgUser , $wgProxyKey;
263263 $scriptPath = OggHandler::getMyScriptPath();
264264 // include the javascript and do the stats
265 - $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey );
 265+ $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey );
266266 $wgOut->addHTML( '
267267 <script type="text/javascript" src="'. htmlspecialchars( $scriptPath ) .'/OggPlayer.js"></script>
268268 <script type="text/javascript" src="'. htmlspecialchars( $wgScriptPath ) . '/extensions/PlayerStatsGrabber/playerStats.js"></script>
269 - <script type="text/javascript">
270 - wgOggPlayer.userHash = '. Xml::encodeJsVar( $jsUserHash ) .';
271 - wgOggPlayer.videoUrl='. Xml::encodeJsVar( $vid_url ) . ';
272 - wgOggPlayer.doStats();
273 - </script>'
 269+ <script type="text/javascript">
 270+ wgOggPlayer.userHash = '. Xml::encodeJsVar( $jsUserHash ) .';
 271+ wgOggPlayer.videoUrl='. Xml::encodeJsVar( $vid_url ) . ';
 272+ wgOggPlayer.doStats();
 273+ </script>'
274274 );
275275 }
276276 }
277 -
278 -?>
Index: trunk/extensions/PlayerStatsGrabber/PlayerStatsGrabber.php
@@ -1,6 +1,6 @@
22 <?php
33 /*
4 - * simple stats output and gather for oggPlay and a "sample page"
 4+ * simple stats output and gather for oggPlay and a "sample page"
55 */
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.
@@ -17,8 +17,8 @@
1818 * config values
1919 */
2020
21 -// $psLogEveryPlayRequestPerUser
22 -// true we log every play request
 21+// $psLogEveryPlayRequestPerUser
 22+// true we log every play request
2323 // false we only log play request from different users
2424 $psLogEveryPlayRequestPerUser = true;
2525
@@ -30,30 +30,30 @@
3131 $wgPlayerStatsDB='';
3232 //$psCentralDB = wfGetDB( DB_MASTER, array(), $wgPlayerStatsDB );
3333
34 -// embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1)
 34+// embed code and "weight" (ie weight of 3 is 3x more likely than weight of 1)
3535 // flash embed code (the raw html that gets outputted to the browsers))
36 -// embed key gets recorded to the database to identify what player was sent to the client in the survey
37 -// (you need to add it as an ENUM option)
 36+// embed key gets recorded to the database to identify what player was sent to the client in the survey
 37+// (you need to add it as an ENUM option)
3838 $flowFLVurl = $psScriptPath .'sample_media/sample_barney.flv';
3939 $flowEmbedCode = <<<EOT
4040 <script type="text/javascript" src="{$psScriptPath}/flow_player/flashembed.min.js"></script>
4141 <script type="text/javascript">
42 - flashembed("example",
 42+ flashembed("example",
4343 {
4444 src:'{$psScriptPath}/flow_player/FlowPlayerDark.swf',
45 - width: 400,
 45+ width: 400,
4646 height: 320,
4747 id:'myflash_id',
4848 },
4949 {
50 - config: {
 50+ config: {
5151 autoPlay: false,
5252 id: 'myflash_id',
5353 autoBuffering: true,
5454 controlBarBackgroundColor:'0x2e8860',
5555 initialScale: 'scale',
5656 videoFile: '{$flowFLVurl}'
57 - }}
 57+ }}
5858 );
5959 </script>
6060
@@ -86,13 +86,13 @@
8787 /*
8888 * end config
8989 */
90 -$wgExtensionMessagesFiles['PlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber.i18n.php';
91 -$wgAutoloadClasses['SpecialPlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber_body.php';
92 -$wgSpecialPages['PlayerStatsGrabber'] = array( 'SpecialPlayerStatsGrabber' );
93 -
 90+$wgExtensionMessagesFiles['PlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber.i18n.php';
 91+$wgAutoloadClasses['SpecialPlayerStatsGrabber'] = dirname( __FILE__ ) . '/PlayerStatsGrabber_body.php';
 92+$wgSpecialPages['PlayerStatsGrabber'] = array( 'SpecialPlayerStatsGrabber' );
 93+
9494 $wgSpecialPageGroups['PlayerStatsGrabber'] = 'wiki'; // like Special:Statistics
9595
96 -// add ajax hook to accept the status input:
 96+// add ajax hook to accept the status input:
9797 $wgAjaxExportList[] = 'mw_push_player_stats';
9898
9999 $wgExtensionCredits['media'][] = array(
@@ -106,9 +106,9 @@
107107
108108 /*
109109 * does a player stats request.. returns the "db key"
110 - * (lets people fill out survey after playing clip)
111 - * or
112 - * (ties survey page data to detection)
 110+ * (lets people fill out survey after playing clip)
 111+ * or
 112+ * (ties survey page data to detection)
113113 */
114114 function mw_push_player_stats() {
115115 return SpecialPlayerStatsGrabber::do_submit_player_log();
@@ -165,5 +165,3 @@
166166 $val );
167167 }
168168 }
169 -
170 -?>

Status & tagging log