Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -88,11 +88,7 @@ |
89 | 89 | $this->m_hasssearchlink = false; |
90 | 90 | $this->m_hasservicelinks = false; |
91 | 91 | $this->m_stubvalues = false; |
92 | | - if ( is_string($caption) ) { |
93 | | - $this->m_caption = trim($caption); |
94 | | - } else { |
95 | | - $this->m_caption = false; |
96 | | - } |
| 92 | + $this->m_caption = is_string($caption)?trim($caption):false; |
97 | 93 | // The following checks for markers generated by MediaWiki to handle special content, |
98 | 94 | // e.g. math. In general, we are not prepared to handle such content properly, and we |
99 | 95 | // also have no means of obtaining the user input at this point. Hence the assignement |
— | — | @@ -458,12 +454,7 @@ |
459 | 455 | * normalised first) |
460 | 456 | */ |
461 | 457 | public function getHash() { |
462 | | - $this->unstub(); |
463 | | - if ($this->isValid()) { |
464 | | - return implode("\t", $this->getDBkeys()); |
465 | | - } else { |
466 | | - return implode("\t", $this->m_errors); |
467 | | - } |
| 458 | + return $this->isValid()?implode("\t", $this->getDBkeys()):implode("\t", $this->m_errors); |
468 | 459 | } |
469 | 460 | |
470 | 461 | /** |
— | — | @@ -509,7 +500,6 @@ |
510 | 501 | * If the value is empty or invalid, NULL is returned. |
511 | 502 | */ |
512 | 503 | public function getExportData() { // default implementation: encode values as untyped string |
513 | | - $this->unstub(); |
514 | 504 | if ($this->isValid()) { |
515 | 505 | $lit = new SMWExpLiteral(smwfHTMLtoUTF8(implode(';',$this->getDBkeys())), $this); |
516 | 506 | return new SMWExpData($lit); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php |
— | — | @@ -21,7 +21,7 @@ |
22 | 22 | wfLoadExtensionMessages('SemanticMediaWiki'); |
23 | 23 | if ($value!='') { |
24 | 24 | $this->m_value = $value; |
25 | | - if ( (strlen($this->m_value) > 255) && ($this->m_typeid != '_txt') && ($this->m_typeid != '_cod') ) { // limit size (for DB indexing) |
| 25 | + if ( ($this->m_typeid != '_txt') && ($this->m_typeid != '_cod') && (strlen($this->m_value) > 255) ) { // limit size (for DB indexing) |
26 | 26 | $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[…]</span> ' . mb_substr($value, mb_strlen($this->m_value) - 42))); |
27 | 27 | } |
28 | 28 | } else { |
— | — | @@ -52,22 +52,14 @@ |
53 | 53 | } |
54 | 54 | |
55 | 55 | public function getLongWikiText($linked = NULL) { |
56 | | - if (!$this->isValid()) { |
57 | | - return $this->getErrorText(); |
58 | | - } else { |
59 | | - return $this->getAbbValue($linked,$this->m_value); |
60 | | - } |
| 56 | + return $this->isValid()?$this->getAbbValue($linked,$this->m_value):$this->getErrorText(); |
61 | 57 | } |
62 | 58 | |
63 | 59 | /** |
64 | 60 | * @todo Rather parse input to obtain properly formatted HTML. |
65 | 61 | */ |
66 | 62 | public function getLongHTMLText($linker = NULL) { |
67 | | - if (!$this->isValid()) { |
68 | | - return $this->getErrorText(); |
69 | | - } else { |
70 | | - return $this->getAbbValue($linker,smwfXMLContentEncode($this->m_value)); |
71 | | - } |
| 63 | + return $this->isValid()?$this->getAbbValue($linker,smwfXMLContentEncode($this->m_value)):$this->getErrorText(); |
72 | 64 | } |
73 | 65 | |
74 | 66 | public function getDBkeys() { |
— | — | @@ -84,8 +76,9 @@ |
85 | 77 | $this->unstub(); |
86 | 78 | if ( ($this->m_typeid != '_txt') && ($this->m_typeid != '_cod') ) { |
87 | 79 | return SMWDataValue::getInfolinks(); |
| 80 | + } else { |
| 81 | + return $this->m_infolinks; |
88 | 82 | } |
89 | | - return $this->m_infolinks; |
90 | 83 | } |
91 | 84 | |
92 | 85 | protected function getServiceLinkParams() { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -139,12 +139,10 @@ |
140 | 140 | if ( ($linker !== NULL) && ($this->m_caption !== '') && ($this->m_outformat != '-') ) { $this->getTitle(); } // init the Title object, may reveal hitherto unnoticed errors |
141 | 141 | if ( ($linker === NULL) || (!$this->isValid()) || ($this->m_outformat == '-') || ($this->m_caption === '') ) { |
142 | 142 | return htmlspecialchars($this->getCaption()); |
| 143 | + } elseif ($this->getNamespace() == NS_MEDIA) { /// NOTE: this extra case is indeed needed |
| 144 | + return $linker->makeMediaLinkObj($this->getTitle(), $this->getCaption()); |
143 | 145 | } else { |
144 | | - if ($this->getNamespace() == NS_MEDIA) { /// NOTE: this extra case is indeed needed |
145 | | - return $linker->makeMediaLinkObj($this->getTitle(), $this->getCaption()); |
146 | | - } else { |
147 | | - return $linker->makeLinkObj($this->getTitle(), $this->getCaption()); |
148 | | - } |
| 146 | + return $linker->makeLinkObj($this->getTitle(), $this->getCaption()); |
149 | 147 | } |
150 | 148 | } |
151 | 149 | |
— | — | @@ -175,12 +173,10 @@ |
176 | 174 | } |
177 | 175 | if ( ($linker === NULL) || ($this->m_outformat == '-') ) { |
178 | 176 | return htmlspecialchars($this->getPrefixedText()); |
179 | | - } else { |
180 | | - if ($this->getNamespace() == NS_MEDIA) { // this extra case is really needed |
181 | | - return $linker->makeMediaLinkObj($this->getTitle(), $this->m_textform); |
182 | | - } else { // all others use default linking, no embedding of images here |
183 | | - return $linker->makeLinkObj($this->getTitle(), $this->m_textform); |
184 | | - } |
| 177 | + } elseif ($this->getNamespace() == NS_MEDIA) { // this extra case is really needed |
| 178 | + return $linker->makeMediaLinkObj($this->getTitle(), $this->m_textform); |
| 179 | + } else { // all others use default linking, no embedding of images here |
| 180 | + return $linker->makeLinkObj($this->getTitle(), $this->m_textform); |
185 | 181 | } |
186 | 182 | } |
187 | 183 | |
— | — | @@ -202,12 +198,7 @@ |
203 | 199 | } |
204 | 200 | |
205 | 201 | public function getHash() { |
206 | | - $this->unstub(); |
207 | | - if ($this->isValid()) { |
208 | | - return $this->getPrefixedText(); |
209 | | - } else { |
210 | | - return implode("\t", $this->getErrors()); |
211 | | - } |
| 202 | + return $this->isValid()?$this->getPrefixedText():implode("\t", $this->getErrors()); |
212 | 203 | } |
213 | 204 | |
214 | 205 | protected function getServiceLinkParams() { |
— | — | @@ -219,7 +210,6 @@ |
220 | 211 | } |
221 | 212 | |
222 | 213 | public function getExportData() { |
223 | | - $this->unstub(); |
224 | 214 | if (!$this->isValid()) return NULL; |
225 | 215 | switch ($this->getNamespace()) { |
226 | 216 | case NS_MEDIA: // special handling for linking media files directly |
— | — | @@ -247,14 +237,13 @@ |
248 | 238 | |
249 | 239 | /** |
250 | 240 | * Return according Title object or NULL if no valid value was set. |
251 | | - * NULL can be returned even if this object returns TRUE for isValue(), |
| 241 | + * NULL can be returned even if this object returns TRUE for isValid(), |
252 | 242 | * since the latter function does not check whether MediaWiki can really |
253 | 243 | * make a Title out of the given data. |
254 | 244 | * However, isValid() will return FALSE *after* this function failed in |
255 | 245 | * trying to create a title. |
256 | 246 | */ |
257 | 247 | public function getTitle() { |
258 | | - $this->unstub(); |
259 | 248 | if ( ($this->isValid()) && ($this->m_title === NULL) ) { |
260 | 249 | if ($this->m_interwiki == '') { |
261 | 250 | $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
— | — | @@ -276,11 +265,7 @@ |
277 | 266 | public function getArticleID() { |
278 | 267 | $this->unstub(); |
279 | 268 | if ($this->m_id === false) { |
280 | | - if ($this->getTitle() !== NULL) { |
281 | | - $this->m_id = $this->m_title->getArticleID(); |
282 | | - } else { |
283 | | - $this->m_id = 0; |
284 | | - } |
| 269 | + $this->m_id = ($this->getTitle() !== NULL)?$this->m_title->getArticleID():0; |
285 | 270 | } |
286 | 271 | return $this->m_id; |
287 | 272 | } |
— | — | @@ -290,11 +275,7 @@ |
291 | 276 | * return FALSE. |
292 | 277 | */ |
293 | 278 | public function getNamespace() { |
294 | | - $this->unstub(); |
295 | | - if (!$this->isValid()) { |
296 | | - return false; |
297 | | - } |
298 | | - return $this->m_namespace; |
| 279 | + return $this->isValid()?$this->m_namespace:false; |
299 | 280 | } |
300 | 281 | |
301 | 282 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php |
— | — | @@ -245,11 +245,8 @@ |
246 | 246 | */ |
247 | 247 | public function getTypeLabels() { |
248 | 248 | $this->initTypeData(); |
249 | | - if ($this->m_typelabels === false) { |
250 | | - return array(); // fallback for unary callers |
251 | | - } else { |
252 | | - return $this->m_typelabels; |
253 | | - } |
| 249 | + // fallback to array() for unary callers |
| 250 | + return ($this->m_typelabels === false)?array():$this->m_typelabels; |
254 | 251 | } |
255 | 252 | |
256 | 253 | /** |
— | — | @@ -258,11 +255,8 @@ |
259 | 256 | */ |
260 | 257 | public function getTypeCaptions() { |
261 | 258 | $this->initTypeData(); |
262 | | - if ($this->m_typecaptions === false) { |
263 | | - return array(); // fallback for unary callers |
264 | | - } else { |
265 | | - return $this->m_typecaptions; |
266 | | - } |
| 259 | + // fallback to array() for unary callers |
| 260 | + return ($this->m_typecaptions === false)?array():$this->m_typecaptions; |
267 | 261 | } |
268 | 262 | |
269 | 263 | /** |