Index: trunk/extensions/OggHandler/OggHandler.php |
— | — | @@ -53,10 +53,13 @@ |
54 | 54 | //if wgPlayerStats collection is enabled or not |
55 | 55 | $wgPlayerStatsCollection=false; |
56 | 56 | |
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 |
59 | 58 | $wgVideoTagOut = false; |
60 | 59 | |
| 60 | +// Defautl skin for mwEmbed player |
| 61 | +// Skins presently available: |
| 62 | +// "kskin" kaltura skin |
| 63 | +// "mvpcf" a jquery ui like skin |
61 | 64 | $wgVideoPlayerSkin = 'kskin'; |
62 | 65 | |
63 | 66 | // Support striped player iframe output for remote embedding |
Index: trunk/extensions/OggHandler/OggHandler_body.php |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | |
79 | 79 | function normaliseParams( $image, &$params ) { |
80 | 80 | $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 |
82 | 82 | foreach($timeParam as $pn){ |
83 | 83 | if ( isset( $params[$pn] ) ) { |
84 | 84 | $length = $this->getLength( $image ); |
— | — | @@ -91,7 +91,7 @@ |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | | - //make sure start time is not > than end time |
| 95 | + // Make sure start time is not > than end time |
96 | 96 | if(isset($params['start']) && isset($params['end']) ){ |
97 | 97 | if($params['start'] > $params['end']) |
98 | 98 | return false; |
— | — | @@ -147,7 +147,7 @@ |
148 | 148 | } |
149 | 149 | $metadata['streams'] = $streams; |
150 | 150 | $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) |
152 | 152 | $metadata['offset'] = $f->getStartOffset(); |
153 | 153 | } catch ( PEAR_Exception $e ) { |
154 | 154 | // File not found, invalid stream, etc. |
— | — | @@ -192,19 +192,19 @@ |
193 | 193 | $noPlayer = isset( $params['noplayer'] ); |
194 | 194 | $noIcon = isset( $params['noicon'] ); |
195 | 195 | |
196 | | - //set up the default targetUrl: |
| 196 | + // Set up the default targetUrl: |
197 | 197 | $targetFileUrl = $file->getURL(); |
198 | 198 | |
199 | 199 | |
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'] ) ){ |
202 | 202 | $targetFileUrl .= '?t=' . seconds2npt( $this->parseTimeString( $params['start'], $length ) ); |
203 | 203 | if(isset( $params[ 'end' ] ) && $params['end'] ) |
204 | 204 | $targetFileUrl.='/'. seconds2npt( $this->parseTimeString( $params['end'], $length) ); |
205 | 205 | } |
206 | 206 | |
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) |
209 | 209 | if (isset( $wgEnabledDerivatives ) && is_array( $wgEnabledDerivatives ) && count( $wgEnabledDerivatives ) != 0){ |
210 | 210 | //get the encode key: |
211 | 211 | $encodeKey = WikiAtHome::getTargetDerivative( $width, $file ); |
— | — | @@ -217,11 +217,11 @@ |
218 | 218 | $derivativeUrl = $file->getThumbUrl( $wjm->getEncodeKey() . '.ogg'); |
219 | 219 | $derivativePath = $file->getThumbPath( $wjm->getEncodeKey() ); |
220 | 220 | |
221 | | - //check that we have the requested theora derivative |
| 221 | + // Check that we have the requested theora derivative |
222 | 222 | if( is_file ( "{$derivativePath}.ogg" )){ |
223 | 223 | $targetFileUrl = $derivativeUrl; |
224 | 224 | }else{ |
225 | | - //output in queue text (send the dstUrl if available ) |
| 225 | + // Output in queue text (send the dstUrl if available ) |
226 | 226 | return new MediaQueueTransformOutput($file, $dstUrl, $width, $height, $wjm->getDonePerc() ); |
227 | 227 | } |
228 | 228 | } |
— | — | @@ -281,7 +281,7 @@ |
282 | 282 | $thumbtime = $this->parseTimeString( $params['thumbtime'], $length ); |
283 | 283 | } |
284 | 284 | 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: |
286 | 286 | if( isset( $params['start'] ) ){ |
287 | 287 | $thumbtime = $this->parseTimeString( $params['start'], $length ); |
288 | 288 | }else{ |
— | — | @@ -293,7 +293,7 @@ |
294 | 294 | |
295 | 295 | wfDebug( "Creating video thumbnail at $dstPath\n" ); |
296 | 296 | |
297 | | - //first check for oggThumb |
| 297 | + // First check for oggThumb |
298 | 298 | if( $wgOggThumbLocation && is_file( $wgOggThumbLocation ) ){ |
299 | 299 | $cmd = wfEscapeShellArg( $wgOggThumbLocation ) . |
300 | 300 | ' -t '. intval( $thumbtime ) . ' ' . |
— | — | @@ -327,7 +327,7 @@ |
328 | 328 | wfEscapeShellArg( $dstPath ) . ' 2>&1'; |
329 | 329 | $retval = 0; |
330 | 330 | $returnText = wfShellExec( $cmd, $retval ); |
331 | | - } |
| 331 | + } |
332 | 332 | |
333 | 333 | if ( $this->removeBadFile( $dstPath, $retval ) || $retval ) { |
334 | 334 | #No mapping, time zero. A last ditch attempt. |
— | — | @@ -339,7 +339,7 @@ |
340 | 340 | |
341 | 341 | $retval = 0; |
342 | 342 | $returnText = wfShellExec( $cmd, $retval ); |
343 | | - //if still bad return error: |
| 343 | + // If still bad return error: |
344 | 344 | if ( $this->removeBadFile( $dstPath, $retval ) || $retval ) { |
345 | 345 | // Filter nonsense |
346 | 346 | $lines = explode( "\n", str_replace( "\r\n", "\n", $returnText ) ); |
— | — | @@ -470,7 +470,7 @@ |
471 | 471 | $wgPlayerStatsCollection, $wgVideoTagOut; |
472 | 472 | |
473 | 473 | 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: |
475 | 475 | |
476 | 476 | // <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> |
477 | 477 | //<link rel="stylesheet" href="js/mwEmbed/skins/styles.css" type="text/css" media="screen" /> |
— | — | @@ -479,6 +479,7 @@ |
480 | 480 | // The above is loaded on-dom-ready for faster dom readyness. |
481 | 481 | // but that has the disadvantage of video player interfaces not being "instantly" ready |
482 | 482 | // on page load. So its a trade off. |
| 483 | + |
483 | 484 | // Loading dynamically also lets us avoid unnecessary code |
484 | 485 | // ie firefox does not need "JSON.js" and IE ~maybe~ needs cortado embed etc. |
485 | 486 | }else{ |
— | — | @@ -493,7 +494,7 @@ |
494 | 495 | 'ogg-player-vlc-activex', 'ogg-player-quicktime-mozilla', 'ogg-player-quicktime-activex', |
495 | 496 | 'ogg-player-totem', 'ogg-player-kaffeine', 'ogg-player-kmplayer', 'ogg-player-mplayerplug-in', |
496 | 497 | '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' ); |
498 | 499 | $msgValues = array_map( 'wfMsg', $msgNames ); |
499 | 500 | $jsMsgs = Xml::encodeJsVar( (object)array_combine( $msgNames, $msgValues ) ); |
500 | 501 | $cortadoUrl = $wgCortadoJarFile; |
— | — | @@ -524,23 +525,6 @@ |
525 | 526 | ); |
526 | 527 | } |
527 | 528 | |
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 | | - |
545 | 529 | } |
546 | 530 | |
547 | 531 | function parserTransformHook( $parser, $file ) { |
— | — | @@ -557,13 +541,13 @@ |
558 | 542 | $instance->setHeaders( $outputPage ); |
559 | 543 | } |
560 | 544 | } |
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) |
562 | 546 | static function iframeOutputHook( &$title, &$article, $doOutput = true ) { |
563 | 547 | global $wgTitle, $wgRequest, $wgOut, $wgEnableIframeEmbed; |
564 | 548 | if( !$wgEnableIframeEmbed ) |
565 | 549 | return true; //continue normal if iframes are "off" (maybe throw a warning in the future) |
566 | 550 | |
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: |
568 | 552 | if( is_object( $wgTitle ) && $wgTitle->getNamespace() == NS_FILE && |
569 | 553 | $wgRequest->getVal('iframe') == 'true' && |
570 | 554 | $wgEnableIframeEmbed && |
— | — | @@ -622,7 +606,7 @@ |
623 | 607 | $thumbDivAttribs = array(); |
624 | 608 | $showDescIcon = false; |
625 | 609 | |
626 | | - // Check if outputting to video tag or oggHandler |
| 610 | + // Check for video tag output |
627 | 611 | if( $wgVideoTagOut ){ |
628 | 612 | return $this->outputVideoTag($url, $width, $height, $length, $offset, $alt); |
629 | 613 | }else{ |
— | — | @@ -647,7 +631,7 @@ |
648 | 632 | 'alt' => $alt, |
649 | 633 | ); |
650 | 634 | } else { |
651 | | - // make an icon later if necessary |
| 635 | + // Make an icon later if necessary |
652 | 636 | $imgAttribs = false; |
653 | 637 | $showDescIcon = !$this->noIcon; |
654 | 638 | //$thumbDivAttribs = array( 'style' => 'text-align: right;' ); |
— | — | @@ -759,26 +743,26 @@ |
760 | 744 | 'startOffset' => $offset, |
761 | 745 | 'linkback' => $linkAttribs['href'], |
762 | 746 | 'apiTitleKey' => $this->file->getTitle()->getDBKey() |
763 | | - ); |
| 747 | + ); |
764 | 748 | |
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 | + */ |
770 | 754 | |
771 | 755 | // Init $timedTextSources string |
772 | 756 | $timedTextSources = ''; |
773 | | - if( $this->file->getRepoName() != 'local' ){ |
| 757 | + if( $this->file->getRepoName() != 'local' ){ |
774 | 758 | |
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(); |
779 | 763 | |
780 | 764 | $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 |
783 | 767 | $params = new FauxRequest( array ( |
784 | 768 | 'action' => 'query', |
785 | 769 | 'list' => 'allpages', |
— | — | @@ -802,7 +786,7 @@ |
803 | 787 | $subtitle_extension = array_pop( $tileParts ); |
804 | 788 | $languageKey = array_pop( $tileParts ); |
805 | 789 | } |
806 | | - //If there is no valid language continue: |
| 790 | + // If there is no valid language continue: |
807 | 791 | if( !isset( $langNames[ $languageKey ] ) ){ |
808 | 792 | continue; |
809 | 793 | } |
— | — | @@ -815,16 +799,16 @@ |
816 | 800 | $timedTextSources.= Xml::tags( 'itext', $textAttr, '' ); |
817 | 801 | } |
818 | 802 | } |
819 | | - } |
| 803 | + } |
820 | 804 | |
821 | | - if( $wgEnableTemporalOggUrls ){ |
822 | | - $videoAttr['URLTimeEncoding'] = 'true'; |
823 | | - } |
| 805 | + if( $wgEnableTemporalOggUrls ){ |
| 806 | + $videoAttr['URLTimeEncoding'] = 'true'; |
| 807 | + } |
824 | 808 | |
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 | + } |
829 | 813 | |
830 | 814 | $s = Xml::tags( 'video', $videoAttr, |
831 | 815 | Xml::tags('div', array( |
— | — | @@ -853,12 +837,12 @@ |
854 | 838 | parent::__construct( $file, $videoUrl, false, $width, $height, $length, false, $path, $noIcon, $offset ); |
855 | 839 | } |
856 | 840 | } |
857 | | -/*utility functions*/ |
| 841 | +/* Utility functions*/ |
858 | 842 | |
859 | 843 | |
860 | 844 | /* |
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 | +*/ |
863 | 847 | function output_iframe_page( $title ) { |
864 | 848 | global $wgEnableIframeEmbed, $wgEnableTemporalOggUrls, $wgOut, $wgUser, |
865 | 849 | $wgEnableScriptLoader; |
— | — | @@ -868,8 +852,7 @@ |
869 | 853 | return false; |
870 | 854 | } |
871 | 855 | |
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: |
874 | 857 | if( $wgEnableTemporalOggUrls ){ |
875 | 858 | $videoParam[ 'start' ] = ( isset( $_GET['starttime'] ) ) ? $_GET['starttime']: ''; |
876 | 859 | $videoParam[ 'end' ] = ( isset( $_GET['endtime'] ) ) ? $_GET['endtime']: ''; |
— | — | @@ -878,7 +861,7 @@ |
879 | 862 | $videoParam['width'] = ( isset( $_GET['width'] ) ) ? intval( $_GET['width'] ) : '400'; |
880 | 863 | $videoParam['height'] = ( isset( $_GET['height'] ) ) ? intval( $_GET['height'] ) : '300'; |
881 | 864 | |
882 | | - //build the html output: |
| 865 | + // Build the html output: |
883 | 866 | $file = wfFindFile( $title ); |
884 | 867 | $thumb = $file->transform( $videoParam ); |
885 | 868 | $out = new OutputPage(); |
— | — | @@ -900,7 +883,7 @@ |
901 | 884 | } |
902 | 885 | </style> |
903 | 886 | <?php |
904 | | - //similar to $out->headElement (but without css) |
| 887 | + // Similar to $out->headElement (but without css) |
905 | 888 | echo $out->getHeadScripts(); |
906 | 889 | echo $out->getHeadLinks(); |
907 | 890 | echo $out->getHeadItems(); |
— | — | @@ -913,14 +896,15 @@ |
914 | 897 | <?php |
915 | 898 | } |
916 | 899 | /* |
917 | | - * takes seconds duration and return hh:mm:ss time |
918 | | - */ |
| 900 | +* Converts seconds duration to npt format: |
| 901 | +* hh:mm:ss.ms |
| 902 | +*/ |
919 | 903 | if(!function_exists('seconds2npt')){ |
920 | 904 | function seconds2npt( $seconds, $short = false ) { |
921 | 905 | $dur = time_duration_2array( $seconds ); |
922 | 906 | if( ! $dur ) |
923 | 907 | return null; |
924 | | - // be sure to output leading zeros (for min,sec): |
| 908 | + // Output leading zeros (for min,sec): |
925 | 909 | if ( $dur['hours'] == 0 && $short == true ) { |
926 | 910 | return sprintf( "%2d:%02d", $dur['minutes'], $dur['seconds'] ); |
927 | 911 | } else { |
— | — | @@ -929,7 +913,7 @@ |
930 | 914 | } |
931 | 915 | } |
932 | 916 | /* |
933 | | - * converts seconds to time unit array |
| 917 | + * Convert seconds to time unit array |
934 | 918 | */ |
935 | 919 | if(!function_exists('time_duration_2array')){ |
936 | 920 | function time_duration_2array ( $seconds, $periods = null ) { |
— | — | @@ -951,7 +935,7 @@ |
952 | 936 | foreach ( $periods as $period => $value ) { |
953 | 937 | $count = floor( $seconds / $value ); |
954 | 938 | 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 |
956 | 940 | if ( $period == 'hours' || $period == 'minutes' || $period == 'seconds' ) { |
957 | 941 | $values[$period] = 0; |
958 | 942 | } |