1 | <?php |
||
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 = '' ) { |
|
29 | |||
30 | /** |
||
31 | * @see StringValue::parseUserValue |
||
32 | */ |
||
33 | 36 | protected function parseUserValue( $value ) { |
|
46 | |||
47 | /** |
||
48 | * @see StringValue::getShortWikiText |
||
49 | */ |
||
50 | 30 | public function getShortWikiText( $linker = null ) { |
|
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 | array( |
||
101 | 7 | 'href' => $this->getTargetLink( $this->m_caption ), |
|
102 | 'target' => '_blank' |
||
103 | 7 | ), |
|
104 | 7 | $this->m_caption |
|
105 | 7 | ); |
|
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() { |
|
133 | |||
134 | 8 | private function getTargetLink( $target ) { |
|
135 | 8 | return $this->resourceIdentifierStringValueParser->getResourceTargetUri() . $target; |
|
136 | } |
||
137 | |||
138 | } |
||
139 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.