Skip to content

Commit

Permalink
sync with mwEmbed ( mostly whitespace updates )
Browse files Browse the repository at this point in the history
git-svn-id: http://www.kaltura.org/kalorg/html5video/trunk/mwEmbed@1179 b58a29cf-3064-46da-94c6-1c29cc75c8e5
  • Loading branch information
KalturaGitBot committed Nov 15, 2010
1 parent 44365ec commit b265151
Show file tree
Hide file tree
Showing 109 changed files with 11,139 additions and 11,125 deletions.
60 changes: 30 additions & 30 deletions ResourceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

// 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
// Allow an installation an optional PHP customization/overrides file
if ( is_file ( dirname( __FILE__ ) .'/../localSettings.php' ) ) {
require_once dirname( __FILE__ ) .'/../localSettings.php';
require_once dirname( __FILE__ ) .'/../localSettings.php';
}

// Load stand alone Resource Loader config
Expand Down Expand Up @@ -122,9 +122,9 @@ function doResourceLoader() {
// Setup script loader header ( to easy identify file data )
if( $this->outputFormat == 'js' ) {
$this->output .= 'var mwResourceLoaderDate = "' .
xml::escapeJsString( date( 'c' ) ) . '";' . "\n";
xml::escapeJsString( date( 'c' ) ) . '";' . "\n";
$this->output .= 'var mwResourceLoaderRequestKey = "' .
xml::escapeJsString( $this->requestKey ) . '";' . "\n";
xml::escapeJsString( $this->requestKey ) . '";' . "\n";
}

// Build the output
Expand All @@ -142,7 +142,7 @@ function doResourceLoader() {
// MwEmbed is a core component so it includes loaders and other styles
if( $resourceName == 'mwEmbed' && $this->outputFormat != 'messages' ){
// Output core components ( parts of core mwEmbed that are in different files )
$coreComponentsList = NamedResourceLoader::getComponentsList();
$coreComponentsList = NamedResourceLoader::getComponentsList();
foreach( $coreComponentsList as $componentClassName ) {
// Output the core component via the script loader:
$this->output .= $this->getLocalizedScriptText( $componentClassName );
Expand All @@ -156,24 +156,24 @@ function doResourceLoader() {

// Output the current language resource js
$this->output .= NamedResourceLoader::getLanguageJs( $this->langCode );

// Output the localSettings.js
$localSettingsJsPath = realpath( dirname( __FILE__ ) ) . '/localSettings.js';
if( is_file( $localSettingsJsPath ) ){
wfSuppressWarnings();
$this->output .= file_get_contents( $localSettingsJsPath );
wfRestoreWarnings();
}
// Add the required core mwEmbed style sheets
}

// Add the required core mwEmbed style sheets
// removed for now because when creating stand alone packages js package with css
// the paths get messed up.
/*if( !isset( $this->namedFileList[ 'mw.style.mwCommon' ] ) ) {
$this->output .= $this->getResourceText( 'mw.style.mwCommon' );
}*/

// Output "special" IE comment tag to support video tags mwEmbed tags.
$this->notMinifiedTopOutput .= '/*@cc_on@if(@_jscript_version<9){\'video audio source track\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n";
// Output "special" IE comment tag to support "special" mwEmbed tags.
$this->notMinifiedTopOutput .='/*@cc_on@if(@_jscript_version<9){\'video audio source itext playlist\'.replace(/\w+/g,function(n){document.createElement(n)})}@end@*/'."\n";
}
}

Expand Down Expand Up @@ -232,7 +232,7 @@ static private function getOnDoneCallback( ){
*
* @param {String} $js_string Javascript string to be minified
* @param {String} $requestKey Unique key for minification
* @return minified javascript value
* @return minified javascript value
*/
static function getMinifiedJs( & $js_string, $requestKey='' ){
global $wgJavaPath, $wgClosureCompilerPath, $wgClosureCompilerLevel;
Expand Down Expand Up @@ -274,14 +274,14 @@ static function getClosureMinifiedJs( & $js_string, $requestKey=''){
// Write the grouped javascript to a temporary file:
// ( closure compiler does not support reading from standard in pipe )
$td = wfTempDir();
$jsFileName = $td . '/' . md5( $requestKey ) . '.tmp.js';
file_put_contents( $jsFileName, $js_string );
$jsFileName = $td . '/' . md5( $requestKey ) . '.tmp.js';
file_put_contents( $jsFileName, $js_string );
$retval = '';
$cmd = $wgJavaPath . ' -jar ' . $wgClosureCompilerPath;
$cmd.= ' --js ' . $jsFileName;

if( $wgClosureCompilerLevel )
$cmd.= ' --compilation_level ' . wfEscapeShellArg( $wgClosureCompilerLevel );
$cmd.= ' --compilation_level ' . wfEscapeShellArg( $wgClosureCompilerLevel );

// only output js ( no warnings )
$cmd.= ' --warning_level QUIET';
Expand Down Expand Up @@ -344,7 +344,7 @@ function getResourceText( $resourceName ){
}
return $sk->generateUserJs( $titleParams[ 'useskin' ] ) . "\n";
}
} else if( isset( $titleParams['gen' ] ) && $titleParams['gen' ] == 'css' ) {
} else if( isset( $titleParams['gen' ] ) && $titleParams['gen' ] == 'css' ) {
return $sk->generateUserStylesheet();
}
} else {
Expand Down Expand Up @@ -377,7 +377,7 @@ function getResourceText( $resourceName ){
$filePath = self::getPathFromClass( $resourceName );

if( ! $filePath ) {
$this->errorMsg .= "\nError could not get file path: ". xml::escapeJsString( $resourceName ) ."\n";
$this->errorMsg .= "\nError could not get file path: ". xml::escapeJsString( $resourceName ) ."\n";
return false;
}

Expand All @@ -399,7 +399,7 @@ function getResourceText( $resourceName ){

return $output;
}else{
$this->errorMsg .= "\nError could not read file: ". xml::escapeJsString( $filePath ) ."\n";
$this->errorMsg .= "\nError could not read file: ". xml::escapeJsString( $filePath ) ."\n";
return false;
}
}
Expand All @@ -424,7 +424,7 @@ private function transformCssOutput( $resourceName, $cssString , $path ='') {
// Using the local mediaWiki entry point we should have our $wgScriptPath global
global $wgScriptPath;
$prePendPath = ( $wgScriptPath == '' ) ? '' : $wgScriptPath . '/';
$cssOptions[ 'prependRelativePath' ] = $prePendPath . dirname( $path ) . '/';
$cssOptions[ 'prependRelativePath' ] = $prePendPath . dirname( $path ) . '/';
} else {
// Get the server URL
$serverUri = $this->getResourceLoaderUri();
Expand Down Expand Up @@ -630,7 +630,7 @@ function preProcRequestVars() {

// Update the outupt format is "css", "messages" or "js"
if( isset( $_GET['format'] ) &&
( $_GET['format'] == 'css' || $_GET['format'] == 'messages')
( $_GET['format'] == 'css' || $_GET['format'] == 'messages')
){
$this->outputFormat = $_GET['format'];
} else {
Expand Down Expand Up @@ -670,10 +670,10 @@ function preProcRequestVars() {
// Check for the requested classes
if ( $reqClassList && count( $reqClassList ) > 0 ) {
// Clean the resource list and populate namedFileList
foreach ( $reqClassList as $reqClass ) {
foreach ( $reqClassList as $reqClass ) {
//do some simple checks:
if ( trim( $reqClass ) != '' ){
if( substr( $reqClass, 0, 3 ) == 'WT:' && strtolower( substr( $reqClass, -3) ) == '.js' ){
if( substr( $reqClass, 0, 3 ) == 'WT:' && strtolower( substr( $reqClass, -3) ) == '.js' ){
// Wiki page requests (must end with .js):
$requestKey .= $reqClass;
}else if( substr( $reqClass, 0, 3 ) != 'WT:' ){
Expand Down Expand Up @@ -719,7 +719,7 @@ public static function checkForCommonsLanguageFormHack( $langKey){
$langKey = str_replace($formName, '', $langKey);
//English wikipedia puts "-" after language keys remove that:
if( $langKey[ strlen( $langKey ) - 1 ] == '-'){
$langKey = substr( $langKey, 0, strlen( $langKey ) - 1 );
$langKey = substr( $langKey, 0, strlen( $langKey ) - 1 );
}
return $langKey;
}
Expand Down Expand Up @@ -765,7 +765,7 @@ function getFileContents( $filePath ) {
global $IP;

$ext = substr($filePath, strrpos($filePath, '.') + 1);
if ( self::validFileExtension( $ext) ) {
if ( self::validFileExtension( $ext) ) {
$this->errorMsg .= "\nError file name must end with .js or .css " . htmlspecialchars( $filePath ) . " \n ";
return false;
}
Expand Down Expand Up @@ -832,7 +832,7 @@ function transformScriptText( $scriptText , $moduleName){
// try each of these search patterns in the same order as before.

// Get the mw.addMessage javascript
self::$addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);
self::$addMessageJs = $this->getAddMessagesFromScriptText( $scriptText , $moduleName);

// Check for mw.includeAllModuleMsgs() call to be replaced with all the msgs
// Use preg_replace_callback to avoid back-refrence substitution
Expand Down Expand Up @@ -881,7 +881,7 @@ static function removeLogStatements( $jsString ){
break;
}
if( count( $matches ) > 0 ){
$startOfLogIndex = strlen( $matches[1][0] ) + $matches[1][1];
$startOfLogIndex = strlen( $matches[1][0] ) + $matches[1][1];
// append everything up to this point:
$outputJs .= substr( $jsString, $i, ( $startOfLogIndex - strlen( $matches[1][0] ) )-$i );

Expand Down Expand Up @@ -913,7 +913,7 @@ static function removeLogStatements( $jsString ){
}
break;
case ')':
if( ! $inquote && !$inSingleQuote ){
if( ! $inquote && !$inSingleQuote ){
$parenthesesDepth--;
}
break;
Expand Down Expand Up @@ -984,7 +984,7 @@ static public function getAddMessagesIndex( $str ){
}
}
// Check for ); at the end
preg_match( '/\s*\)\s*\;?/', $str, $matches, PREG_OFFSET_CAPTURE, $returnIndex['e'] );
preg_match( '/\s*\)\s*\;?/', $str, $matches, PREG_OFFSET_CAPTURE, $returnIndex['e'] );
if( $matches[0][1] ){
$returnIndex[ 'efull' ] = $matches[0][1] + strlen( $matches[0][0] );
}
Expand Down Expand Up @@ -1111,7 +1111,7 @@ function getMsgKeysFromScriptText( & $scriptString , $moduleName){
$inx = self::getAddMessageKeyIndex( $scriptString );
if( $inx ) {
// get the javascript array string:
$javaScriptArrayString = substr($scriptString, $inx['s'], ($inx['e']-$inx['s'])) ;
$javaScriptArrayString = substr($scriptString, $inx['s'], ($inx['e']-$inx['s'])) ;
// Match all the quoted msg keys
preg_match_all( "/\"([^\"]*)\"/", $javaScriptArrayString, $matches);
$messageSet = array();
Expand Down Expand Up @@ -1240,7 +1240,7 @@ public function isFileCached() {
* Loads and outputs the file from the file cache
*/
public function outputFile() {
if ( ResourceLoader::clientAcceptsGzip() && substr( $this->filename, -3 ) == '.gz' ) {
if ( ResourceLoader::clientAcceptsGzip() && substr( $this->filename, -3 ) == '.gz' ) {
header( 'Content-Encoding: gzip' );
readfile( $this->filename );
return true;
Expand Down
14 changes: 7 additions & 7 deletions includes/NamedResourceLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static function loadResourcePaths(){
wfProfileIn( $fname );


$mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' ) ? $IP : $IP .'/' .$wgMwEmbedDirectory;
$mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' ) ? $IP : $IP .'/' .$wgMwEmbedDirectory;
// Add the mwEmbed localizations
$wgExtensionMessagesFiles[ 'mwEmbed' ] = $mwEmbedAbsolutePath . '/mwEmbed.i18n.php';

Expand Down Expand Up @@ -90,7 +90,7 @@ public static function loadResourcePaths(){
}

// Get all the classes from the enabled mwEmbed modules folder
foreach( self::$moduleList as $na => $moduleName ) {
foreach( self::$moduleList as $na => $moduleName ) {
$relativeSlash = ( $wgMwEmbedDirectory == '' )? '' : '/';
$modulePath = $wgMwEmbedDirectory . $relativeSlash . 'modules/' . $moduleName;
self::proccessModulePath( $moduleName, $modulePath );
Expand Down Expand Up @@ -124,7 +124,7 @@ private static function proccessModulePath( $moduleName, $modulePath ){
self::$directoryContext = $modulePath;

// Check for the loader.js
if( !is_file( $modulePath . '/loader.js' ) ){
if( !is_file( $modulePath . '/loader.js' ) ){
throw new MWException( "Javascript Module $moduleName missing loader.js file\n" );
return false;
}
Expand All @@ -151,7 +151,7 @@ private static function proccessModulePath( $moduleName, $modulePath ){
*/
private static function proccessLoaderContent( & $fileContent , $moduleName){
// Add the mwEmbed loader js to its global collector:
self::$combinedLoadersJs .= $fileContent;
self::$combinedLoadersJs .= $fileContent;

// Is there a way to pass arguments in preg_replace_callback ?
self::$currentModuleName = $moduleName;
Expand All @@ -169,7 +169,7 @@ private static function proccessLoaderContent( & $fileContent , $moduleName){
*/
public static function getLanguageJs( $langKey = 'en' ){
global $wgMwEmbedDirectory;
$path = $wgMwEmbedDirectory . '/languages/classes/Language' . ucfirst( $langKey ) . '.js';
$path = $wgMwEmbedDirectory . '/languages/classes/Language' . ucfirst( $langKey ) . '.js';
if( is_file( $path ) ){
$languageJs = file_get_contents( $path );
return $languageJs;
Expand Down Expand Up @@ -231,7 +231,7 @@ private static function preg_buildModuleList( $jsvar ){
}
$moduleSet = explode(',', $jsvar[1] );

$mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory;
$mwEmbedAbsolutePath = ( $wgMwEmbedDirectory == '' )? $IP: $IP .'/' .$wgMwEmbedDirectory;

foreach( $moduleSet as $na => $moduleName ) {
// Skip empty module names
Expand Down Expand Up @@ -272,7 +272,7 @@ private static function preg_classPathLoader( $jsvar ) {
foreach ( $jClassSet as $resourceName => $classPath ) {
// Strip $ from resource (as they are stripped on URL request parameter input)
$resourceName = str_replace( '$', '', $resourceName );
$classPath = ( self::$directoryContext == '' )? $classPath : self::$directoryContext . '/' . $classPath;
$classPath = ( self::$directoryContext == '' )? $classPath : self::$directoryContext . '/' . $classPath;

// Throw an error if we already have defined this class:
// This prevents a module from registering a shared class
Expand Down
8 changes: 4 additions & 4 deletions includes/noMediaWikiConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,9 @@ function wfLoadMsgKeys( $langKey ){
throw new MWException( "Missing msgFile: " . htmlspecialchars( $msgFile ) . "\n" );
}
require( $msgFile );
// First include the English fallback,
// First include the English fallback,
$wgMessageCache = array_merge( $wgMessageCache, $messages[ 'en' ] );
// Then override with the current language:
// Then override with the current language:
if( isset( $messages[ $langKey ] ) ) {
$wgMessageCache = array_merge( $wgMessageCache, $messages[ $langKey ] );
}
Expand Down Expand Up @@ -198,8 +198,8 @@ function wfProfileOut( $name ){
}
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}

/**
Expand Down
Loading

0 comments on commit b265151

Please sign in to comment.