1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SIL; |
4
|
|
|
|
5
|
|
|
use SMW\DataValueFactory; |
6
|
|
|
use SMW\DIProperty; |
7
|
|
|
use SMW\DIWikiPage; |
8
|
|
|
|
9
|
|
|
use SMWDIBlob as DIBlob; |
10
|
|
|
|
11
|
|
|
use Title; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @license GNU GPL v2+ |
15
|
|
|
* @since 1.0 |
16
|
|
|
* |
17
|
|
|
* @author mwjames |
18
|
|
|
*/ |
19
|
|
|
class InterlanguageLink { |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var string|null |
23
|
|
|
*/ |
24
|
|
|
private $languageCode = ''; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var Title |
28
|
|
|
*/ |
29
|
|
|
private $linkReference; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @since 1.0 |
33
|
|
|
* |
34
|
|
|
* @param string|null $languageCode |
35
|
|
|
* @param Title|string $linkReference |
36
|
|
|
*/ |
37
|
8 |
|
public function __construct( $languageCode = null, $linkReference ) { |
38
|
8 |
|
$this->languageCode = $languageCode; |
39
|
8 |
|
$this->linkReference = $linkReference instanceOf Title ? $linkReference : Title::newFromText( $linkReference ); |
40
|
8 |
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @since 1.0 |
44
|
|
|
* |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
6 |
|
public function getLanguageCode() { |
48
|
6 |
|
return $this->languageCode; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @since 1.0 |
53
|
|
|
* |
54
|
|
|
* @return Title |
55
|
|
|
*/ |
56
|
6 |
|
public function getLinkReference() { |
57
|
6 |
|
return $this->linkReference; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @since 1.0 |
62
|
|
|
* |
63
|
|
|
* @return string |
64
|
|
|
*/ |
65
|
3 |
|
public function getContainerId() { |
66
|
3 |
|
return 'ill.'. $this->getLanguageCode(); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @since 1.0 |
71
|
|
|
* |
72
|
|
|
* @return string |
73
|
|
|
*/ |
74
|
1 |
|
public function getHash() { |
75
|
1 |
|
return $this->getLanguageCode() . '#' . $this->getLinkReference()->getPrefixedText(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @since 1.0 |
80
|
|
|
* |
81
|
|
|
* @return DataValue |
82
|
|
|
*/ |
83
|
3 |
|
public function newLanguageDataValue() { |
84
|
3 |
|
return DataValueFactory::getInstance()->newDataItemValue( |
|
|
|
|
85
|
3 |
|
new DIBlob( $this->getLanguageCode() ), |
86
|
3 |
|
new DIProperty( PropertyRegistry::SIL_ILL_LANG ) |
87
|
|
|
); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @since 1.0 |
92
|
|
|
* |
93
|
|
|
* @return DataValue |
94
|
|
|
*/ |
95
|
3 |
|
public function newLinkReferenceDataValue() { |
96
|
3 |
|
return DataValueFactory::getInstance()->newDataItemValue( |
|
|
|
|
97
|
3 |
|
DIWikiPage::newFromTitle( $this->getLinkReference() ), |
98
|
3 |
|
new DIProperty( PropertyRegistry::SIL_ILL_REF ) |
99
|
|
|
); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @since 1.0 |
104
|
|
|
* |
105
|
|
|
* @return DIProperty |
106
|
|
|
*/ |
107
|
3 |
|
public function newContainerProperty() { |
108
|
3 |
|
return new DIProperty( PropertyRegistry::SIL_CONTAINER ); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
} |
112
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.