r53337 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r53336‎ | r53337 | r53338 >
Date:22:41, 15 July 2009
Author:dale
Status:deferred
Tags:
Comment:
* addressed r53282#c3209 moved conditional inclusion of $wgExtensionMessages in mwScriptLoader.php to Setup.php
* put a @ in front of get_headers() should hopefully avoid errors where allow_url_fopen=0
* combined $wgPhpCliPath into the similar used $wgPhpCli var
* minor js & example file mwEmbed fixes
Modified paths:
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/GlobalFunctions.php (modified) (history)
  • /trunk/phase3/includes/HttpFunctions.php (modified) (history)
  • /trunk/phase3/includes/RawPage.php (modified) (history)
  • /trunk/phase3/includes/Setup.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Player_Themable.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Player_Timed_Text.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/jsScriptLoader.php (modified) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/mediaWikiUploadHelper.OFF.js (deleted) (history)
  • /trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/mwScriptLoader.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/GlobalFunctions.php
@@ -2953,6 +2953,28 @@
29542954 global $wgScriptPath, $wgScriptExtension;
29552955 return "{$wgScriptPath}/{$script}{$wgScriptExtension}";
29562956 }
 2957+/**
 2958+ * Get the script url.
 2959+ *
 2960+ * @return script url
 2961+ */
 2962+function wfGetScriptUrl(){
 2963+ if( isset( $_SERVER['SCRIPT_NAME'] ) ) {
 2964+ #
 2965+ # as it was called, minus the query string.
 2966+ #
 2967+ # Some sites use Apache rewrite rules to handle subdomains,
 2968+ # and have PHP set up in a weird way that causes PHP_SELF
 2969+ # to contain the rewritten URL instead of the one that the
 2970+ # outside world sees.
 2971+ #
 2972+ # If in this mode, use SCRIPT_URL instead, which mod_rewrite
 2973+ # provides containing the "before" URL.
 2974+ return $_SERVER['SCRIPT_NAME'];
 2975+ } else {
 2976+ return $_SERVER['URL'];
 2977+ }
 2978+}
29572979
29582980 /**
29592981 * Convenience function converts boolean values into "true"
Index: trunk/phase3/includes/Setup.php
@@ -59,10 +59,10 @@
6060 }
6161
6262 /**
63 - * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
64 - * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
 63+ * Unconditional protection for NS_MEDIAWIKI since otherwise it's too easy for a
 64+ * sysadmin to set $wgNamespaceProtection incorrectly and leave the wiki insecure.
6565 *
66 - * Note that this is the definition of editinterface and it can be granted to
 66+ * Note that this is the definition of editinterface and it can be granted to
6767 * all users if desired.
6868 */
6969 $wgNamespaceProtection[NS_MEDIAWIKI] = 'editinterface';
@@ -311,6 +311,16 @@
312312 wfProfileOut( $fname.'-misc2' );
313313 wfProfileIn( $fname.'-extensions' );
314314
 315+/*
 316+ * load the $wgExtensionMessagesFiles for the script loader
 317+ * this can't be done in a normal extension type way
 318+ * since the script-loader is an entry point
 319+ */
 320+if( $wgEnableScriptLoader && strpos( wfGetScriptUrl(), "mwScriptLoader.php" ) !== false ){
 321+ $wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php";
 322+}
 323+
 324+
