r61512 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r61511‎ | r61512 | r61513 >
Date:08:04, 26 January 2010
Author:dale
Status:ok
Tags:
Comment:
* white space and comment clean up per r61056 #c5410
Modified paths:
  • /trunk/extensions/OggHandler/OggHandler.php (modified) (history)
  • /trunk/extensions/OggHandler/OggHandler_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OggHandler/OggHandler.php
@@ -53,10 +53,13 @@
5454 //if wgPlayerStats collection is enabled or not
5555 $wgPlayerStatsCollection=false;
5656
57 -//if $wgEnableJS2system = true and the below variable is set to true
58 -// then we can output the <video> tag and its re-written by mv_embed
 57+// Output Video tag support
5958 $wgVideoTagOut = false;
6059
 60+// Defautl skin for mwEmbed player
 61+// Skins presently available:
 62+// "kskin" kaltura skin
 63+// "mvpcf" a jquery ui like skin
6164 $wgVideoPlayerSkin = 'kskin';
6265
6366 // Support striped player iframe output for remote embedding
Index: trunk/extensions/OggHandler/OggHandler_body.php
@@ -77,7 +77,7 @@
7878
7979 function normaliseParams( $image, &$params ) {
8080 $timeParam = array('thumbtime', 'start', 'end');
81 - //parse time values if endtime or thumbtime can't be more than length -1
 81+ // Parse time values if endtime or thumbtime can't be more than length -1
8282 foreach($timeParam as $pn){
8383 if ( isset( $params[$pn] ) ) {
8484 $length = $this->getLength( $image );
@@ -91,7 +91,7 @@
9292 }
9393 }
9494 }
95 - //make sure start time is not > than end time
 95+ // Make sure start time is not > than end time
9696 if(isset($params['start']) && isset($params['end']) ){
9797 if($params['start'] > $params['end'])
9898 return false;
@@ -147,7 +147,7 @@
148148 }
149149 $metadata['streams'] = $streams;
150150 $metadata['length'] = $f->getLength();
151 - //get the offset of the file (in cases where the file is a segment copy)
 151+ // Get the offset of the file (in cases where the file is a segment copy)
