r22972 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22971‎ | r22972 | r22973 >
Date:20:45, 13 June 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Removed some uses of deprecated datavalue API, generate ugly notices for remaining ones.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_OldDataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -172,7 +172,7 @@
173173 $count = 0;
174174 foreach ($objects as $object) {
175175 $count += 1;
176 - $html .= $object->getValueDescription();
 176+ $html .= $object->getLongHTMLText($skin);
177177 if ($count<$objectcount) $html .= ", ";
178178 }
179179 $html .= $vsep."\n";
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_OldDataValue.php
@@ -302,19 +302,32 @@
303303 /*********************************************************************/
304304
305305 public function getShortWikiText($linked = NULL) {
306 - return $this->getUserValue();
 306+ return $this->vuser;
307307 }
308308
309309 public function getShortHTMLText($linker = NULL) {
310 - return $this->getUserValue();
 310+ return $this->getShortWikiText();
311311 }
312312
313313 public function getLongWikiText($linked = NULL) {
314 - return $this->getValueDescription();
 314+ // copied from deprecated getValueDescription
 315+ if ($this->description === false) {
 316+ if ($this->error === false) {
 317+ if (count($this->others)>0) {
 318+ $sep = '';
 319+ foreach ($this->others as $other) {
 320+ $this->description .= $sep . $other;
 321+ if ('' == $sep) $sep = ' ('; else $sep = ', ';
 322+ }
 323+ if (' (' != $sep) $this->description .= ')';
 324+ }
 325+ } else { $this->description = '<span class="smwwarning">' . $this->error . '</span>'; }
 326+ }
 327+ return $this->description;
315328 }
316329
317330 public function getLongHTMLText($linker = NULL) {
318 - return $this->getValueDescription();
 331+ return $this->getLongWikiText();
319332 }
320333
321334 /**
@@ -329,8 +342,11 @@
330343 * This method might return FALSE if the data value was
331344 * initialised not from a user value string and parsing the
332345 * given value failed.
 346+ *
 347+ * @DEPRECATED
333348 */
334349 function getUserValue() {
 350+ trigger_error("The function getUserValue() is deprecated. Use getShortWikiText() or getShortHTMLText(),", E_USER_NOTICE);
335351 return $this->vuser;
336352 }
337353
@@ -338,8 +354,11 @@
339355 * Return a single value string, obtained by parsing the
340356 * supplied user or XSD value. Canonical representation
341357 * that includes a unit. Wikitext.
 358+ *
 359+ * @DEPRECATED
342360 */
343361 function getStringValue() {
 362+ trigger_error("The function getUserValue() is deprecated. Use getShortWikiText() or getShortHTMLText(),", E_USER_NOTICE);
344363 if ( count($this->others) > 0 ) {
345364 reset($this->others);
346365 return current($this->others); // return first element
@@ -409,8 +428,11 @@
410429 * Return the long description of the value, as printed for
411430 * example in the factbox. If errors occurred, return the error message
412431 * The result always is a wiki-source string.
 432+ *
 433+ * @DEPRECATED
413434 */
414435 function getValueDescription() {
 436+ trigger_error("The function getValueDescription() is deprecated. Use getLongWikiText() or getLongHTMLText().", E_USER_NOTICE);
415437 if ($this->description === false) {
416438 if ($this->error === false) {
417439 if (count($this->others)>0) {
@@ -454,7 +476,7 @@
455477 * be used to compare different value objects.
456478 */
457479 function getHash() {
458 - return $this->getValueDescription() . $this->vxsd . $this->unit;
 480+ return $this->getLongWikiText() . $this->vxsd . $this->unit;
459481 // (user_out is needed here to distinguish error messages, which
460482 // usually have no XSD and no unit)
461483 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -21,6 +21,7 @@
2222 * @DEPRECATED
2323 */
2424 static function newAttributeValue($attribute, $value=false) {
 25+ trigger_error("The function SMWDataValue::newAttributeValue() is deprecated.", E_USER_NOTICE);
2526 return SMWDataValueFactory::newAttributeValue($attribute, $value);
2627 }
2728
@@ -33,6 +34,7 @@
3435 * @DEPRECATED
3536 */
3637 static function newSpecialValue($specialprop, $value=false) {
 38+ trigger_error("The function SMWDataValue::newSpecialValue() is deprecated.", E_USER_NOTICE);
3739 return SMWDataValueFactory::newSpecialValue($specialprop, $value);
3840 }
3941
@@ -44,6 +46,7 @@
4547 * @DEPRECATED
4648 */
4749 static function newTypedValue(SMWTypeHandler $type, $value=false) {
 50+ trigger_error("The function SMWDataValue::newTypedValue() is deprecated.", E_USER_NOTICE);
4851 return SMWDataValueFactory::newTypeHandlerValue($type, $value);
4952 }
5053
@@ -55,6 +58,7 @@
5659 * @DEPRECATED
5760 */
5861 public function getUserValue() {
 62+ trigger_error("The function SMWDataValue::getUserValue() is deprecated.", E_USER_NOTICE);
5963 return $this->getShortWikiText();
6064 }
6165
@@ -62,6 +66,7 @@
6367 * @DEPRECATED
6468 */
6569 public function getValueDescription() {
 70+ trigger_error("The function SMWDataValue::getValueDescription() is deprecated.", E_USER_NOTICE);
6671 return $this->getLongWikiText();
6772 }
6873
@@ -69,6 +74,7 @@
7075 * @DEPRECATED
7176 */
7277 public function getTooltip() {
 78+ //trigger_error("The function SMWDataValue::getTooltip() is deprecated.", E_USER_NOTICE);
7379 return '';
7480 }
7581
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php
@@ -155,7 +155,7 @@
156156 }
157157 $i++;
158158 if ($i < 4) {
159 - $r .= $value->getValueDescription();
 159+ $r .= $value->getLongHTMLText($this->getSkin());
160160 $sep = '&nbsp;&nbsp;';
161161 foreach ($value->getInfolinks() as $link) {
162162 $r .= $sep . $link->getHTML($this->getSkin());
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -185,7 +185,7 @@
186186 $sql, 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions,$value_column) );
187187 if($db->numRows( $res ) > 0) {
188188 while($row = $db->fetchObject($res)) {
189 - $dv = SMWDataValue::newTypedValue(SMWTypeHandlerFactory::getTypeHandlerByID($row->value_datatype));
 189+ $dv = SMWDataValueFactory::newTypehandlerValue(SMWTypeHandlerFactory::getTypeHandlerByID($row->value_datatype));
190190 $dv->setAttribute($attribute->getText());
191191 $dv->setXSDValue($row->value_xsd, $row->value_unit);
192192 $result[] = $dv;
@@ -201,7 +201,7 @@
202202 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions,$value_column) );
203203 if($db->numRows( $res ) > 0) {
204204 while($row = $db->fetchObject($res)) {
205 - $dv = SMWDataValue::newTypedValue(SMWTypeHandlerFactory::getTypeHandlerByID('text'));
 205+ $dv = SMWDataValueFactory::newTypehandlerValue(SMWTypeHandlerFactory::getTypeHandlerByID('text'));
206206 $dv->setAttribute($attribute->getText());
207207 $dv->setXSDValue($row->value_blob, '');
208208 $result[] = $dv;
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Types.php
@@ -58,6 +58,7 @@
5959 }
6060
6161 public function getShortHTMLText($linker = NULL) {
 62+ ///TODO Support linking
6263 return implode(', ', $this->m_typevalues);
6364 }
6465

Status & tagging log