-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageLoader.body.php
More file actions
35 lines (27 loc) · 1.31 KB
/
ImageLoader.body.php
File metadata and controls
35 lines (27 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
if ( !defined( 'MEDIAWIKI' ) ) die( 'This file is meant to be used by mediawiki.' );
class ImageLoader {
private static function error( $message, $arg = false ) {
return '<strong class="error">'
. wfMessage( 'error-prefix' )->plain()
. ( !$arg ? wfMessage( $message )->plain() : wfMessage( $message, $arg )->plain() )
. '</strong><br />';
}
public static function parserFunction( &$parser, $class = false, $arg = false ) {
global $wgImagePrefix, $wgImageSuffix;
// $parser->disableCache();
if ( !$class )
return self::error( 'no-class' );
// first check the class, otherwise if someone uses {{#image:class{{!}}argument}},
// they get a no-argument error instead of the invalid-image-class error, which is confusing.
// (the class is in this case class|argument, which is obviously not what we want)
if ( !$wgImagePrefix[$class] || !$wgImageSuffix[$class] )
return self::error( 'invalid-class', $class );
if ( !$arg )
return self::error( 'no-argument' );
return $parser->insertStripItem(
'<img src="' . $wgImagePrefix[$class] . htmlspecialchars( $arg ) . $wgImageSuffix[$class] . '"></img>',
$parser->mStripState
);
}
}