r111241 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111240‎ | r111241 | r111242 >
Date:15:28, 11 February 2012
Author:mkroetzsch
Status:deferred
Tags:
Comment:
export auxiliary representations (used with some data types) also for special properties like Modification date; Bug 30989
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -154,28 +154,31 @@
155155 if ( $property->isUserDefined() ) {
156156 $pe = self::getResourceElementForProperty( $property );
157157 $peHelper = self::getResourceElementForProperty( $property, true );
158 -
 158+
159159 foreach ( $dataItems as $dataItem ) {
160160 $ed = self::getDataItemExpElement( $dataItem );
161 -
162161 if ( !is_null( $ed ) ) {
163162 $expData->addPropertyObjectValue( $pe, $ed );
164163 }
165 -
 164+
166165 $edHelper = self::getDataItemHelperExpElement( $dataItem );
167 -
168166 if ( !is_null( $edHelper ) ) {
169167 $expData->addPropertyObjectValue( $peHelper, $edHelper );
170168 }
171169 }
172170 } else { // pre-defined property, only exported if known
173171 $diSubject = $expData->getSubject()->getDataItem();
174 - if ( ( $diSubject == null ) || ( $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) ) {
175 - return; // subject datavalue (wikipage) required for treating special properties properly
 172+ // subject wikipage required for disambiguating special properties:
 173+ if ( is_null( $diSubject ) ||
 174+ $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) {
 175+ return;
176176 }
177177
178178 $pe = self::getSpecialPropertyResource( $property->getKey(), $diSubject->getNamespace() );
179 - if ( is_null( $pe ) ) return; // unknown special property, not exported
 179+ if ( is_null( $pe ) ) return; // unknown special property, not exported
 180+ // have helper property ready before entering the for loop, even if not needed:
 181+ $peHelper = self::getResourceElementForProperty( $property, true );
 182+
180183 if ( $property->getKey() == '_REDI' || $property->getKey() == '_URI' ) {
181184 $filterNamespace = true;
182185 if ( $property->getKey() == '_REDI' ) {
@@ -193,11 +196,12 @@
194197 ( $dataItem->getNamespace() != $diSubject->getNamespace() ) ) ) {
195198 continue;
196199 }
197 -
 200+
198201 $ed = self::getDataItemExpElement( $dataItem );
199 -
 202+
200203 if ( !is_null( $ed ) ) {
201 - if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getUri() === '' ) ) {
 204+ if ( $property->getKey() == '_CONC' &&
 205+ $ed->getSubject()->getUri() === '' ) {
202206 // equivalent to anonymous class -> simplify description
203207 foreach ( $ed->getProperties() as $subp ) {
204208 if ( $subp->getUri() != self::getSpecialNsResource( 'rdf', 'type' )->getUri() ) {
@@ -206,14 +210,19 @@
207211 }
208212 }
209213 }
210 - } elseif ( is_array( $pe ) ) {
211 - foreach ( $pe as $extraPropertyElement ) {
212 - $expData->addPropertyObjectValue( $extraPropertyElement, $ed );
213 - }
 214+ } elseif ( $property->getKey() == '_REDI' ) {
 215+ $expData->addPropertyObjectValue( $pe, $ed );
 216+ $peUri = self::getSpecialPropertyResource( '_URI' );
 217+ $expData->addPropertyObjectValue( $peUri, $ed );
214218 } else {
215219 $expData->addPropertyObjectValue( $pe, $ed );
216220 }
217221 }
 222+
 223+ $edHelper = self::getDataItemHelperExpElement( $dataItem );
 224+ if ( !is_null( $edHelper ) ) {
 225+ $expData->addPropertyObjectValue( $peHelper, $edHelper );
 226+ }
218227 }
219228 }
220229 }
@@ -620,7 +629,7 @@
621630 *
622631 * For dataitems that do not have such a simplification, the method
623632 * returns null.
624 - *
 633+ *
625634 * @note If a helper element is used, then it must be the same as
626635 * getDataItemHelperExpElement( $dataItem->getSortKeyDataItem() ).
627636 * Query conditions like ">" use sortkeys for values, and helper