152152 $metadata['offset'] = $f->getStartOffset();
153153 } catch ( PEAR_Exception $e ) {
154154 // File not found, invalid stream, etc.
@@ -192,19 +192,19 @@
193193 $noPlayer = isset( $params['noplayer'] );
194194 $noIcon = isset( $params['noicon'] );
195195
196 - //set up the default targetUrl:
 196+ // Set up the default targetUrl:
197197 $targetFileUrl = $file->getURL();
198198
199199
200 - //add temporal request parameter if $wgEnableTemporalOggUrls is on:
201 - if($wgEnableTemporalOggUrls && isset( $params['start'] ) ){
 200+ // Add temporal request parameter if $wgEnableTemporalOggUrls is on:
 201+ if( $wgEnableTemporalOggUrls && isset( $params['start'] ) ){
202202 $targetFileUrl .= '?t=' . seconds2npt( $this->parseTimeString( $params['start'], $length ) );
203203 if(isset( $params[ 'end' ] ) && $params['end'] )
204204 $targetFileUrl.='/'. seconds2npt( $this->parseTimeString( $params['end'], $length) );
205205 }
206206
207 - //check if $wgEnabledDerivatives is "set" and we have a target derivative set:
208 - //(presently set by the wikiAtHome extension)
 207+ // Check if $wgEnabledDerivatives is "set" and we have a target derivative set:
 208+ // (presently set by the wikiAtHome extension)
209209 if (isset( $wgEnabledDerivatives ) && is_array( $wgEnabledDerivatives ) && count( $wgEnabledDerivatives ) != 0){
210210 //get the encode key:
211211 $encodeKey = WikiAtHome::getTargetDerivative( $width, $file );
@@ -217,11 +217,11 @@
218218 $derivativeUrl = $file->getThumbUrl( $wjm->getEncodeKey() . '.ogg');
219219 $derivativePath = $file->getThumbPath( $wjm->getEncodeKey() );
220220
221 - //check that we have the requested theora derivative
 221+ // Check that we have the requested theora derivative
222222 if( is_file ( "{$derivativePath}.ogg" )){
223223 $targetFileUrl = $derivativeUrl;
224224 }else{
225 - //output in queue text (send the dstUrl if available )
 225+ // Output in queue text (send the dstUrl if available )
226226 return new MediaQueueTransformOutput($file, $dstUrl, $width, $height, $wjm->getDonePerc() );
227227 }
228228 }
@@ -281,7 +281,7 @@
282282 $thumbtime = $this->parseTimeString( $params['thumbtime'], $length );
283283 }
284284 if ( $thumbtime === false ) {
285 - //if start time param isset use that for the thumb:
 285+ // If start time param isset use that for the thumb:
286286 if( isset( $params['start'] ) ){
287287 $thumbtime = $this->parseTimeString( $params['start'], $length );
288288 }else{
@@ -293,7 +293,7 @@
294294
295295 wfDebug( "Creating video thumbnail at $dstPath\n" );
296296
297 - //first check for oggThumb
 297+ // First check for oggThumb
298298 if( $wgOggThumbLocation && is_file( $wgOggThumbLocation ) ){
299299 $cmd = wfEscapeShellArg( $wgOggThumbLocation ) .
300300 ' -t '. intval( $thumbtime ) . ' ' .
@@ -327,7 +327,7 @@
328328 wfEscapeShellArg( $dstPath ) . ' 2>&1';
329329 $retval = 0;
330330 $returnText = wfShellExec( $cmd, $retval );
331 - }
 331+ }
332332
333333 if ( $this->removeBadFile( $dstPath, $retval ) || $retval ) {
334334 #No mapping, time zero. A last ditch attempt.
@@ -339,7 +339,7 @@
340340
341341 $retval = 0;
342342 $returnText = wfShellExec( $cmd, $retval );
343 - //if still bad return error:
 343+ // If still bad return error:
344344 if ( $this->removeBadFile( $dstPath, $retval ) || $retval ) {
345345 // Filter nonsense
346346 $lines = explode( "\n", str_replace( "\r\n", "\n", $returnText ) );
@@ -470,7 +470,7 @@
471471 $wgPlayerStatsCollection, $wgVideoTagOut;
472472
473473 if( $wgVideoTagOut ){
474 - // We could add "video" tag module stuff here if want. specifically:
 474+ // We could add "video" tag javascript here if want. specifically:
475475
476476 // <script type="text/javascript" src="js/mwEmbed/jsScriptLoader.php?class=window.jQuery,mwEmbed,$j.ui,mw.EmbedPlayer,nativeEmbed,ctrlBuilder,mvpcfConfig,kskinConfig,$j.fn.menu,$j.cookie,$j.ui.slider,mw.TimedText&debug=true"></script>
477477 //<link rel="stylesheet" href="js/mwEmbed/skins/styles.css" type="text/css" media="screen" />
@@ -479,6 +479,7 @@
480480 // The above is loaded on-dom-ready for faster dom readyness.
481481 // but that has the disadvantage of video player interfaces not being "instantly" ready
482482 // on page load. So its a trade off.
 483+
483484 // Loading dynamically also lets us avoid unnecessary code
484485 // ie firefox does not need "JSON.js" and IE ~maybe~ needs cortado embed etc.
485486 }else{
@@ -493,7 +494,7 @@
494495 'ogg-player-vlc-activex', 'ogg-player-quicktime-mozilla', 'ogg-player-quicktime-activex',
495496 'ogg-player-totem', 'ogg-player-kaffeine', 'ogg-player-kmplayer', 'ogg-player-mplayerplug-in',
496497 'ogg-player-thumbnail', 'ogg-player-selected', 'ogg-use-player', 'ogg-more', 'ogg-download',
497 - 'ogg-desc-link', 'ogg-dismiss', 'ogg-player-soundthumb', 'ogg-no-xiphqt' );
 498+ 'ogg-desc-link', 'ogg-dismiss', 'ogg-player-soundthumb', 'ogg-no-xiphqt' );
498499 $msgValues = array_map( 'wfMsg', $msgNames );
499500 $jsMsgs = Xml::encodeJsVar( (object)array_combine( $msgNames, $msgValues ) );
500501 $cortadoUrl = $wgCortadoJarFile;
@@ -524,23 +525,6 @@
525526 );
526527 }
527528
528 - // If collecting stats add relevant code:
529 - if( $wgPlayerStatsCollection ){
530 - //the player stats js file MUST be on the same server as OggHandler
531 - $playerStats_js = htmlspecialchars ( $wgScriptPath ). '/extensions/PlayerStatsGrabber/playerStats.js';
532 -
533 - $jsUserHash = sha1( $wgUser->getName() . $wgProxyKey );
534 - $enUserHash = Xml::encodeJsVar( $jsUserHash );
535 -
536 - $out->addHeadItem( 'playerStatsCollection', <<<EOT
537 -<script type="text/javascript">
538 -wgOggPlayer.userHash = $enUserHash;
539 -</script>
540 -<script type="text/javascript" src="$playerStats_js"></script>
541 -EOT
542 -);
543 - }
544 -
545529 }
546530
547531 function parserTransformHook( $parser, $file ) {
@@ -557,13 +541,13 @@
558542 $instance->setHeaders( $outputPage );
559543 }
560544 }
561 - //checks if we have an iframe requested (outputs a iframe version of the player for remote embedding)
 545+ // Output an iframe version of the player for remote embedding)
