r46627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46626‎ | r46627 | r46628 >
Date:00:40, 31 January 2009
Author:dale
Status:deferred
Tags:
Comment:
some style updates per user suggestions
firefogg updates for more error handling
scraper updates
language updates
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MagicWords.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_MetavidInterface.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Navigator.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Stream.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Title.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialListStreams.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/firefogg.js (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mv_upload.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/maintenance/metavid2mvWiki.inc.php
@@ -631,12 +631,19 @@
632632 include_once( 'scrape_and_insert.inc.php' );
633633 $mvScrape = new MV_BaseScraper();
634634
635 - // do people query:
636 - if ( $forcePerson != '' ) {
637 - $res = $dbr->query( "SELECT * FROM `metavid`.`people` WHERE `name_clean` LIKE '$forcePerson'" );
638 - } else {
639 - $res = $dbr->query( "SELECT * FROM `metavid`.`people`" );
 635+ //get all people from the people category
 636+ $result = $dbr->select( 'categorylinks', 'cl_sortkey', array (
 637+ 'cl_to' => 'Person',
 638+ '`cl_sortkey` LIKE \'%' . mysql_escape_string( $val
 639+ ) . '%\' COLLATE latin1_general_ci' ), __METHOD__, array (
 640+ 'LIMIT' => $result_limit
 641+ ) );
 642+ $out = '';
 643+ while ( $row = $dbr->fetchObject( $result ) ) {
 644+ $person_name = $row->cl_sortkey;
 645+ $person_ary[$person_name] = true;
640646 }
 647+
641648 if ( $dbr->numRows( $res ) == 0 )
642649 die( 'could not find people: ' . "\n" );
643650 $person_ary = array ();
Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -6,7 +6,7 @@
77 * for more info visit http://metavid.org/wiki/Code
88 *
99 */
10 -define( 'MV_VERSION', '1.0r46610' );
 10+define( 'MV_VERSION', '1.0r46611' );
1111
1212 if ( !defined( 'MEDIAWIKI' ) ) die( 1 );
1313
@@ -606,6 +606,21 @@
607607 return sprintf( "%d:%02d:%02d", $dur['hours'], $dur['minutes'], $dur['seconds'] );
608608 }
609609 }
 610+function seconds2Description( $seconds, $short=false){
 611+ $dur = time_duration_2array( $seconds );
 612+ $o='';
 613+ if( $dur['hours'] )
 614+ $o.= wfMsg('mv_hours', intval( $dur['hours']) );
 615+ if( $dur['minutes'] ){
 616+ $o.=($o!='')?' ':'';
 617+ $o.= wfMsg('mv_minutes', intval( $dur['minutes']) );
 618+ }
 619+ if( $short==false && $dur['seconds'] ){
 620+ $o.=($o!='')?' ':'';
 621+ $o.= wfMsg('mv_seconds', intval( $dur['seconds']) );
 622+ }
 623+ return $o;
 624+}
610625 /*
611626 * converts seconds to time unit array
612627 */
Index: trunk/extensions/MetavidWiki/includes/MV_Stream.php
@@ -99,6 +99,14 @@
100100 return $this->name;
101101 }
102102 }
 103+ function getStreamStartDate(){
 104+ if( $this->date_start_time == '' ){
 105+ $this->db_load_stream();
 106+ return $this->date_start_time;
 107+ }else{
 108+ return $this->date_start_time;
 109+ }
 110+ }
103111 /*
104112 * @@todo cache this!:
105113 */
Index: trunk/extensions/MetavidWiki/includes/MV_MagicWords.php
@@ -55,9 +55,12 @@
5656 case 'POPULARCLIPS':
5757 return $this->getTopClips();
5858 break;
 59+ case 'RECENTSTREAMS':
 60+ return $this->getRecentStreams();
 61+ break;
5962 case 'PERSONSPEECHES':
6063 return $this->getPersonOut();
61 - break;
 64+ break;
