Go to the documentation of this file.
99 $modulesWithDeps =
array();
100 foreach (
$res as $row ) {
101 $module = $this->
getModule( $row->md_module );
104 $modulesWithDeps[] = $row->md_module;
117 $modulesWithMessages =
array();
120 if ( $module && count( $module->getMessages() ) ) {
121 $modulesWithMessages[] =
$name;
124 $modulesWithoutMessages = array_flip(
$modules );
125 if ( count( $modulesWithMessages ) ) {
127 'mr_resource' => $modulesWithMessages,
131 foreach (
$res as $row ) {
132 $module = $this->
getModule( $row->mr_resource );
135 unset( $modulesWithoutMessages[$row->mr_resource] );
139 foreach ( array_keys( $modulesWithoutMessages )
as $name ) {
142 $module->setMsgBlobMtime( $lang, 0 );
162 protected function filter( $filter, $data ) {
163 global $wgResourceLoaderMinifierStatementsOnOwnLine, $wgResourceLoaderMinifierMaxLineLength;
168 if ( trim( $data ) ===
'' || !in_array( $filter,
array(
'minify-js',
'minify-css' ) ) ) {
175 $key =
wfMemcKey(
'resourceloader',
'filter', $filter, self::$filterCacheVersion, md5( $data ) );
177 $cacheEntry =
$cache->get( $key );
178 if ( is_string( $cacheEntry ) ) {
191 $wgResourceLoaderMinifierStatementsOnOwnLine,
192 $wgResourceLoaderMinifierMaxLineLength
194 $result .=
"\n/* cache key: $key */";
198 $result .=
"\n/* cache key: $key */";
204 }
catch ( Exception
$e ) {
206 wfDebugLog(
'resourceloader', __METHOD__ .
": minification failed: $e" );
207 $this->hasErrors =
true;
223 global $IP, $wgResourceModules, $wgResourceLoaderSources, $wgLoadScript, $wgEnableJavaScriptTest;
231 $this->
addSource( $wgResourceLoaderSources );
234 $this->
register( include
"$IP/resources/Resources.php" );
237 $this->
register( $wgResourceModules );
239 if ( $wgEnableJavaScriptTest ===
true ) {
259 public function register(
$name, $info = null ) {
264 foreach ( $registrations
as $name => $info ) {
266 if ( isset( $this->moduleInfos[
$name] ) ) {
270 'ResourceLoader duplicate registration error. ' .
271 'Another module has already been registered as ' .
$name
276 if ( !self::isValidModuleName(
$name ) ) {
278 throw new MWException(
"ResourceLoader module name '$name' is invalid, see ResourceLoader::isValidModuleName()" );
283 $this->moduleInfos[
$name] =
array(
'object' => $info );
284 $info->setName(
$name );
285 $this->modules[
$name] = $info;
286 } elseif ( is_array( $info ) ) {
288 $this->moduleInfos[
$name] = $info;
292 'ResourceLoader module info type error for module \'' .
$name .
298 wfProfileOut( __METHOD__ );
303 public function registerTestModules() {
304 global $IP, $wgEnableJavaScriptTest;
306 if ( $wgEnableJavaScriptTest !== true ) {
307 throw new MWException( 'Attempt to
register JavaScript test modules but <code>$wgEnableJavaScriptTest</code>
is false. Edit your <code>LocalSettings.php</
code> to enable
it.
' );
310 wfProfileIn( __METHOD__ );
312 // Get core test suites
313 $testModules = array();
314 $testModules['qunit
'] = array();
315 // Get other test suites (e.g. from extensions)
316 wfRunHooks( 'ResourceLoaderTestModules
', array( &$testModules, &$this ) );
318 // Add the testrunner (which configures QUnit) to the dependencies.
319 // Since it must be ready before any of the test suites are executed.
320 foreach ( $testModules['qunit
'] as &$module ) {
321 // Make sure all test modules are top-loading so that when QUnit starts
322 // on document-ready, it will run once and finish. If some tests arrive
323 // later (possibly after QUnit has already finished) they will be ignored.
324 $module['position
'] = 'top
';
325 $module['dependencies
'][] = 'test.mediawiki.qunit.testrunner
';
328 $testModules['qunit
'] = ( include "$IP/tests/qunit/QUnitTestResources.php" ) + $testModules['qunit
'];
330 foreach ( $testModules as $id => $names ) {
331 // Register test modules
332 $this->register( $testModules[$id] );
334 // Keep track of their names so that they can be loaded together
335 $this->testModuleNames[$id] = array_keys( $testModules[$id] );
338 wfProfileOut( __METHOD__ );
351 public function addSource( $id, $properties = null ) {
352 // Allow multiple sources to be registered in one call
353 if ( is_array( $id ) ) {
354 foreach ( $id as $key => $value ) {
355 $this->addSource( $key, $value );
360 // Disallow duplicates
361 if ( isset( $this->sources[$id] ) ) {
362 throw new MWException(
364 'Another
source has already been registered
as ' . $id
368 // Validate properties
369 foreach ( self::$requiredSourceProperties as $prop ) {
370 if ( !isset( $properties[$prop] ) ) {
371 throw new MWException( "Required property $prop missing from source ID $id" );
375 $this->sources[$id] = $properties;
383 public function getModuleNames() {
384 return array_keys( $this->moduleInfos );
397 public function getTestModuleNames( $framework = 'all
' ) {
399 if ( $framework == 'all
' ) {
400 return $this->testModuleNames;
401 } elseif ( isset( $this->testModuleNames[$framework] ) && is_array( $this->testModuleNames[$framework] ) ) {
402 return $this->testModuleNames[$framework];
419 public function getModule( $name ) {
420 if ( !isset( $this->modules[$name] ) ) {
421 if ( !isset( $this->moduleInfos[$name] ) ) {
425 // Construct the requested object
426 $info = $this->moduleInfos[$name];
428 if ( isset( $info['object'] ) ) {
429 // Object given in info array
430 $object = $info['object'];
432 if ( !isset( $info['class'] ) ) {
435 $class = $info['class'];
437 $object = new $class( $info );
439 $object->setName( $name );
440 $this->modules[$name] = $object;
443 return $this->modules[$name];
451 public function getSources() {
452 return $this->sources;
460 public function respond( ResourceLoaderContext $context ) {
461 global $wgCacheEpoch, $wgUseFileCache;
463 // Use file cache if enabled and available...
464 if ( $wgUseFileCache ) {
465 $fileCache = ResourceFileCache::newFromContext( $context );
466 if ( $this->tryRespondFromFileCache( $fileCache, $context ) ) {
467 return; // output handled
471 // Buffer output to catch warnings. Normally we'd use ob_clean()
on the
491 if ( $module->getGroup() ===
'private' ) {
492 wfDebugLog(
'resourceloader', __METHOD__ .
": request for private module '$name' denied" );
493 $this->hasErrors =
true;
508 }
catch ( Exception
$e ) {
510 wfDebugLog(
'resourceloader', __METHOD__ .
": preloading module info failed: $e" );
511 $this->hasErrors =
true;
527 $mtime = max( $mtime, $module->getModifiedTime( $context ) );
528 }
catch ( Exception
$e ) {
530 wfDebugLog(
'resourceloader', __METHOD__ .
": calculating maximum modified time failed: $e" );
531 $this->hasErrors =
true;
553 if ( $context->
getDebug() && strlen( $warnings = ob_get_contents() ) ) {
555 $this->hasErrors =
true;
559 if ( isset( $fileCache ) && !$errors && !count( $missing ) ) {
562 if ( $fileCache->isCacheWorthy() ) {
565 $fileCache->incrMissesRecent( $context->
getRequest() );
588 global $wgResourceLoaderMaxage;
592 if ( is_null( $context->
getVersion() ) || $errors ) {
593 $maxage = $wgResourceLoaderMaxage[
'unversioned'][
'client'];
594 $smaxage = $wgResourceLoaderMaxage[
'unversioned'][
'server'];
598 $maxage = $wgResourceLoaderMaxage[
'versioned'][
'client'];
599 $smaxage = $wgResourceLoaderMaxage[
'versioned'][
'server'];
601 if ( $context->
getOnly() ===
'styles' ) {
602 header(
'Content-Type: text/css; charset=utf-8' );
603 header(
'Access-Control-Allow-Origin: *' );
605 header(
'Content-Type: text/javascript; charset=utf-8' );
610 header(
'Cache-Control: private, no-cache, must-revalidate' );
611 header(
'Pragma: no-cache' );
613 header(
"Cache-Control: public, max-age=$maxage, s-maxage=$smaxage" );
614 $exp = min( $maxage, $smaxage );
633 $ims = $context->
getRequest()->getHeader(
'If-Modified-Since' );
635 if ( $ims !==
false && !$context->
getDebug() ) {
636 $imsTS = strtok( $ims,
';' );
649 header(
'HTTP/1.0 304 Not Modified' );
650 header(
'Status: 304 Not Modified' );
667 global $wgResourceLoaderMaxage;
672 ? $wgResourceLoaderMaxage[
'unversioned'][
'server']
673 : $wgResourceLoaderMaxage[
'versioned'][
'server'];
694 if ( $context->
getDebug() && strlen( $warnings = ob_get_contents() ) ) {
717 $encText = str_replace(
'*/',
'* /', $text );
718 return "/*\n$encText\n*/\n";
728 global $wgShowExceptionDetails;
730 if ( $wgShowExceptionDetails ) {
752 if ( !count(
$modules ) && !count( $missing ) ) {
753 return "/* This file is the Web entry point for MediaWiki's ResourceLoader:
754 <https://www.mediawiki.org/wiki/ResourceLoader>. In this request,
755 no modules were requested. Max made me put this here. */";
764 }
catch ( Exception
$e ) {
766 wfDebugLog(
'resourceloader', __METHOD__ .
": pre-fetching blobs from MessageBlobStore failed: $e" );
767 $this->hasErrors =
true;
775 foreach ( $missing
as $name ) {
776 $states[
$name] =
'missing';
794 if ( $context->
getDebug() && !$context->
getOnly() && $module->supportsURLLoading() ) {
795 $scripts = $module->getScriptURLsForDebug( $context );
797 $scripts = $module->getScript( $context );
800 if ( is_string( $scripts ) && strlen( $scripts ) && substr( rtrim( $scripts ), -1 ) !==
';' ) {
812 $stylePairs = $module->getStyles( $context );
813 if ( count ( $stylePairs ) ) {
816 if ( $context->
getDebug() && !$context->
getOnly() && $module->supportsURLLoading() ) {
818 'url' => $module->getStyleURLsForDebug( $context )
824 foreach ( $stylePairs
as $media => $style ) {
826 if ( is_array( $style ) ) {
827 $stylePairs[$media] =
array();
828 foreach ( $style
as $cssText ) {
829 if ( is_string( $cssText ) ) {
830 $stylePairs[$media][] = $this->
filter(
'minify-css', $cssText );
833 } elseif ( is_string( $style ) ) {
834 $stylePairs[$media] = $this->
filter(
'minify-css', $style );
840 'css' => self::makeCombinedStyles( $stylePairs )
847 $messagesBlob = isset( $blobs[
$name] ) ? $blobs[
$name] :
'{}';
850 switch ( $context->
getOnly() ) {
852 if ( is_string( $scripts ) ) {
855 } elseif ( is_array( $scripts ) ) {
864 $out .= isset( $styles[
'css'] ) ? implode(
'', $styles[
'css'] ) :
'';
878 }
catch ( Exception
$e ) {
880 wfDebugLog(
'resourceloader', __METHOD__ .
": generating module package failed: $e" );
881 $this->hasErrors =
true;
886 $states[
$name] =
'error';
889 $isRaw |= $module->isRaw();
899 $states[
$name] =
'ready';
904 if ( count( $states ) ) {
910 if ( $context->
getOnly() ===
'styles' ) {
937 if ( is_string( $scripts ) ) {
938 $scripts =
new XmlJsCode(
"function ( $, jQuery ) {\n{$scripts}\n}" );
939 } elseif ( !is_array( $scripts ) ) {
940 throw new MWException(
'Invalid scripts error. Array of URLs or string of code expected.' );
943 'mw.loader.implement',
983 foreach ( $stylePairs
as $media => $styles ) {
987 $styles = (
array)$styles;
988 foreach ( $styles
as $style ) {
989 $style = trim( $style );
991 if ( $style !==
'' ) {
996 if ( $media ===
'' || $media ==
'all' ) {
998 } elseif ( is_string( $media ) ) {
999 $out[] =
"@media $media {\n" . str_replace(
"\n",
"\n\t",
"\t" . $style ) .
"}";
1023 if ( is_array(
$name ) ) {
1053 $script = str_replace(
"\n",
"\n\t", trim( $script ) );
1055 "( function ( name, version, dependencies, group, source ) {\n\t$script\n} )",
1086 $dependencies =
null, $group =
null,
$source =
null
1088 if ( is_array(
$name ) ) {
1090 'mw.loader.register',
1097 'mw.loader.register',
1119 if ( is_array( $id ) ) {
1121 'mw.loader.addSource',
1127 'mw.loader.addSource',
1128 array( $id, $properties ),
1142 return "if(window.mw){\n" . trim( $script ) .
"\n}";
1155 array( $configuration ),
1171 $pos = strrpos( $module,
'.' );
1172 $prefix = $pos ===
false ?
'' : substr( $module, 0, $pos );
1173 $suffix = $pos ===
false ? $module : substr( $module, $pos + 1 );
1174 $groups[$prefix][] = $suffix;
1178 foreach ( $groups
as $prefix => $suffixes ) {
1179 $p = $prefix ===
'' ?
'' : $prefix .
'.';
1180 $arr[] = $p . implode(
',', $suffixes );
1182 $str = implode(
'|', $arr );
1192 global $wgRequest, $wgResourceLoaderDebug;
1195 $retval = $wgRequest->getFuzzyBool(
'debug',
1196 $wgRequest->getCookie(
'resourceLoaderDebug',
'', $wgResourceLoaderDebug ) );
1216 $printable =
false, $handheld =
false, $extraQuery =
array() ) {
1219 $only, $printable, $handheld, $extraQuery
1245 $printable =
false, $handheld =
false, $extraQuery =
array() ) {
1247 'modules' => self::makePackedModulesString(
$modules ),
1250 'debug' =>
$debug ?
'true' :
'false',
1252 if (
$user !==
null ) {
1258 if ( $only !==
null ) {
1284 return !preg_match(
'/[|,!]/', $moduleName ) && strlen( $moduleName ) <= 255;
1294 global $wgResourceLoaderLESSFunctions, $wgResourceLoaderLESSImportPaths;
1299 if ( !function_exists(
'ctype_digit' ) ) {
1300 throw new MWException(
'lessc requires the Ctype extension' );
1303 $less =
new lessc();
1304 $less->setPreserveComments(
true );
1305 $less->setVariables( self::getLESSVars() );
1306 $less->setImportDir( $wgResourceLoaderLESSImportPaths );
1307 foreach ( $wgResourceLoaderLESSFunctions
as $name => $func ) {
1308 $less->registerFunction(
$name, $func );
1320 global $wgResourceLoaderLESSVars;
1322 $lessVars = $wgResourceLoaderLESSVars;
static makeLoaderConditionalScript( $script)
Returns JS code which runs given JS code if the client-side framework is present.
Object passed around to modules which contains information about the state of a specific loader reque...
The index of the header message $result[1]=The index of the body text message $result[2 through n]=Parameters passed to body text message. Please note the header message cannot receive/use parameters. 'ImportHandleLogItemXMLTag':When parsing a XML tag in a log item. $reader:XMLReader object $logInfo:Array of information Return false to stop further processing of the tag 'ImportHandlePageXMLTag':When parsing a XML tag in a page. $reader:XMLReader object $pageInfo:Array of information Return false to stop further processing of the tag 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information Return false to stop further processing of the tag 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. $reader:XMLReader object Return false to stop further processing of the tag 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. $reader:XMLReader object $revisionInfo:Array of information Return false to stop further processing of the tag 'InfoAction':When building information to display on the action=info page. $context:IContextSource object & $pageInfo:Array of information 'InitializeArticleMaybeRedirect':MediaWiki check to see if title is a redirect. $title:Title object for the current page $request:WebRequest $ignoreRedirect:boolean to skip redirect check $target:Title/string of redirect target $article:Article object 'InterwikiLoadPrefix':When resolving if a given prefix is an interwiki or not. Return true without providing an interwiki to continue interwiki search. $prefix:interwiki prefix we are looking for. & $iwData:output array describing the interwiki with keys iw_url, iw_local, iw_trans and optionally iw_api and iw_wikiid. 'InternalParseBeforeSanitize':during Parser 's internalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings. Ideal for syntax-extensions after template/parser function execution which respect nowiki and HTML-comments. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InternalParseBeforeLinks':during Parser 's internalParse method before links but after nowiki/noinclude/includeonly/onlyinclude and other processings. & $parser:Parser object & $text:string containing partially parsed text & $stripState:Parser 's internal StripState object 'InvalidateEmailComplete':Called after a user 's email has been invalidated successfully. $user:user(object) whose email is being invalidated 'IRCLineURL':When constructing the URL to use in an IRC notification. Callee may modify $url and $query, URL will be constructed as $url . $query & $url:URL to index.php & $query:Query string $rc:RecentChange object that triggered url generation 'IsFileCacheable':Override the result of Article::isFileCacheable()(if true) $article:article(object) being checked 'IsTrustedProxy':Override the result of wfIsTrustedProxy() $ip:IP being check $result:Change this value to override the result of wfIsTrustedProxy() 'IsUploadAllowedFromUrl':Override the result of UploadFromUrl::isAllowedUrl() $url:URL used to upload from & $allowed:Boolean indicating if uploading is allowed for given URL 'isValidEmailAddr':Override the result of User::isValidEmailAddr(), for instance to return false if the domain name doesn 't match your organization. $addr:The e-mail address entered by the user & $result:Set this and return false to override the internal checks 'isValidPassword':Override the result of User::isValidPassword() $password:The password entered by the user & $result:Set this and return false to override the internal checks $user:User the password is being validated for 'Language::getMessagesFileName':$code:The language code or the language we 're looking for a messages file for & $file:The messages file path, you can override this to change the location. 'LanguageGetNamespaces':Provide custom ordering for namespaces or remove namespaces. Do not use this hook to add namespaces. Use CanonicalNamespaces for that. & $namespaces:Array of namespaces indexed by their numbers 'LanguageGetMagic':DEPRECATED, use $magicWords in a file listed in $wgExtensionMessagesFiles instead. Use this to define synonyms of magic words depending of the language $magicExtensions:associative array of magic words synonyms $lang:language code(string) 'LanguageGetSpecialPageAliases':DEPRECATED, use $specialPageAliases in a file listed in $wgExtensionMessagesFiles instead. Use to define aliases of special pages names depending of the language $specialPageAliases:associative array of magic words synonyms $lang:language code(string) 'LanguageGetTranslatedLanguageNames':Provide translated language names. & $names:array of language code=> language name $code language of the preferred translations 'LanguageLinks':Manipulate a page 's language links. This is called in various places to allow extensions to define the effective language links for a page. $title:The page 's Title. & $links:Associative array mapping language codes to prefixed links of the form "language:title". & $linkFlags:Associative array mapping prefixed links to arrays of flags. Currently unused, but planned to provide support for marking individual language links in the UI, e.g. for featured articles. 'LinkBegin':Used when generating internal and interwiki links in Linker::link(), before processing starts. Return false to skip default processing and return $ret. See documentation for Linker::link() for details on the expected meanings of parameters. $skin:the Skin object $target:the Title that the link is pointing to & $html:the contents that the< a > tag should have(raw HTML) $result
wfResetOutputBuffers( $resetGzipEncoding=true)
Clear away any user-level output buffers, discarding contents.
static minify( $css)
Removes whitespace from CSS data.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
static makeConfigSetScript(array $configuration)
Returns JS code which will set the MediaWiki configuration array to the given value.
isCacheGood( $timestamp='')
Check if up to date cache file exists.
static formatException( $e)
Handle exception display.
We use the convention $dbr for read and $dbw for write to help you keep track of whether the database object is a the world will explode Or to be a subsequent write query which succeeded on the master may fail when replicated to the slave due to a unique key collision Replication on the slave will stop and it may take hours to repair the database and get it back online Setting read_only in my cnf on the slave will avoid this but given the dire we prefer to have as many checks as possible We provide a but the wrapper functions like please read the documentation for except in special pages derived from QueryPage It s a common pitfall for new developers to submit code containing SQL queries which examine huge numbers of rows Remember that COUNT * is(N), counting rows in atable is like counting beans in a bucket.------------------------------------------------------------------------ Replication------------------------------------------------------------------------The largest installation of MediaWiki, Wikimedia, uses a large set ofslave MySQL servers replicating writes made to a master MySQL server. Itis important to understand the issues associated with this setup if youwant to write code destined for Wikipedia.It 's often the case that the best algorithm to use for a given taskdepends on whether or not replication is in use. Due to our unabashedWikipedia-centrism, we often just use the replication-friendly version, but if you like, you can use wfGetLB() ->getServerCount() > 1 tocheck to see if replication is in use.===Lag===Lag primarily occurs when large write queries are sent to the master.Writes on the master are executed in parallel, but they are executed inserial when they are replicated to the slaves. The master writes thequery to the binlog when the transaction is committed. The slaves pollthe binlog and start executing the query as soon as it appears. They canservice reads while they are performing a write query, but will not readanything more from the binlog and thus will perform no more writes. Thismeans that if the write query runs for a long time, the slaves will lagbehind the master for the time it takes for the write query to complete.Lag can be exacerbated by high read load. MediaWiki 's load balancer willstop sending reads to a slave when it is lagged by more than 30 seconds.If the load ratios are set incorrectly, or if there is too much loadgenerally, this may lead to a slave permanently hovering around 30seconds lag.If all slaves are lagged by more than 30 seconds, MediaWiki will stopwriting to the database. All edits and other write operations will berefused, with an error returned to the user. This gives the slaves achance to catch up. Before we had this mechanism, the slaves wouldregularly lag by several minutes, making review of recent editsdifficult.In addition to this, MediaWiki attempts to ensure that the user seesevents occurring on the wiki in chronological order. A few seconds of lagcan be tolerated, as long as the user sees a consistent picture fromsubsequent requests. This is done by saving the master binlog positionin the session, and then at the start of each request, waiting for theslave to catch up to that position before doing any reads from it. Ifthis wait times out, reads are allowed anyway, but the request isconsidered to be in "lagged slave mode". Lagged slave mode can bechecked by calling wfGetLB() ->getLaggedSlaveMode(). The onlypractical consequence at present is a warning displayed in the pagefooter.===Lag avoidance===To avoid excessive lag, queries which write large numbers of rows shouldbe split up, generally to write one row at a time. Multi-row INSERT ...SELECT queries are the worst offenders should be avoided altogether.Instead do the select first and then the insert.===Working with lag===Despite our best efforts, it 's not practical to guarantee a low-lagenvironment. Lag will usually be less than one second, but mayoccasionally be up to 30 seconds. For scalability, it 's very importantto keep load on the master low, so simply sending all your queries tothe master is not the answer. So when you have a genuine need forup-to-date data, the following approach is advised:1) Do a quick query to the master for a sequence number or timestamp 2) Run the full query on the slave and check if it matches the data you gotfrom the master 3) If it doesn 't, run the full query on the masterTo avoid swamping the master every time the slaves lag, use of thisapproach should be kept to a minimum. In most cases you should just readfrom the slave and let the user deal with the delay.------------------------------------------------------------------------ Lock contention------------------------------------------------------------------------Due to the high write rate on Wikipedia(and some other wikis), MediaWiki developers need to be very careful to structure their writesto avoid long-lasting locks. By default, MediaWiki opens a transactionat the first query, and commits it before the output is sent. Locks willbe held from the time when the query is done until the commit. So youcan reduce lock time by doing as much processing as possible before youdo your write queries.Often this approach is not good enough, and it becomes necessary toenclose small groups of queries in their own transaction. Use thefollowing syntax:$dbw=wfGetDB(DB_MASTER
static makeLoaderImplementScript( $name, $scripts, $styles, $messages)
Return JS code that calls mw.loader.implement with given module properties.
static makeLoaderSourcesScript( $id, $properties=null)
Returns JS code which calls mw.loader.addSource() with the given parameters.
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
static makePackedModulesString( $modules)
Convert an array of module names to a packed query string.
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
wfDebugLog( $logGroup, $text, $dest='all')
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfProfileIn( $functionname)
Begin profiling of a function.
static minify( $s, $statementsOnOwnLine=false, $maxLineLength=1000)
Returns minified JavaScript code.
sendResponseHeaders(ResourceLoaderContext $context, $mtime, $errors)
Send content type and last modified headers to the client.
wfGetCache( $inputType)
Get a cache object.
static $filterCacheVersion
array $moduleInfos
Associative array mapping module name to info associative array.
static transformCssMedia( $media)
Transform "media" attribute based on request parameters.
makeModuleResponse(ResourceLoaderContext $context, array $modules, array $missing=array())
Generate code for a response.
ResourceLoader module based on local JavaScript/CSS files.
preloadModuleInfo(array $modules, ResourceLoaderContext $context)
Load information stored in the database about modules.
static makeLoaderQuery( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a query array (array representation of query string) for load.php.
wfAppendQuery( $url, $query)
Append a query string to an existing URL, which may or may not already have query string parameters a...
A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to interpret a given string a...
static makeLoaderRegisterScript( $name, $version=null, $dependencies=null, $group=null, $source=null)
Returns JS code which calls mw.loader.register with the given parameters.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
wfMemcKey()
Get a cache key.
static get(ResourceLoader $resourceLoader, $modules, $lang)
Get the message blobs for a set of modules.
wfScript( $script='index')
Get the path to a specified script file, respecting file extensions; this is a wrapper around $wgScri...
wfIncrStats( $key, $count=1)
Increment a statistics counter.
static makeLoaderStateScript( $name, $state=null)
Returns a JS call to mw.loader.state, which sets the state of a module or modules to a given value.
wfProfileOut( $functionname='missing')
Stop profiling of a function.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
wfRunHooks( $event, array $args=array(), $deprecatedVersion=null)
Call hook functions defined in $wgHooks.
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
static makeComment( $text)
Generate a CSS or JS comment block.
when a variable name is used in a it is silently declared as a new masking the global
static makeLoaderURL( $modules, $lang, $skin, $user=null, $version=null, $debug=false, $only=null, $printable=false, $handheld=false, $extraQuery=array())
Build a load.php URL.
fetchText()
Get the uncompressed text from the cache.
const TS_MW
MediaWiki concatenated string timestamp (YYYYMMDDHHMMSS)
getModule( $name)
Get the ResourceLoaderModule object for a given module name.
static useFileCache(ResourceLoaderContext $context)
Check if an RL request can be cached.
Allows to change the fields on the form that will be generated $name
tryRespondFromFileCache(ResourceFileCache $fileCache, ResourceLoaderContext $context)
Send out code for a response from file cache if possible.
static getLESSVars()
Get global LESS variables.
static makeCombinedStyles(array $stylePairs)
Combines an associative array mapping media type to CSS into a single stylesheet with "@media" blocks...
array $testModuleNames
Associative array mapping framework ids to a list of names of test suite modules like array( 'qunit' ...
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going and make changes or fix bugs In addition
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned $skin
static getLessCompiler()
Returns LESS compiler set up for use with MediaWiki.
=Architecture==Two class hierarchies are used to provide the functionality associated with the different content models:*Content interface(and AbstractContent base class) define functionality that acts on the concrete content of a page, and *ContentHandler base class provides functionality specific to a content model, but not acting on concrete content. The most important function of ContentHandler is to act as a factory for the appropriate implementation of Content. These Content objects are to be used by MediaWiki everywhere, instead of passing page content around as text. All manipulation and analysis of page content must be done via the appropriate methods of the Content object. For each content model, a subclass of ContentHandler has to be registered with $wgContentHandlers. The ContentHandler object for a given content model can be obtained using ContentHandler::getForModelID($id). Also Title, WikiPage and Revision now have getContentHandler() methods for convenience. ContentHandler objects are singletons that provide functionality specific to the content type, but not directly acting on the content of some page. ContentHandler::makeEmptyContent() and ContentHandler::unserializeContent() can be used to create a Content object of the appropriate type. However, it is recommended to instead use WikiPage::getContent() resp. Revision::getContent() to get a page 's content as a Content object. These two methods should be the ONLY way in which page content is accessed. Another important function of ContentHandler objects is to define custom action handlers for a content model, see ContentHandler::getActionOverrides(). This is similar to what WikiPage::getActionOverrides() was already doing.==Serialization==With the ContentHandler facility, page content no longer has to be text based. Objects implementing the Content interface are used to represent and handle the content internally. For storage and data exchange, each content model supports at least one serialization format via ContentHandler::serializeContent($content). The list of supported formats for a given content model can be accessed using ContentHandler::getSupportedFormats(). Content serialization formats are identified using MIME type like strings. The following formats are built in:*text/x-wiki - wikitext *text/javascript - for js pages *text/css - for css pages *text/plain - for future use, e.g. with plain text messages. *text/html - for future use, e.g. with plain html messages. *application/vnd.php.serialized - for future use with the api and for extensions *application/json - for future use with the api, and for use by extensions *application/xml - for future use with the api, and for use by extensions In PHP, use the corresponding CONTENT_FORMAT_XXX constant. Note that when using the API to access page content, especially action=edit, action=parse and action=query &prop=revisions, the model and format of the content should always be handled explicitly. Without that information, interpretation of the provided content is not reliable. The same applies to XML dumps generated via maintenance/dumpBackup.php or Special:Export. Also note that the API will provide encapsulated, serialized content - so if the API was called with format=json, and contentformat is also json(or rather, application/json), the page content is represented as a string containing an escaped json structure. Extensions that use JSON to serialize some types of page content may provide specialized API modules that allow access to that content in a more natural form.==Compatibility==The ContentHandler facility is introduced in a way that should allow all existing code to keep functioning at least for pages that contain wikitext or other text based content. However, a number of functions and hooks have been deprecated in favor of new versions that are aware of the page 's content model, and will now generate warnings when used. Most importantly, the following functions have been deprecated:*Revisions::getText() and Revisions::getRawText() is deprecated in favor Revisions::getContent() *WikiPage::getText() is deprecated in favor WikiPage::getContent() Also, the old Article::getContent()(which returns text) is superceded by Article::getContentObject(). However, both methods should be avoided since they do not provide clean access to the page 's actual content. For instance, they may return a system message for non-existing pages. Use WikiPage::getContent() instead. Code that relies on a textual representation of the page content should eventually be rewritten. However, ContentHandler::getContentText() provides a stop-gap that can be used to get text for a page. Its behavior is controlled by $wgContentHandlerTextFallback it
Abstraction for resource loader modules, with name registration and maxage functionality.
Dynamic JavaScript and CSS resource loading system.
filter( $filter, $data)
Run JavaScript or CSS data through a filter, caching the filtered result for future calls.
static inDebugMode()
Determine whether debug mode was requested Order of priority is 1) request param, 2) cookie,...
We ve cleaned up the code here by removing clumps of infrequently used code and moving them off somewhere else It s much easier for someone working with this code to see what s _really_ going on
__construct()
Register core modules and runs registration hooks.
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
static $requiredSourceProperties
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
static makeMessageSetScript( $messages)
Returns JS code which, when called, will register a given list of messages.
tryRespondLastModified(ResourceLoaderContext $context, $mtime)
Respond with 304 Last Modified if appropiate.
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify source
if(PHP_SAPI !='cli') $source
static logException(Exception $e)
Log an exception to the exception log (if enabled).
addSource( $id, $properties=null)
Add a foreign source of modules.
static makeCustomLoaderScript( $name, $version, $dependencies, $group, $source, $script)
Returns JS code which calls the script given by $script.
lessphp v0.4.0@2cc77e3c7b http://leafo.net/lessphp
and how to run hooks for an and one after Each event has a preferably in CamelCase For ArticleDelete hook A clump of code and data that should be run when an event happens This can be either a function and a chunk of or an object and a method hook function The function part of a third party developers and administrators to define code that will be run at certain points in the mainline code
return true to allow those checks to and false if checking is done use this to change the tables headers temp or archived zone change it to an object instance and return false override the list derivative used the name of the old file when set the default code will be skipped add a value to it if you want to add a cookie that have to vary cache options can modify $query
Resource loader request result caching in the file system.
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account incomplete not yet checked for validity & $retval
const TS_RFC2822
RFC 2822 format, for E-mail and HTTP headers.
static isValidModuleName( $moduleName)
Check a module name for validity.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
cacheTimestamp()
Get the last-modified timestamp of the cache file.