562546 static function iframeOutputHook( &$title, &$article, $doOutput = true ) {
563547 global $wgTitle, $wgRequest, $wgOut, $wgEnableIframeEmbed;
564548 if( !$wgEnableIframeEmbed )
565549 return true; //continue normal if iframes are "off" (maybe throw a warning in the future)
566550
567 - //make sure we are in the right namespace and iframe=true was called:
 551+ // Make sure we are in the right namespace and iframe=true was called:
568552 if( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE &&
569553 $wgRequest->getVal('iframe') == 'true' &&
570554 $wgEnableIframeEmbed &&
@@ -622,7 +606,7 @@
623607 $thumbDivAttribs = array();
624608 $showDescIcon = false;
625609
626 - // Check if outputting to video tag or oggHandler
 610+ // Check for video tag output
627611 if( $wgVideoTagOut ){
628612 return $this->outputVideoTag($url, $width, $height, $length, $offset, $alt);
629613 }else{
@@ -647,7 +631,7 @@
648632 'alt' => $alt,
649633 );
650634 } else {
651 - // make an icon later if necessary
 635+ // Make an icon later if necessary
652636 $imgAttribs = false;
653637 $showDescIcon = !$this->noIcon;
654638 //$thumbDivAttribs = array( 'style' => 'text-align: right;' );
@@ -759,26 +743,26 @@
760744 'startOffset' => $offset,
761745 'linkback' => $linkAttribs['href'],
762746 'apiTitleKey' => $this->file->getTitle()->getDBKey()
763 - );
 747+ );
764748
765 - /*
766 - * Output inline metadata for video tag
767 - * this will eventually be phased out in favor of "ROE" type xml
768 - * representation of all media asset info.
769 - */
 749+ /*
 750+ * Output inline metadata for video tag
 751+ * this will eventually be phased out in favor of "ROE" type xml
 752+ * representation of all media asset info.
 753+ */
770754
771755 // Init $timedTextSources string
772756 $timedTextSources = '';
773 - if( $this->file->getRepoName() != 'local' ){
 757+ if( $this->file->getRepoName() != 'local' ){
774758
775 - //Set the api provider name to "commons" for shared
776 - // ( provider names should have identified the provider
777 - // instead of the provider type "shared" )
778 - $apiProviderName = ( $this->file->getRepoName() == 'shared' ) ? 'commons': $this->file->getRepoName();
 759+ //Set the api provider name to "commons" for shared
 760+ // ( provider names should have identified the provider
 761+ // instead of the provider type "shared" )
 762+ $apiProviderName = ( $this->file->getRepoName() == 'shared' ) ? 'commons': $this->file->getRepoName();
779763
780764 $videoAttr[ 'apiProvider' ] = 'commons';
781 - } else if( $wgEnableTimedText ){
782 - // Get the list of subtitles available
 765+ } else if( $wgEnableTimedText ){
 766+ // Get the list of subtitles available
783767 $params = new FauxRequest( array (
784768 'action' => 'query',
785769 'list' => 'allpages',
@@ -802,7 +786,7 @@
803787 $subtitle_extension = array_pop( $tileParts );
804788 $languageKey = array_pop( $tileParts );
805789 }
806 - //If there is no valid language continue:
 790+ // If there is no valid language continue:
807791 if( !isset( $langNames[ $languageKey ] ) ){
808792 continue;
809793 }
@@ -815,16 +799,16 @@
816800 $timedTextSources.= Xml::tags( 'itext', $textAttr, '' );
817801 }
818802 }
819 - }
 803+ }
