* @param $messages Mixed: List of messages associated with this module. May either be an
* associative array mapping message key to value, or a JSON-encoded message blob containing
* the same data, wrapped in an XmlJsCode object.
+ *
+ * @return string
*/
public static function makeLoaderImplementScript( $name, $scripts, $styles, $messages ) {
if ( is_string( $scripts ) ) {
*
* @param $messages Mixed: Either an associative array mapping message key to value, or a
* JSON-encoded message blob containing the same data, wrapped in an XmlJsCode object.
+ *
+ * @return string
*/
public static function makeMessageSetScript( $messages ) {
return Xml::encodeJsCall( 'mw.messages.set', array( (object)$messages ) );
* single stylesheet with @media blocks.
*
* @param $styles Array: List of CSS strings keyed by media type
+ *
+ * @return string
*/
public static function makeCombinedStyles( array $styles ) {
$out = '';
*
* - ResourceLoader::makeLoaderStateScript( array( $name => $state, ... ) ):
* Set the state of modules with the given names to the given states
+ *
+ * @param $name string
+ * @param $state
+ *
+ * @return string
*/
public static function makeLoaderStateScript( $name, $state = null ) {
if ( is_array( $name ) ) {
* @param $dependencies Array: List of module names on which this module depends
* @param $group String: Group which the module is in.
* @param $script String: JavaScript code
+ *
+ * @return string
*/
public static function makeCustomLoaderScript( $name, $version, $dependencies, $group, $script ) {
$script = str_replace( "\n", "\n\t", trim( $script ) );
* @param $version Integer: Module version number as a timestamp
* @param $dependencies Array: List of module names on which this module depends
* @param $group String: group which the module is in.
+ *
+ * @return string
*/
public static function makeLoaderRegisterScript( $name, $version = null,
$dependencies = null, $group = null )
* present.
*
* @param $script String: JavaScript code
+ *
+ * @return string
*/
public static function makeLoaderConditionalScript( $script ) {
$script = str_replace( "\n", "\n\t", trim( $script ) );
* the given value.
*
* @param $configuration Array: List of configuration values keyed by variable name
+ *
+ * @return string
*/
public static function makeConfigSetScript( array $configuration ) {
return Xml::encodeJsCall( 'mw.config.set', array( $configuration ) );
}
-
+
/**
* Convert an array of module names to a packed query string.
*
$suffix = $pos === false ? $module : substr( $module, $pos + 1 );
$groups[$prefix][] = $suffix;
}
-
+
$arr = array();
foreach ( $groups as $prefix => $suffixes ) {
$p = $prefix === '' ? '' : $prefix . '.';
$str = implode( '|', $arr );
return str_replace( ".", "!", $str ); # bug 28840
}
-
+
/**
* Determine whether debug mode was requested
* Order of priority is 1) request param, 2) cookie, 3) $wg setting
public static function inDebugMode() {
global $wgRequest, $wgResourceLoaderDebug;
static $retval = null;
- if ( !is_null( $retval ) )
+ if ( !is_null( $retval ) ) {
return $retval;
+ }
return $retval = $wgRequest->getFuzzyBool( 'debug',
$wgRequest->getCookie( 'resourceLoaderDebug', '', $wgResourceLoaderDebug ) );
}