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 | + */ |
4 | 9 | |
5 | 10 | # Abort if called from a web server |
6 | 11 | if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) { |
7 | 12 | print "This script must be run from the command line\n"; |
8 | 13 | exit(); |
9 | 14 | } |
10 | | -define('MEDIAWIKI',true); |
11 | | -//get the scriptLoader globals: |
| 15 | +define( 'MEDIAWIKI', true ); |
| 16 | +// get the scriptLoader globals: |
12 | 17 | require_once('../../jsScriptLoader.php'); |
13 | 18 | |
14 | 19 | $mwSTART_MSG_KEY = '#<JAVASCRIPT EN REPLACE>'; |
15 | 20 | $mwEND_MSG_KEY = '#</JAVASCRIPT EN REPLACE>'; |
16 | 21 | $mwLangFilePath = '../languages/mwEmbed.i18n.php'; |
17 | | -//get options (like override JS or override php |
| 22 | +// get options (like override JS or override PHP) |
18 | 23 | |
| 24 | +// read in mwEmbed.i18n.php |
| 25 | +$rawLangFile = file_get_contents( $mwLangFilePath ); |
19 | 26 | |
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 ); |
25 | 29 | if( $startInx === false || $endInx === false ){ |
26 | 30 | print "Could not find $mwSTART_MSG_KEY or $mwEND_MSG_KEY in mwEmbed.i18n.php \n"; |
27 | 31 | exit(); |
28 | 32 | } |
29 | 33 | |
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 ); |
33 | 37 | |
34 | | -//build replacement from all javascript in mwEmbed |
35 | | - |
| 38 | +// build replacement from all javascript in mwEmbed |
36 | 39 | $path = realpath('../../'); |
37 | 40 | |
38 | 41 | $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) |
40 | 43 | $msgSet = '$messages[\'en\'] = array('; |
41 | 44 | |
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' ){ |
45 | 48 | $jsFileText = file_get_contents( $fname ); |
46 | | - $mwPos = strpos($fname, 'mwEmbed') + 7; |
| 49 | + $mwPos = strpos( $fname, 'mwEmbed' ) + 7; |
47 | 50 | $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 |
49 | 52 | $jsFileText, |
50 | | - $matches) ){ |
51 | | - $msgSet .= doJsonMerge($matches[1]); |
52 | | - } |
53 | | - } |
| 53 | + $matches ) ){ |
| 54 | + $msgSet .= doJsonMerge( $matches[1] ); |
| 55 | + } |
| 56 | + } |
54 | 57 | } |
55 | | -//close up the msgSet: |
56 | | -$msgSet.=");\n"; |
| 58 | +// close up the msgSet: |
| 59 | +$msgSet.= ");\n"; |
57 | 60 | |
58 | | -function doJsonMerge($json_txt){ |
| 61 | +function doJsonMerge( $json_txt ){ |
59 | 62 | global $curFileName; |
60 | 63 | |
61 | 64 | $out = "\n\t/* |
62 | 65 | \t* js file: {$curFileName} |
63 | 66 | \t*/\n"; |
64 | 67 | $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"; |
68 | 71 | } |
69 | 72 | return $out; |
70 | | - }else{ |
| 73 | + } else { |
71 | 74 | print "could not get any json vars\n"; |
72 | 75 | return ''; |
73 | 76 | } |
74 | 77 | } |
75 | 78 | |
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 ) ) ){ |
78 | 81 | print "updated $mwLangFilePath file\n"; |
79 | 82 | 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 @@ |
5 | 5 | all file checks and conditions should be checked prior to loading this page. |
6 | 6 | this page serves as a wrapper for the cortado java applet |
7 | 7 | |
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 |
9 | 9 | */ |
10 | 10 | |
11 | 11 | cortado_iframe(); |
12 | 12 | |
13 | 13 | 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 />' ); |
16 | 16 | } |
17 | | - //load the http GETS: |
| 17 | + |
| 18 | + // load the http GETS: |
18 | 19 | // set the parent domain if provided |
19 | 20 | $parent_domain = isset( $_GET['parent_domain'] ) ? $_GET['parent_domain'] : false; |
20 | 21 | |
21 | | - //default to null media in not provided: |
| 22 | + // default to null media in not provided: |
22 | 23 | $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' ); |
25 | 26 | } |
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; |
31 | 33 | } |
32 | 34 | |
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 ); |
38 | 40 | } |
39 | 41 | |
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; |
43 | 45 | } |
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 ) |
50 | 52 | $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 ) |
55 | 57 | $height = 20; |
56 | 58 | } |
57 | 59 | |
58 | | - //everything good output page: |
| 60 | + // everything good output page: |
59 | 61 | output_page(array( |
60 | 62 | 'id' => $id, |
61 | 63 | 'media_url' => $media_url, |
— | — | @@ -96,11 +98,12 @@ |
97 | 99 | return strtr( $string, $pairs ); |
98 | 100 | } |
99 | 101 | |
100 | | -function error_out($error=''){ |
101 | | - output_page(array('error' => $error)); |
| 102 | +function error_out( $error = '' ){ |
| 103 | + output_page( array( 'error' => $error ) ); |
102 | 104 | exit(); |
103 | 105 | } |
104 | | -function output_page($params){ |
| 106 | + |
| 107 | +function output_page( $params ){ |
105 | 108 | extract( $params ); |
106 | 109 | ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
107 | 110 | <html xmlns="http://www.w3.org/1999/xhtml"> |
— | — | @@ -108,20 +111,20 @@ |
109 | 112 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> |
110 | 113 | <title>cortado_embed</title> |
111 | 114 | <script type="text/javascript"> |
112 | | - <? //set the parent domain: |
| 115 | + <?php //set the parent domain: |
113 | 116 | 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 ) { |
117 | 120 | 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 ) ?>'); |
119 | 122 | } |
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 | + } |
126 | 129 | </script> |
127 | 130 | <style type="text/css"> |
128 | 131 | <!-- |
— | — | @@ -135,40 +138,38 @@ |
136 | 139 | </style></head> |
137 | 140 | <body onload="setGlobalJplayer()" > |
138 | 141 | <?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 ) ){ ?> |
141 | 144 | <div id="jPlayer"></div> |
142 | 145 | <OBJECT id="<?php echo htmlspecialchars( $id ) ?>" |
143 | 146 | code="com.fluendo.player.Cortado.class" |
144 | 147 | <?php echo $appid ?> |
145 | 148 | 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 ) ?>" /> |
149 | 152 | <param name="local" value="false"/> |
150 | 153 | <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 ) ?>" /> |
153 | 156 | <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 } ?> |
159 | 160 | <param name="showStatus" value="hide" /> |
160 | 161 | <param name="autoPlay" value="true" /> |
161 | 162 | <param name="BufferSize" value="8192" /> |
162 | 163 | <param name="BufferHigh" value="30" /> |
163 | 164 | <param name="BufferLow" value="5" /> |
164 | 165 | </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 |
168 | 169 | } |
169 | 170 | ?> |
170 | 171 | </body> |
171 | 172 | </html> |
172 | | -<? |
| 173 | +<?php |
173 | 174 | } |
174 | 175 | /* |
175 | 176 | javascript envoked version: |
— | — | @@ -218,5 +219,4 @@ |
219 | 220 | doPlayer(); |
220 | 221 | </script> |
221 | 222 | * |
222 | | -*/ |
223 | | -?> |
| 223 | +*/ |
\ No newline at end of file |
Index: trunk/phase3/js2/mwEmbed/php/jsAutoloadLocalClasses.php |
— | — | @@ -1,90 +1,89 @@ |
2 | 2 | <?php |
3 | | -if ( !defined( 'MEDIAWIKI' ) ) die(1); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die( 1 ); |
4 | 4 | |
5 | 5 | global $wgJSAutoloadLocalClasses, $wgMwEmbedDirectory; |
6 | 6 | |
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'; |
9 | 9 | |
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'; |
12 | 12 | |
13 | | - $wgJSAutoloadLocalClasses['j.secureEvalJSON'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.json-1.3.js'; |
| 13 | +$wgJSAutoloadLocalClasses['j.secureEvalJSON'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.json-1.3.js'; |
14 | 14 | |
15 | | - $wgJSAutoloadLocalClasses['j.cookie'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.cookie.js'; |
| 15 | +$wgJSAutoloadLocalClasses['j.cookie'] = $wgMwEmbedDirectory . 'jquery/plugins/jquery.cookie.js'; |
16 | 16 | |
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'; |
19 | 19 | |
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'; |
24 | 24 | |
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'; |
27 | 27 | |
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'; |
30 | 30 | |
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'; |
33 | 33 | |
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'; |
58 | 58 | |
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'; |
70 | 70 | |
71 | | - //libClipEdit: |
72 | | - $wgJSAutoloadLocalClasses['mvClipEdit'] = $wgMwEmbedDirectory . 'libClipEdit/mvClipEdit.js'; |
| 71 | +// libClipEdit: |
| 72 | +$wgJSAutoloadLocalClasses['mvClipEdit'] = $wgMwEmbedDirectory . 'libClipEdit/mvClipEdit.js'; |
73 | 73 | |
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'; |
83 | 83 | |
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'; |
88 | 88 | |
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 |
4 | 5 | * 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 |
6 | 7 | * |
7 | 8 | * the following English language portion is automatically merged via the maintenance script. |
8 | | -*/ |
| 9 | + */ |
9 | 10 | |
10 | 11 | #<JAVASCRIPT EN REPLACE> |
11 | 12 | $messages['en'] = array( |
— | — | @@ -253,6 +254,4 @@ |
254 | 255 | 'size-kilobytes' => '$1 K', |
255 | 256 | 'size-bytes' => '$1 B', |
256 | 257 | ); |
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 @@ |
8 | 8 | mv_embed_iframe(); |
9 | 9 | |
10 | 10 | 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 | + |
20 | 20 | $roe_url = 'http://metavid.org/wiki/Special:MvExportStream?feed_format=roe&stream_name=' . htmlspecialchars( $stream_name ) . |
21 | 21 | '&t=' . htmlspecialchars( $time ); |
22 | | - //everything good output page: |
| 22 | + //everything good output page: |
23 | 23 | output_page(array( |
24 | 24 | 'roe_url' => $roe_url, |
25 | 25 | 'width' => $width, |
26 | 26 | 'height' => $height, |
27 | 27 | )); |
28 | 28 | } |
29 | | -function output_page($params){ |
| 29 | +function output_page( $params ){ |
30 | 30 | extract( $params ); |
31 | 31 | ?> |
32 | 32 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
— | — | @@ -46,11 +46,11 @@ |
47 | 47 | <script type="text/javascript" src="mv_embed.js"></script> |
48 | 48 | </head> |
49 | 49 | <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> |
52 | 52 | </body> |
53 | 53 | </html> |
54 | | -<? |
| 54 | +<?php |
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
— | — | @@ -80,5 +80,4 @@ |
81 | 81 | "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER |
82 | 82 | ); |
83 | 83 | 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 @@ |
49 | 49 | */ |
50 | 50 | |
51 | 51 | class JSMin { |
52 | | - const ORD_LF = 10; |
53 | | - const ORD_SPACE = 32; |
| 52 | + const ORD_LF = 10; |
| 53 | + const ORD_SPACE = 32; |
54 | 54 | |
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 = ''; |
62 | 62 | |
63 | | - // -- Public Static Methods -------------------------------------------------- |
| 63 | + // -- Public Static Methods -------------------------------------------------- |
64 | 64 | |
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 | + } |
69 | 69 | |
70 | | - // -- Public Instance Methods ------------------------------------------------ |
| 70 | + // -- Public Instance Methods ------------------------------------------------ |
71 | 71 | |
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 | + } |
76 | 76 | |
77 | | - // -- Protected Instance Methods --------------------------------------------- |
| 77 | + // -- Protected Instance Methods --------------------------------------------- |
78 | 78 | |
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; |
83 | 83 | |
84 | | - case 2: |
85 | | - $this->a = $this->b; |
| 84 | + case 2: |
| 85 | + $this->a = $this->b; |
86 | 86 | |
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(); |
91 | 91 | |
92 | | - if ($this->a === $this->b) { |
93 | | - break; |
94 | | - } |
| 92 | + if( $this->a === $this->b ) { |
| 93 | + break; |
| 94 | + } |
95 | 95 | |
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 | + } |
99 | 99 | |
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 | + } |
106 | 106 | |
107 | | - case 3: |
108 | | - $this->b = $this->next(); |
| 107 | + case 3: |
| 108 | + $this->b = $this->next(); |
109 | 109 | |
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 === '?' ) ) { |
114 | 114 | |
115 | | - $this->output .= $this->a . $this->b; |
| 115 | + $this->output .= $this->a . $this->b; |
116 | 116 | |
117 | | - for (;;) { |
118 | | - $this->a = $this->get(); |
| 117 | + for (;;) { |
| 118 | + $this->a = $this->get(); |
119 | 119 | |
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 | + } |
129 | 128 | |
130 | | - $this->output .= $this->a; |
131 | | - } |
| 129 | + $this->output .= $this->a; |
| 130 | + } |
132 | 131 | |
133 | | - $this->b = $this->next(); |
134 | | - } |
135 | | - } |
136 | | - } |
| 132 | + $this->b = $this->next(); |
| 133 | + } |
| 134 | + } |
| 135 | + } |
137 | 136 | |
138 | | - protected function get() { |
139 | | - $c = $this->lookAhead; |
140 | | - $this->lookAhead = null; |
| 137 | + protected function get() { |
| 138 | + $c = $this->lookAhead; |
| 139 | + $this->lookAhead = null; |
141 | 140 | |
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 | + } |
150 | 149 | |
151 | | - if ($c === "\r") { |
152 | | - return "\n"; |
153 | | - } |
| 150 | + if( $c === "\r" ) { |
| 151 | + return "\n"; |
| 152 | + } |
154 | 153 | |
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 | + } |
158 | 157 | |
159 | | - return ' '; |
160 | | - } |
| 158 | + return ' '; |
| 159 | + } |
161 | 160 | |
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 | + } |
165 | 164 | |
166 | | - protected function min() { |
167 | | - $this->a = "\n"; |
168 | | - $this->action(3); |
| 165 | + protected function min() { |
| 166 | + $this->a = "\n"; |
| 167 | + $this->action( 3 ); |
169 | 168 | |
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; |
179 | 178 | |
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; |
189 | 188 | |
190 | | - case ' ': |
191 | | - $this->action(3); |
192 | | - break; |
| 189 | + case ' ': |
| 190 | + $this->action( 3 ); |
| 191 | + break; |
193 | 192 | |
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; |
203 | 201 | |
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 | + } |
211 | 209 | |
212 | | - $this->action(3); |
213 | | - break; |
| 210 | + $this->action( 3 ); |
| 211 | + break; |
214 | 212 | |
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; |
226 | 224 | |
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; |
236 | 233 | |
237 | | - default: |
238 | | - $this->action(1); |
239 | | - break; |
240 | | - } |
241 | | - } |
242 | | - } |
| 234 | + default: |
| 235 | + $this->action( 1 ); |
| 236 | + break; |
| 237 | + } |
| 238 | + } |
| 239 | + } |
243 | 240 | |
244 | | - return $this->output; |
245 | | - } |
| 241 | + return $this->output; |
| 242 | + } |
246 | 243 | |
247 | | - protected function next() { |
248 | | - $c = $this->get(); |
| 244 | + protected function next() { |
| 245 | + $c = $this->get(); |
249 | 246 | |
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(); |
255 | 252 | |
256 | | - if (ord($c) <= self::ORD_LF) { |
257 | | - return $c; |
258 | | - } |
259 | | - } |
| 253 | + if( ord( $c ) <= self::ORD_LF ) { |
| 254 | + return $c; |
| 255 | + } |
| 256 | + } |
260 | 257 | |
261 | | - case '*': |
262 | | - $this->get(); |
| 258 | + case '*': |
| 259 | + $this->get(); |
263 | 260 | |
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; |
272 | 269 | |
273 | | - case null: |
274 | | - throw new JSMinException('Unterminated comment.'); |
275 | | - } |
276 | | - } |
| 270 | + case null: |
| 271 | + throw new JSMinException( 'Unterminated comment.' ); |
| 272 | + } |
| 273 | + } |
277 | 274 | |
278 | | - default: |
279 | | - return $c; |
280 | | - } |
281 | | - } |
| 275 | + default: |
| 276 | + return $c; |
| 277 | + } |
| 278 | + } |
282 | 279 | |
283 | | - return $c; |
284 | | - } |
| 280 | + return $c; |
| 281 | + } |
285 | 282 | |
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 | + } |
290 | 287 | } |
291 | 288 | |
292 | 289 | // -- 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 @@ |
2 | 2 | <?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: |
5 | 8 | 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' ); |
8 | 11 | |
9 | | - //run the main action: |
| 12 | + // run the main action: |
10 | 13 | $myScriptLoader = new jsScriptLoader(); |
11 | | - //preset request values via normal $_GET operation: |
| 14 | + // preset request values via normal $_GET operation: |
12 | 15 | $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'; |
15 | 18 | } |
16 | 19 | |
17 | | -//setup page output hook |
18 | | -class jsScriptLoader{ |
| 20 | +// setup page output hook |
| 21 | +class jsScriptLoader { |
19 | 22 | var $jsFileList = array(); |
20 | 23 | var $jsout = ''; |
21 | 24 | var $rKey = ''; // the request key |
22 | | - var $error_msg =''; |
| 25 | + var $error_msg = ''; |
23 | 26 | 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; |
26 | 29 | |
27 | 30 | function doScriptLoader(){ |
28 | | - global $wgJSAutoloadClasses,$wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP, |
| 31 | + global $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgEnableScriptLoaderJsFile, $IP, |
29 | 32 | $wgEnableScriptMinify, $wgUseFileCache; |
30 | 33 | |
31 | | - //process the request |
| 34 | + // process the request |
32 | 35 | $this->procRequestVars(); |
33 | 36 | |
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: |
35 | 38 | if( $wgUseFileCache && !$this->debug ) { |
36 | | - //setup file cache obj: |
| 39 | + // setup file cache obj: |
37 | 40 | $this->sFileCache = new simpleFileCache( $this->rKey ); |
38 | 41 | 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 |
40 | 43 | $this->outputJsHeaders(); |
41 | 44 | $this->sFileCache->outputFromFileCache(); |
42 | 45 | die(); |
43 | 46 | } |
44 | 47 | } |
45 | 48 | |
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"; |
49 | 52 | $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; |
65 | 68 | } |
66 | 69 | } |
67 | | - //make sure the skin name is valid |
| 70 | + // make sure the skin name is valid |
68 | 71 | $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 ) ){ |
72 | 75 | $this->jsout .= Skin::generateUserJs( $skin ) . "\n"; |
73 | | - //success continue: |
| 76 | + // success continue: |
74 | 77 | continue; |
75 | 78 | } |
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"; |
83 | 86 | } |
84 | 87 | continue; |
85 | 88 | } |
86 | 89 | } |
87 | 90 | |
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 ) |
91 | 94 | $this->jsout .= "\n/** |
92 | 95 | * File: $file_name |
93 | 96 | */\n"; |
94 | | - $this->jsout .= ( $this->doProccessJsFile( $file_name ) ). "\n"; |
| 97 | + $this->jsout .= ( $this->doProccessJsFile( $file_name ) ) . "\n"; |
95 | 98 | } |
96 | 99 | } |
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 |
100 | 103 | $this->jsout = JSMin::minify( $this->jsout); |
101 | 104 | } |
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; |
107 | 110 | } |
108 | | - //check for error msg: |
| 111 | + // check for error msg: |
109 | 112 | 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(); |
115 | 118 | } |
116 | 119 | } |
| 120 | + |
117 | 121 | 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) |
124 | 128 | $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" ); |
126 | 130 | } |
| 131 | + |
127 | 132 | 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() ) { |
132 | 137 | header( 'Content-Encoding: gzip' ); |
133 | 138 | 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; |
139 | 144 | } |
140 | 145 | } |
141 | | - /* |
| 146 | + |
| 147 | + /** |
142 | 148 | * updates the proc Request |
143 | 149 | */ |
144 | 150 | function procRequestVars(){ |
145 | 151 | global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgStyleVersion; |
146 | 152 | |
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; |
150 | 156 | } |
151 | 157 | |
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) |
153 | 159 | if( isset( $_GET['urid'] ) && $_GET['urid'] !=''){ |
154 | 160 | $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; |
159 | 165 | } |
160 | 166 | |
161 | 167 | $reqClassList = false; |
162 | | - if( isset($_GET['class']) && $_GET['class']!=''){ |
| 168 | + if( isset( $_GET['class'] ) && $_GET['class'] != '' ){ |
163 | 169 | $reqClassList = explode( ',', $_GET['class'] ); |
164 | 170 | } |
165 | | - //check for the requested classes |
| 171 | + |
| 172 | + // check for the requested classes |
166 | 173 | if( $reqClassList ){ |
167 | | - //clean the class list and populate jsFileList |
| 174 | + // clean the class list and populate jsFileList |
168 | 175 | 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; |
173 | 180 | $this->rKey .= $reqClass; |
174 | 181 | $this->jsvarurl = true; |
175 | 182 | continue; |
176 | 183 | } |
177 | 184 | |
178 | | - $reqClass = ereg_replace("[^A-Za-z0-9_\-\.]", "", $reqClass ); |
| 185 | + $reqClass = ereg_replace("[^A-Za-z0-9_\-\.]", '', $reqClass ); |
179 | 186 | |
180 | 187 | 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"; |
188 | 195 | } |
189 | 196 | } |
190 | 197 | } |
191 | 198 | } |
192 | 199 | |
193 | | - //check for requested files if enabled: |
| 200 | + // check for requested files if enabled: |
194 | 201 | 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 ) ) { |
206 | 213 | $this->jsFileList[] = $IP . $reqFile; |
207 | | - $this->rKey.=$reqFile; |
| 214 | + $this->rKey.= $reqFile; |
208 | 215 | } |
209 | | - }else{ |
210 | | - $this->error_msg.= 'Not valid requsted javascript file' . "\n"; |
| 216 | + } else { |
| 217 | + $this->error_msg.= 'Not valid requsted JavaScript file' . "\n"; |
211 | 218 | } |
212 | 219 | } |
213 | 220 | } |
214 | 221 | } |
215 | 222 | |
216 | | - //add the language code to the rKey: |
| 223 | + // add the language code to the rKey: |
217 | 224 | $this->rKey .= '_' . $wgContLanguageCode; |
218 | 225 | |
219 | | - //add the unique rid to the rKey |
| 226 | + // add the unique rid to the rKey |
220 | 227 | $this->rKey .= $this->urid; |
221 | 228 | |
222 | | - //add a min flag: |
223 | | - if($wgEnableScriptMinify){ |
224 | | - $this->rKey.='_min'; |
| 229 | + // add a min flag: |
| 230 | + if( $wgEnableScriptMinify ){ |
| 231 | + $this->rKey.= '_min'; |
225 | 232 | } |
226 | 233 | } |
| 234 | + |
227 | 235 | function doProccessJsFile( $file_name ){ |
228 | 236 | global $IP, $wgEnableScriptLocalization, $IP; |
229 | 237 | |
230 | | - //load the file: |
231 | | - $str = @file_get_contents("{$IP}/{$file_name}"); |
| 238 | + // load the file: |
| 239 | + $str = @file_get_contents( "{$IP}/{$file_name}" ); |
232 | 240 | |
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) |
235 | 243 | $this->error_msg.= 'Requested File: ' . htmlspecialchars( $file_name ) . ' could not be read' . "\n"; |
236 | 244 | return ''; |
237 | 245 | } |
238 | 246 | $this->cur_file = $file_name; |
239 | 247 | |
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: |
241 | 249 | //if( !$this->debug ) |
242 | 250 | // $str = preg_replace('/\n\s*js_log\s*\([^\)]([^;]|\n])*;/', "\n", $str); |
243 | 251 | |
244 | 252 | // 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 | + ); |
249 | 259 | |
250 | 260 | return $str; |
251 | 261 | } |
252 | | - function languageMsgReplace($jvar){ |
253 | | - if(!isset($jvar[1])) |
254 | | - return ; |
255 | 262 | |
| 263 | + function languageMsgReplace( $jvar ){ |
| 264 | + if( !isset( $jvar[1] ) ) |
| 265 | + return; |
| 266 | + |
256 | 267 | $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 ){ |
260 | 271 | $jmsg[$msgKey] = wfMsgNoTrans( $msgKey ); |
261 | 272 | } |
262 | 273 | //return the updated loadGM json with fixed new lines: |
263 | 274 | return 'loadGM( ' . json_encode( $jmsg ) . ')'; |
264 | | - }else{ |
| 275 | + } else { |
265 | 276 | $this->error_msg.= "Could not parse JSON language msg in File:\n" . |
266 | | - $this->cur_file ."\n"; |
| 277 | + $this->cur_file . "\n"; |
267 | 278 | } |
268 | | - //could not parse json (throw error?) |
| 279 | + // could not parse json (throw error?) |
269 | 280 | return $jvar[0]; |
270 | 281 | } |
271 | 282 | } |
| 283 | + |
272 | 284 | //a simple version of HTMLFileCache (@@todo abstract shared pieces) |
273 | | -class simpleFileCache{ |
| 285 | +class simpleFileCache { |
274 | 286 | var $mFileCache; |
275 | | - var $filename= null; |
276 | | - var $rKey= null; |
| 287 | + var $filename = null; |
| 288 | + var $rKey = null; |
| 289 | + |
277 | 290 | public function __construct( &$rKey ) { |
278 | 291 | $this->rKey = $rKey; |
279 | 292 | $this->filename = $this->fileCacheName(); // init name |
280 | 293 | } |
| 294 | + |
281 | 295 | public function fileCacheName() { |
282 | | - global $wgUseGzip; |
| 296 | + global $wgUseGzip; |
283 | 297 | if( !$this->mFileCache ) { |
284 | 298 | global $wgFileCacheDirectory; |
285 | 299 | |
— | — | @@ -297,9 +311,11 @@ |
298 | 312 | } |
299 | 313 | return $this->mFileCache; |
300 | 314 | } |
| 315 | + |
301 | 316 | public function isFileCached() { |
302 | 317 | return file_exists( $this->filename ); |
303 | 318 | } |
| 319 | + |
304 | 320 | public function outputFromFileCache(){ |
305 | 321 | global $wgUseGzip; |
306 | 322 | if( $wgUseGzip ) { |
— | — | @@ -310,55 +326,56 @@ |
311 | 327 | /* Send uncompressed (check if fileCache is in compressed state (ends with .gz) |
312 | 328 | * (unlikely to execute this since $wgUseGzip would have created a new file above.. but just in case: |
313 | 329 | */ |
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 | + } |
319 | 335 | } |
320 | | - }else{ |
321 | | - //just output the file |
322 | | - readfile( $this->filename ); |
| 336 | + } else { |
| 337 | + // just output the file |
| 338 | + readfile( $this->filename ); |
323 | 339 | } |
324 | 340 | //return true |
325 | 341 | return true; |
326 | 342 | } |
327 | | - public function saveToFileCache(& $text ) { |
| 343 | + |
| 344 | + public function saveToFileCache( &$text ) { |
328 | 345 | global $wgUseFileCache, $wgUseGzip; |
329 | 346 | if( !$wgUseFileCache ) { |
330 | 347 | return 'Error: Called saveToFileCache with $wgUseFileCache off'; |
331 | 348 | } |
332 | | - if( strcmp($text,'') == 0 ) return 'saveToFileCache: empty output file'; |
| 349 | + if( strcmp( $text, '' ) == 0 ) return 'saveToFileCache: empty output file'; |
333 | 350 | |
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(); |
336 | 353 | |
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 | + } |
342 | 359 | |
343 | | - if($status !== true) |
344 | | - return $status; |
| 360 | + if( $status !== true ) |
| 361 | + return $status; |
345 | 362 | $f = fopen( $this->filename, 'w' ); |
346 | | - if($f) { |
| 363 | + if( $f ) { |
347 | 364 | fwrite( $f, $outputText ); |
348 | 365 | 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?'; |
351 | 368 | } |
352 | 369 | return true; |
353 | 370 | } |
| 371 | + |
354 | 372 | 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 |
357 | 375 | |
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; |
362 | 380 | } |
363 | 381 | } |
364 | | -} |
365 | | -?> |
\ No newline at end of file |
| 382 | +} |
\ No newline at end of file |