summaryrefslogtreecommitdiff
blob: 54bb73aea04b45a0b21ea55830c52e9bb146867b (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
<?php
declare( strict_types = 1 );

/**
 * Message group for MediaWiki extensions.
 * @author Niklas Laxström
 * @license GPL-2.0-or-later
 * @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.
	 * @param IContextSource|null $context
	 * @return string
	 */
	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 ( (string)$desc === '' ) {
				$desc = $this->getMessage( $msgkey, $this->getSourceLanguage() );
			}
		}

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

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

		return $desc;
	}
}