315325 # Extension setup functions for extensions other than skins
316326 # Entries should be added to this variable during the inclusion
317327 # of the extension file. This allows the extension to perform
Index: trunk/phase3/includes/RawPage.php
@@ -111,22 +111,7 @@
112112 function view() {
113113 global $wgOut, $wgScript;
114114
115 - if( isset( $_SERVER['SCRIPT_NAME'] ) ) {
116 - # Normally we use PHP_SELF to get the URL to the script
117 - # as it was called, minus the query string.
118 - #
119 - # Some sites use Apache rewrite rules to handle subdomains,
120 - # and have PHP set up in a weird way that causes PHP_SELF
121 - # to contain the rewritten URL instead of the one that the
122 - # outside world sees.
123 - #
124 - # If in this mode, use SCRIPT_URL instead, which mod_rewrite
125 - # provides containing the "before" URL.
126 - $url = $_SERVER['SCRIPT_NAME'];
127 - } else {
128 - $url = $_SERVER['URL'];
129 - }
130 -
 115+ $url = wfGetScriptUrl();
131116 if( $url == '' ) {
132117 # This will make the next check fail with a confusing error
133118 # message, so we should mention it separately.
Index: trunk/phase3/includes/DefaultSettings.php
@@ -3684,16 +3684,11 @@
36853685 $wgMaxShellTime = 180;
36863686
36873687 /**
3688 -* Executable name of PHP cli client (php/php5)
 3688+* Executable Path of PHP cli client (php/php5) (should be setup on install)
36893689 */
3690 -$wgPhpCli = 'php';
 3690+$wgPhpCli = '/usr/bin/php';
36913691
36923692 /**
3693 - * the full path to shell out to php scripts:
3694 - */
3695 -$wgPhpCliPath = '/usr/bin/php';
3696 -
3697 -/**
36983693 * DJVU settings
36993694 * Path of the djvudump executable
37003695 * Enable this and $wgDjvuRenderer to enable djvu rendering
Index: trunk/phase3/includes/HttpFunctions.php
@@ -25,7 +25,7 @@
2626 /**
2727 * Simple wrapper for Http::request( 'GET' )
2828 */
29 - public static function get( $url, $timeout = false) {
 29+ public static function get( $url, $timeout = false ) {
3030 $opts = Array();
3131 if( $timeout )
3232 $opts['timeout'] = $timeout;
@@ -42,8 +42,9 @@
4343 public static function doDownload( $url, $target_file_path , $dl_mode = self::SYNC_DOWNLOAD , $redirectCount = 0 ){
4444 global $wgPhpCli, $wgMaxUploadSize, $wgMaxRedirects;
4545 // do a quick check to HEAD to insure the file size is not > $wgMaxUploadSize
46 - $head = get_headers( $url, 1 );
 46+ $head = @get_headers( $url, 1 );
4747
 48+
4849 // check for redirects:
4950 if( isset( $head['Location'] ) && strrpos( $head[0], '302' ) !== false ){
5051 if( $redirectCount < $wgMaxRedirects ){
Index: trunk/phase3/mwScriptLoader.php
@@ -29,13 +29,8 @@
3030
3131 wfProfileIn( 'mvwScriptLoader.php' );
3232
33 -if( isset( $_SERVER['SCRIPT_URL'] ) ) {
34 - $url = $_SERVER['SCRIPT_URL'];
35 -} else {
36 - $url = $_SERVER['PHP_SELF'];
37 -}
3833
39 -if( strpos( $url, "mwScriptLoader$wgScriptExtension" ) === false ){
 34+if( strpos( wfGetScriptUrl(), "mwScriptLoader.php" ) === false ){
4035 wfHttpError( 403, 'Forbidden',
4136 'mvwScriptLoader must be accessed through the primary script entry point.' );
4237 return;
@@ -48,10 +43,9 @@
4944 die( 1 );
5045 }
5146
 47+//moved to setup.php
5248 // load the mwEmbed language file:
53 -$wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php";
54 -// enable the msgs before we go on:
55 -wfLoadExtensionMessages( 'mwEmbed' );
 49+//$wgExtensionMessagesFiles['mwEmbed'] = "{$IP}/js2/mwEmbed/php/languages/mwEmbed.i18n.php";
5650
5751 // run jsScriptLoader action:
5852 $myScriptLoader = new jsScriptLoader();
Index: trunk/phase3/js2/mwEmbed/example_usage/Player_Themable.html
@@ -19,7 +19,7 @@
2020 <body bgcolor="#FFF">
2121 <h3> Sample Themed Player:</h3>
2222 <a id="doThemeRoller" class="ui-icon_link ui-state-default ui-corner-all" href="#">loading theme editor<blink>...</blink></a><p><p>
23 -<video src="media/sample_fish.ogg" thumbnail="media/sample_fish.jpg" durationHint="26"></video>
 23+<video src="http://upload.wikimedia.org/wikipedia/commons/e/e2/Herbert_Hoover_video_montage.ogg" thumbnail="http://upload.wikimedia.org/wikipedia/commons/thumb/e/e2/Herbert_Hoover_video_montage.ogg/mid-Herbert_Hoover_video_montage.ogg.jpg" durationHint="22"></video>
2424 </table>
2525
2626 </body>
Index: trunk/phase3/js2/mwEmbed/example_usage/Player_Timed_Text.html
@@ -39,7 +39,7 @@
4040 <h4>Archive.org video with local SRTs (copied locally until we get srt over json for archive.org ;)</h4>
4141 <textarea cols="120" rows="12">
4242 <video poster="http://www.archive.org/download/princess_iron_fan/format=thumbnail" URLTimeEncoding="true"
43 - duration="1:13:0" linkback="http://www.archive.org/details/princess_iron_fan">
 43+ durationHint="1:13:0" linkback="http://www.archive.org/details/princess_iron_fan">
4444 <source type="video/ogg" src="http://www.archive.org/download/princess_iron_fan/princess_iron_fan.ogv"></source>
4545 <source type="video/h264" src="http://www.archive.org/download/princess_iron_fan/princess_iron_fan_512kb.mp4"></source>
4646 <text category="SUB" lang="en" type="text/x-srt" default="true"
Index: trunk/phase3/js2/mwEmbed/libAddMedia/mediaWikiUploadHelper.OFF.js
@@ -1,163 +0,0 @@
2 -/* the upload javascript
3 -presently does hackery to work with Special:Upload page...
4 -will be replaced with upload API once that is ready
5 -*/
6 -
7 -loadGM({
8 - "upload-enable-converter" : "Enable video converter (to upload source video not yet converted to theora format) <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
9 - "upload-fogg_not_installed": "If you want to upload video consider installing <a href=\"http://firefogg.org\">firefogg.org</a>, <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg\">more info</a>",
10 - "upload-transcode-in-progress":"Doing Transcode & Upload (do not close this window)",
11 - "upload-in-progress": "Upload in Progress (do not close this window)",
12 - "upload-transcoded-status": "Transcoded",
13 - "uploaded-status": "Uploaded",
14 - "upload-select-file": "Select File...",
15 - "wgfogg_wrong_version": "You have firefogg installed but its outdated, <a href=\"http://firefogg.org\">please upgrade</a> ",
16 - "wgfogg_waring_ogg_upload": "You have selected an ogg file for conversion to ogg (this is probably unnessesary). Maybe disable the video converter?",
17 - "wgfogg_waring_bad_extension" : "You have selected a file with an unsuported extension. <a href=\"http://commons.wikimedia.org/wiki/Commons:Firefogg#Supported_File_Types\">More help</a>",
18 - "upload-stats-fileprogres": "$1 of $2",
19 -
20 - "mv_upload_done" : "Your upload <i>should be</i> accessible <a href=\"$1\">here</a>",
21 - "upload-unknown-size": "Unknown size",
22 -
23 - "successfulupload" : "Successful upload",
24 - "uploaderror" : "Upload error",
25 - "uploadwarning": "Upload warning",
26 - "unknown-error": "Unknown Error",
27 - "return-to-form": "Return to form",
28 -
29 - "file-exists-duplicate" : "This file is a duplicate of the following file",
30 - "fileexists" : "A file with this name exists already, please check <b><tt>$1</tt></b> if you are not sure if you want to change it.",
31 - "fileexists-thumb": "<center><b>Existing file</b></center>",
32 - "ignorewarning" : "Ignore warning and save file anyway",
33 - "file-thumbnail-no" : "The filename begins with <b><tt>$1</tt></b>"
34 -});
35 -
36 -var default_upload_options = {
37 - 'target_div':'',
38 - 'upload_done_action':'redirect',
39 - 'api_url':false
40 -}
41 -
42 -var mediaWikiUploadHelper = function(iObj){
43 - return this.init( iObj );
44 -}
45 -mediaWikiUploadHelper.prototype = {
46 - init:function( iObj ){
47 - var _this = this;
48 - js_log('init uploader');
49 - if(!iObj)
50 - iObj = {};
51 - for(var i in default_upload_options){
52 - if(iObj[i]){
53 - this[i] = iObj[i];
54 - }else{
55 - this[i] = default_upload_options[i];
56 - }
57 - }
58 - //check if we are on the uplaod page:
59 - this.on_upload_page = ( wgPageName== "Special:Upload")?true:false;
60 - js_log('f:mvUploader: onuppage:' + this.on_upload_page);
61 - //grab firefogg.js:
62 - mvJsLoader.doLoad([
63 - 'mvFirefogg'
64 - ],function(){
65 - //if we are not on the upload page grab the upload html via ajax:
66 - //@@todo refactor with
67 - if( !_this.on_upload_page){
68 - $j.get(wgArticlePath.replace(/\$1/, 'Special:Upload'), {}, function(data){
69 - //add upload.js:
70 - $j.getScript( stylepath + '/common/upload.js', function(){
71 - //really _really_ need an "upload api"!
72 - wgAjaxUploadDestCheck = true;
73 - wgAjaxLicensePreview = false;
74 - wgUploadAutoFill = true;
75 - //strip out inline scripts:
76 - sp = data.indexOf('<div id="content">');
77 - se = data.indexOf('<!-- end content -->');
78 - if(sp!=-1 && se !=-1){
79 - result_data = data.substr(sp, (se-sp) ).replace('/\<script\s.*?\<\/script\>/gi',' ');
80 - js_log("trying to set: " + result_data );
81 - //$j('#'+_this.target_div).html( result_data );
82 - }
83 - _this.setupFirefogg();
84 - });
85 - });
86 - }else{
87 - //@@could check if firefogg is enabled here:
88 - _this.setupFirefogg();
89 - //if only want httpUploadFrom help enable it here:
90 - }
91 - }
92 - );
93 - },
94 - /**
95 - * setupBaseUpInterface supports intefaces for progress indication if the browser supports it
96 - * also sets up ajax progress updates for http posts
97 - * //pre
98 - */
99 - setupBaseUpInterface:function(){
100 - //check if this feature is not false (we want it on by default (null) instances that don't have the upload api or any modifications)
101 - this.upForm = new mvBaseUploadInterface( {
102 - 'api_url' : this.api_url,
103 - 'parent_uploader': this
104 - }
105 - );
106 - this.upForm.setupForm();
107 - },
108 - setupFirefogg:function(){
109 - var _this = this;
110 - //add firefogg html if not already there: ( same as $wgEnableFirebug added in SpecialUpload.php )
111 - if( $j('#fogg-video-file').length==0 ){
112 - js_log('add addFirefoggHtml');
113 - _this.addFirefoggHtml();
114 - }else{
115 - js_log('firefogg already init:');
116 - }
117 - //set up the upload_done action
118 - //redirect if we are on the upload page
119 - //do a callback if in called from gui)
120 - var intFirefoggObj = ( this.on_upload_page )?
121 - {'upload_done_action':'redirect'}:
122 - {'upload_done_action':function( rTitle ){
123 - js_log( 'add_done_action callback for uploader' );
124 - //call the parent insert resource preview
125 - _this.upload_done_action( rTitle );
126 - }
127 - };
128 -
129 - if( _this.api_url )
130 - intFirefoggObj['api_url'] = _this.api_url;
131 -
132 - js_log('new mvFirefogg extends mvUploader (this)');
133 - this.fogg = new mvFirefogg( intFirefoggObj );
134 - this.fogg.setupForm();
135 - },
136 - //same add code as specialUpload if($wgEnableFirefogg){
137 - addFirefoggHtml:function(){
138 - var itd_html = $j('#mw-upload-table .mw-input:first').html();
139 - $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>');
140 - //add in firefogg control
141 - $j('#wg-base-upload').after('<p id="fogg-enable-item" >' +
142 - '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + gM('upload-select-file') + '">' +
143 - "<span id='wgfogg_not_installed'>" +
144 - gM('upload-fogg_not_installed') +
145 - "</span>" +
146 - "<span class='error' id='wgfogg_wrong_version' style='display:none;'><br>" +
147 - gM('wgfogg_wrong_version') +
148 - "<br>" +
149 - "</span>" +
150 - "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none;'><br>"+
151 - gM('wgfogg_waring_ogg_upload') +
152 - "<br>" +
153 - "</span>" +
154 - "<span class='error' id='wgfogg_waring_bad_extension' style='display:none;'><br>"+
155 - gM('wgfogg_waring_bad_extension') +
156 - "<br>" +
157 - "</span>" +
158 - "<span id='wgfogg_installed' style='display:none' >"+
159 - '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' +
160 - gM('upload-enable-converter') +
161 - '</span><br></p>');
162 - },
163 -
164 -};
Index: trunk/phase3/js2/mwEmbed/libAddMedia/remoteSearchDriver.js
@@ -1548,7 +1548,7 @@
15491549 if( this.content_providers[this.disp_item] ){
15501550 var cp = this.content_providers[this.disp_item];
15511551 about_desc ='<span style="position:relative;top:0px;font-style:italic;">' +
1552 - '<i>' + gM('results_from', cp.homepage, cp.title) + '</i></span>';
 1552+ '<i>' + gM('results_from', [cp.homepage, cp.title]) + '</i></span>';
15531553 $j('#tab-'+this.disp_item).append( '<div id="rds_results_bar">'+
15541554 '<span style="float:left;top:0px;font-style:italic;">'+
15551555 gM('rsd_layout')+' '+
Index: trunk/phase3/js2/mwEmbed/jsScriptLoader.php
@@ -54,6 +54,7 @@
5555 foreach( $this->jsFileList as $classKey => $file_name ){
5656 // special case: - title classes:
5757 if( substr( $classKey, 0, 3 ) == 'WT:' ){
 58+ global $wgUser;
5859 // get just the tile part:
5960 $title_block = substr( $classKey, 3 );
6061 if( $title_block[0] == '-' && strpos( $title_block, '|' ) !== false ){
@@ -66,12 +67,13 @@
6768 $skin = $val;
6869 }
6970 }
 71+ $sk = $wgUser->getSkin();
7072 // make sure the skin name is valid
7173 $skinNames = Skin::getSkinNames();
7274 // get the lower case skin name (array keys)
7375 $skinNames = array_keys( $skinNames );
7476 if( in_array( strtolower( $skin ), $skinNames ) ){
75 - $this->jsout .= Skin::generateUserJs( $skin ) . "\n";
 77+ $this->jsout .= $sk->generateUserJs( $skin ) . "\n";
7678 // success continue:
7779 continue;
7880 }
@@ -147,7 +149,8 @@
148150 * updates the proc Request
149151 */
150152 function procRequestVars(){
151 - global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses, $wgJSAutoloadLocalClasses, $wgStyleVersion;
 153+ global $wgContLanguageCode, $wgEnableScriptMinify, $wgJSAutoloadClasses,
 154+ $wgJSAutoloadLocalClasses, $wgStyleVersion, $wgEnableScriptLoaderJsFile;
152155
153156 // set debug flag:
154157 if( ( isset( $_GET['debug'] ) && $_GET['debug'] == 'true' ) || ( isset( $wgEnableScriptDebug ) && $wgEnableScriptDebug == true ) ){
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1160,7 +1160,6 @@
11611161 'media_tip' => 'File link',
11621162 'sig_tip' => 'Your signature with timestamp',
11631163 'hr_tip' => 'Horizontal line (use sparingly)',
1164 -'add_media_wizard' => 'Add media wizard',
11651164
11661165 # Edit pages
11671166 'summary' => 'Summary:',

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53282here it is ... the upload-api, script-server, js2 (javascript phase2) branch ...dale23:52, 14 July 2009

Status & tagging log