Index: trunk/extensions/Translate/groups/mediawiki-defines.txt |
— | — | @@ -555,6 +555,7 @@ |
556 | 556 | magicfile = MathStatFunctions/MathStatFunctions.i18n.magic.php |
557 | 557 | |
558 | 558 | Media Functions |
| 559 | +magicfile = MediaFunctions/MediaFunctions.i18n.magic.php |
559 | 560 | |
560 | 561 | Meta Keywords |
561 | 562 | optional = metakeywords, metadescription |
Index: trunk/extensions/MediaFunctions/LICENCE |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | All rights reserved |
4 | 4 | |
5 | 5 | Redistribution and use in source and binary forms, with or without |
6 | | -modification, are permitted provided that the following conditions |
| 6 | +modification, are permitted provided that the following conditions |
7 | 7 | are met: |
8 | 8 | |
9 | 9 | 1. Redistributions of source code must retain the above copyright |
— | — | @@ -24,4 +24,4 @@ |
25 | 25 | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 | 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR |
27 | 27 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
28 | | -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
\ No newline at end of file |
| 28 | +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Index: trunk/extensions/MediaFunctions/MediaFunctions.class.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | * @return string |
25 | 25 | */ |
26 | 26 | public static function mediamime( $parser, $name = '' ) { |
27 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 27 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
28 | 28 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
29 | 29 | return $file->getMimeType(); |
30 | 30 | } |
— | — | @@ -38,7 +38,7 @@ |
39 | 39 | * @return string |
40 | 40 | */ |
41 | 41 | public static function mediasize( $parser, $name = '' ) { |
42 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 42 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
43 | 43 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
44 | 44 | return $parser->mOptions->getSkin()->formatSize( $file->getSize() ); |
45 | 45 | } |
— | — | @@ -53,7 +53,7 @@ |
54 | 54 | * @return string |
55 | 55 | */ |
56 | 56 | public static function mediaheight( $parser, $name = '' ) { |
57 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 57 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
58 | 58 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
59 | 59 | return $file->getHeight(); |
60 | 60 | } |
— | — | @@ -68,7 +68,7 @@ |
69 | 69 | * @return string |
70 | 70 | */ |
71 | 71 | public static function mediawidth( $parser, $name = '' ) { |
72 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 72 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
73 | 73 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
74 | 74 | return $file->getWidth(); |
75 | 75 | } |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | * @return string |
86 | 86 | */ |
87 | 87 | public static function mediadimensions( $parser, $name = '' ) { |
88 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 88 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
89 | 89 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
90 | 90 | return $file->getDimensionsString(); |
91 | 91 | } |
— | — | @@ -100,11 +100,11 @@ |
101 | 101 | * @return string |
102 | 102 | */ |
103 | 103 | public static function mediaexif( $parser, $name = '', $meta = '' ) { |
104 | | - if( ( $file = self::resolve( $name ) ) instanceof File ) { |
| 104 | + if ( ( $file = self::resolve( $name ) ) instanceof File ) { |
105 | 105 | $parser->mOutput->addImage( $file->getTitle()->getDBkey() ); |
106 | | - if( $meta && $file->getHandler()->getMetadataType( $file ) == 'exif' ) { |
| 106 | + if ( $meta && $file->getHandler()->getMetadataType( $file ) == 'exif' ) { |
107 | 107 | $data = unserialize( $file->getMetadata() ); |
108 | | - if( $data && isset( $data[$meta] ) ) |
| 108 | + if ( $data && isset( $data[$meta] ) ) |
109 | 109 | return htmlspecialchars( $data[$meta] ); |
110 | 110 | } |
111 | 111 | return ''; |
— | — | @@ -123,10 +123,10 @@ |
124 | 124 | * @return mixed File or string |
125 | 125 | */ |
126 | 126 | private static function resolve( $text ) { |
127 | | - if( $text ) { |
| 127 | + if ( $text ) { |
128 | 128 | $title = Title::newFromText( $text ); |
129 | | - if( $title instanceof Title ) { |
130 | | - if( $title->getNamespace() != NS_IMAGE ) |
| 129 | + if ( $title instanceof Title ) { |
| 130 | + if ( $title->getNamespace() != NS_IMAGE ) |
131 | 131 | $title = Title::makeTitle( NS_IMAGE, $title->getText() ); |
132 | 132 | $file = wfFindFile( $title ); |
133 | 133 | return $file instanceof File |
Index: trunk/extensions/MediaFunctions/MediaFunctions.i18n.magic.php |
— | — | @@ -8,42 +8,26 @@ |
9 | 9 | * @version 1.1 |
10 | 10 | */ |
11 | 11 | |
| 12 | +$magicWords = array(); |
| 13 | + |
12 | 14 | /** |
13 | | - * Get translated magic words, if available |
14 | | - * |
15 | | - * @param string $lang Language code |
16 | | - * @return array |
| 15 | + * English |
17 | 16 | */ |
18 | | -function efMediaFunctionsWords( $lang ) { |
19 | | - $words = array(); |
| 17 | +$magicWords['en'] = array( |
| 18 | + 'mediamime' => array( 0, 'mediamime' ), |
| 19 | + 'mediasize' => array( 0, 'mediasize' ), |
| 20 | + 'mediaheight' => array( 0, 'mediaheight' ), |
| 21 | + 'mediawidth' => array( 0, 'mediawidth' ), |
| 22 | + 'mediadimensions' => array( 0, 'mediadimensions' ), |
| 23 | + 'mediaexif' => array( 0, 'mediaexif' ), |
| 24 | +); |
20 | 25 | |
21 | | - /** |
22 | | - * English |
23 | | - */ |
24 | | - $words['en'] = array( |
25 | | - 'mediamime' => array( 0, 'mediamime' ), |
26 | | - 'mediasize' => array( 0, 'mediasize' ), |
27 | | - 'mediaheight' => array( 0, 'mediaheight' ), |
28 | | - 'mediawidth' => array( 0, 'mediawidth' ), |
29 | | - 'mediadimensions' => array( 0, 'mediadimensions' ), |
30 | | - 'mediaexif' => array( 0, 'mediaexif' ), |
31 | | - ); |
32 | | - |
33 | | - /** |
34 | | - * Dutch |
35 | | - */ |
36 | | - $words['nl'] = array( |
37 | | - 'mediamime' => array( 0, 'mediamime' ), |
38 | | - 'mediasize' => array( 0, 'mediagrootte', 'mediasize' ), |
39 | | - 'mediaheight' => array( 0, 'mediahoogte', 'mediaheight' ), |
40 | | - 'mediawidth' => array( 0, 'mediabreedte', 'mediawidth' ), |
41 | | - 'mediadimensions' => array( 0, 'mediaafmetingen', 'mediadimensions' ), |
42 | | - 'mediaexif' => array( 0, 'mediaexif' ), |
43 | | - ); |
44 | | - |
45 | | - # English is used as a fallback, and the English synonyms are |
46 | | - # used if a translation has not been provided for a given word |
47 | | - return ( $lang == 'en' || !isset( $words[$lang] ) ) |
48 | | - ? $words['en'] |
49 | | - : array_merge( $words['en'], $words[$lang] ); |
50 | | -} |
| 26 | +/** |
| 27 | + * Dutch |
| 28 | + */ |
| 29 | +$magicWords['nl'] = array( |
| 30 | + 'mediasize' => array( 0, 'mediagrootte', 'mediasize' ), |
| 31 | + 'mediaheight' => array( 0, 'mediahoogte', 'mediaheight' ), |
| 32 | + 'mediawidth' => array( 0, 'mediabreedte', 'mediawidth' ), |
| 33 | + 'mediadimensions' => array( 0, 'mediaafmetingen', 'mediadimensions' ), |
| 34 | +); |
Index: trunk/extensions/MediaFunctions/MediaFunctions.i18n.php |
— | — | @@ -7,6 +7,8 @@ |
8 | 8 | * @version 1.2 |
9 | 9 | */ |
10 | 10 | |
| 11 | +require_once( dirname( __FILE__ ) . '/MediaFunctions.i18n.magic.php' ); |
| 12 | + |
11 | 13 | $messages = array(); |
12 | 14 | |
13 | 15 | /* English |
Index: trunk/extensions/MediaFunctions/MediaFunctions.php |
— | — | @@ -1,28 +1,27 @@ |
2 | 2 | <?php |
3 | | -if (!defined('MEDIAWIKI')) die(); |
| 3 | +if ( !defined( 'MEDIAWIKI' ) ) die(); |
4 | 4 | /** |
5 | 5 | * Parser functions for MediaWiki providing information |
6 | 6 | * about various media files |
7 | 7 | * |
8 | 8 | * @addtogroup Extensions |
9 | 9 | * @author Rob Church <robchur@gmail.com> |
10 | | - * @version 1.1 |
| 10 | + * @version 1.2 |
11 | 11 | */ |
12 | 12 | |
13 | 13 | $wgExtensionCredits['parserhook'][] = array( |
14 | 14 | 'path' => __FILE__, |
15 | 15 | 'name' => 'MediaFunctions', |
16 | | - 'version' => '1.1', |
| 16 | + 'version' => '1.2', |
17 | 17 | 'author' => 'Rob Church', |
18 | 18 | 'url' => 'http://www.mediawiki.org/wiki/Extension:MediaFunctions', |
19 | 19 | 'description' => 'Parser functions for obtaining information about media files', |
20 | 20 | 'descriptionmsg' => 'mediafunctions-desc', |
21 | 21 | ); |
22 | 22 | |
23 | | -$dir = dirname(__FILE__) . '/'; |
| 23 | +$dir = dirname( __FILE__ ) . '/'; |
24 | 24 | $wgExtensionMessagesFiles['MediaFunctions'] = $dir . 'MediaFunctions.i18n.php'; |
25 | 25 | $wgAutoloadClasses['MediaFunctions'] = $dir . 'MediaFunctions.class.php'; |
26 | | -$wgHooks['LanguageGetMagic'][] = 'efMediaFunctionsGetMagic'; |
27 | 26 | $wgExtensionFunctions[] = 'efMediaFunctionsSetup'; |
28 | 27 | |
29 | 28 | /** |
— | — | @@ -38,17 +37,3 @@ |
39 | 38 | $wgParser->setFunctionHook( 'mediadimensions', array( 'MediaFunctions', 'mediadimensions' ) ); |
40 | 39 | $wgParser->setFunctionHook( 'mediaexif', array( 'MediaFunctions', 'mediaexif' ) ); |
41 | 40 | } |
42 | | - |
43 | | -/** |
44 | | - * Associate magic words with synonyms |
45 | | - * |
46 | | - * @param array $words Magic words |
47 | | - * @param string $lang Language code |
48 | | - * @return bool |
49 | | - */ |
50 | | -function efMediaFunctionsGetMagic( &$words, $lang ) { |
51 | | - require_once( dirname( __FILE__ ) . '/MediaFunctions.i18n.magic.php' ); |
52 | | - foreach( efMediaFunctionsWords( $lang ) as $word => $trans ) |
53 | | - $words[$word] = $trans; |
54 | | - return true; |
55 | | -} |