r53294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53293‎ | r53294 | r53295 >
Date:07:05, 15 July 2009
Author:ashley
Status:deferred
Tags:
Comment:
coding style cleanup for new files in js2 folder
Modified paths:
  • /trunk/phase3/js2/mwEmbed/jsScriptLoader.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/cortado_iframe.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/maintenance/mergeJavascriptMsg.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/minify/JSMin.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/php/mv_embed_iframe.php (modified) (history)

Diff [purge]

Index: trunk/phase3/js2/mwEmbed/php/maintenance/mergeJavascriptMsg.php
@@ -1,81 +1,82 @@
2 -<?
3 -//merges in javascript with mwEmbed.i18n.php
 2+<?php
 3+/**
 4+ * Merges in JavaScript with mwEmbed.i18n.php
 5+ *
 6+ * @file
 7+ * @ingroup Maintenance
 8+ */
49
510 # Abort if called from a web server
611 if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
712 print "This script must be run from the command line\n";
813 exit();
914 }
10 -define('MEDIAWIKI',true);
11 -//get the scriptLoader globals:
 15+define( 'MEDIAWIKI', true );
 16+// get the scriptLoader globals:
1217 require_once('../../jsScriptLoader.php');
1318
1419 $mwSTART_MSG_KEY = '#<JAVASCRIPT EN REPLACE>';
1520 $mwEND_MSG_KEY = '#</JAVASCRIPT EN REPLACE>';
1621 $mwLangFilePath = '../languages/mwEmbed.i18n.php';
17 -//get options (like override JS or override php
 22+// get options (like override JS or override PHP)
1823
 24+// read in mwEmbed.i18n.php
 25+$rawLangFile = file_get_contents( $mwLangFilePath );
1926
20 -//read in mwEmbed.i18n.php
21 -$rawLangFile = file_get_contents($mwLangFilePath);
22 -
23 -$startInx = strpos($rawLangFile, $mwSTART_MSG_KEY) + strlen($mwSTART_MSG_KEY);
24 -$endInx = strpos($rawLangFile, $mwEND_MSG_KEY);
 27+$startInx = strpos( $rawLangFile, $mwSTART_MSG_KEY) + strlen( $mwSTART_MSG_KEY );
 28+$endInx = strpos( $rawLangFile, $mwEND_MSG_KEY );
2529 if( $startInx === false || $endInx === false ){
2630 print "Could not find $mwSTART_MSG_KEY or $mwEND_MSG_KEY in mwEmbed.i18n.php \n";
2731 exit();
2832 }
2933
30 -$preFile = substr( $rawLangFile, 0, $startInx);
31 -$msgSet = substr( $rawLangFile, $startInx, $endInx-$startInx);
32 -$postFile = substr($rawLangFile, $endInx);
 34+$preFile = substr( $rawLangFile, 0, $startInx );
 35+$msgSet = substr( $rawLangFile, $startInx, $endInx-$startInx );
 36+$postFile = substr( $rawLangFile, $endInx );
3337
34 -//build replacement from all javascript in mwEmbed
35 -
 38+// build replacement from all javascript in mwEmbed
3639 $path = realpath('../../');
3740
3841 $curFileName = '';
39 -//@@todo existing msgSet should be parsed (or we just "include" the file first)
 42+// @@todo existing msgSet should be parsed (or we just "include" the file first)
4043 $msgSet = '$messages[\'en\'] = array(';
4144
42 -$objects = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);
43 -foreach($objects as $fname => $object){
44 - if(substr($fname, -3) == '.js'){
 45+$objects = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $path ), RecursiveIteratorIterator::SELF_FIRST );
 46+foreach( $objects as $fname => $object){
 47+ if( substr( $fname, -3 ) == '.js' ){
4548 $jsFileText = file_get_contents( $fname );
46 - $mwPos = strpos($fname, 'mwEmbed') + 7;
 49+ $mwPos = strpos( $fname, 'mwEmbed' ) + 7;
4750 $curFileName = substr( $fname, $mwPos );
48 - if( preg_match('/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', //@@todo fix: will break down if someone does }) in their msg text
 51+ if( preg_match( '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', //@@todo fix: will break down if someone does }) in their msg text
4952 $jsFileText,
50 - $matches) ){
51 - $msgSet .= doJsonMerge($matches[1]);
52 - }
53 - }
 53+ $matches ) ){
 54+ $msgSet .= doJsonMerge( $matches[1] );
 55+ }
 56+ }
5457 }
55 -//close up the msgSet:
56 -$msgSet.=");\n";
 58+// close up the msgSet:
 59+$msgSet.= ");\n";
