1 | <?php |
||
23 | class NotificationGroupValue extends StringValue { |
||
24 | |||
25 | /** |
||
26 | * DV identifier |
||
27 | */ |
||
28 | const TYPE_ID = '_notification_group'; |
||
29 | |||
30 | /** |
||
31 | * Special group name |
||
32 | */ |
||
33 | const SPECIAL_GROUP = 'smw-notifications-entity-specification-change-group'; |
||
34 | |||
35 | /** |
||
36 | * Get name in a possible localized representation |
||
37 | * |
||
38 | * @since 1.0 |
||
39 | * |
||
40 | * @param string $language |
||
41 | * |
||
42 | * @return string |
||
43 | */ |
||
44 | 7 | public static function getSpecialGroupName( $language = Message::CONTENT_LANGUAGE ) { |
|
47 | |||
48 | /** |
||
49 | * @see StringValue::parseUserValue |
||
50 | */ |
||
51 | 6 | protected function parseUserValue( $value ) { |
|
76 | |||
77 | /** |
||
78 | * @see StringValue::getShortWikiText |
||
79 | */ |
||
80 | 3 | public function getShortWikiText( $linker = null ) { |
|
81 | |||
82 | 3 | if ( !$this->isValid() ) { |
|
83 | 1 | return ''; |
|
84 | } |
||
85 | |||
86 | 2 | if ( !$this->m_caption ) { |
|
87 | 2 | $this->m_caption = $this->m_dataitem->getString(); |
|
88 | } |
||
89 | |||
90 | 2 | if ( $linker === null ) { |
|
91 | return $this->m_caption; |
||
92 | } |
||
93 | |||
94 | // return Html::rawElement( |
||
|
|||
95 | // 'span', |
||
96 | // array(), |
||
97 | // '[' . $this->getTargetLink( urlencode( $this->m_caption ) ) . ' ' . $this->m_caption .']' |
||
98 | // ); |
||
99 | |||
100 | 2 | $text = SpecialPage::getTitleFor( 'SearchByProperty' )->getPrefixedText(); |
|
101 | |||
102 | // This is a bit heavy handed ... |
||
103 | 2 | return '[[' . $text . '/' . SMW_NOTIFICATIONS_TO_GROUP . '/' . rawurlencode( $this->m_caption ) . '|' . $this->m_caption . ']]'; |
|
104 | } |
||
105 | |||
106 | /** |
||
107 | * @see StringValue::getShortHTMLText |
||
108 | */ |
||
109 | 3 | public function getShortHTMLText( $linker = null ) { |
|
110 | |||
111 | 3 | if ( !$this->isValid() ) { |
|
112 | 1 | return ''; |
|
113 | } |
||
114 | |||
115 | 2 | if ( !$this->m_caption ) { |
|
116 | $this->m_caption = $this->m_dataitem->getString(); |
||
117 | } |
||
118 | |||
119 | 2 | if ( $linker === null ) { |
|
120 | return $this->m_caption; |
||
121 | } |
||
122 | |||
123 | 2 | $url = SpecialPage::getTitleFor( 'SearchByProperty' )->getLocalUrl( |
|
124 | array( |
||
125 | 2 | 'property' => SMW_NOTIFICATIONS_TO_GROUP, |
|
126 | 2 | 'value' => $this->m_caption |
|
127 | ) |
||
128 | ); |
||
129 | |||
130 | 2 | return Html::rawElement( |
|
131 | 2 | 'a', |
|
132 | array( |
||
133 | 2 | 'href' => $url, |
|
134 | // 'target' => '_blank' |
||
135 | ), |
||
136 | 2 | $this->m_caption |
|
137 | ); |
||
138 | } |
||
139 | |||
140 | /** |
||
141 | * @see StringValue::getLongWikiText |
||
142 | */ |
||
143 | 2 | public function getLongWikiText( $linked = null ) { |
|
146 | |||
147 | /** |
||
148 | * @see StringValue::getLongHTMLText |
||
149 | */ |
||
150 | 2 | public function getLongHTMLText( $linker = null ) { |
|
153 | |||
154 | 5 | private function isKnownNotificationsGroup( $value ) { |
|
172 | |||
173 | 3 | private function hasUserContext() { |
|
176 | |||
177 | } |
||
178 |
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.