r48583 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48582‎ | r48583 | r48584 >
Date:17:09, 19 March 2009
Author:dale
Status:deferred (Comments)
Tags:todo 
Comment:
minor fixes/rewording of parent stream reference
Modified paths:
  • /trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/MV_Index.php (modified) (history)
  • /trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php (modified) (history)
  • /trunk/extensions/MetavidWiki/languages/MV_Messages.php (modified) (history)
  • /trunk/extensions/MetavidWiki/skins/mv_search.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MetavidWiki/includes/MV_GlobalFunctions.php
@@ -672,18 +672,22 @@
673673 return sprintf( "%d:%02d:%02d", $dur['hours'], $dur['minutes'], $dur['seconds'] );
674674 }
675675 }
676 -function seconds2Description( $seconds, $short=false){
 676+function seconds2Description( $seconds, $short=false, $singular=false){
677677 $dur = time_duration_2array( $seconds );
678678 $o='';
679 - if( $dur['hours'] )
680 - $o.= wfMsg('mv_hours', intval( $dur['hours']) );
681 - if( $dur['minutes'] ){
 679+ if( $dur['hours'] != 0 ){
 680+ $msg = ($singular)?'mv_hours_singular':'mv_hours';
 681+ $o.= wfMsg($msg, intval( $dur['hours']) );
 682+ }
 683+ if( $dur['minutes'] != 0 ){
 684+ $msg = ($singular)?'mv_minutes_singular':'mv_minutes';
682685 $o.=($o!='')?' ':'';
683 - $o.= wfMsg('mv_minutes', intval( $dur['minutes']) );
684 - }
685 - if( $short==false && $dur['seconds'] ){
 686+ $o.= wfMsg($msg, intval( $dur['minutes']) );
 687+ }
 688+ if( ( $short == false || $o == '' ) && $dur['seconds'] ){
 689+ $msg = ($singular)?'mv_seconds_singular':'mv_seconds';
686690 $o.=($o!='')?' ':'';
687 - $o.= wfMsg('mv_seconds', intval( $dur['seconds']) );
 691+ $o.= wfMsg($msg, intval( $dur['seconds']) );
688692 }
689693 return $o;
690694 }
Index: trunk/extensions/MetavidWiki/includes/MV_Index.php
@@ -511,8 +511,8 @@
512512 __METHOD__,
513513 $options );
514514
515 - //echo "SQL:".$dbr->lastQuery($result)." \n";
516 - //die;
 515+ //echo "SQL:".$dbr->lastQuery($result)." \n";
 516+ //die;
517517 // $result = $dbr->query($sql, 'MV_Index:doFiltersQuery_base');
518518
519519 $this->numResults = $dbr->numRows( $result );
Index: trunk/extensions/MetavidWiki/includes/specials/MV_SpecialMediaSearch.php
@@ -416,8 +416,9 @@
417417 $clip_desc_txt = 'Speech By ' . $personTitle->getText();
418418 }
419419
420 - $pmeta_out.='This clip is part of a '. seconds2Description ( $pMvTitle->getSegmentDuration() ). ' ' .
421 - $sk->makeKnownLinkObj($pAnnoStreamLink, $clip_desc_txt );
 420+ $pmeta_out.='This '. $sk->makeKnownLinkObj($pAnnoStreamLink, seconds2Description ( $mvTitle->getSegmentDuration(), true, true ) ).
 421+ ' clip is part of a larger '.
 422+ $sk->makeKnownLinkObj($pAnnoStreamLink, seconds2Description ( $pMvTitle->getSegmentDuration(), true, true ) ) . ' Speech';
422423 if($pmvd->category){
423424 $pmeta_out.='<br>Covering: ';
424425 $coma='';
@@ -859,9 +860,9 @@
860861 if ( $f['t'] != 'match' ) // no desc for text search
861862 $o .= ( $query_key ) ? $a : $a . wfMsg( 'mv_' . $f['t'] ) . ' ';
862863 if ( $f['t'] == 'date_range' ) { // handle special case of date range:
863 - $o .= wfMsg( 'mv_time_separator', $bo . htmlspecialchars( $f['vs'] ) . $bc, $bo . htmlspecialchars( $f['ve'] ) . $bc );
 864+ $o .= ' '+ wfMsg( 'mv_time_separator', $bo . htmlspecialchars( $f['vs'] ) . $bc, $bo . htmlspecialchars( $f['ve'] ) . $bc );
864865 } else {
865 - $o .= $bo . str_replace( '_', ' ', htmlspecialchars( $f['v'] ) ) . $bc;
 866+ $o .=' '. $bo . str_replace( '_', ' ', htmlspecialchars( $f['v'] ) ) . $bc .' ';
866867 }
867868 }
868869 }
Index: trunk/extensions/MetavidWiki/languages/MV_Messages.php
@@ -427,8 +427,11 @@
428428 'mv_other_options' => 'Other options',
429429 'mv_contextmenu_opt' => 'Enable context menus',
430430 'mv_hours' => '$1 {{PLURAL:$1|hour|hours}} ',
 431+ 'mv_hours_singular' => '$1 hour',
431432 'mv_minutes' => '$1 {{PLURAL:$1|minute|minutes}}',
 433+ 'mv_minutes_singular' => '$1 minute',
432434 'mv_seconds' => '$1 {{PLURAL:$1|second|seconds}}',
 435+ 'mv_seconds_singular' => '$1 second',
433436 'mv_stream_length' => 'Total video length: ',
434437
435438 'mv_sequence_timeline' => 'Sequence timeline:',
Index: trunk/extensions/MetavidWiki/skins/mv_search.js
@@ -389,6 +389,8 @@
390390 js_log('selected:' + v.innerHTML );
391391 //update the image:
392392 $j('#mv_person_img_'+inx).attr('src', $j(v).children('img').attr('src'));
 393+ //update the text:
 394+ $j('#mv_person_input_'+inx).val( $j('#mv_person_input_'+inx).val().replace('_', ' ') );
393395 },
394396 formatItem:function(row){
395397 //return '<img width="44" src="'+ row[2] + '">'+row[1];

Comments

#Comment by Raymond (talk | contribs)   17:40, 19 March 2009

What is the purpose of

 	'mv_hours' => '$1 {{PLURAL:$1|hour|hours}} ',
+	'mv_hours_singular' => '$1 hour',
 	'mv_minutes' => '$1 {{PLURAL:$1|minute|minutes}}',
+	'mv_minutes_singular' => '$1 minute',
 	'mv_seconds' => '$1 {{PLURAL:$1|second|seconds}}',
+	'mv_seconds_singular' => '$1 second',

For this we have the PLURAL function.

#Comment by Mdale (talk | contribs)   17:44, 19 March 2009

needed to force singular without outputting a leading value. any suggestions?

#Comment by Mdale (talk | contribs)   17:46, 19 March 2009

ie "this is a 34 second clip" .. "this is a 34 seconds clip" maybe put the whole expression into msg?

#Comment by Raymond (talk | contribs)   19:03, 19 March 2009

Use

$o.= wfMsgExt($msg, 'parsemag', $wgLang->formatNum( intval( $dur['hours']) ) );

instead. This respects the PLURAL function and converts the numbers to other scripts if needed.

Status & tagging log