summaryrefslogtreecommitdiff
blob: e44d1d5d3a84b4e36ea897f20d9b29f83a92b2eb (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
 * This file a contains a message group implementation.
 *
 * @file
 * @author Niklas Laxström
 * @license GPL-2.0+
 */

/**
 * Message group for %MediaWiki extensions.
 * @ingroup MessageGroup
 */
class MediaWikiExtensionMessageGroup extends FileBasedMessageGroup {
	/**
	 * MediaWiki extensions all should have key in their i18n files
	 * describing them. This override method implements the logic
	 * to retrieve them. Also URLs are included if available.
	 * Needs the Configure extension.
	 */
	public function getDescription( IContextSource $context = null ) {
		$language = $this->getSourceLanguage();
		if ( $context ) {
			$language = $context->getLanguage()->getCode();
		}

		$msgkey = $this->getFromConf( 'BASIC', 'descriptionmsg' );
		$desc = '';
		if ( $msgkey ) {
			$desc = $this->getMessage( $msgkey, $language );
			if ( strval( $desc ) === '' ) {
				$desc = $this->getMessage( $msgkey, $this->getSourceLanguage() );
			}
		}

		if ( strval( $desc ) === '' ) {
			// That failed, default to 'description'
			$desc = parent::getDescription( $context );
		}

		$url = $this->getFromConf( 'BASIC', 'extensionurl' );
		if ( $url ) {
			$desc .= "\n\n$url";
		}

		return $desc;
	}
}