diff --git a/LocalSettings.php b/LocalSettings.php new file mode 100644 index 0000000000..81589c36a8 --- /dev/null +++ b/LocalSettings.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/ResourceLoader.php b/ResourceLoader.php index 371a7439ff..8ec78d6d5f 100644 --- a/ResourceLoader.php +++ b/ResourceLoader.php @@ -5,8 +5,6 @@ */ //Setup the script local script cache directory -// ( has to be hard coded rather than config based for fast non-mediawiki config hits ) -$wgScriptCacheDirectory = realpath( dirname( __FILE__ ) ) . '/includes/cache'; // Check if being used in mediaWiki ( ResourceLoader.php is NOT an entry point ) if( is_file ( dirname( __FILE__ ) .'../mwResourceLoader.php' ) @@ -16,10 +14,8 @@ // Check if we are an entry point or being used as part of MEDIAWIKI: if ( !defined( 'MEDIAWIKI' ) && !defined( 'SCRIPTLOADER_MEDIAWIKI') ) { - // Allow an installation an optional PHP customization/overrides file - if ( is_file ( dirname( __FILE__ ) .'/../localSettings.php' ) ) { - require_once dirname( __FILE__ ) .'/../localSettings.php'; - } + // Include settings ( will include LocalSettings.php in the root mwEmbed folder + require_once( dirname( __FILE__ ) . '/includes/DefaultSettings.php' ); // Load stand alone Resource Loader config // ( if running as a remote, mediaWiki variables / functions are already included as part of mediaWiki ) @@ -1215,8 +1211,9 @@ public function getCacheFileName() { $this->filename = "{$wgScriptCacheDirectory}/{$hash1}/{$hash2}/{$hash}.js"; // Check for defined files:: - if( is_file( $this->filename ) ) - return $this->filename; + if( is_file( $this->filename ) ){ + return $this->filename; + } // Check for non-config based gzip version already there? if( is_file( $this->filename . '.gz') ){ diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php new file mode 100644 index 0000000000..a6ba9ef2ef --- /dev/null +++ b/includes/DefaultSettings.php @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/modules/EmbedPlayer/mw.EmbedPlayer.js b/modules/EmbedPlayer/mw.EmbedPlayer.js index 695a06d3bd..344e5ca3cc 100644 --- a/modules/EmbedPlayer/mw.EmbedPlayer.js +++ b/modules/EmbedPlayer/mw.EmbedPlayer.js @@ -2068,8 +2068,7 @@ mw.EmbedPlayer.prototype = { this.controls = true; } if( !this.useNativePlayerControls() && !this.isPersistentNativePlayer() && !_this.controlBuilder.checkOverlayControls() ){ - // give the interface more space for the controls: - //this.$interface.css('height', this.height + _this.controlBuilder.height ) + // Update the video size per available control space. $j(this).css('height', this.height - _this.controlBuilder.height ); } diff --git a/modules/KalturaSupport/kalturaIframe.php b/modules/KalturaSupport/kalturaIframe.php index b6fbc2d9bb..2b44ba4ab9 100644 --- a/modules/KalturaSupport/kalturaIframe.php +++ b/modules/KalturaSupport/kalturaIframe.php @@ -4,15 +4,7 @@ * */ -// Some predefined constants ( need to load these from config.. -// and or allow configuration payload to be passed in via iframe message. -define( 'KALTURA_SERVICE_URL', 'http://www.kaltura.com/' ); -define( 'KALTURA_CDN_URL', 'http://cdn.kaltura.com' ); -define( 'KALTURA_SERVICE_BASE', '/api_v3/index.php?'); -define( 'KALTURA_MWEMBED_PATH', str_replace( 'mwEmbedFrame.php', '', $_SERVER['SCRIPT_NAME'] ) ); -define( 'KALTURA_UICONF_CACHE_TIME', 600 ); - -define( 'KALTURA_GENERIC_SERVER_ERROR', "Error getting sources from server, something maybe broken or server is under high loa.d Please try again."); +define( 'KALTURA_GENERIC_SERVER_ERROR', "Error getting sources from server, something maybe broken or server is under high load. Please try again."); // Setup the kalturaIframe $mykalturaIframe = new kalturaIframe(); @@ -87,13 +79,13 @@ private function parseRequest(){ // Check for required config if( $this->playerAttributes['wid'] == null ){ - $this->error = 'Can not display player, missing widget id'; + $this->outputIframeError( 'Can not display player, missing widget id' ); } } // Load the kaltura library and grab the most compatible flavor private function getFlavorSources(){ - + global $wgKalturaCDNUrl; // Check the access control before returning any source urls if( !$this->isAccessControlAllowed() ) { return array(); @@ -107,7 +99,7 @@ private function getFlavorSources(){ if( isset( $resultObject['flavors']['code'] ) ){ switch( $resultObject['flavors']['code'] ){ case 'ENTRY_ID_NOT_FOUND': - $this->error = "

Entry Id not found

