MediaWiki REL1_39
CodexModule.php
Go to the documentation of this file.
1<?php
22
23use Config;
24
32class CodexModule extends FileModule {
33
34 protected $dirSpecificStyles = [];
35
36 public function __construct( array $options = [], $localBasePath = null, $remoteBasePath = null ) {
37 if ( isset( $options['dirSpecificStyles'] ) ) {
38 $this->dirSpecificStyles = $options['dirSpecificStyles'];
39 }
40
41 parent::__construct( $options, $localBasePath, $remoteBasePath );
42 }
43
44 public function getStyleFiles( Context $context ) {
45 // Add direction-specific styles
46 $dir = $context->getDirection();
47 if ( isset( $this->dirSpecificStyles[ $dir ] ) ) {
48 $this->styles = array_merge( $this->styles, (array)$this->dirSpecificStyles[ $dir ] );
49 // Empty dirSpecificStyles so we don't add them twice if getStyleFiles() is called twice
50 $this->dirSpecificStyles = [];
51 }
52
53 return parent::getStyleFiles( $context );
54 }
55
77 public static function getIcons( Context $context, Config $config, array $iconNames = [] ) {
78 global $IP;
79 static $allIcons = null;
80 if ( $allIcons === null ) {
81 $allIcons = json_decode( file_get_contents( "$IP/resources/lib/codex-icons/codex-icons.json" ), true );
82 }
83 return array_intersect_key( $allIcons, array_flip( $iconNames ) );
84 }
85}
86
88class_alias( CodexModule::class, 'ResourceLoaderCodexModule' );
if(!defined( 'MEDIAWIKI')) if(ini_get('mbstring.func_overload')) if(!defined( 'MW_ENTRY_POINT')) global $IP
Environment checks.
Definition Setup.php:91
Module for codex that has direction-specific style files and a static helper function for embedding i...
getStyleFiles(Context $context)
Get a list of file paths for all styles in this module, in order of proper inclusion.
__construct(array $options=[], $localBasePath=null, $remoteBasePath=null)
static getIcons(Context $context, Config $config, array $iconNames=[])
Retrieve the specified icon definitions from codex-icons.json.
Context object that contains information about the state of a specific ResourceLoader web request.
Definition Context.php:46
Module based on local JavaScript/CSS files.
string $remoteBasePath
Remote base path, see __construct()
string $localBasePath
Local base path, see __construct()
Interface for configuration instances.
Definition Config.php:30