r89993 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89992‎ | r89993 | r89994 >
Date:18:56, 13 June 2011
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
fixed compat issues in timeline and eventline formats
Modified paths:
  • /trunk/extensions/SemanticResultFormats/Timeline/SRF_Timeline.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticResultFormats/Timeline/SRF_Timeline.php
@@ -61,15 +61,22 @@
6262
6363 $this->includeJS();
6464
65 - $isEventline = ( 'eventline' == $this->mFormat );
 65+ $isEventline = 'eventline' == $this->mFormat;
6666
6767 if ( !$isEventline && ( $this->m_tlstart == '' ) ) { // seek defaults
6868 foreach ( $res->getPrintRequests() as $pr ) {
6969 if ( ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) ) {
70 - if ( method_exists ( $pr->getData(), 'getValueKey' ) ) {
71 - $date_value = $pr->getData()->getValueKey();
72 - } else {
73 - $date_value = $pr->getData()->getXSDValue();
 70+ $dataValue = $pr->getData();
 71+
 72+ // SMW >= 1.6
 73+ if ( method_exists ( $dataValue, 'getDataItem' ) ) {
 74+ $date_value = $dataValue->getDataItem()->getLabel();
 75+ } // SMW 1.5.x
 76+ elseif ( method_exists ( $dataValue, 'getValueKey' ) ) {
 77+ $date_value = $dataValue->getValueKey();
 78+ } // SMW < 1.5
 79+ else {
 80+ $date_value = $dataValue->getXSDValue();
7481 }
7582
7683 if ( ( $this->m_tlend == '' ) && ( $this->m_tlstart != '' ) &&
@@ -166,13 +173,19 @@
167174 foreach ( $row as $field ) { // Loop over the returned properties
168175 $first_value = true;
169176 $pr = $field->getPrintRequest();
 177+ $dataValue = $pr->getData();
170178
171 - if ( $pr->getData() == '' ) {
 179+ if ( $dataValue == '' ) {
172180 $date_value = null;
173 - } elseif ( method_exists ( $pr->getData(), 'getValueKey' ) ) {
174 - $date_value = $pr->getData()->getValueKey();
175 - } else {
176 - $date_value = $pr->getData()->getXSDValue();
 181+ } // SMW >= 1.6
 182+ elseif ( method_exists ( $dataValue, 'getDataItem' ) ) {
 183+ $date_value = $dataValue->getDataItem()->getLabel();
 184+ } // SMW 1.5.x
 185+ elseif ( method_exists ( $dataValue, 'getValueKey' ) ) {
 186+ $date_value = $dataValue->getValueKey();
 187+ } // SMW < 1.5
 188+ else {
 189+ $date_value = $dataValue->getXSDValue();
177190 }
178191
179192 while ( ( $object = efSRFGetNextDV( $field ) ) !== false ) { // Loop over property values
@@ -343,20 +356,22 @@
344357 }
345358
346359 if ( $isEventline && ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) && ( '' != $pr->getLabel() ) && ( $date_value != $this->m_tlstart ) && ( $date_value != $this->m_tlend ) ) {
347 - if ( method_exists( $object, 'getValueKey' ) ) {
348 - $event = array(
349 - $object->getXMLSchemaDate(),
350 - $pr->getLabel(),
351 - $object->getValueKey()
352 - );
353 - }
 360+ // SMW >= 1.6
 361+ if ( method_exists ( $object, 'getDataItem' ) ) {
 362+ $numericValue = $object->getDataItem()->getForCalendarModel( SMWDITime::CM_GREGORIAN );
 363+ } // SMW 1.5.x
 364+ elseif ( method_exists ( $object, 'getValueKey' ) ) {
 365+ $numericValue = $object->getValueKey();
 366+ } // SMW < 1.5
354367 else {
355 - $event = array(
356 - $object->getXMLSchemaDate(),
357 - $pr->getLabel(),
358 - $object->getNumericValue()
359 - );
360 - }
 368+ $numericValue = $object->getNumericValue();
 369+ }
 370+
 371+ $event = array(
 372+ $object->getXMLSchemaDate(),
 373+ $pr->getLabel(),
 374+ $numericValue
 375+ );
361376 }
362377
363378 return $event;

Comments

#Comment by F.trott (talk | contribs)   08:18, 14 June 2011

Finally! :-)