6265 case 'VIDEOBILL':
6366 return $this->getBillOut();
6467 break;
Index: trunk/extensions/MetavidWiki/includes/MV_Index.php
@@ -70,7 +70,7 @@
7171 $do_cat_lookup = true;
7272 } else {
7373 if ( SMW_VERSION >= 1.2 ) {
74 - // the following is too slow to use but gennerally works:
 74+ // the following is too slow to use but generally works:
7575 // has to be rewritten with sub-queries or something more elaborate
7676 // for now just do lookup after the fact
7777 $do_smw_lookup = true;
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialListStreams.php
@@ -84,7 +84,7 @@
8585 # make sure the first letter is upper case (makeTitle() should do that)
8686 $result->title = strtoupper( $result->title[0] ) . substr( $result->title, 1 );
8787 $img_url = $mvImageArchive . $result->title . '?size=icon&time=0:00:00';
88 - $img_url = MV_StreamImage::getStreamImageURL( $result->stream_id, '0:00:00', 'icon', true );
 88+ $img_url = MV_StreamImage::getStreamImageURL( $result->stream_id, '0:00:10', 'icon', true );
8989 $img_html = '<img src="' . htmlspecialchars( $img_url ) . '" width="80" height="60">';
9090
9191
Index: trunk/extensions/MetavidWiki/includes/MV_Title.php
@@ -90,6 +90,18 @@
9191 if ( $sn == '' )$sn = $this->stream_name;
9292 return ucfirst( str_replace( '_', ' ', $sn ) );
9393 }
 94+ function getStreamNameDate(){
 95+ $d = $this->mvStream->getStreamStartDate();
 96+ if(!isset($d) || $d==0)
 97+ return $this->getStreamNameText();
 98+ $sn_parts = split('_',$this->stream_name);
 99+ //remove the date part of the array:
 100+ array_pop( $sn_parts);
 101+ foreach($sn_parts as & $sp)
 102+ $sp = ucfirst($sp);
 103+ $sn = (count($sn_parts)>1)? implode(' ', $sn_parts): $sp[0];
 104+ return $sn .' on '. date('M jS, Y',$d);
 105+ }
94106 /*
95107 * makes title like db key:
96108 */
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_MetavidInterface.php
@@ -80,13 +80,14 @@
8181
8282 // also add prev next paging
8383 $this->page_header = '<h1 class="videoHeader">' .
84 - $this->article->mvTitle->getStreamNameText() . ' :: ' .
 84+ $this->article->mvTitle->getStreamNameDate() . ' :: ' .
8585 $this->components['MV_Tools']->stream_paging_links( 'prev' ) .
8686 ' <span title="' . htmlspecialchars( wfMsg( 'mv_click_to_edit' ) ) . '" id="mv_stream_time">' . $this->article->mvTitle->getTimeDesc( $span_separated = true ) . '</span>' .
8787 $this->components['MV_Tools']->stream_paging_links( 'next' ) .
88 - wfMsg( 'mv_of' ) . seconds2ntp( $this->article->mvTitle->getDuration() ) .
89 - '</h1>';
90 -
 88+ '<br><span style="font-size:80%">'.
 89+ wfMsg( 'mv_stream_length' ) . seconds2Description( $this->article->mvTitle->getDuration(), true ) .
 90+ '</span></h1>';
 91+
9192 if($mvEnableStreamNotice){
9293 $wgOut->addWikiText( wfMsg('mv_warning_wiki'));
9394 $this->page_header.=$wgOut->getHTML();
Index: trunk/extensions/MetavidWiki/includes/MV_MetavidInterface/MV_Navigator.php
@@ -54,7 +54,12 @@
5555 $tool_tip = '';
5656 // print_r($row);
5757 if ( trim( $row->Speech_by ) != '' ) {
58 - $o .= wfMsg( 'mv_' . $pntype . '_speech', $sk->makeKnownLinkObj( $streamTitle, str_replace( '_', ' ', $row->Speech_by ) ) );
 58+ //check if the person has an icon:
 59+ $pimg = mv_get_person_img( $row->Speech_by );
 60+ $o .= wfMsg( 'mv_' . $pntype . '_speech', $sk->makeKnownLinkObj( $streamTitle, '<img title="'.str_replace('_',' ',$row->Speech_by).'" width="40" src="' . $pimg->getURL() . '">' ) );
 61+ //$o .= wfMsg( 'mv_' . $pntype . '_speech', $sk->makeKnownLinkObj( $streamTitle, str_replace( '_', ' ', $row->Speech_by ) ) );
 62+
 63+
5964 // $tool_tip.= 'Speech By: '. $row->Speech_by;
6065 } else if ( trim( $row->Bill ) != '' ) {
6166 $o .= wfMsg( 'mv_' . $pntype . '_bill', $sk->makeKnownLinkObj( $streamTitle, str_replace( '_', ' ', $row->Bill ) ) );
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -277,8 +277,11 @@
278278
279279 'mv_other_options' => 'Other Options',
280280 'mv_contextmenu_opt' => 'Enable Context Menus',
 281+ 'mv_hours'=>'$1 {{PLURAL:$1|hour|hours}} ',
 282+ 'mv_minutes' => '$1 {{PLURAL:$1|minute|minutes}}',
 283+ 'mv_seconds' => '$1 {{PLURAL:$1|second|seconds}}',
 284+ 'mv_stream_length' => 'Total Video Length: ',
281285
282 -
283286 'mv_sequence_timeline' => 'Sequence timeline:',
284287 'mv_edit_sequence_desc_help' => 'Sequence description',
285288 'mv_edithelpsequence' => 'Help:Sequence_Editing',
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/mv_upload.js
@@ -12,6 +12,7 @@
1313 gMsg['uploaded-status'] = 'Uploaded';
1414 gMsg['upload-select-file'] = 'Select File...';
1515 gMsg['wgfogg_wrong_version'] = 'You have firefogg installed but its outdated, <a href="http://firefogg.org">please upgrade</a> ';
 16+gMsg['wgfogg_waring_ogg_upload'] = 'You have selected an ogg file for conversion to ogg (this is probably unessesary). Maybe disable the video converter?';
1617
1718 var default_upload_options = {
1819 'target_div':'',
@@ -98,14 +99,17 @@
99100 $j('#mw-upload-table .mw-input').eq(0).html('<div id="wg-base-upload">' + itd_html + '</div>');
100101 //add in firefogg control
101102 $j('#wg-base-upload').after('<p id="fogg-enable-item" >' +
102 - '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="Select File..">' +
103 - '<span id="wgfogg_not_installed">' +
 103+ '<input style="display:none" id="fogg-video-file" name="fogg-video-file" type="button" value="' + getMsg('upload-select-file') + '">' +
 104+ "<span class='error' id='wgfogg_not_installed'>" +
104105 getMsg('upload-fogg_not_installed') +
105106 '</span>'+
106 - '<span id="wgfogg_wrong_version">'+
 107+ "<span class='error' id='wgfogg_wrong_version'>"+
107108 getMsg('wgfogg_wrong_version')+
108109 '</span>'+
109 - '<span id="wgfogg_installed" style="display:none" >'+
 110+ "<span class='error' id='wgfogg_waring_ogg_upload' style='display:none' >"+
 111+ getMsg('wgfogg_waring_ogg_upload')+
 112+ '</span>'+
 113+ "<span id='wgfogg_installed' style='display:none' >"+
110114 '<input id="wgEnableFirefogg" type="checkbox" name="wgEnableFirefogg" >' +
111115 getMsg('upload-enable-converter') +
112116 '<span><br></p>');
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libAddMedia/firefogg.js
@@ -8,7 +8,7 @@
99 init_firefogg();
1010 });
1111 }
12 -var min_firefogg_version = '0.9.2';
 12+var min_firefogg_version = '0.9.3';
1313 function init_firefogg( iObj ){
1414 if(!iObj)
1515 iObj = {};
@@ -39,7 +39,7 @@
4040 var fogg = new upFirefogg( iObj );
4141
4242 //do the version check:
43 - var fv = fogg.ogg.version;
 43+ var fv = fogg.fogg.version;
4444 if(fv.replace(/[^0-9]/gi, '') < min_firefogg_version.replace(/[^0-9]/gi, '') ){
4545 e = document.getElementById('wgfogg_wrong_version');
4646 if(e)
@@ -86,7 +86,7 @@
8787 }
8888 }
8989 //init the Firefogg obj
90 - this.ogg = new Firefogg();
 90+ this.fogg = new Firefogg();
9191 },
9292 enable_fogg:function(){
9393 var _this = this;
@@ -114,30 +114,65 @@
115115 },
116116 select_fogg:function(){
117117 var _this = this;
118 - if(_this.ogg.selectVideo()) {
 118+ if(_this.fogg.selectVideo()) {
119119 var editForm = document.getElementById( 'mw-upload-form' );
120120 _this.org_onsubmit = editForm.onsubmit;
121121 editForm.onsubmit = function return_false(){
122122 return false;
123 - };
 123+ };
 124+
 125+ //update destination filename:
 126+ if( _this.fogg.sourceFilename ){
 127+ var destFileInput = document.getElementById( 'wpDestFile');
 128+ var sf = _this.fogg.sourceFilename;
 129+
 130+ var ext = '';
 131+ if( sf.lastIndexOf('.') != -1){
 132+ ext = sf.substring( sf.lastIndexOf('.')+1 );
 133+ }
 134+ //set upload warning
 135+ if( ext == 'ogg' || ext == 'ogv' ){
 136+ e = document.getElementById('wgfogg_waring_ogg_upload');
 137+ if(e)
 138+ e.style.display='block';
 139+ return false;
 140+ }else if( ext == 'avi' || ext == 'mov' || ext == 'mp4' ||
 141+ ext == 'mpeg' || ext == 'mpeg2' || ext == 'mpeg4' ||
 142+ ext == 'dv' ){
 143+ //hide ogg warning
 144+ e = document.getElementById('wgfogg_waring_ogg_upload');
 145+ if(e)
 146+ e.style.display='none';
 147+ sf = sf.replace(ext, 'ogg');
 148+ destFileInput.value = sf;
 149+ }else{
 150+ //not ogg extension error
 151+ e = document.getElementById('wgfogg_waring_bad_extension');
 152+ if(e)
 153+ e.style.display='block';
 154+ }
 155+ }
124156 //set binding for "upload" button to call our transcode process
125157 addHandler( editForm, 'submit', function() {
126158 //check if the title and or description are empty don't let the person submit
127159 e = document.getElementById('wpDestFile')
128 - if(typeof e.value == 'undefined' || e.value=='' || e.value.substr(-4) != '.ogg')
129 - return alert('destination file is empty or does not end with .ogg');
 160+ //if(typeof e.value == 'undefined' || e.value=='' || e.value.substr(-4) != '.fogg')
 161+ // return alert('destination file is empty or does not end with .fogg');
130162
131 - e = document.getElementById('wpUploadDescription');
132 - if(e){
133 - if(typeof e.value == 'undefined' || e.value=='')
134 - return alert('Description is empty');
135 - }
 163+ //e = document.getElementById('wpUploadDescription');
 164+ //if(e){
 165+ // if(typeof e.value == 'undefined' || e.value=='')
 166+ // return alert('Description is empty');
 167+ //}
136168 //for commons check wpDescText1
137169 e = document.getElementById('wpDescText1');
138170 if(e){
139171 if(typeof e.value == 'undefined' || e.value=='')
140172 return alert('Description is empty');
141173 }
 174+ //get the input
 175+ var formData = _this.getEditFormData( editForm );
 176+ debugger;
142177
143178 //display the loader:
144179 e = document.getElementById('dlbox-centered')
@@ -153,54 +188,51 @@
154189
155190 //@@todo read this from the config file rather than hard code it:
156191 var options = JSON.stringify({'maxSize': 400, 'videoBitrate': 500});
157 - _this.ogg.encode(options);
 192+ _this.fogg.encode(options);
158193 var encodingStatus = function() {
159 - var status = _this.ogg.status();
 194+ var status = _this.fogg.status();
160195
161196 //update progress bar
162 - _this.fogg_update_progress( _this.ogg.progress() );
 197+ _this.fogg_update_progress( _this.fogg.progress() );
163198
164199 //loop to get new status if still encoding
165 - if( _this.ogg.state == 'encoding' ) {
 200+ if( _this.fogg.state == 'encoding' ) {
166201 setTimeout(encodingStatus, 500);
167202 }
168203 //encoding done, state can also be 'encoding failed'
169 - else if ( _this.ogg.state == 'encoding done' ) {
 204+ else if ( _this.fogg.state == 'encoding done' ) {
170205 //hide the fogg-status-transcode
171206 e = document.getElementById('fogg-status-transcode');
172207 e.style.display='none';
173208 //show the fogg-status-upload
174209 e = document.getElementById('fogg-status-upload');
175 - e.style.display='inline';
176 -
177 - //get the input
178 - var data = _this.getEditFormData( editForm );
 210+ e.style.display='inline';
179211
180212 //hard code some values
181 - data['wpSourceType']='file';
 213+ formData['wpSourceType']='file';
182214
183 - var data_str = JSON.stringify(data);
 215+ var data_str = JSON.stringify( formData );
184216 //alert('send data:'+ data_str);
185217 //send to the post url:
186218 js_log('sending to:' + editForm.action);
187 - _this.ogg.upload(editForm.action, 'wpUploadFile', data_str);
 219+ _this.fogg.upload(editForm.action, 'wpUploadFile', data_str);
188220 var uploadStatus = function() {
189 - var status = _this.ogg.status();
190 - //js_log(' up stats: ' + status + ' p:' + _this.ogg.progress() + ' state: '+ _this.ogg.state + ' result page:' + result_page);
 221+ var status = _this.fogg.status();
 222+ //js_log(' up stats: ' + status + ' p:' + _this.fogg.progress() + ' state: '+ _this.fogg.state + ' result page:' + result_page);
191223
192224 //update progress bar
193 - _this.fogg_update_progress( _this.ogg.progress() );
 225+ _this.fogg_update_progress( _this.fogg.progress() );
194226
195227 //loop to get new status if still uploading
196 - if(_this.ogg.state == 'uploading') {
 228+ if(_this.fogg.state == 'uploading') {
197229 setTimeout(uploadStatus, 500);
198230 }
199231 //upload sucsefull, state can also be 'upload failed'
200 - else if(_this.ogg.state == 'upload done') {
201 - //js_log('upload done: ' + JSON.parse(_this.ogg.uploadstatus()).responseText);
 232+ else if(_this.fogg.state == 'upload done') {
 233+ //js_log('upload done: ' + JSON.parse(_this.fogg.uploadstatus()).responseText);
202234 //@@todo handle errors same problem as #695 in mv_remote_media_search.js
203235 //we need to add image uploading to the api rather than parse the HTML output of the pages
204 - var result_page = JSON.parse(_this.ogg.uploadstatus()).responseText;
 236+ var result_page = JSON.parse(_this.fogg.uploadstatus()).responseText;
205237 var sstring = 'var wgTitle = "' + data['wpDestFile'].replace('_',' ');
206238 if( result_page.toLowerCase().indexOf( sstring.toLowerCase() ) != -1){
207239 js_log('upload done got redirect found: ' +sstring + ' r:' + _this.upload_done_action);
@@ -233,11 +265,11 @@
234266 }
235267 //upload error:
236268 else{
237 - alert('upload error: ' + _this.ogg.state);
 269+ alert('upload error: ' + _this.fogg.state);
238270 }
239271 }
240272 uploadStatus();
241 - }else if(_this.ogg.state == 'encoding fail'){
 273+ }else if(_this.fogg.state == 'encoding fail'){
242274 //@@todo error handling:
243275 alert('encoding failed');
244276 }
@@ -251,7 +283,7 @@
252284 }
253285 },
254286 getEditFormData:function( editForm ){
255 - var data = {};
 287+ var data = {};
256288 //get all the form fields:
257289 var inputs = editForm.getElementsByTagName('input');
258290 for(var i=0;i < inputs.length; i++){
@@ -278,6 +310,16 @@
279311 e = document.getElementById('wg-base-upload');
280312 if(e) e.style.display='inline';
281313
 314+ //hide ogg warning
 315+ e = document.getElementById('wgfogg_waring_ogg_upload');
 316+ if(e)
 317+ e.style.display='none';
 318+
 319+ //hide not ogg extension error
 320+ e = document.getElementById('wgfogg_waring_bad_extension');
 321+ if(e)
 322+ e.style.display='block';
 323+
282324 //hide fogg stuff
283325 e = document.getElementById('fogg-video-file');
284326 if(e) e.style.display='none';

Status & tagging log