1 | <?php |
||
16 | class AnnotatedLanguageParserFunction { |
||
17 | |||
18 | /** |
||
19 | * @var InterlanguageLinksLookup |
||
20 | */ |
||
21 | private $interlanguageLinksLookup; |
||
22 | |||
23 | /** |
||
24 | * @since 1.0 |
||
25 | * |
||
26 | * @param InterlanguageLinksLookup $interlanguageLinksLookup |
||
27 | */ |
||
28 | 4 | public function __construct( InterlanguageLinksLookup $interlanguageLinksLookup ) { |
|
29 | 4 | $this->interlanguageLinksLookup = $interlanguageLinksLookup; |
|
30 | 4 | } |
|
31 | |||
32 | /** |
||
33 | * @since 1.0 |
||
34 | * |
||
35 | * @param Title $source |
||
36 | * @param string $template |
||
37 | * |
||
38 | * @return string |
||
39 | */ |
||
40 | 3 | public function parse( Title $source, $template ) { |
|
41 | |||
42 | 3 | $source = $this->interlanguageLinksLookup->getRedirectTargetFor( $source ); |
|
43 | |||
44 | 3 | if ( $source === null ) { |
|
45 | return ''; |
||
46 | } |
||
47 | |||
48 | 3 | $languageCode = $this->interlanguageLinksLookup->findPageLanguageForTarget( $source ); |
|
49 | |||
50 | 3 | if ( $languageCode === '' ) { |
|
51 | 1 | return ''; |
|
52 | } |
||
53 | |||
54 | 2 | if ( $template === '' ) { |
|
55 | 1 | return $languageCode; |
|
56 | } |
||
57 | |||
58 | 1 | $templateText = $this->createTemplateInclusionCode( |
|
59 | 1 | $source, |
|
60 | $languageCode, |
||
61 | $template |
||
62 | ); |
||
63 | |||
64 | 1 | return [ $templateText, 'noparse' => $templateText === '', 'isHTML' => false ]; |
|
65 | } |
||
66 | |||
67 | 1 | private function createTemplateInclusionCode( $source, $languageCode, $template ) { |
|
81 | |||
82 | 1 | private function modifyTargetLink( $targetLink ) { |
|
90 | |||
91 | } |
||
92 |