MediaWiki REL1_28
SVG.php
Go to the documentation of this file.
1<?php
23use Wikimedia\ScopedCallback;
24
30class SvgHandler extends ImageHandler {
32
37 private static $metaConversion = [
38 'originalwidth' => 'ImageWidth',
39 'originalheight' => 'ImageLength',
40 'description' => 'ImageDescription',
41 'title' => 'ObjectName',
42 ];
43
44 function isEnabled() {
46 if ( !isset( $wgSVGConverters[$wgSVGConverter] ) ) {
47 wfDebug( "\$wgSVGConverter is invalid, disabling SVG rendering.\n" );
48
49 return false;
50 } else {
51 return true;
52 }
53 }
54
55 public function mustRender( $file ) {
56 return true;
57 }
58
59 function isVectorized( $file ) {
60 return true;
61 }
62
67 function isAnimatedImage( $file ) {
68 # @todo Detect animated SVGs
69 $metadata = $file->getMetadata();
70 if ( $metadata ) {
71 $metadata = $this->unpackMetadata( $metadata );
72 if ( isset( $metadata['animated'] ) ) {
73 return $metadata['animated'];
74 }
75 }
76
77 return false;
78 }
79
92 public function getAvailableLanguages( File $file ) {
93 $metadata = $file->getMetadata();
94 $langList = [];
95 if ( $metadata ) {
96 $metadata = $this->unpackMetadata( $metadata );
97 if ( isset( $metadata['translations'] ) ) {
98 foreach ( $metadata['translations'] as $lang => $langType ) {
99 if ( $langType === SVGReader::LANG_FULL_MATCH ) {
100 $langList[] = $lang;
101 }
102 }
103 }
104 }
105 return $langList;
106 }
107
114 public function getDefaultRenderLanguage( File $file ) {
115 return 'en';
116 }
117
123 function canAnimateThumbnail( $file ) {
124 return false;
125 }
126
134 if ( !parent::normaliseParams( $image, $params ) ) {
135 return false;
136 }
137 # Don't make an image bigger than wgMaxSVGSize on the smaller side
138 if ( $params['physicalWidth'] <= $params['physicalHeight'] ) {
139 if ( $params['physicalWidth'] > $wgSVGMaxSize ) {
140 $srcWidth = $image->getWidth( $params['page'] );
141 $srcHeight = $image->getHeight( $params['page'] );
142 $params['physicalWidth'] = $wgSVGMaxSize;
143 $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight, $wgSVGMaxSize );
144 }
145 } else {
146 if ( $params['physicalHeight'] > $wgSVGMaxSize ) {
147 $srcWidth = $image->getWidth( $params['page'] );
148 $srcHeight = $image->getHeight( $params['page'] );
149 $params['physicalWidth'] = File::scaleHeight( $srcHeight, $srcWidth, $wgSVGMaxSize );
150 $params['physicalHeight'] = $wgSVGMaxSize;
151 }
152 }
153
154 return true;
155 }
156
165 function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) {
166 if ( !$this->normaliseParams( $image, $params ) ) {
167 return new TransformParameterError( $params );
168 }
169 $clientWidth = $params['width'];
170 $clientHeight = $params['height'];
171 $physicalWidth = $params['physicalWidth'];
172 $physicalHeight = $params['physicalHeight'];
173 $lang = isset( $params['lang'] ) ? $params['lang'] : $this->getDefaultRenderLanguage( $image );
174
175 if ( $flags & self::TRANSFORM_LATER ) {
176 return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
177 }
178
179 $metadata = $this->unpackMetadata( $image->getMetadata() );
180 if ( isset( $metadata['error'] ) ) { // sanity check
181 $err = wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
182
183 return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight, $err );
184 }
185
186 if ( !wfMkdirParents( dirname( $dstPath ), null, __METHOD__ ) ) {
187 return new MediaTransformError( 'thumbnail_error', $clientWidth, $clientHeight,
188 wfMessage( 'thumbnail_dest_directory' )->text() );
189 }
190
191 $srcPath = $image->getLocalRefPath();
192 if ( $srcPath === false ) { // Failed to get local copy
193 wfDebugLog( 'thumbnail',
194 sprintf( 'Thumbnail failed on %s: could not get local copy of "%s"',
195 wfHostname(), $image->getName() ) );
196
197 return new MediaTransformError( 'thumbnail_error',
198 $params['width'], $params['height'],
199 wfMessage( 'filemissing' )->text()
200 );
201 }
202
203 // Make a temp dir with a symlink to the local copy in it.
204 // This plays well with rsvg-convert policy for external entities.
205 // https://git.gnome.org/browse/librsvg/commit/?id=f01aded72c38f0e18bc7ff67dee800e380251c8e
206 $tmpDir = wfTempDir() . '/svg_' . wfRandomString( 24 );
207 $lnPath = "$tmpDir/" . basename( $srcPath );
208 $ok = mkdir( $tmpDir, 0771 ) && symlink( $srcPath, $lnPath );
210 $cleaner = new ScopedCallback( function () use ( $tmpDir, $lnPath ) {
211 MediaWiki\suppressWarnings();
212 unlink( $lnPath );
213 rmdir( $tmpDir );
214 MediaWiki\restoreWarnings();
215 } );
216 if ( !$ok ) {
217 wfDebugLog( 'thumbnail',
218 sprintf( 'Thumbnail failed on %s: could not link %s to %s',
219 wfHostname(), $lnPath, $srcPath ) );
220 return new MediaTransformError( 'thumbnail_error',
221 $params['width'], $params['height'],
222 wfMessage( 'thumbnail-temp-create' )->text()
223 );
224 }
225
226 $status = $this->rasterize( $lnPath, $dstPath, $physicalWidth, $physicalHeight, $lang );
227 if ( $status === true ) {
228 return new ThumbnailImage( $image, $dstUrl, $dstPath, $params );
229 } else {
230 return $status; // MediaTransformError
231 }
232 }
233
245 public function rasterize( $srcPath, $dstPath, $width, $height, $lang = false ) {
247 $err = false;
248 $retval = '';
249 if ( isset( $wgSVGConverters[$wgSVGConverter] ) ) {
250 if ( is_array( $wgSVGConverters[$wgSVGConverter] ) ) {
251 // This is a PHP callable
253 $args = array_merge( [ $srcPath, $dstPath, $width, $height, $lang ],
254 array_slice( $wgSVGConverters[$wgSVGConverter], 1 ) );
255 if ( !is_callable( $func ) ) {
256 throw new MWException( "$func is not callable" );
257 }
258 $err = call_user_func_array( $func, $args );
259 $retval = (bool)$err;
260 } else {
261 // External command
262 $cmd = str_replace(
263 [ '$path/', '$width', '$height', '$input', '$output' ],
264 [ $wgSVGConverterPath ? wfEscapeShellArg( "$wgSVGConverterPath/" ) : "",
265 intval( $width ),
266 intval( $height ),
267 wfEscapeShellArg( $srcPath ),
268 wfEscapeShellArg( $dstPath ) ],
270 );
271
272 $env = [];
273 if ( $lang !== false ) {
274 $env['LANG'] = $lang;
275 }
276
277 wfDebug( __METHOD__ . ": $cmd\n" );
278 $err = wfShellExecWithStderr( $cmd, $retval, $env );
279 }
280 }
281 $removed = $this->removeBadFile( $dstPath, $retval );
282 if ( $retval != 0 || $removed ) {
283 $this->logErrorForExternalProcess( $retval, $err, $cmd );
284 return new MediaTransformError( 'thumbnail_error', $width, $height, $err );
285 }
286
287 return true;
288 }
289
290 public static function rasterizeImagickExt( $srcPath, $dstPath, $width, $height ) {
291 $im = new Imagick( $srcPath );
292 $im->setImageFormat( 'png' );
293 $im->setBackgroundColor( 'transparent' );
294 $im->setImageDepth( 8 );
295
296 if ( !$im->thumbnailImage( intval( $width ), intval( $height ), /* fit */ false ) ) {
297 return 'Could not resize image';
298 }
299 if ( !$im->writeImage( $dstPath ) ) {
300 return "Could not write to $dstPath";
301 }
302 }
303
310 function getImageSize( $file, $path, $metadata = false ) {
311 if ( $metadata === false && $file instanceof File ) {
312 $metadata = $file->getMetadata();
313 }
314 $metadata = $this->unpackMetadata( $metadata );
315
316 if ( isset( $metadata['width'] ) && isset( $metadata['height'] ) ) {
317 return [ $metadata['width'], $metadata['height'], 'SVG',
318 "width=\"{$metadata['width']}\" height=\"{$metadata['height']}\"" ];
319 } else { // error
320 return [ 0, 0, 'SVG', "width=\"0\" height=\"0\"" ];
321 }
322 }
323
324 function getThumbType( $ext, $mime, $params = null ) {
325 return [ 'png', 'image/png' ];
326 }
327
337 function getLongDesc( $file ) {
339
340 $metadata = $this->unpackMetadata( $file->getMetadata() );
341 if ( isset( $metadata['error'] ) ) {
342 return wfMessage( 'svg-long-error', $metadata['error']['message'] )->text();
343 }
344
345 $size = $wgLang->formatSize( $file->getSize() );
346
347 if ( $this->isAnimatedImage( $file ) ) {
348 $msg = wfMessage( 'svg-long-desc-animated' );
349 } else {
350 $msg = wfMessage( 'svg-long-desc' );
351 }
352
353 $msg->numParams( $file->getWidth(), $file->getHeight() )->params( $size );
354
355 return $msg->parse();
356 }
357
363 function getMetadata( $file, $filename ) {
364 $metadata = [ 'version' => self::SVG_METADATA_VERSION ];
365 try {
366 $metadata += SVGMetadataExtractor::getMetadata( $filename );
367 } catch ( Exception $e ) { // @todo SVG specific exceptions
368 // File not found, broken, etc.
369 $metadata['error'] = [
370 'message' => $e->getMessage(),
371 'code' => $e->getCode()
372 ];
373 wfDebug( __METHOD__ . ': ' . $e->getMessage() . "\n" );
374 }
375
376 return serialize( $metadata );
377 }
378
379 function unpackMetadata( $metadata ) {
380 MediaWiki\suppressWarnings();
381 $unser = unserialize( $metadata );
382 MediaWiki\restoreWarnings();
383 if ( isset( $unser['version'] ) && $unser['version'] == self::SVG_METADATA_VERSION ) {
384 return $unser;
385 } else {
386 return false;
387 }
388 }
389
391 return 'parsed-svg';
392 }
393
394 function isMetadataValid( $image, $metadata ) {
395 $meta = $this->unpackMetadata( $metadata );
396 if ( $meta === false ) {
397 return self::METADATA_BAD;
398 }
399 if ( !isset( $meta['originalWidth'] ) ) {
400 // Old but compatible
402 }
403
404 return self::METADATA_GOOD;
405 }
406
407 protected function visibleMetadataFields() {
408 $fields = [ 'objectname', 'imagedescription' ];
409
410 return $fields;
411 }
412
418 function formatMetadata( $file, $context = false ) {
419 $result = [
420 'visible' => [],
421 'collapsed' => []
422 ];
423 $metadata = $file->getMetadata();
424 if ( !$metadata ) {
425 return false;
426 }
427 $metadata = $this->unpackMetadata( $metadata );
428 if ( !$metadata || isset( $metadata['error'] ) ) {
429 return false;
430 }
431
432 /* @todo Add a formatter
433 $format = new FormatSVG( $metadata );
434 $formatted = $format->getFormattedData();
435 */
436
437 // Sort fields into visible and collapsed
438 $visibleFields = $this->visibleMetadataFields();
439
440 $showMeta = false;
441 foreach ( $metadata as $name => $value ) {
442 $tag = strtolower( $name );
443 if ( isset( self::$metaConversion[$tag] ) ) {
444 $tag = strtolower( self::$metaConversion[$tag] );
445 } else {
446 // Do not output other metadata not in list
447 continue;
448 }
449 $showMeta = true;
451 in_array( $tag, $visibleFields ) ? 'visible' : 'collapsed',
452 'exif',
453 $tag,
454 $value
455 );
456 }
457
458 return $showMeta ? $result : false;
459 }
460
466 public function validateParam( $name, $value ) {
467 if ( in_array( $name, [ 'width', 'height' ] ) ) {
468 // Reject negative heights, widths
469 return ( $value > 0 );
470 } elseif ( $name == 'lang' ) {
471 // Validate $code
472 if ( $value === '' || !Language::isValidBuiltInCode( $value ) ) {
473 wfDebug( "Invalid user language code\n" );
474
475 return false;
476 }
477
478 return true;
479 }
480
481 // Only lang, width and height are acceptable keys
482 return false;
483 }
484
489 public function makeParamString( $params ) {
490 $lang = '';
491 if ( isset( $params['lang'] ) && $params['lang'] !== 'en' ) {
492 $params['lang'] = strtolower( $params['lang'] );
493 $lang = "lang{$params['lang']}-";
494 }
495 if ( !isset( $params['width'] ) ) {
496 return false;
497 }
498
499 return "$lang{$params['width']}px";
500 }
501
502 public function parseParamString( $str ) {
503 $m = false;
504 if ( preg_match( '/^lang([a-z]+(?:-[a-z]+)*)-(\d+)px$/', $str, $m ) ) {
505 return [ 'width' => array_pop( $m ), 'lang' => $m[1] ];
506 } elseif ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
507 return [ 'width' => $m[1], 'lang' => 'en' ];
508 } else {
509 return false;
510 }
511 }
512
513 public function getParamMap() {
514 return [ 'img_lang' => 'lang', 'img_width' => 'width' ];
515 }
516
522 $scriptParams = [ 'width' => $params['width'] ];
523 if ( isset( $params['lang'] ) ) {
524 $scriptParams['lang'] = $params['lang'];
525 }
526
527 return $scriptParams;
528 }
529
530 public function getCommonMetaArray( File $file ) {
531 $metadata = $file->getMetadata();
532 if ( !$metadata ) {
533 return [];
534 }
535 $metadata = $this->unpackMetadata( $metadata );
536 if ( !$metadata || isset( $metadata['error'] ) ) {
537 return [];
538 }
539 $stdMetadata = [];
540 foreach ( $metadata as $name => $value ) {
541 $tag = strtolower( $name );
542 if ( $tag === 'originalwidth' || $tag === 'originalheight' ) {
543 // Skip these. In the exif metadata stuff, it is assumed these
544 // are measured in px, which is not the case here.
545 continue;
546 }
547 if ( isset( self::$metaConversion[$tag] ) ) {
548 $tag = self::$metaConversion[$tag];
549 $stdMetadata[$tag] = $value;
550 }
551 }
552
553 return $stdMetadata;
554 }
555}
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
serialize()
unserialize( $serialized)
$wgSVGConverter
Pick a converter defined in $wgSVGConverters.
$wgSVGMaxSize
Don't scale a SVG larger than this.
$wgSVGConverterPath
If not in the executable PATH, specify the SVG converter path.
$wgSVGConverters
Scalable Vector Graphics (SVG) may be uploaded as images.
wfDebug( $text, $dest='all', array $context=[])
Sends a line to the debug log if enabled or, optionally, to a comment in output.
wfTempDir()
Tries to get the system directory for temporary files.
wfRandomString( $length=32)
Get a random string containing a number of pseudo-random hex characters.
wfHostname()
Fetch server name for use in error reporting etc.
wfEscapeShellArg()
Version of escapeshellarg() that works better on Windows.
wfShellExecWithStderr( $cmd, &$retval=null, $environ=[], $limits=[])
Execute a shell command, returning both stdout and stderr.
wfDebugLog( $logGroup, $text, $dest='all', array $context=[])
Send a line to a supplementary debug log file, if configured, or main debug log if not.
wfMkdirParents( $dir, $mode=null, $caller=null)
Make directory, and make all parent directories if they don't exist.
if( $line===false) $args
Definition cdb.php:64
Implements some public methods and some protected utility functions which are required by multiple ch...
Definition File.php:50
static scaleHeight( $srcWidth, $srcHeight, $dstWidth)
Calculate the height of a thumbnail using the source and destination width.
Definition File.php:1989
getMetadata()
Get handler-specific metadata Overridden by LocalFile, UnregisteredLocalFile STUB.
Definition File.php:638
Media handler abstract base class for images.
MediaWiki exception.
const METADATA_COMPATIBLE
static addMeta(&$array, $visibility, $type, $id, $value, $param=false)
This is used to generate an array element for each metadata value That array is then used to generate...
logErrorForExternalProcess( $retval, $err, $cmd)
Log an error that occurred in an external process.
const METADATA_GOOD
removeBadFile( $dstPath, $retval=0)
Check for zero-sized thumbnails.
Basic media transform error class.
static getMetadata( $filename)
Handler for SVG images.
Definition SVG.php:30
validateParam( $name, $value)
Definition SVG.php:466
isVectorized( $file)
The material is vectorized and thus scaling is lossless.
Definition SVG.php:59
normaliseParams( $image, &$params)
Definition SVG.php:132
formatMetadata( $file, $context=false)
Definition SVG.php:418
parseParamString( $str)
Parse a param string made with makeParamString back into an array.
Definition SVG.php:502
getMetadata( $file, $filename)
Definition SVG.php:363
mustRender( $file)
True if handled types cannot be displayed directly in a browser but can be rendered.
Definition SVG.php:55
getScriptParams( $params)
Definition SVG.php:521
makeParamString( $params)
Definition SVG.php:489
getCommonMetaArray(File $file)
Get an array of standard (FormatMetadata type) metadata values.
Definition SVG.php:530
unpackMetadata( $metadata)
Definition SVG.php:379
static array $metaConversion
A list of metadata tags that can be converted to the commonly used exif tags.
Definition SVG.php:37
doTransform( $image, $dstPath, $dstUrl, $params, $flags=0)
Definition SVG.php:165
getImageSize( $file, $path, $metadata=false)
Definition SVG.php:310
getAvailableLanguages(File $file)
Which languages (systemLanguage attribute) is supported.
Definition SVG.php:92
getLongDesc( $file)
Subtitle for the image.
Definition SVG.php:337
getMetadataType( $image)
Get a string describing the type of metadata, for display purposes.
Definition SVG.php:390
getThumbType( $ext, $mime, $params=null)
Get the thumbnail extension and MIME type for a given source MIME type.
Definition SVG.php:324
getDefaultRenderLanguage(File $file)
What language to render file in if none selected.
Definition SVG.php:114
rasterize( $srcPath, $dstPath, $width, $height, $lang=false)
Transform an SVG file to PNG This function can be called outside of thumbnail contexts.
Definition SVG.php:245
isEnabled()
False if the handler is disabled for all files.
Definition SVG.php:44
canAnimateThumbnail( $file)
We do not support making animated svg thumbnails.
Definition SVG.php:123
visibleMetadataFields()
Get a list of metadata items which should be displayed when the metadata table is collapsed.
Definition SVG.php:407
static rasterizeImagickExt( $srcPath, $dstPath, $width, $height)
Definition SVG.php:290
isAnimatedImage( $file)
Definition SVG.php:67
const SVG_METADATA_VERSION
Definition SVG.php:31
isMetadataValid( $image, $metadata)
Check if the metadata string is valid for this handler.
Definition SVG.php:394
getParamMap()
Get an associative array mapping magic word IDs to parameter names.
Definition SVG.php:513
Media transform output for images.
Shortcut class for parameter validation errors.
when a variable name is used in a it is silently declared as a new local masking the global
Definition design.txt:95
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
Definition design.txt:18
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as $wgLang
Definition design.txt:56
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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 $status
Definition hooks.txt:1049
the array() calling protocol came about after MediaWiki 1.4rc1.
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. Return false to stop further processing of the tag $reader:XMLReader object $logInfo:Array of information 'ImportHandlePageXMLTag':When parsing a XML tag in a page. Return false to stop further processing of the tag $reader:XMLReader object & $pageInfo:Array of information 'ImportHandleRevisionXMLTag':When parsing a XML tag in a page revision. Return false to stop further processing of the tag $reader:XMLReader object $pageInfo:Array of page information $revisionInfo:Array of revision information 'ImportHandleToplevelXMLTag':When parsing a top level XML tag. Return false to stop further processing of the tag $reader:XMLReader object 'ImportHandleUploadXMLTag':When parsing a XML tag in a file upload. Return false to stop further processing of the tag $reader:XMLReader object $revisionInfo:Array of information 'ImportLogInterwikiLink':Hook to change the interwiki link used in log entries and edit summaries for transwiki imports. & $fullInterwikiPrefix:Interwiki prefix, may contain colons. & $pageTitle:String that contains page title. 'ImportSources':Called when reading from the $wgImportSources configuration variable. Can be used to lazy-load the import sources list. & $importSources:The value of $wgImportSources. Modify as necessary. See the comment in DefaultSettings.php for the detail of how to structure this array. '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 '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 '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 '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. '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 IP::isTrustedProxy() & $ip:IP being check & $result:Change this value to override the result of IP::isTrustedProxy() '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 Sanitizer::validateEmail(), 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. '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) '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 '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. 'LanguageSelector':Hook to change the language selector available on a page. $out:The output page. $cssClassName:CSS class name of the language selector. 'LinkBegin':DEPRECATED! Use HtmlPageLinkRendererBegin instead. 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
Definition hooks.txt:1937
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 local account incomplete not yet checked for validity & $retval
Definition hooks.txt:268
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 $image
Definition hooks.txt:917
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation 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 "&lt;div ...>$1&lt;/div>"). - flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException':Called before an exception(or PHP error) is logged. This is meant for integration with external error aggregation services
it s the revision text itself In either if gzip is the revision text is gzipped $flags
Definition hooks.txt:2710
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books $tag
Definition hooks.txt:1033
Allows to change the fields on the form that will be generated $name
Definition hooks.txt:304
returning false will NOT prevent logging $e
Definition hooks.txt:2110
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
Definition injection.txt:37
$context
Definition load.php:50
if( $ext=='php'|| $ext=='php5') $mime
Definition router.php:65
$params
if(!isset( $args[0])) $lang