" . htmlspecialchars( $resultObject['flavors']['message'] ); + $this->fatalIframeError( "Entry Id not found", htmlspecialchars( $resultObject['flavors']['message'] ) ); break; } // @@TODO should probably refactor to use throw catch error system. @@ -116,7 +108,7 @@ private function getFlavorSources(){ foreach( $resultObject['flavors'] as $KalturaFlavorAsset ){ - $assetUrl = KALTURA_CDN_URL .'/p/' . $this->getPartnerId() . '/sp/' . + $assetUrl = $wgKalturaCDNUrl .'/p/' . $this->getPartnerId() . '/sp/' . $this->getPartnerId() . '00/flvclipper/entry_id/' . $this->playerAttributes['entry_id'] . '/flavor/' . $KalturaFlavorAsset->id; if( strpos( $KalturaFlavorAsset->tags, 'iphone' ) !== false ){ @@ -164,13 +156,14 @@ private function getCacheDir(){ } private function getResultObject(){ + global $wgKalturaUiConfCacheTime; // Check if we have a cached result object: if( $this->resultObj ){ return $this->resultObj; } $cacheFile = $this->getCacheDir() . '/' . $this->getResultObjectCacheKey() . ".entry.txt"; - $cacheLife = KALTURA_UICONF_CACHE_TIME; + $cacheLife = $wgKalturaUiConfCacheTime; // Check modify time on cached php file $filemtime = @filemtime($cacheFile); // returns FALSE if file does not exist @@ -233,7 +226,7 @@ function getResultObjectFromApi(){ $rawResultObject = $client->doQueue(); $client->throwExceptionIfError($this->resultObj); } catch( Exception $e ){ - $this->error = KALTURA_GENERIC_SERVER_ERROR . "\n" . $e->getMessage(); + $this->fatalIframeError( KALTURA_GENERIC_SERVER_ERROR . "\n" . $e->getMessage() ); return array(); } @@ -256,12 +249,12 @@ function getReferer(){ return ( isset( $_SERVER['HTTP_REFERER'] ) ) ? $_SERVER['HTTP_REFERER'] : 'http://www.kaltura.org/'; } function getClient(){ - global $mwEmbedRoot; + global $mwEmbedRoot, $wgKalturaUiConfCacheTime; $cacheDir = $mwEmbedRoot . '/includes/cache'; $cacheFile = $this->getCacheDir() . '/' . $this->getPartnerId() . ".ks.txt"; - $cacheLife = KALTURA_UICONF_CACHE_TIME; + $cacheLife = $wgKalturaUiConfCacheTime; $conf = new KalturaConfiguration( $this->getPartnerId() ); $client = new KalturaClient( $conf ); @@ -274,8 +267,7 @@ function getClient(){ $this->ks = $session->ks; file_put_contents( $cacheFile, $this->ks ); } catch ( Exception $e ){ - $this->error = $this->error = KALTURA_GENERIC_SERVER_ERROR . "\n" . $e->getMessage(); - return false; + $this->fatalIframeError( KALTURA_GENERIC_SERVER_ERROR . "\n" . $e->getMessage() ); } } else { $this->ks = file_get_contents( $cacheFile ); @@ -311,39 +303,36 @@ function getPlayerData() { function isAccessControlAllowed() { $resultObject = $this->getResultObject(); $accessControl = $resultObject['accessControl']; + // Checks if admin - if($accessControl->isAdmin) { + if( $accessControl->isAdmin ) { return true; } /* Domain Name Restricted */ if($accessControl->isSiteRestricted) { - $this->error = "

Un authorized domain

We're sorry, this content is only available on certain domains."; - return false; + $this->fatalIframeError( "Un authorized domain", "We're sorry, this content is only available on certain domains." ); } /* Country Restricted */ if($accessControl->isCountryRestricted) { - $this->error = "

Un authorized country

We're sorry, this content is only available on certain countries."; - return false; + $this->fatalIframeError( "Un authorized country", "We're sorry, this content is only available on certain countries."); } /* Session Restricted */ if($accessControl->isSessionRestricted) { - $this->error = "

No KS where KS is required

We're sorry, access to this content is restricted."; - return false; + $this->fatalIframeError( "No KS where KS is required", "We're sorry, access to this content is restricted."); } if($accessControl->isScheduledNow == null) { - $this->error = "

Out of scheduling

We're sorry, this content is currently unavailable."; - return false; + $this->fatalIframeError( "Out of scheduling", "We're sorry, this content is currently unavailable."); } return true; } function getPlayEventUrl() { - + global $wgKalturaServiceUrl, $wgKalturaServiceBase; $param = array( 'service' => 'stats', 'action' => 'collect', @@ -381,7 +370,7 @@ function getPlayEventUrl() { $param['kalsig'] = md5( $sigString ); $requestString = http_build_query( $param ); - return KALTURA_SERVICE_URL . KALTURA_SERVICE_BASE . $requestString; + return $wgKalturaServiceUrl . $wgKalturaServiceBase . $requestString; } // Returns a simple image with a direct link to the asset @@ -400,8 +389,7 @@ private function getFileLinkHTML(){ $flavorUrl = $sources['ogg']['src']; } else { // Throw an exception ( no web streams ) - $this->error = 'No web streams available, please check your enabled flavors'; - return ; + $this->fatalIframeError( 'No web streams available, please check your enabled flavors' ); } // The outer container: $o='