5760
58 -function doJsonMerge($json_txt){
 61+function doJsonMerge( $json_txt ){
5962 global $curFileName;
6063
6164 $out = "\n\t/*
6265 \t* js file: {$curFileName}
6366 \t*/\n";
6467 $jmsg = json_decode( '{' . $json_txt . '}', true );
65 - if( count($jmsg) != 0 ){
66 - foreach($jmsg as $k=>$v){
67 - $out.="\t'{$k}' => '".str_replace('\'', '\\\'', $v) ."',\n";
 68+ if( count( $jmsg ) != 0 ){
 69+ foreach( $jmsg as $k => $v ){
 70+ $out.="\t'{$k}' => '" . str_replace( '\'', '\\\'', $v ) . "',\n";
6871 }
6972 return $out;
70 - }else{
 73+ } else {
7174 print "could not get any json vars\n";
7275 return '';
7376 }
7477 }
7578
76 -//rebuild and output to file
77 -if( file_put_contents($mwLangFilePath, trim($preFile) . "\n" . trim($msgSet) . "\n" . trim($postFile))){
 79+// rebuild and output to file
 80+if( file_put_contents( $mwLangFilePath, trim( $preFile ) . "\n" . trim( $msgSet ) . "\n" . trim( $postFile ) ) ){
7881 print "updated $mwLangFilePath file\n";
7982 exit();
80 -}
81 -
82 -?>
\ No newline at end of file
 83+}
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/php/cortado_iframe.php
@@ -4,57 +4,59 @@
55 all file checks and conditions should be checked prior to loading this page.
66 this page serves as a wrapper for the cortado java applet
77
8 -@@this may be depreciated in favor of a central hosted java applet
 8+@@this may be deprecated in favor of a central hosted java applet
99 */
1010
1111 cortado_iframe();
1212
1313 function cortado_iframe() {
14 - if(!function_exists('filter_input')){
15 - die('your version of php lacks <b>filter_input()</b> function</br>');
 14+ if( !function_exists( 'filter_input' ) ){
 15+ die( 'your version of PHP lacks <b>filter_input()</b> function<br />' );
1616 }
17 - //load the http GETS:
 17+
 18+ // load the http GETS:
1819 // set the parent domain if provided
1920 $parent_domain = isset( $_GET['parent_domain'] ) ? $_GET['parent_domain'] : false;
2021
21 - //default to null media in not provided:
 22+ // default to null media in not provided:
2223 $media_url = isset( $_GET['media_url'] ) ? $_GET['media_url'] : false;
23 - if( strval($media_url) === ''){
24 - error_out('not valid or missing media url');
 24+ if( strval( $media_url ) === '' ){
 25+ error_out( 'invalid or missing media URL' );
2526 }
26 - //default duration to 30 seconds if not provided. (ideally cortado would read this from the video file)
27 - //$duration = (isset($_GET['duration']))?$_GET['duration']:0;
28 - $duration = filter_input(INPUT_GET, 'duration', FILTER_SANITIZE_NUMBER_INT);
29 - if( is_null($duration) || $duration===false){
30 - $duration=0;
 27+
 28+ // default duration to 30 seconds if not provided. (ideally cortado would read this from the video file)
 29+ //$duration = ( isset( $_GET['duration'] ) ) ? $_GET['duration'] : 0;
 30+ $duration = filter_input( INPUT_GET, 'duration', FILTER_SANITIZE_NUMBER_INT );
 31+ if( is_null( $duration ) || $duration === false ){
 32+ $duration = 0;
3133 }
3234
33 - //id (set to random if none provided)
34 - //$id = (isset($_GET['id']))?$_GET['id']:'vid_'.rand('10000000');
35 - $id = isset($_GET['id']) ? $_GET['id'] : false;
36 - if( is_null($id) || $id===false){
37 - $id = 'vid_'.rand(0,10000000);
 35+ // id (set to random if none provided)
 36+ //$id = ( isset( $_GET['id'] ) ) ? $_GET['id'] : 'vid_' . rand( '10000000' );
 37+ $id = isset( $_GET['id'] ) ? $_GET['id'] : false;
 38+ if( is_null( $id ) || $id === false ){
 39+ $id = 'vid_' . rand( 0, 10000000 );
3840 }
3941
40 - $width = filter_input(INPUT_GET, 'width', FILTER_SANITIZE_NUMBER_INT);
41 - if( is_null($width) || $width===false){
42 - $width=320;
 42+ $width = filter_input( INPUT_GET, 'width', FILTER_SANITIZE_NUMBER_INT );
 43+ if( is_null( $width ) || $width === false ){
 44+ $width = 320;
4345 }
44 - $height = filter_input(INPUT_GET, 'height', FILTER_SANITIZE_NUMBER_INT);
45 - //default to video:
46 - $stream_type = (isset($_GET['stream_type']))?$_GET['stream_type']:'video';
47 - if($stream_type=='video'){
48 - $audio=$video='true';
49 - if(is_null($height) || $height===false)
 46+ $height = filter_input( INPUT_GET, 'height', FILTER_SANITIZE_NUMBER_INT );
 47+ // default to video:
 48+ $stream_type = ( isset( $_GET['stream_type'] ) ) ? $_GET['stream_type'] : 'video';
 49+ if( $stream_type == 'video' ){
 50+ $audio = $video = 'true';
 51+ if( is_null( $height ) || $height === false )
5052 $height = 240;
51 - } else { // if($stream_type=='audio')
52 - $audio='true';
53 - $video='false';
54 - if(is_null($height) || $height===false)
 53+ } else { // if( $stream_type == 'audio' )
 54+ $audio = 'true';
 55+ $video = 'false';
 56+ if( is_null( $height ) || $height === false )
5557 $height = 20;
5658 }
5759
58 - //everything good output page:
 60+ // everything good output page:
5961 output_page(array(
6062 'id' => $id,
6163 'media_url' => $media_url,
@@ -96,11 +98,12 @@
9799 return strtr( $string, $pairs );
98100 }
99101
100 -function error_out($error=''){
101 - output_page(array('error' => $error));
 102+function error_out( $error = '' ){
 103+ output_page( array( 'error' => $error ) );
102104 exit();
103105 }
104 -function output_page($params){
 106+
 107+function output_page( $params ){
105108 extract( $params );
106109 ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
107110 <html xmlns="http://www.w3.org/1999/xhtml">
@@ -108,20 +111,20 @@
109112 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
110113 <title>cortado_embed</title>
111114 <script type="text/javascript">
112 - <? //set the parent domain:
 115+ <?php //set the parent domain:
113116 if( $parent_domain ){?>
114 - try{
115 - document.domain = '<?php echo htmlspecialchars( $parent_domain )?>';
116 - }catch (e){
 117+ try {
 118+ document.domain = '<?php echo htmlspecialchars( $parent_domain ) ?>';
 119+ } catch ( e ) {
117120 if( window.console )
118 - console.log('could not set domain to <?php echo htmlspecialchars( $parent_domain )?>');
 121+ console.log('could not set domain to <?php echo htmlspecialchars( $parent_domain ) ?>');
119122 }
120 - <?
121 - } ?>
122 - var jPlayer = null;
123 - function setGlobalJplayer(){
124 - jPlayer = document.getElementById('<?php echo htmlspecialchars( $id ) ?>');
125 - }
 123+ <?php
 124+ } ?>
 125+ var jPlayer = null;
 126+ function setGlobalJplayer(){
 127+ jPlayer = document.getElementById('<?php echo htmlspecialchars( $id ) ?>');
 128+ }
126129 </script>
127130 <style type="text/css">
128131 <!--
@@ -135,40 +138,38 @@
136139 </style></head>
137140 <body onload="setGlobalJplayer()" >
138141 <?php
139 - $appid = ( preg_match("/MSIE/i", getenv("HTTP_USER_AGENT")) ) ? '' : 'classid="java:com.fluendo.player.Cortado.class"';
140 - if (empty($error)){ ?>
 142+ $appid = ( preg_match( "/MSIE/i", getenv( "HTTP_USER_AGENT" ) ) ) ? '' : 'classid="java:com.fluendo.player.Cortado.class"';
 143+ if( empty( $error ) ){ ?>
141144 <div id="jPlayer"></div>
142145 <OBJECT id="<?php echo htmlspecialchars( $id ) ?>"
143146 code="com.fluendo.player.Cortado.class"
144147 <?php echo $appid ?>
145148 archive="binPlayers/cortado/cortado-wmf-r46643.jar"
146 - width="<?php echo htmlspecialchars( $width )?>"
147 - height="<?php echo htmlspecialchars( $height )?>" >
148 - <param name="url" value="<?php echo htmlspecialchars( $media_url )?>" />
 149+ width="<?php echo htmlspecialchars( $width ) ?>"
 150+ height="<?php echo htmlspecialchars( $height ) ?>" >
 151+ <param name="url" value="<?php echo htmlspecialchars( $media_url ) ?>" />
149152 <param name="local" value="false"/>
150153 <param name="keepaspect" value="true" />
151 - <param name="video" value="<?php echo htmlspecialchars( $video )?>" />
152 - <param name="audio" value="<?php echo htmlspecialchars( $audio )?>" />
 154+ <param name="video" value="<?php echo htmlspecialchars( $video ) ?>" />
 155+ <param name="audio" value="<?php echo htmlspecialchars( $audio ) ?>" />
153156 <param name="seekable" value="false" />
154 - <? if($duration!=0){
155 - ?>
156 - <param name="duration" value="<?php echo htmlspecialchars( $duration )?>" />
157 - <?
158 - } ?>
 157+ <?php if( $duration != 0 ){ ?>
 158+ <param name="duration" value="<?php echo htmlspecialchars( $duration ) ?>" />
 159+ <?php } ?>
159160 <param name="showStatus" value="hide" />
160161 <param name="autoPlay" value="true" />
161162 <param name="BufferSize" value="8192" />
162163 <param name="BufferHigh" value="30" />
163164 <param name="BufferLow" value="5" />
164165 </OBJECT>
165 - <? }else{ ?>
166 - <b>Error:</b> <?php echo htmlspecialchars( $error )?>
167 - <?
 166+ <?php } else { ?>
 167+ <b>Error:</b> <?php echo htmlspecialchars( $error ) ?>
 168+ <?php
168169 }
169170 ?>
170171 </body>
171172 </html>
172 -<?
 173+<?php
173174 }
174175 /*
175176 javascript envoked version:
@@ -218,5 +219,4 @@
219220 doPlayer();
220221 </script>
221222 *
222 -*/
223 -?>
 223+*/
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php
@@ -1,90 +1,89 @@
22 <?php
3 -if ( !defined( 'MEDIAWIKI' ) ) die(1);
 3+if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
44
55 global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory;
66
7 - //the basis of the loader calls:
8 - $wgJSAutoloadLocalClasses['mv_embed'] = $wgMwEmbedDirectory . 'mv_embed.js';
 7+// the basis of the loader calls:
 8+$wgJSAutoloadLocalClasses['mv_embed'] = $wgMwEmbedDirectory . 'mv_embed.js';
99
10 - //core:
11 - $wgJSAutoloadLocalClasses['window.jQuery'] = $wgMwEmbedDirectory . 'jquery/jquery-1.3.2.js';
 10+// core:
 11+$wgJSAutoloadLocalClasses['window.jQuery'] = $wgMwEmbedDirectory . 'jquery/jquery-1.3.2.js';
1212
13 - $wgJSAutoloadLocalClasses['j.secureEvalJSON'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.json-1.3.js';
 13+$wgJSAutoloadLocalClasses['j.secureEvalJSON'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.json-1.3.js';
1414
15 - $wgJSAutoloadLocalClasses['j.cookie'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.cookie.js';
 15+$wgJSAutoloadLocalClasses['j.cookie'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.cookie.js';
1616
17 - $wgJSAutoloadLocalClasses['j.contextMenu'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.contextMenu.js';
18 - $wgJSAutoloadLocalClasses['j.fn.pngFix'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.pngFix.js';
 17+$wgJSAutoloadLocalClasses['j.contextMenu'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.contextMenu.js';
 18+$wgJSAutoloadLocalClasses['j.fn.pngFix'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.pngFix.js';
1919
20 - $wgJSAutoloadLocalClasses['j.fn.autocomplete'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.autocomplete.js';
21 - $wgJSAutoloadLocalClasses['j.fn.hoverIntent'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.hoverIntent.js';
22 - $wgJSAutoloadLocalClasses['Date.fromString'] = $wgMwEmbedDirectory . 'jquery/plugins/date.js';
23 - $wgJSAutoloadLocalClasses['j.fn.datePicker'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.datePicker.js';
 20+$wgJSAutoloadLocalClasses['j.fn.autocomplete'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.autocomplete.js';
 21+$wgJSAutoloadLocalClasses['j.fn.hoverIntent'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.hoverIntent.js';
 22+$wgJSAutoloadLocalClasses['Date.fromString'] = $wgMwEmbedDirectory . 'jquery/plugins/date.js';
 23+$wgJSAutoloadLocalClasses['j.fn.datePicker'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.datePicker.js';
2424
25 - //jcrop
26 - $wgJSAutoloadLocalClasses['j.Jcrop'] = $wgMwEmbedDirectory . 'libClipEdit/Jcrop/js/jquery.Jcrop.js';
 25+// jcrop
 26+$wgJSAutoloadLocalClasses['j.Jcrop'] = $wgMwEmbedDirectory . 'libClipEdit/Jcrop/js/jquery.Jcrop.js';
2727
28 - //color picker
29 - $wgJSAutoloadLocalClasses['j.fn.ColorPicker'] = $wgMwEmbedDirectory . 'libClipEdit/colorpicker/js/colorpicker.js';
 28+// color picker
 29+$wgJSAutoloadLocalClasses['j.fn.ColorPicker'] = $wgMwEmbedDirectory . 'libClipEdit/colorpicker/js/colorpicker.js';
3030
31 - //jquery.ui
32 - $wgJSAutoloadLocalClasses['j.ui'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.core.js';
 31+// jquery.ui
 32+$wgJSAutoloadLocalClasses['j.ui'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.core.js';
3333
34 - $wgJSAutoloadLocalClasses['j.effects.blind'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.blind.js';
35 - $wgJSAutoloadLocalClasses['j.effects.drop'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.drop.js';
36 - $wgJSAutoloadLocalClasses['j.effects.pulsate'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.pulsate.js';
37 - $wgJSAutoloadLocalClasses['j.effects.transfer'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.transfer.js';
38 - $wgJSAutoloadLocalClasses['j.ui.droppable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.droppable.js';
39 - $wgJSAutoloadLocalClasses['j.ui.slider'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.slider.js';
40 - $wgJSAutoloadLocalClasses['j.effects.bounce'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.bounce.js';
41 - $wgJSAutoloadLocalClasses['j.effects.explode'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.explode.js';
42 - $wgJSAutoloadLocalClasses['j.effects.scale'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.scale.js';
43 - $wgJSAutoloadLocalClasses['j.ui.datepicker'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.datepicker.js';
44 - $wgJSAutoloadLocalClasses['j.ui.progressbar'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.progressbar.js';
45 - $wgJSAutoloadLocalClasses['j.ui.sortable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.sortable.js';
46 - $wgJSAutoloadLocalClasses['j.effects.clip'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.clip.js';
47 - $wgJSAutoloadLocalClasses['j.effects.fold'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.fold.js';
48 - $wgJSAutoloadLocalClasses['j.effects.shake'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.shake.js';
49 - $wgJSAutoloadLocalClasses['j.ui.dialog'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.dialog.js';
50 - $wgJSAutoloadLocalClasses['j.ui.resizable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.resizable.js';
51 - $wgJSAutoloadLocalClasses['j.ui.tabs'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.tabs.js';
52 - $wgJSAutoloadLocalClasses['j.effects.core'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.core.js';
53 - $wgJSAutoloadLocalClasses['j.effects.highlight']= $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.highlight.js';
54 - $wgJSAutoloadLocalClasses['j.effects.slide'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.slide.js';
55 - $wgJSAutoloadLocalClasses['j.ui.accordion'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.accordion.js';
56 - $wgJSAutoloadLocalClasses['j.ui.draggable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.draggable.js';
57 - $wgJSAutoloadLocalClasses['j.ui.selectable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.selectable.js';
 34+$wgJSAutoloadLocalClasses['j.effects.blind'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.blind.js';
 35+$wgJSAutoloadLocalClasses['j.effects.drop'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.drop.js';
 36+$wgJSAutoloadLocalClasses['j.effects.pulsate'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.pulsate.js';
 37+$wgJSAutoloadLocalClasses['j.effects.transfer'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.transfer.js';
 38+$wgJSAutoloadLocalClasses['j.ui.droppable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.droppable.js';
 39+$wgJSAutoloadLocalClasses['j.ui.slider'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.slider.js';
 40+$wgJSAutoloadLocalClasses['j.effects.bounce'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.bounce.js';
 41+$wgJSAutoloadLocalClasses['j.effects.explode'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.explode.js';
 42+$wgJSAutoloadLocalClasses['j.effects.scale'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.scale.js';
 43+$wgJSAutoloadLocalClasses['j.ui.datepicker'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.datepicker.js';
 44+$wgJSAutoloadLocalClasses['j.ui.progressbar'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.progressbar.js';
 45+$wgJSAutoloadLocalClasses['j.ui.sortable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.sortable.js';
 46+$wgJSAutoloadLocalClasses['j.effects.clip'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.clip.js';
 47+$wgJSAutoloadLocalClasses['j.effects.fold'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.fold.js';
 48+$wgJSAutoloadLocalClasses['j.effects.shake'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.shake.js';
 49+$wgJSAutoloadLocalClasses['j.ui.dialog'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.dialog.js';
 50+$wgJSAutoloadLocalClasses['j.ui.resizable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.resizable.js';
 51+$wgJSAutoloadLocalClasses['j.ui.tabs'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.tabs.js';
 52+$wgJSAutoloadLocalClasses['j.effects.core'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.core.js';
 53+$wgJSAutoloadLocalClasses['j.effects.highlight']= $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.highlight.js';
 54+$wgJSAutoloadLocalClasses['j.effects.slide'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/effects.slide.js';
 55+$wgJSAutoloadLocalClasses['j.ui.accordion'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.accordion.js';
 56+$wgJSAutoloadLocalClasses['j.ui.draggable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.draggable.js';
 57+$wgJSAutoloadLocalClasses['j.ui.selectable'] = $wgMwEmbedDirectory . 'jquery/jquery.ui-1.7.1/ui/ui.selectable.js';
5858
59 - //libAddMedia:
60 - $wgJSAutoloadLocalClasses['mvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvFirefogg.js';
61 - $wgJSAutoloadLocalClasses['mvAdvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvAdvFirefogg.js';
62 - $wgJSAutoloadLocalClasses['mvBaseUploadInterface'] = $wgMwEmbedDirectory . 'libAddMedia/mvBaseUploadInterface.js';
63 - $wgJSAutoloadLocalClasses['remoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/remoteSearchDriver.js';
64 - $wgJSAutoloadLocalClasses['seqRemoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/seqRemoteSearchDriver.js';
65 - $wgJSAutoloadLocalClasses['baseRemoteSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/baseRemoteSearch.js';
66 - $wgJSAutoloadLocalClasses['mediaWikiSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/mediaWikiSearch.js';
67 - $wgJSAutoloadLocalClasses['metavidSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/metavidSearch.js';
68 - $wgJSAutoloadLocalClasses['archiveOrgSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/archiveOrgSearch.js';
69 - $wgJSAutoloadLocalClasses['baseRemoteSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/baseRemoteSearch.js';
 59+// libAddMedia:
 60+$wgJSAutoloadLocalClasses['mvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvFirefogg.js';
 61+$wgJSAutoloadLocalClasses['mvAdvFirefogg'] = $wgMwEmbedDirectory . 'libAddMedia/mvAdvFirefogg.js';
 62+$wgJSAutoloadLocalClasses['mvBaseUploadInterface'] = $wgMwEmbedDirectory . 'libAddMedia/mvBaseUploadInterface.js';
 63+$wgJSAutoloadLocalClasses['remoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/remoteSearchDriver.js';
 64+$wgJSAutoloadLocalClasses['seqRemoteSearchDriver'] = $wgMwEmbedDirectory . 'libAddMedia/seqRemoteSearchDriver.js';
 65+$wgJSAutoloadLocalClasses['baseRemoteSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/baseRemoteSearch.js';
 66+$wgJSAutoloadLocalClasses['mediaWikiSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/mediaWikiSearch.js';
 67+$wgJSAutoloadLocalClasses['metavidSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/metavidSearch.js';
 68+$wgJSAutoloadLocalClasses['archiveOrgSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/archiveOrgSearch.js';
 69+$wgJSAutoloadLocalClasses['baseRemoteSearch'] = $wgMwEmbedDirectory . 'libAddMedia/searchLibs/baseRemoteSearch.js';
7070
71 - //libClipEdit:
72 - $wgJSAutoloadLocalClasses['mvClipEdit'] = $wgMwEmbedDirectory . 'libClipEdit/mvClipEdit.js';
 71+// libClipEdit:
 72+$wgJSAutoloadLocalClasses['mvClipEdit'] = $wgMwEmbedDirectory . 'libClipEdit/mvClipEdit.js';
7373
74 - //libEmbedObj:
75 - $wgJSAutoloadLocalClasses['embedVideo'] = $wgMwEmbedDirectory . 'libEmbedVideo/embedVideo.js';
76 - $wgJSAutoloadLocalClasses['flashEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/flashEmbed.js';
77 - $wgJSAutoloadLocalClasses['genericEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/genericEmbed.js';
78 - $wgJSAutoloadLocalClasses['htmlEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/htmlEmbed.js';
79 - $wgJSAutoloadLocalClasses['javaEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/javaEmbed.js';
80 - $wgJSAutoloadLocalClasses['nativeEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/nativeEmbed.js';
81 - $wgJSAutoloadLocalClasses['quicktimeEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/quicktimeEmbed.js';
82 - $wgJSAutoloadLocalClasses['vlcEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/vlcEmbed.js';
 74+// libEmbedObj:
 75+$wgJSAutoloadLocalClasses['embedVideo'] = $wgMwEmbedDirectory . 'libEmbedVideo/embedVideo.js';
 76+$wgJSAutoloadLocalClasses['flashEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/flashEmbed.js';
 77+$wgJSAutoloadLocalClasses['genericEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/genericEmbed.js';
 78+$wgJSAutoloadLocalClasses['htmlEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/htmlEmbed.js';
 79+$wgJSAutoloadLocalClasses['javaEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/javaEmbed.js';
 80+$wgJSAutoloadLocalClasses['nativeEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/nativeEmbed.js';
 81+$wgJSAutoloadLocalClasses['quicktimeEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/quicktimeEmbed.js';
 82+$wgJSAutoloadLocalClasses['vlcEmbed'] = $wgMwEmbedDirectory . 'libEmbedVideo/vlcEmbed.js';
8383
84 - //libSequencer:
85 - $wgJSAutoloadLocalClasses['mvPlayList'] = $wgMwEmbedDirectory . 'libSequencer/mvPlayList.js';
86 - $wgJSAutoloadLocalClasses['mvSequencer'] = $wgMwEmbedDirectory . 'libSequencer/mvSequencer.js';
87 - $wgJSAutoloadLocalClasses['mvSequencer'] = $wgMwEmbedDirectory . 'libSequencer/mvSequencer.js';
 84+// libSequencer:
 85+$wgJSAutoloadLocalClasses['mvPlayList'] = $wgMwEmbedDirectory . 'libSequencer/mvPlayList.js';
 86+$wgJSAutoloadLocalClasses['mvSequencer'] = $wgMwEmbedDirectory . 'libSequencer/mvSequencer.js';
 87+$wgJSAutoloadLocalClasses['mvSequencer'] = $wgMwEmbedDirectory . 'libSequencer/mvSequencer.js';
8888
89 - //libTimedText:
90 - $wgJSAutoloadLocalClasses['mvTimedEffectsEdit'] = $wgMwEmbedDirectory . 'libTimedText/mvTimedEffectsEdit.js';
91 -?>
\ No newline at end of file
 89+// libTimedText:
 90+$wgJSAutoloadLocalClasses['mvTimedEffectsEdit'] = $wgMwEmbedDirectory . 'libTimedText/mvTimedEffectsEdit.js';
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/php/languages/mwEmbed.i18n.php
@@ -1,10 +1,11 @@
2 -<?
3 -/* localization file for mwEmbed
 2+<?php
 3+/**
 4+ * Localization file for mwEmbed
45 * updates can be merged from javascript by running maintenance/mergeJavascriptMsg.php
5 - * this file follows the "extension" conventions for language msgs in mediaWiki But should be "usable" stand-alone with the script-loader
 6+ * this file follows the "extension" conventions for language msgs in MediaWiki but should be "usable" stand-alone with the script-loader
67 *
78 * the following English language portion is automatically merged via the maintenance script.
8 -*/
 9+ */
910
1011 #<JAVASCRIPT EN REPLACE>
1112 $messages['en'] = array(
@@ -253,6 +254,4 @@
254255 'size-kilobytes' => '$1 K',
255256 'size-bytes' => '$1 B',
256257 );
257 -#</JAVASCRIPT EN REPLACE>
258 -
259 -?>
\ No newline at end of file
 258+#</JAVASCRIPT EN REPLACE>
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/php/mv_embed_iframe.php
@@ -7,25 +7,25 @@
88 mv_embed_iframe();
99
1010 function mv_embed_iframe() {
11 - if(!function_exists('filter_input')){
12 - die('your version of php lacks <b>filter_input()</b> function</br>');
13 - }
14 - //default to null media in not provided:
15 - $stream_name = ( isset($_GET['sn']) )? $_GET['sn'] : die('no stream name provided');
16 - $time = ( isset($_GET['t']) )? $_GET['t']: '';
17 - $width = ( isset($_GET['width']) )? intval( $_GET['width'] ) : '400';
18 - $height = ( isset($_GET['height']) )? intval( $_GET['height'] ) : '300'; //
19 -
 11+ if( !function_exists( 'filter_input' ) ){
 12+ die( 'your version of PHP lacks <b>filter_input()</b> function<br />' );
 13+ }
 14+ // default to null media in not provided:
 15+ $stream_name = ( isset( $_GET['sn'] ) )? $_GET['sn'] : die('no stream name provided');
 16+ $time = ( isset( $_GET['t'] ) )? $_GET['t']: '';
 17+ $width = ( isset( $_GET['width'] ) )? intval( $_GET['width'] ) : '400';
 18+ $height = ( isset( $_GET['height'] ) )? intval( $_GET['height'] ) : '300'; //
 19+
2020 $roe_url = 'http://metavid.org/wiki/Special:MvExportStream?feed_format=roe&stream_name=' . htmlspecialchars( $stream_name ) .
2121 '&t=' . htmlspecialchars( $time );
22 - //everything good output page:
 22+ //everything good output page:
2323 output_page(array(
2424 'roe_url' => $roe_url,
2525 'width' => $width,
2626 'height' => $height,
2727 ));
2828 }
29 -function output_page($params){
 29+function output_page( $params ){
3030 extract( $params );
3131 ?>
3232 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
@@ -46,11 +46,11 @@
4747 <script type="text/javascript" src="mv_embed.js"></script>
4848 </head>
4949 <body>
50 - <video roe="<?php echo $roe_url ?>" width="<?php echo htmlspecialchars( $width )?>"
51 - height="<?php echo htmlspecialchars( $height )?>"></video>
 50+ <video roe="<?php echo $roe_url ?>" width="<?php echo htmlspecialchars( $width ) ?>"
 51+ height="<?php echo htmlspecialchars( $height ) ?>"></video>
5252 </body>
5353 </html>
54 -<?
 54+<?php
5555 }
5656
5757 /**
@@ -80,5 +80,4 @@
8181 "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER
8282 );
8383 return strtr( $string, $pairs );
84 -}
85 -?>
 84+}
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/php/minify/JSMin.php
@@ -48,246 +48,242 @@
4949 */
5050
5151 class JSMin {
52 - const ORD_LF = 10;
53 - const ORD_SPACE = 32;
 52+ const ORD_LF = 10;
 53+ const ORD_SPACE = 32;
5454
55 - protected $a = '';
56 - protected $b = '';
57 - protected $input = '';
58 - protected $inputIndex = 0;
59 - protected $inputLength = 0;
60 - protected $lookAhead = null;
61 - protected $output = '';
 55+ protected $a = '';
 56+ protected $b = '';
 57+ protected $input = '';
 58+ protected $inputIndex = 0;
 59+ protected $inputLength = 0;
 60+ protected $lookAhead = null;
 61+ protected $output = '';
6262
63 - // -- Public Static Methods --------------------------------------------------
 63+ // -- Public Static Methods --------------------------------------------------
6464
65 - public static function minify($js) {
66 - $jsmin = new JSMin($js);
67 - return $jsmin->min();
68 - }
 65+ public static function minify( $js ) {
 66+ $jsmin = new JSMin( $js );
 67+ return $jsmin->min();
 68+ }
6969
70 - // -- Public Instance Methods ------------------------------------------------
 70+ // -- Public Instance Methods ------------------------------------------------
7171
72 - public function __construct($input) {
73 - $this->input = str_replace("\r\n", "\n", $input);
74 - $this->inputLength = strlen($this->input);
75 - }
 72+ public function __construct( $input ) {
 73+ $this->input = str_replace( "\r\n", "\n", $input );
 74+ $this->inputLength = strlen( $this->input );
 75+ }
7676
77 - // -- Protected Instance Methods ---------------------------------------------
 77+ // -- Protected Instance Methods ---------------------------------------------
7878
79 - protected function action($d) {
80 - switch($d) {
81 - case 1:
82 - $this->output .= $this->a;
 79+ protected function action( $d ) {
 80+ switch( $d ) {
 81+ case 1:
 82+ $this->output .= $this->a;
8383
84 - case 2:
85 - $this->a = $this->b;
 84+ case 2:
 85+ $this->a = $this->b;
8686
87 - if ($this->a === "'" || $this->a === '"') {
88 - for (;;) {
89 - $this->output .= $this->a;
90 - $this->a = $this->get();
 87+ if( $this->a === "'" || $this->a === '"' ) {
 88+ for (;;) {
 89+ $this->output .= $this->a;
 90+ $this->a = $this->get();
9191
92 - if ($this->a === $this->b) {
93 - break;
94 - }
 92+ if( $this->a === $this->b ) {
 93+ break;
 94+ }
9595
96 - if (ord($this->a) <= self::ORD_LF) {
97 - throw new JSMinException('Unterminated string literal.');
98 - }
 96+ if( ord( $this->a ) <= self::ORD_LF ) {
 97+ throw new JSMinException( 'Unterminated string literal.' );
 98+ }
9999
100 - if ($this->a === '\\') {
101 - $this->output .= $this->a;
102 - $this->a = $this->get();
103 - }
104 - }
105 - }
 100+ if( $this->a === '\\' ) {
 101+ $this->output .= $this->a;
 102+ $this->a = $this->get();
 103+ }
 104+ }
 105+ }
106106
107 - case 3:
108 - $this->b = $this->next();
 107+ case 3:
 108+ $this->b = $this->next();
109109
110 - if ($this->b === '/' && (
111 - $this->a === '(' || $this->a === ',' || $this->a === '=' ||
112 - $this->a === ':' || $this->a === '[' || $this->a === '!' ||
113 - $this->a === '&' || $this->a === '|' || $this->a === '?')) {
 110+ if( $this->b === '/' && (
 111+ $this->a === '(' || $this->a === ',' || $this->a === '=' ||
 112+ $this->a === ':' || $this->a === '[' || $this->a === '!' ||
 113+ $this->a === '&' || $this->a === '|' || $this->a === '?' ) ) {
114114
115 - $this->output .= $this->a . $this->b;
 115+ $this->output .= $this->a . $this->b;
116116
117 - for (;;) {
118 - $this->a = $this->get();
 117+ for (;;) {
 118+ $this->a = $this->get();
119119
120 - if ($this->a === '/') {
121 - break;
122 - } elseif ($this->a === '\\') {
123 - $this->output .= $this->a;
124 - $this->a = $this->get();
125 - } elseif (ord($this->a) <= self::ORD_LF) {
126 - throw new JSMinException('Unterminated regular expression '.
127 - 'literal.');
128 - }
 120+ if( $this->a === '/' ) {
 121+ break;
 122+ } elseif( $this->a === '\\' ) {
 123+ $this->output .= $this->a;
 124+ $this->a = $this->get();
 125+ } elseif( ord( $this->a ) <= self::ORD_LF ) {
 126+ throw new JSMinException( 'Unterminated regular expression literal.' );
 127+ }
129128
130 - $this->output .= $this->a;
131 - }
 129+ $this->output .= $this->a;
 130+ }
132131
133 - $this->b = $this->next();
134 - }
135 - }
136 - }
 132+ $this->b = $this->next();
 133+ }
 134+ }
 135+ }
137136
138 - protected function get() {
139 - $c = $this->lookAhead;
140 - $this->lookAhead = null;
 137+ protected function get() {
 138+ $c = $this->lookAhead;
 139+ $this->lookAhead = null;
141140
142 - if ($c === null) {
143 - if ($this->inputIndex < $this->inputLength) {
144 - $c = $this->input[$this->inputIndex];
145 - $this->inputIndex += 1;
146 - } else {
147 - $c = null;
148 - }
149 - }
 141+ if( $c === null ) {
 142+ if( $this->inputIndex < $this->inputLength ) {
 143+ $c = $this->input[$this->inputIndex];
 144+ $this->inputIndex += 1;
 145+ } else {
 146+ $c = null;
 147+ }
 148+ }
150149
151 - if ($c === "\r") {
152 - return "\n";
153 - }
 150+ if( $c === "\r" ) {
 151+ return "\n";
 152+ }
154153
155 - if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
156 - return $c;
157 - }
 154+ if( $c === null || $c === "\n" || ord( $c ) >= self::ORD_SPACE ) {
 155+ return $c;
 156+ }
158157
159 - return ' ';
160 - }
 158+ return ' ';
 159+ }
161160
162 - protected function isAlphaNum($c) {
163 - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
164 - }
 161+ protected function isAlphaNum( $c ) {
 162+ return ord( $c ) > 126 || $c === '\\' || preg_match( '/^[\w\$]$/', $c ) === 1;
 163+ }
165164
166 - protected function min() {
167 - $this->a = "\n";
168 - $this->action(3);
 165+ protected function min() {
 166+ $this->a = "\n";
 167+ $this->action( 3 );
169168
170 - while ($this->a !== null) {
171 - switch ($this->a) {
172 - case ' ':
173 - if ($this->isAlphaNum($this->b)) {
174 - $this->action(1);
175 - } else {
176 - $this->action(2);
177 - }
178 - break;
 169+ while( $this->a !== null ) {
 170+ switch( $this->a ) {
 171+ case ' ':
 172+ if( $this->isAlphaNum( $this->b ) ) {
 173+ $this->action( 1 );
 174+ } else {
 175+ $this->action( 2 );
 176+ }
 177+ break;
179178
180 - case "\n":
181 - switch ($this->b) {
182 - case '{':
183 - case '[':
184 - case '(':
185 - case '+':
186 - case '-':
187 - $this->action(1);
188 - break;
 179+ case "\n":
 180+ switch( $this->b ) {
 181+ case '{':
 182+ case '[':
 183+ case '(':
 184+ case '+':
 185+ case '-':
 186+ $this->action( 1 );
 187+ break;
189188
190 - case ' ':
191 - $this->action(3);
192 - break;
 189+ case ' ':
 190+ $this->action( 3 );
 191+ break;
193192
194 - default:
195 - if ($this->isAlphaNum($this->b)) {
196 - $this->action(1);
197 - }
198 - else {
199 - $this->action(2);
200 - }
201 - }
202 - break;
 193+ default:
 194+ if( $this->isAlphaNum( $this->b ) ) {
 195+ $this->action( 1 );
 196+ } else {
 197+ $this->action( 2 );
 198+ }
 199+ }
 200+ break;
203201
204 - default:
205 - switch ($this->b) {
206 - case ' ':
207 - if ($this->isAlphaNum($this->a)) {
208 - $this->action(1);
209 - break;
210 - }
 202+ default:
 203+ switch( $this->b ) {
 204+ case ' ':
 205+ if( $this->isAlphaNum( $this->a ) ) {
 206+ $this->action( 1 );
 207+ break;
 208+ }
211209
212 - $this->action(3);
213 - break;
 210+ $this->action( 3 );
 211+ break;
214212
215 - case "\n":
216 - switch ($this->a) {
217 - case '}':
218 - case ']':
219 - case ')':
220 - case '+':
221 - case '-':
222 - case '"':
223 - case "'":
224 - $this->action(1);
225 - break;
 213+ case "\n":
 214+ switch( $this->a ) {
 215+ case '}':
 216+ case ']':
 217+ case ')':
 218+ case '+':
 219+ case '-':
 220+ case '"':
 221+ case "'":
 222+ $this->action( 1 );
 223+ break;
226224
227 - default:
228 - if ($this->isAlphaNum($this->a)) {
229 - $this->action(1);
230 - }
231 - else {
232 - $this->action(3);
233 - }
234 - }
235 - break;
 225+ default:
 226+ if( $this->isAlphaNum( $this->a ) ) {
 227+ $this->action( 1 );
 228+ } else {
 229+ $this->action( 3 );
 230+ }
 231+ }
 232+ break;
236233
237 - default:
238 - $this->action(1);
239 - break;
240 - }
241 - }
242 - }
 234+ default:
 235+ $this->action( 1 );
 236+ break;
 237+ }
 238+ }
 239+ }
243240
244 - return $this->output;
245 - }
 241+ return $this->output;
 242+ }
246243
247 - protected function next() {
248 - $c = $this->get();
 244+ protected function next() {
 245+ $c = $this->get();
249246
250 - if ($c === '/') {
251 - switch($this->peek()) {
252 - case '/':
253 - for (;;) {
254 - $c = $this->get();
 247+ if( $c === '/' ) {
 248+ switch( $this->peek() ) {
 249+ case '/':
 250+ for (;;) {
 251+ $c = $this->get();
255252
256 - if (ord($c) <= self::ORD_LF) {
257 - return $c;
258 - }
259 - }
 253+ if( ord( $c ) <= self::ORD_LF ) {
 254+ return $c;
 255+ }
 256+ }
260257
261 - case '*':
262 - $this->get();
 258+ case '*':
 259+ $this->get();
263260
264 - for (;;) {
265 - switch($this->get()) {
266 - case '*':
267 - if ($this->peek() === '/') {
268 - $this->get();
269 - return ' ';
270 - }
271 - break;
 261+ for (;;) {
 262+ switch( $this->get() ) {
 263+ case '*':
 264+ if( $this->peek() === '/' ) {
 265+ $this->get();
 266+ return ' ';
 267+ }
 268+ break;
272269
273 - case null:
274 - throw new JSMinException('Unterminated comment.');
275 - }
276 - }
 270+ case null:
 271+ throw new JSMinException( 'Unterminated comment.' );
 272+ }
 273+ }
277274
278 - default:
279 - return $c;
280 - }
281 - }
 275+ default:
 276+ return $c;
 277+ }
 278+ }
282279
283 - return $c;
284 - }
 280+ return $c;
 281+ }
285282
286 - protected function peek() {
287 - $this->lookAhead = $this->get();
288 - return $this->lookAhead;
289 - }
 283+ protected function peek() {
 284+ $this->lookAhead = $this->get();
 285+ return $this->lookAhead;
 286+ }
290287 }
291288
292289 // -- Exceptions ---------------------------------------------------------------
293 -class JSMinException extends Exception {}
294 -?>
\ No newline at end of file
 290+class JSMinException extends Exception {}
\ No newline at end of file
Index: trunk/phase3/js2/mwEmbed/jsScriptLoader.php
@@ -1,284 +1,298 @@
22 <?php
3 -//This core jsScriptLoader class provides the script loader functionality
4 -//check if we are being invoked in mediaWiki context or stand alone usage:
 3+/**
 4+ * This core jsScriptLoader class provides the script loader functionality
 5+ * @file
 6+ */
 7+// check if we are being invoked in MediaWiki context or stand alone usage:
58 if ( !defined( 'MEDIAWIKI' ) ){
6 - //load noMediaWiki helper:
7 - require_once( realpath( dirname(__FILE__) ) . '/php/noMediaWikiConfig.php' );
 9+ // load noMediaWiki helper:
 10+ require_once( realpath( dirname( __FILE__ ) ) . '/php/noMediaWikiConfig.php' );
811
9 - //run the main action:
 12+ // run the main action:
1013 $myScriptLoader = new jsScriptLoader();
11 - //preset request values via normal $_GET operation:
 14+ // preset request values via normal $_GET operation:
1215 $myScriptLoader->doScriptLoader();
13 -}else{
14 - $wgExtensionMessagesFiles['mwEmbed'] = realpath( dirname(__FILE__) ) .'/php/mwEmbed.i18n.php';
 16+} else {
 17+ $wgExtensionMessagesFiles['mwEmbed'] = realpath( dirname( __FILE__ ) ) . '/php/mwEmbed.i18n.php';
1518 }
1619
17 -//setup page output hook
18 -class jsScriptLoader{
 20+// setup page output hook
 21+class jsScriptLoader {
1922 var $jsFileList = array();
2023 var $jsout = '';
2124 var $rKey = ''; // the request key
22 - var $error_msg ='';
 25+ var $error_msg = '';
2326 var $debug = false;
24 - var $jsvarurl =false; // if we should include generated js (special class '-')
25 - var $doProcReqFlag =true;
 27+ var $jsvarurl = false; // if we should include generated js (special class '-')
 28+ var $doProcReqFlag = true;
2629
2730 function doScriptLoader(){
28 - global $wgJSAutoloadClasses,$wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP,
 31+ global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP,
2932 $wgEnableScriptMinify, $wgUseFileCache;
3033
31 - //process the request
 34+ // process the request
3235 $this->procRequestVars();
3336
34 - //if cache is on and file is present grab it from there:
 37+ // if cache is on and file is present grab it from there:
3538 if( $wgUseFileCache && !$this->debug ) {
36 - //setup file cache obj:
 39+ // setup file cache obj:
3740 $this->sFileCache = new simpleFileCache( $this->rKey );
3841 if( $this->sFileCache->isFileCached() ){
39 - //just output headers so we can use php "efficient" readfile
 42+ // just output headers so we can use php "efficient" readfile
4043 $this->outputJsHeaders();
4144 $this->sFileCache->outputFromFileCache();
4245 die();
4346 }
4447 }
4548
46 - //setup script loader header info
47 - $this->jsout .= 'var mwSlScript = "'. $_SERVER['SCRIPT_NAME'] . '";' . "\n";
48 - $this->jsout .= 'var mwSlGenISODate = "'. date('c') . '";' ."\n";
 49+ // setup script loader header info
 50+ $this->jsout .= 'var mwSlScript = "' . $_SERVER['SCRIPT_NAME'] . '";' . "\n";
 51+ $this->jsout .= 'var mwSlGenISODate = "' . date( 'c' ) . '";' ."\n";
4952 $this->jsout .= 'var mwSlURID = "' . $this->urid . '";' ."\n";
50 - //Build the Output:
51 - //swap in the appropriate language per js_file
52 - foreach($this->jsFileList as $classKey => $file_name){
53 - //special case: - title classes:
54 - if( substr( $classKey, 0, 3) == 'WT:' ){
55 - //get just the tile part:
56 - $title_block = substr( $classKey, 3);
57 - if($title_block[0] == '-' && strpos($title_block, '|') !== false){
58 - //special case of "-" title with skin
59 - $parts = explode('|', $title_block);
60 - $title = array_shift($parts);
61 - foreach($parts as $tparam){
62 - list($key, $val)= explode('=', $tparam);
63 - if( $key=='useskin' ){
64 - $skin= $val;
 53+ // Build the output:
 54+ // swap in the appropriate language per js_file
 55+ foreach( $this->jsFileList as $classKey => $file_name ){
 56+ // special case: - title classes:
 57+ if( substr( $classKey, 0, 3 ) == 'WT:' ){
 58+ // get just the tile part:
 59+ $title_block = substr( $classKey, 3 );
 60+ if( $title_block[0] == '-' && strpos( $title_block, '|' ) !== false ){
 61+ // special case of "-" title with skin
 62+ $parts = explode( '|', $title_block );
 63+ $title = array_shift( $parts );
 64+ foreach( $parts as $tparam ){
 65+ list( $key, $val ) = explode( '=', $tparam );
 66+ if( $key == 'useskin' ){
 67+ $skin = $val;
6568 }
6669 }
67 - //make sure the skin name is valid
 70+ // make sure the skin name is valid
6871 $skinNames = Skin::getSkinNames();
69 - //get the lower case skin name (array keys)
70 - $skinNames = array_keys($skinNames);
71 - if( in_array(strtolower($skin), $skinNames )){
 72+ // get the lower case skin name (array keys)
 73+ $skinNames = array_keys( $skinNames );
 74+ if( in_array( strtolower( $skin ), $skinNames ) ){
7275 $this->jsout .= Skin::generateUserJs( $skin ) . "\n";
73 - //success continue:
 76+ // success continue:
7477 continue;
7578 }
76 - }else{
77 - //its a wikiTitle append the output of the wikitext:
78 - $t = Title::newFromText ( $title_block );
79 - $a = new Article( $t );
80 - //only get content if the page is not empty:
81 - if($a->getID() !== 0 ){
82 - $this->jsout .= $a->getContent() . "\n";
 79+ } else {
 80+ // it's a wikiTitle append the output of the wikitext:
 81+ $t = Title::newFromText( $title_block );
 82+ $a = new Article( $t );
 83+ // only get content if the page is not empty:
 84+ if( $a->getID() !== 0 ){
 85+ $this->jsout .= $a->getContent() . "\n";
8386 }
8487 continue;
8588 }
8689 }
8790
88 - if( trim( $file_name ) != ''){
89 - //if in debug add a comment with the file name:
90 - if($this->debug)
 91+ if( trim( $file_name ) != '' ){
 92+ // if in debug add a comment with the file name:
 93+ if( $this->debug )
9194 $this->jsout .= "\n/**
9295 * File: $file_name
9396 */\n";
94 - $this->jsout .= ( $this->doProccessJsFile( $file_name ) ). "\n";
 97+ $this->jsout .= ( $this->doProccessJsFile( $file_name ) ) . "\n";
9598 }
9699 }
97 - //check if we should minify :
98 - if( $wgEnableScriptMinify && !$this->debug){
99 - //do the minification and output
 100+ // check if we should minify :
 101+ if( $wgEnableScriptMinify && !$this->debug ){
 102+ // do the minification and output
100103 $this->jsout = JSMin::minify( $this->jsout);
101104 }
102 - //save to the file cache:
103 - if( $wgUseFileCache && !$this->debug) {
104 - $status = $this->sFileCache->saveToFileCache($this->jsout);
105 - if($status!==true)
106 - $this->error_msg.= $status;
 105+ // save to the file cache:
 106+ if( $wgUseFileCache && !$this->debug ) {
 107+ $status = $this->sFileCache->saveToFileCache( $this->jsout );
 108+ if( $status !== true )
 109+ $this->error_msg.= $status;
107110 }
108 - //check for error msg:
 111+ // check for error msg:
109112 if( $this->error_msg != ''){
110 - echo 'alert(\'Error With ScriptLoader.php ::' . str_replace("\n", '\'+"\n"+'."\n'", $this->error_msg ). '\');';
111 - echo trim($this->jsout);
112 - }else{
113 - //all good lets output cache forever headers:
114 - $this->outputJsWithHeaders();
 113+ echo 'alert(\'Error With ScriptLoader.php ::' . str_replace( "\n", '\'+"\n"+'."\n'", $this->error_msg ) . '\');';
 114+ echo trim( $this->jsout );
 115+ } else {
 116+ // all good lets output cache forever headers:
 117+ $this->outputJsWithHeaders();
115118 }
116119 }
 120+
117121 function outputJsHeaders(){
118 - global $wgJsMimeType;
119 - //output js mime type:
120 - header( 'Content-type: '.$wgJsMimeType);
121 - header( "Pragma: public" );
122 - //cache forever:
123 - //(the point is we never have to re validate since we should always change the request url based on the svn or article version)
 122+ global $wgJsMimeType;
 123+ // output js mime type:
 124+ header( 'Content-type: ' . $wgJsMimeType );
 125+ header( 'Pragma: public' );
 126+ // cache forever:
 127+ // (the point is we never have to revalidate since we should always change the request url based on the svn or article version)
124128 $one_year = 60*60*24*365;
125 - header("Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM");
 129+ header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $one_year ) . " GM" );
126130 }
 131+
127132 function outputJsWithHeaders(){
128 - global $wgUseGzip;
129 - $this->outputJsHeaders();
130 - if( $wgUseGzip ) {
131 - if( wfClientAcceptsGzip() ) {
 133+ global $wgUseGzip;
 134+ $this->outputJsHeaders();
 135+ if( $wgUseGzip ) {
 136+ if( wfClientAcceptsGzip() ) {
132137 header( 'Content-Encoding: gzip' );
133138 echo gzencode( $this->jsout );
134 - }else{
135 - echo $this->jsout;
136 - }
137 - }else{
138 - echo $this->jsout;
 139+ } else {
 140+ echo $this->jsout;
 141+ }
 142+ } else {
 143+ echo $this->jsout;
139144 }
140145 }
141 - /*
 146+
 147+ /**
142148 * updates the proc Request
143149 */
144150 function procRequestVars(){
145151 global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgStyleVersion;
146152
147 - //set debug flag:
148 - if( (isset($_GET['debug']) && $_GET['debug']=='true') || (isset($wgEnableScriptDebug) && $wgEnableScriptDebug==true )){
149 - $this->debug = true;
 153+ // set debug flag:
 154+ if( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ){
 155+ $this->debug = true;
150156 }
151157
152 - //set the urid: (be sure to escape it as it goes into our js output)
 158+ // set the urid: (be sure to escape it as it goes into our js output)
153159 if( isset( $_GET['urid'] ) && $_GET['urid'] !=''){
154160 $this->urid = htmlspecialchars( $_GET['urid'] );
155 - }else{
156 - //just give it the current style sheet id:
157 - //@@todo read the svn version number
158 - $this->urid = $wgStyleVersion;
 161+ } else {
 162+ // just give it the current style sheet id:
 163+ // @@todo read the svn version number
 164+ $this->urid = $wgStyleVersion;
159165 }
160166
161167 $reqClassList = false;
162 - if( isset($_GET['class']) && $_GET['class']!=''){
 168+ if( isset( $_GET['class'] ) && $_GET['class'] != '' ){
163169 $reqClassList = explode( ',', $_GET['class'] );
164170 }
165 - //check for the requested classes
 171+
 172+ // check for the requested classes
166173 if( $reqClassList ){
167 - //clean the class list and populate jsFileList
 174+ // clean the class list and populate jsFileList
168175 foreach( $reqClassList as $reqClass ){
169 - if(trim($reqClass) != ''){
170 - //check for special case '-' class for user generated js
171 - if( substr( $reqClass, 0, 3) == 'WT:' ){
172 - $this->jsFileList[ $reqClass ] = true;
 176+ if( trim( $reqClass ) != '' ){
 177+ // check for special case '-' class for user generated js
 178+ if( substr( $reqClass, 0, 3 ) == 'WT:' ){
 179+ $this->jsFileList[$reqClass] = true;
173180 $this->rKey .= $reqClass;
174181 $this->jsvarurl = true;
175182 continue;
176183 }
177184
178 - $reqClass = ereg_replace("[^A-Za-z0-9_\-\.]", "", $reqClass );
 185+ $reqClass = ereg_replace("[^A-Za-z0-9_\-\.]", '', $reqClass );
179186
180187 if( isset( $wgJSAutoloadLocalClasses[$reqClass] ) ){
181 - $this->jsFileList[ $reqClass ] = $wgJSAutoloadLocalClasses[ $reqClass ];
182 - $this->rKey.=$reqClass;
183 - }else if( isset($wgJSAutoloadClasses[$reqClass])) {
184 - $this->jsFileList[ $reqClass ] = $wgJSAutoloadClasses[ $reqClass ];
185 - $this->rKey.=$reqClass;
186 - }else{
187 - $this->error_msg.= 'Requested class: ' . $reqClass . ' not found'."\n";
 188+ $this->jsFileList[$reqClass] = $wgJSAutoloadLocalClasses[$reqClass];
 189+ $this->rKey.= $reqClass;
 190+ } else if( isset( $wgJSAutoloadClasses[$reqClass] ) ) {
 191+ $this->jsFileList[$reqClass] = $wgJSAutoloadClasses[$reqClass];
 192+ $this->rKey.= $reqClass;
 193+ } else {
 194+ $this->error_msg.= 'Requested class: ' . $reqClass . ' not found' . "\n";
188195 }
189196 }
190197 }
191198 }
192199
193 - //check for requested files if enabled:
 200+ // check for requested files if enabled:
194201 if( $wgEnableScriptLoaderJsFile ){
195 - if( isset($_GET['files'])){
196 - $reqFileList = explode(',', isset($_GET['files']));
197 - //clean the file list and populate jsFileList
198 - foreach($reqFileList as $reqFile){
199 - //no jumping dirs:
200 - $reqFile = str_replace('../','',$reqFile);
201 - //only allow alphanumeric underscores periods and ending with .js
202 - $reqFile = ereg_replace("[^A-Za-z0-9_\-\/\.]", "", $reqFile );
203 - if( substr($reqFile, -3) == '.js' ){
204 - //don't add it twice:
205 - if( !in_array($reqFile, $jsFileList )) {
 202+ if( isset( $_GET['files'] ) ){
 203+ $reqFileList = explode( ',', isset( $_GET['files'] ) );
 204+ // clean the file list and populate jsFileList
 205+ foreach( $reqFileList as $reqFile ){
 206+ // no jumping dirs:
 207+ $reqFile = str_replace( '../', '', $reqFile );
 208+ // only allow alphanumeric underscores periods and ending with .js
 209+ $reqFile = ereg_replace( "[^A-Za-z0-9_\-\/\.]", '', $reqFile );
 210+ if( substr( $reqFile, -3 ) == '.js' ){
 211+ // don't add it twice:
 212+ if( !in_array( $reqFile, $jsFileList ) ) {
206213 $this->jsFileList[] = $IP . $reqFile;
207 - $this->rKey.=$reqFile;
 214+ $this->rKey.= $reqFile;
208215 }
209 - }else{
210 - $this->error_msg.= 'Not valid requsted javascript file' . "\n";
 216+ } else {
 217+ $this->error_msg.= 'Not valid requsted JavaScript file' . "\n";
211218 }
212219 }
213220 }
214221 }
215222
216 - //add the language code to the rKey:
 223+ // add the language code to the rKey:
217224 $this->rKey .= '_' . $wgContLanguageCode;
218225
219 - //add the unique rid to the rKey
 226+ // add the unique rid to the rKey
220227 $this->rKey .= $this->urid;
221228
222 - //add a min flag:
223 - if($wgEnableScriptMinify){
224 - $this->rKey.='_min';
 229+ // add a min flag:
 230+ if( $wgEnableScriptMinify ){
 231+ $this->rKey.= '_min';
225232 }
226233 }
 234+
227235 function doProccessJsFile( $file_name ){
228236 global $IP, $wgEnableScriptLocalization, $IP;
229237
230 - //load the file:
231 - $str = @file_get_contents("{$IP}/{$file_name}");
 238+ // load the file:
 239+ $str = @file_get_contents( "{$IP}/{$file_name}" );
232240
233 - if($str===false){
234 - //@@todo check php error level (don't want to expose paths if errors are hidden)
 241+ if( $str === false ){
 242+ // @@todo check php error level (don't want to expose paths if errors are hidden)
235243 $this->error_msg.= 'Requested File: ' . htmlspecialchars( $file_name ) . ' could not be read' . "\n";
236244 return '';
237245 }
238246 $this->cur_file = $file_name;
239247
240 - //strip out js_log debug lines not much luck with this regExp yet:
 248+ // strip out js_log debug lines not much luck with this regExp yet:
241249 //if( !$this->debug )
242250 // $str = preg_replace('/\n\s*js_log\s*\([^\)]([^;]|\n])*;/', "\n", $str);
243251
244252 // do language swap
245 - if($wgEnableScriptLocalization)
246 - $str = preg_replace_callback('/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', //@@todo fix: will break down if someone does }) in their msg text
247 - array($this, 'languageMsgReplace'),
248 - $str);
 253+ if( $wgEnableScriptLocalization )
 254+ $str = preg_replace_callback(
 255+ '/loadGM\s*\(\s*{(.*)}\s*\)\s*/siU', // @@todo fix: will break down if someone does }) in their msg text
 256+ array( $this, 'languageMsgReplace' ),
 257+ $str
 258+ );
249259
250260 return $str;
251261 }
252 - function languageMsgReplace($jvar){
253 - if(!isset($jvar[1]))
254 - return ;
255262
 263+ function languageMsgReplace( $jvar ){
 264+ if( !isset( $jvar[1] ) )
 265+ return;
 266+
256267 $jmsg = json_decode( '{' . $jvar[1] . '}', true );
257 - //do the language lookup:
258 - if($jmsg){
259 - foreach($jmsg as $msgKey => $default_en_value){
 268+ // do the language lookup:
 269+ if( $jmsg ){
 270+ foreach( $jmsg as $msgKey => $default_en_value ){
260271 $jmsg[$msgKey] = wfMsgNoTrans( $msgKey );
261272 }
262273 //return the updated loadGM json with fixed new lines:
263274 return 'loadGM( ' . json_encode( $jmsg ) . ')';
264 - }else{
 275+ } else {
265276 $this->error_msg.= "Could not parse JSON language msg in File:\n" .
266 - $this->cur_file ."\n";
 277+ $this->cur_file . "\n";
267278 }
268 - //could not parse json (throw error?)
 279+ // could not parse json (throw error?)
269280 return $jvar[0];
270281 }
271282 }
 283+
272284 //a simple version of HTMLFileCache (@@todo abstract shared pieces)
273 -class simpleFileCache{
 285+class simpleFileCache {
274286 var $mFileCache;
275 - var $filename= null;
276 - var $rKey= null;
 287+ var $filename = null;
 288+ var $rKey = null;
 289+
277290 public function __construct( &$rKey ) {
278291 $this->rKey = $rKey;
279292 $this->filename = $this->fileCacheName(); // init name
280293 }
 294+
281295 public function fileCacheName() {
282 - global $wgUseGzip;
 296+ global $wgUseGzip;
283297 if( !$this->mFileCache ) {
284298 global $wgFileCacheDirectory;
285299
@@ -297,9 +311,11 @@
298312 }
299313 return $this->mFileCache;
300314 }
 315+
301316 public function isFileCached() {
302317 return file_exists( $this->filename );
303318 }
 319+
304320 public function outputFromFileCache(){
305321 global $wgUseGzip;
306322 if( $wgUseGzip ) {
@@ -310,55 +326,56 @@
311327 /* Send uncompressed (check if fileCache is in compressed state (ends with .gz)
312328 * (unlikely to execute this since $wgUseGzip would have created a new file above.. but just in case:
313329 */
314 - if(substr($this->filename, -3)=='.gz'){
315 - readgzfile( $this->filename );
316 - }else{
317 - readfile( $this->filename );
318 - }
 330+ if( substr( $this->filename, -3 ) == '.gz' ){
 331+ readgzfile( $this->filename );
 332+ } else {
 333+ readfile( $this->filename );
 334+ }
319335 }
320 - }else{
321 - //just output the file
322 - readfile( $this->filename );
 336+ } else {
 337+ // just output the file
 338+ readfile( $this->filename );
323339 }
324340 //return true
325341 return true;
326342 }
327 - public function saveToFileCache(& $text ) {
 343+
 344+ public function saveToFileCache( &$text ) {
328345 global $wgUseFileCache, $wgUseGzip;
329346 if( !$wgUseFileCache ) {
330347 return 'Error: Called saveToFileCache with $wgUseFileCache off';
331348 }
332 - if( strcmp($text,'') == 0 ) return 'saveToFileCache: empty output file';
 349+ if( strcmp( $text, '' ) == 0 ) return 'saveToFileCache: empty output file';
333350
334 - //check the directories if we could not create them error out:
335 - $status = $this->checkCacheDirs();
 351+ // check the directories if we could not create them error out:
 352+ $status = $this->checkCacheDirs();
336353
337 - if($wgUseGzip){
338 - $outputText = gzencode( trim($text) );
339 - }else{
340 - $outputText = trim($text);
341 - }
 354+ if( $wgUseGzip ){
 355+ $outputText = gzencode( trim( $text ) );
 356+ } else {
 357+ $outputText = trim( $text );
 358+ }
342359
343 - if($status !== true)
344 - return $status;
 360+ if( $status !== true )
 361+ return $status;
345362 $f = fopen( $this->filename, 'w' );
346 - if($f) {
 363+ if( $f ) {
347364 fwrite( $f, $outputText );
348365 fclose( $f );
349 - }else{
350 - return 'Could not open file for writing. Check your cache directory permissions?';
 366+ } else {
 367+ return 'Could not open file for writing. Check your cache directory permissions?';
351368 }
352369 return true;
353370 }
 371+
354372 protected function checkCacheDirs() {
355 - $mydir2 = substr($this->filename,0,strrpos($this->filename,'/')); # subdirectory level 2
356 - $mydir1 = substr($mydir2,0,strrpos($mydir2,'/')); # subdirectory level 1
 373+ $mydir2 = substr( $this->filename, 0, strrpos( $this->filename, '/' ) ); # subdirectory level 2
 374+ $mydir1 = substr( $mydir2, 0, strrpos( $mydir2, '/' ) ); # subdirectory level 1
357375
358 - if( wfMkdirParents( $mydir1 ) === false || wfMkdirParents( $mydir2 ) === false){
359 - return 'Could not create cache directory. Check your cache directory permissions?';
360 - }else{
361 - return true;
 376+ if( wfMkdirParents( $mydir1 ) === false || wfMkdirParents( $mydir2 ) === false ){
 377+ return 'Could not create cache directory. Check your cache directory permissions?';
 378+ } else {
 379+ return true;
362380 }
363381 }
364 -}
365 -?>
\ No newline at end of file
 382+}
\ No newline at end of file

Status & tagging log