-
-
Save ankita-kumari/4254e114390795d97d18 to your computer and use it in GitHub Desktop.
protected function readStyleFile( $path, $flip, $context = null ) { | |
$localPath = $this->getLocalPath( $path ); | |
$remotePath = $this->getRemotePath( $path ); | |
if ( !file_exists( $localPath ) ) { | |
$msg = __METHOD__ . ": style file not found: \"$localPath\""; | |
wfDebugLog( 'resourceloader', $msg ); | |
throw new MWException( $msg ); | |
} |
public function readStyleFiles( array $styles, $flip, $context = null ) {
if ( empty( $styles ) ) {
return array();
}
foreach ( $styles as $media => $files ) {
$uniqueFiles = array_unique( $files, SORT_REGULAR );
$styleFiles = array();
foreach ( $uniqueFiles as $file ) {
$styleFiles[] = $this->readStyleFile( $file, $flip, $context );
}
$styles[$media] = implode( "\n", $styleFiles );
}
return $styles;
}
public function getStyles( ResourceLoaderContext $context ) {
$styles = $this->readStyleFiles(
$this->getStyleFiles( $context ),
$this->getFlip( $context ),
$context
);
// Collect referenced files
$this->localFileRefs = array_unique( $this->localFileRefs );
// If the list has been modified since last time we cached it, update the cache
try {
if ( $this->localFileRefs !== $this->getFileDependencies( $context->getSkin() ) ) {
$dbw = wfGetDB( DB_MASTER );
$dbw->replace( 'module_deps',
array( array( 'md_module', 'md_skin' ) ), array(
'md_module' => $this->getName(),
'md_skin' => $context->getSkin(),
'md_deps' => FormatJson::encode( $this->localFileRefs ),
)
);
}
} catch ( Exception $e ) {
wfDebugLog( 'resourceloader', METHOD . ": failed to update DB: $e" );
}
return $styles;
}
public function getStyleFiles( ResourceLoaderContext $context ) {
return array_merge_recursive(
self::collateFilePathListByOption( $this->styles, 'media', 'all' ),
self::collateFilePathListByOption(
self::tryForKey( $this->skinStyles, $context->getSkin(), 'default' ),
'media',
'all'
)
);
}
protected $localBasePath = '';