* @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 ) );
}
return $retval;
}
+ /**
+ * @return ResourceLoader
+ */
public function getResourceLoader() {
return $this->resourceLoader;
}
-
+
+ /**
+ * @return WebRequest
+ */
public function getRequest() {
return $this->request;
}
+ /**
+ * @return array
+ */
public function getModules() {
return $this->modules;
}
+ /**
+ * @return string
+ */
public function getLanguage() {
if ( $this->language === null ) {
global $wgLang;
return $this->language;
}
+ /**
+ * @return string
+ */
public function getDirection() {
if ( $this->direction === null ) {
$this->direction = $this->request->getVal( 'dir' );
return $this->direction;
}
+ /**
+ * @return string
+ */
public function getSkin() {
return $this->skin;
}
+ /**
+ * @return string
+ */
public function getUser() {
return $this->user;
}
+ /**
+ * @return bool
+ */
public function getDebug() {
return $this->debug;
}
+ /**
+ * @return String
+ */
public function getOnly() {
return $this->only;
}
+ /**
+ * @return String
+ */
public function getVersion() {
return $this->version;
}
+ /**
+ * @return bool
+ */
public function shouldIncludeScripts() {
return is_null( $this->only ) || $this->only === 'scripts';
}
+ /**
+ * @return bool
+ */
public function shouldIncludeStyles() {
return is_null( $this->only ) || $this->only === 'styles';
}
+ /**
+ * @return bool
+ */
public function shouldIncludeMessages() {
return is_null( $this->only ) || $this->only === 'messages';
}
+ /**
+ * @return string
+ */
public function getHash() {
if ( !isset( $this->hash ) ) {
$this->hash = implode( '|', array(
public function getGroup() {
return $this->group;
}
-
+
+ /**
+ * @return string
+ */
public function getPosition() {
return $this->position;
}
/* Protected Methods */
+ /**
+ * @param $path string
+ * @return string
+ */
protected function getLocalPath( $path ) {
return "{$this->localBasePath}/$path";
}
-
+
+ /**
+ * @param $path string
+ * @return string
+ */
protected function getRemotePath( $path ) {
return "{$this->remoteBasePath}/$path";
}
*
* @param $styles Array: List of media type/list of file paths pairs, to read, remap and
* concetenate
+ *
+ * @param $flip bool
+ *
* @return Array: List of concatenated and remapped CSS data from $styles,
* keyed by media type
*/
* This method can be used as a callback for array_map()
*
* @param $path String: File path of script file to read
+ * @param $flip bool
+ *
* @return String: CSS data in script file
*/
protected function readStyleFile( $path, $flip ) {
* Set this module's origin. This is called by ResourceLodaer::register()
* when registering the module. Other code should not call this.
*
- * @param $name Int origin
+ * @param $origin Int origin
*/
public function setOrigin( $origin ) {
$this->origin = $origin;
* Where on the HTML page should this module's JS be loaded?
* 'top': in the <head>
* 'bottom': at the bottom of the <body>
+ *
+ * @return string
*/
public function getPosition() {
return 'bottom';
/**
* Gets list of pages used by this module. Obviously, it makes absolutely no
* sense to include JavaScript files here... :D
- *
+ *
+ * @param $context ResourceLoaderContext
+ *
* @return Array: List of pages
*/
protected function getPages( ResourceLoaderContext $context ) {
/**
* Gets list of pages used by this module
- *
+ *
+ * @param $context ResourceLoaderContext
+ *
* @return Array: List of pages
*/
protected function getPages( ResourceLoaderContext $context ) {
/* Methods */
+ /**
+ * @param $context ResourceLoaderContext
+ * @return string
+ */
public function getScript( ResourceLoaderContext $context ) {
global $IP, $wgLoadScript, $wgLegacyJavaScriptGlobals;
return $out;
}
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array|mixed
+ */
public function getModifiedTime( ResourceLoaderContext $context ) {
global $IP, $wgCacheEpoch;
}
return $this->modifiedTime[$hash] = $time;
}
-
+
/* Methods */
-
+
+ /**
+ * @return string
+ */
public function getGroup() {
return 'startup';
}
/* Protected Methods */
protected $origin = self::ORIGIN_USER_SITEWIDE;
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array
+ */
protected function getPages( ResourceLoaderContext $context ) {
if ( $context->getUser() ) {
$user = User::newFromName( $context->getUser() );
}
return array();
}
-
+
/* Methods */
-
+
+ /**
+ * @return string
+ */
public function getGroup() {
return 'user';
}
/* Protected Methods */
protected $origin = self::ORIGIN_USER_INDIVIDUAL;
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array
+ */
protected function getPages( ResourceLoaderContext $context ) {
if ( $context->getUser() ) {
$username = $context->getUser();
}
return array();
}
-
+
/* Methods */
-
+
+ /**
+ * @return string
+ */
public function getGroup() {
return 'user';
}
/* Methods */
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array|int|Mixed
+ */
public function getModifiedTime( ResourceLoaderContext $context ) {
$hash = $context->getHash();
if ( isset( $this->modifiedTime[$hash] ) ) {
}
}
+ /**
+ * @param $context ResourceLoaderContext
+ * @return string
+ */
public function getScript( ResourceLoaderContext $context ) {
return Xml::encodeJsCall( 'mw.user.options.set',
array( $this->contextUserOptions( $context ) ) );
}
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array
+ */
public function getStyles( ResourceLoaderContext $context ) {
global $wgAllowUserCssPrefs;
return array();
}
+ /**
+ * @return string
+ */
public function getGroup() {
return 'private';
}
/* Methods */
+ /**
+ * @param $context ResourceLoaderContext
+ * @return string
+ */
public function getScript( ResourceLoaderContext $context ) {
$scripts = '';
foreach ( $this->getPages( $context ) as $titleText => $options ) {
return $scripts;
}
+ /**
+ * @param $context ResourceLoaderContext
+ * @return array
+ */
public function getStyles( ResourceLoaderContext $context ) {
global $wgScriptPath;
return $styles;
}
+ /**
+ * @param $context ResourceLoaderContext
+ * @return int|mixed
+ */
public function getModifiedTime( ResourceLoaderContext $context ) {
$modifiedTime = 1; // wfTimestamp() interprets 0 as "now"
$mtimes = $this->getTitleMtimes( $context );
}
return $modifiedTime;
}
-
+
+ /**
+ * @param $context ResourceLoaderContext
+ * @return bool
+ */
public function isKnownEmpty( ResourceLoaderContext $context ) {
return count( $this->getTitleMtimes( $context ) ) == 0;
}