Go to the documentation of this file.
79 $this->{$member} = $option;
106 if (
$config->get(
'UseSiteJs' ) ) {
108 $pages[$script] = [
'type' =>
'script' ];
112 if (
$config->get(
'UseSiteCss' ) ) {
113 foreach ( $this->styles
as $style ) {
114 $pages[$style] = [
'type' =>
'style' ];
156 if (
$title->isRedirect() ) {
178 return $content->serialize( $format );
187 $title->getLatestRevID() );
191 $revision->setTitle(
$title );
194 wfDebugLog(
'resourceloader', __METHOD__ .
': failed to load content of JS/CSS page!' );
207 if (
$options[
'type'] !==
'script' ) {
211 if ( strval( $script ) !==
'' ) {
213 $scripts .= ResourceLoader::makeComment( $titleText ) . $script .
"\n";
226 if (
$options[
'type'] !==
'style' ) {
231 if ( strval( $style ) ===
'' ) {
234 if ( $this->
getFlip( $context ) ) {
235 $style = CSSJanus::transform( $style,
true,
false );
238 [ $style,
false, $this->
getConfig()->
get(
'ScriptPath' ),
true ] );
239 if ( !isset(
$styles[$media] ) ) {
242 $style = ResourceLoader::makeComment( $titleText ) . $style;
267 $summary = parent::getDefinitionSummary(
$context );
269 'pages' => $this->
getPages( $context ),
284 if ( $this->
getGroup() ===
'user' ) {
285 foreach ( $revisions
as $revision ) {
286 if ( $revision[
'page_len'] > 0 ) {
297 return count( $revisions ) === 0;
316 $pageNames = array_keys( $this->
getPages( $context ) );
318 $key = implode(
'|', $pageNames );
319 if ( !isset( $this->titleInfo[$key] ) ) {
320 $this->titleInfo[$key] = static::fetchTitleInfo(
$dbr, $pageNames, __METHOD__ );
322 return $this->titleInfo[$key];
328 foreach ( $pages
as $titleText ) {
335 if ( !
$batch->isEmpty() ) {
338 [
'page_namespace',
'page_title',
'page_touched',
'page_len',
'page_latest' ],
339 $batch->constructSet(
'page', $db ),
342 foreach (
$res as $row ) {
347 'page_len' => $row->page_len,
348 'page_latest' => $row->page_latest,
349 'page_touched' => $row->page_touched,
365 $rl =
$context->getResourceLoader();
371 foreach ( $moduleNames
as $name ) {
372 $module = $rl->getModule(
$name );
373 if ( $module instanceof
self ) {
374 $mDB = $module->getDB();
376 if ( $mDB && $mDB->getWikiID() === $db->
getWikiID() ) {
377 $wikiModules[] = $module;
378 $allPages += $module->getPages(
$context );
383 if ( !$wikiModules ) {
388 $pageNames = array_keys( $allPages );
390 $hash = sha1( implode(
'|', $pageNames ) );
397 $allInfo =
$cache->getWithSetCallback(
398 $cache->makeGlobalKey(
'resourceloader',
'titleinfo', $db->
getWikiID(), $hash ),
400 function ( $curVal, &$ttl,
array &$setOpts )
use ( $func, $pageNames, $db,
$fname ) {
401 $setOpts += Database::getCacheSetOptions( $db );
403 return call_user_func( $func, $db, $pageNames,
$fname );
405 [
'checkKeys' => [
$cache->makeGlobalKey(
'resourceloader',
'titleinfo', $db->
getWikiID() ) ] ]
408 foreach ( $wikiModules
as $wikiModule ) {
409 $pages = $wikiModule->getPages(
$context );
412 foreach ( $pages
as $page => $unused ) {
415 $intersect[
$title->getPrefixedText() ] = 1;
418 $rl->getLogger()->info(
419 'Invalid wiki page title "{title}" in ' . __METHOD__,
424 $info = array_intersect_key( $allInfo, $intersect );
425 $pageNames = array_keys( $pages );
427 $key = implode(
'|', $pageNames );
428 $wikiModule->setTitleInfo( $key, $info );
447 if ( $old && in_array( $old->getContentFormat(), $formats ) ) {
449 } elseif ( $new && in_array( $new->getContentFormat(), $formats ) ) {
452 $purge = (
$title->isCssOrJsPage() ||
$title->isCssJsSubpage() );
457 $key =
$cache->makeGlobalKey(
'resourceloader',
'titleinfo', $wikiId );
458 $cache->touchCheckKey( $key );
Object passed around to modules which contains information about the state of a specific loader reque...
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
getDB()
Get the Database object used in getTitleInfo().
const ORIGIN_USER_SITEWIDE
getStyles(ResourceLoaderContext $context)
static newKnownCurrent(IDatabase $db, $pageId, $revId)
Load a revision based on a known page ID and current revision ID from the DB.
Abstraction for ResourceLoader modules which pull from wiki pages.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
getGroup()
Get group name.
getScript(ResourceLoaderContext $context)
if(!defined( 'MEDIAWIKI')) $fname
This file is not a valid entry point, perform no further processing unless MEDIAWIKI is defined.
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
isKnownEmpty(ResourceLoaderContext $context)
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static call( $callable, array $args=[], $ttl=3600)
Shortcut method for creating a MemoizedCallable and invoking it with the specified arguments.
namespace and then decline to actually register it file or subcat img or subcat $title
static preloadTitleInfo(ResourceLoaderContext $context, IDatabase $db, array $moduleNames)
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
enableModuleContentVersion()
Disable module content versioning.
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
static fetchTitleInfo(IDatabase $db, array $pages, $fname=__METHOD__)
__construct(array $options=null)
validateScriptFile( $fileName, $contents)
Validate a given script file; if valid returns the original source.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
setTitleInfo( $key, array $titleInfo)
getContentObj(Title $title)
Represents a title within MediaWiki.
Abstraction for ResourceLoader modules, with name registration and maxage functionality.
static getMainWANInstance()
Get the main WAN cache object.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
getDefinitionSummary(ResourceLoaderContext $context)
getPages(ResourceLoaderContext $context)
Subclasses should return an associative array of resources in the module.
you have access to all of the normal MediaWiki so you can get a DB use the etc For full docs on the Maintenance class
const CONTENT_FORMAT_JAVASCRIPT
static invalidateModuleCache(Title $title, Revision $old=null, Revision $new=null, $wikiId)
Clear the preloadTitleInfo() cache for all wiki modules on this wiki on page change if it was a JS or...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
getTitleInfo(ResourceLoaderContext $context)
Get the information about the wiki pages for a given context.
the array() calling protocol came about after MediaWiki 1.4rc1.