820804
821 - if( $wgEnableTemporalOggUrls ){
822 - $videoAttr['URLTimeEncoding'] = 'true';
823 - }
 805+ if( $wgEnableTemporalOggUrls ){
 806+ $videoAttr['URLTimeEncoding'] = 'true';
 807+ }
824808
825 - // Set player skin:
826 - if( $wgVideoPlayerSkin ){
827 - $videoAttr['class'] = htmlspecialchars ( $wgVideoPlayerSkin );
828 - }
 809+ // Set player skin:
 810+ if( $wgVideoPlayerSkin ){
 811+ $videoAttr['class'] = htmlspecialchars ( $wgVideoPlayerSkin );
 812+ }
829813
830814 $s = Xml::tags( 'video', $videoAttr,
831815 Xml::tags('div', array(
@@ -853,12 +837,12 @@
854838 parent::__construct( $file, $videoUrl, false, $width, $height, $length, false, $path, $noIcon, $offset );
855839 }
856840 }
857 -/*utility functions*/
 841+/* Utility functions*/
858842
859843
860844 /*
861 - * outputs a minimal iframe for remote embedding (with mv_embed loaded via the script-loader if enabled)
862 - */
 845+* Output a minimal iframe for remote embedding (with mv_embed loaded via the script-loader if enabled)
 846+*/
863847 function output_iframe_page( $title ) {
864848 global $wgEnableIframeEmbed, $wgEnableTemporalOggUrls, $wgOut, $wgUser,
865849 $wgEnableScriptLoader;
@@ -868,8 +852,7 @@
869853 return false;
870854 }
871855
872 - //safe grab the input vars is set:
873 - //check for start end if temporal urls are enabled:
 856+ // Check for start end if temporal urls are enabled:
874857 if( $wgEnableTemporalOggUrls ){
875858 $videoParam[ 'start' ] = ( isset( $_GET['starttime'] ) ) ? $_GET['starttime']: '';
876859 $videoParam[ 'end' ] = ( isset( $_GET['endtime'] ) ) ? $_GET['endtime']: '';
@@ -878,7 +861,7 @@
879862 $videoParam['width'] = ( isset( $_GET['width'] ) ) ? intval( $_GET['width'] ) : '400';
880863 $videoParam['height'] = ( isset( $_GET['height'] ) ) ? intval( $_GET['height'] ) : '300';
881864
882 - //build the html output:
 865+ // Build the html output:
883866 $file = wfFindFile( $title );
884867 $thumb = $file->transform( $videoParam );
885868 $out = new OutputPage();
@@ -900,7 +883,7 @@
901884 }
902885 </style>
903886 <?php
904 - //similar to $out->headElement (but without css)
 887+ // Similar to $out->headElement (but without css)
905888 echo $out->getHeadScripts();
906889 echo $out->getHeadLinks();
907890 echo $out->getHeadItems();
@@ -913,14 +896,15 @@
914897 <?php
915898 }
916899 /*
917 - * takes seconds duration and return hh:mm:ss time
918 - */
 900+* Converts seconds duration to npt format:
 901+* hh:mm:ss.ms
 902+*/
919903 if(!function_exists('seconds2npt')){
920904 function seconds2npt( $seconds, $short = false ) {
921905 $dur = time_duration_2array( $seconds );
922906 if( ! $dur )
923907 return null;
924 - // be sure to output leading zeros (for min,sec):
 908+ // Output leading zeros (for min,sec):
925909 if ( $dur['hours'] == 0 && $short == true ) {
926910 return sprintf( "%2d:%02d", $dur['minutes'], $dur['seconds'] );
927911 } else {
@@ -929,7 +913,7 @@
930914 }
931915 }
932916 /*
933 - * converts seconds to time unit array
 917+ * Convert seconds to time unit array
934918 */
935919 if(!function_exists('time_duration_2array')){
936920 function time_duration_2array ( $seconds, $periods = null ) {
@@ -951,7 +935,7 @@
952936 foreach ( $periods as $period => $value ) {
953937 $count = floor( $seconds / $value );
954938 if ( $count == 0 ) {
955 - // must include hours minutes and seconds even if they are 0
 939+ // Must include hours minutes and seconds even if they are 0
956940 if ( $period == 'hours' || $period == 'minutes' || $period == 'seconds' ) {
957941 $values[$period] = 0;
958942 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r61056* added player skin variable...dale18:47, 14 January 2010

Status & tagging log