1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SCI\DataValues; |
4
|
|
|
|
5
|
|
|
use SMW\DataValues\StringValue; |
|
|
|
|
6
|
|
|
use SMWDIBlob as DIBlob; |
|
|
|
|
7
|
|
|
use Html; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @license GNU GPL v2+ |
11
|
|
|
* @since 1.0 |
12
|
|
|
* |
13
|
|
|
* @author mwjames |
14
|
|
|
*/ |
15
|
|
|
class ResourceIdentifierStringValue extends StringValue { |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var ResourceIdentifierStringValueParser |
19
|
|
|
*/ |
20
|
|
|
private $resourceIdentifierStringValueParser; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @param string $typeid |
24
|
|
|
*/ |
25
|
42 |
|
public function __construct( $typeid = '' ) { |
26
|
42 |
|
parent::__construct( $typeid ); |
27
|
42 |
|
$this->resourceIdentifierStringValueParser = new ResourceIdentifierStringValueParser( $typeid ); |
28
|
42 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @see StringValue::parseUserValue |
32
|
|
|
*/ |
33
|
36 |
|
protected function parseUserValue( $value ) { |
34
|
|
|
|
35
|
36 |
|
$inputValue = $value; |
36
|
|
|
// $this->m_caption = $value; |
37
|
|
|
|
38
|
36 |
|
if ( !$this->resourceIdentifierStringValueParser->parse( $value ) ) { |
39
|
13 |
|
$this->addError( wfMessage( 'sci-datavalue-invalid-id-value', $inputValue, $this->resourceIdentifierStringValueParser->getCanonicalName() )->inContentLanguage()->escaped() ); |
|
|
|
|
40
|
13 |
|
$this->m_dataitem = new DIBlob( 'ERROR' ); |
|
|
|
|
41
|
13 |
|
return; |
42
|
|
|
} |
43
|
|
|
|
44
|
24 |
|
parent::parseUserValue( $value ); |
45
|
24 |
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @see StringValue::getShortWikiText |
49
|
|
|
*/ |
50
|
30 |
|
public function getShortWikiText( $linker = null ) { |
51
|
|
|
|
52
|
30 |
|
if ( !$this->isValid() ) { |
53
|
12 |
|
return ''; |
54
|
|
|
} |
55
|
|
|
|
56
|
18 |
|
if ( !$this->m_caption ) { |
57
|
18 |
|
$this->m_caption = $this->m_dataitem->getString(); |
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
18 |
|
if ( $preferredCaption = $this->getPreferredCaption() ) { |
61
|
1 |
|
return $preferredCaption; |
62
|
|
|
} |
63
|
|
|
|
64
|
18 |
|
if ( $linker === null ) { |
65
|
10 |
|
return $this->m_caption; |
66
|
|
|
} |
67
|
|
|
|
68
|
8 |
|
return Html::rawElement( |
69
|
8 |
|
'span', |
70
|
|
|
[ |
71
|
8 |
|
'class' => 'plainlinks' |
72
|
|
|
], |
73
|
8 |
|
'[' . $this->getTargetLink( urlencode( $this->m_caption ) ) . ' ' . $this->m_caption .']' |
74
|
|
|
); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @see StringValue::getShortHTMLText |
79
|
|
|
*/ |
80
|
29 |
|
public function getShortHTMLText( $linker = null ) { |
81
|
|
|
|
82
|
29 |
|
if ( !$this->isValid() ) { |
83
|
12 |
|
return ''; |
84
|
|
|
} |
85
|
|
|
|
86
|
17 |
|
if ( !$this->m_caption ) { |
87
|
|
|
$this->m_caption = $this->m_dataitem->getString(); |
|
|
|
|
88
|
|
|
} |
89
|
|
|
|
90
|
17 |
|
if ( $preferredCaption = $this->getPreferredCaption() ) { |
91
|
|
|
return $preferredCaption; |
92
|
|
|
} |
93
|
|
|
|
94
|
17 |
|
if ( $linker === null ) { |
95
|
10 |
|
return $this->m_caption; |
96
|
|
|
} |
97
|
|
|
|
98
|
7 |
|
return Html::rawElement( |
99
|
7 |
|
'a', |
100
|
|
|
[ |
101
|
7 |
|
'href' => $this->getTargetLink( $this->m_caption ), |
102
|
7 |
|
'target' => '_blank' |
103
|
|
|
], |
104
|
7 |
|
$this->m_caption |
105
|
|
|
); |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @see StringValue::getLongWikiText |
110
|
|
|
*/ |
111
|
29 |
|
public function getLongWikiText( $linked = null ) { |
112
|
29 |
|
return $this->getShortWikiText( $linked ); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @see StringValue::getLongHTMLText |
117
|
|
|
*/ |
118
|
29 |
|
public function getLongHTMLText( $linker = null ) { |
119
|
29 |
|
return $this->getShortHTMLText( $linker ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @see DataValue::getPreferredCaption |
124
|
|
|
*/ |
125
|
18 |
|
public function getPreferredCaption() { |
126
|
|
|
|
127
|
18 |
|
if ( $this->m_outformat == '-' ) { |
128
|
1 |
|
return $this->m_caption; |
129
|
|
|
} |
130
|
|
|
|
131
|
18 |
|
return false; |
132
|
|
|
} |
133
|
|
|
|
134
|
8 |
|
private function getTargetLink( $target ) { |
135
|
8 |
|
return $this->resourceIdentifierStringValueParser->getResourceTargetUri() . $target; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
} |
139
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths