Index: trunk/extensions/TimedMediaHandler/handlers/TextHandler/TextHandler.php |
— | — | @@ -83,6 +83,7 @@ |
84 | 84 | } |
85 | 85 | wfDebug("Get text tracks from remote api \n"); |
86 | 86 | $query = $this->getTextPagesQuery(); |
| 87 | + |
87 | 88 | // Error in getting timed text namespace return empty array; |
88 | 89 | if( $query === false ){ |
89 | 90 | return array(); |
— | — | @@ -100,7 +101,7 @@ |
101 | 102 | $params = new FauxRequest( $this->getTextPagesQuery() ); |
102 | 103 | $api = new ApiMain( $params ); |
103 | 104 | $api->execute(); |
104 | | - $data = $api->getResultData(); |
| 105 | + $data = $api->getResultData(); |
105 | 106 | // Get the list of language Names |
106 | 107 | return $this->getTextTracksFromData( $data ); |
107 | 108 | } |
— | — | @@ -128,7 +129,6 @@ |
129 | 130 | $interWikiPrefix = ( $providerName == 'local' )? '' : $providerName . ':'; |
130 | 131 | |
131 | 132 | $langNames = Language::getLanguageNames(); |
132 | | - |
133 | 133 | if( $data['query'] && $data['query']['allpages'] ){ |
134 | 134 | foreach( $data['query']['allpages'] as $na => $page ){ |
135 | 135 | $subTitle = Title::newFromText( $interWikiPrefix . $page['title'] ) ; |
Index: trunk/extensions/TimedMediaHandler/MwEmbedModules/TimedText/resources/mw.TimedText.js |
— | — | @@ -398,11 +398,13 @@ |
399 | 399 | */ |
400 | 400 | loadTextSources: function( callback ) { |
401 | 401 | var _this = this; |
402 | | - this.textSources = [ ]; |
403 | | - |
404 | | - // Try to get sources from text provider: |
405 | | - var provider_id = ( this.embedPlayer.apiProvider ) ? this.embedPlayer.apiProvider : 'local'; |
406 | | - var apiUrl = mw.getApiProviderURL( provider_id ); |
| 402 | + this.textSources = []; |
| 403 | + |
| 404 | + // Setup the provider id ( set to local if not found ) |
| 405 | + var providerId = $( this.embedPlayer ).attr('data-mwprovider') ? |
| 406 | + $( this.embedPlayer ).attr('data-mwprovider') : |
| 407 | + 'local'; |
| 408 | + var apiUrl = mw.getApiProviderURL( providerId ); |
407 | 409 | var apiTitleKey = this.embedPlayer.apiTitleKey; |
408 | 410 | if( !apiUrl || !apiTitleKey ) { |
409 | 411 | mw.log("Error: loading source without apiProvider or apiTitleKey"); |
— | — | @@ -411,15 +413,21 @@ |
412 | 414 | |
413 | 415 | //For now only support mediaWikTrack provider library |
414 | 416 | this.textProvider = new mw.MediaWikTrackProvider( { |
415 | | - 'provider_id' : provider_id, |
| 417 | + 'providerId' : providerId, |
416 | 418 | 'apiUrl': apiUrl, |
417 | 419 | 'embedPlayer': this.embedPlayer |
418 | 420 | } ); |
| 421 | + |
419 | 422 | // Get local reference to all timed text sources: ( text/xml, text/x-srt etc ) |
420 | 423 | var inlineSources = this.embedPlayer.mediaElement.getSources( 'text' ); |
421 | 424 | |
422 | 425 | // Add all the sources to textSources |
423 | 426 | for( var i = 0 ; i < inlineSources.length ; i++ ) { |
| 427 | + // Check if the inline source has a text provider: |
| 428 | + var textSourceProvider = $( this.embedPlayer ).attr('data-mwprovider') ? |
| 429 | + $( this.embedPlayer ).attr('data-mwprovider') : |
| 430 | + this.textProvider; |
| 431 | + |
424 | 432 | // Make a new textSource: |
425 | 433 | var source = new TextSource( inlineSources[i] , this.textProvider); |
426 | 434 | this.textSources.push( source); |
— | — | @@ -672,6 +680,7 @@ |
673 | 681 | }, |
674 | 682 | |
675 | 683 | // Simple interface to add a transcription request |
| 684 | + // TODO this should probably be moved to a gadget |
676 | 685 | getAddSubRequest: function(){ |
677 | 686 | var _this = this; |
678 | 687 | var buttons = {}; |
— | — | @@ -1490,8 +1499,8 @@ |
1491 | 1500 | */ |
1492 | 1501 | var default_textProvider_attr = [ |
1493 | 1502 | 'apiUrl', |
1494 | | - 'provider_id', |
1495 | | - 'timed_text_NS', |
| 1503 | + 'providerId', |
| 1504 | + 'timedTextNS', |
1496 | 1505 | 'embedPlayer' |
1497 | 1506 | ]; |
1498 | 1507 | |
— | — | @@ -1504,7 +1513,7 @@ |
1505 | 1514 | apiUrl: null, |
1506 | 1515 | |
1507 | 1516 | // The timed text namespace |
1508 | | - timed_text_NS: null, |
| 1517 | + timedTextNS: null, |
1509 | 1518 | |
1510 | 1519 | /** |
1511 | 1520 | * @constructor |
— | — | @@ -1526,9 +1535,13 @@ |
1527 | 1536 | loadTitleKey: function( titleKey, callback ) { |
1528 | 1537 | var request = { |
1529 | 1538 | 'action': 'parse', |
1530 | | - 'page': titleKey, |
| 1539 | + 'page': titleKey |
| 1540 | + /** |
| 1541 | + * For now we don't use cache helpers since the request is |
| 1542 | + * going over jsonp we kill any outer cache anyway |
1531 | 1543 | 'smaxage' : 300, |
1532 | 1544 | 'maxage' : 300 |
| 1545 | + */ |
1533 | 1546 | }; |
1534 | 1547 | mw.getJSON( this.apiUrl, request, function( data ) { |
1535 | 1548 | if ( data && data.parse && data.parse.text['*'] ) { |
— | — | @@ -1574,9 +1587,13 @@ |
1575 | 1588 | 'apprefix' : unescape( titleKey ), |
1576 | 1589 | 'apnamespace' : this.getTimedTextNS(), |
1577 | 1590 | 'aplimit' : 200, |
1578 | | - 'prop':'revisions', |
| 1591 | + 'prop':'revisions' |
| 1592 | + /** |
| 1593 | + * For now we don't use cache helpers since the request is |
| 1594 | + * going over jsonp we kill any outer cache anyway |
1579 | 1595 | 'smaxage' : 300, |
1580 | 1596 | 'maxage' : 300 |
| 1597 | + */ |
1581 | 1598 | }; |
1582 | 1599 | mw.getJSON( this.apiUrl, request, function( sourcePages ) { |
1583 | 1600 | // If "timedText" is not a valid namespace try "just" with prefix: |
— | — | @@ -1635,15 +1652,15 @@ |
1636 | 1653 | * Return the namespace ( if not encoded on the page return default 102 ) |
1637 | 1654 | */ |
1638 | 1655 | getTimedTextNS: function() { |
1639 | | - if( this.timed_text_NS ) |
1640 | | - return this.timed_text_NS; |
| 1656 | + if( this.timedTextNS ) |
| 1657 | + return this.timedTextNS; |
1641 | 1658 | if ( typeof wgNamespaceIds != 'undefined' && wgNamespaceIds['timedtext'] ) { |
1642 | | - this.timed_text_NS = wgNamespaceIds['timedtext']; |
| 1659 | + this.timedTextNS = wgNamespaceIds['timedtext']; |
1643 | 1660 | }else{ |
1644 | 1661 | //default value is 102 ( probably should store this elsewhere ) |
1645 | | - this.timed_text_NS = 102; |
| 1662 | + this.timedTextNS = 102; |
1646 | 1663 | } |
1647 | | - return this.timed_text_NS; |
| 1664 | + return this.timedTextNS; |
1648 | 1665 | }, |
1649 | 1666 | |
1650 | 1667 | /** |