
mkroetzsch at svn
Feb 11, 2012, 7:28 AM
Post #1 of 1
(13 views)
Permalink
|
|
SVN: [111241] trunk/extensions/SemanticMediaWiki/includes/export/ SMW_Exporter.php
|
|
https://www.mediawiki.org/wiki/Special:Code/MediaWiki/111241 Revision: 111241 Author: mkroetzsch Date: 2012-02-11 15:28:57 +0000 (Sat, 11 Feb 2012) Log Message: ----------- 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: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php =================================================================== --- trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php 2012-02-11 15:14:15 UTC (rev 111240) +++ trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php 2012-02-11 15:28:57 UTC (rev 111241) @@ -154,28 +154,31 @@ if ( $property->isUserDefined() ) { $pe = self::getResourceElementForProperty( $property ); $peHelper = self::getResourceElementForProperty( $property, true ); - + foreach ( $dataItems as $dataItem ) { $ed = self::getDataItemExpElement( $dataItem ); - if ( !is_null( $ed ) ) { $expData->addPropertyObjectValue( $pe, $ed ); } - + $edHelper = self::getDataItemHelperExpElement( $dataItem ); - if ( !is_null( $edHelper ) ) { $expData->addPropertyObjectValue( $peHelper, $edHelper ); } } } else { // pre-defined property, only exported if known $diSubject = $expData->getSubject()->getDataItem(); - if ( ( $diSubject == null ) || ( $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) ) { - return; // subject datavalue (wikipage) required for treating special properties properly + // subject wikipage required for disambiguating special properties: + if ( is_null( $diSubject ) || + $diSubject->getDIType() != SMWDataItem::TYPE_WIKIPAGE ) { + return; } $pe = self::getSpecialPropertyResource( $property->getKey(), $diSubject->getNamespace() ); - if ( is_null( $pe ) ) return; // unknown special property, not exported + if ( is_null( $pe ) ) return; // unknown special property, not exported + // have helper property ready before entering the for loop, even if not needed: + $peHelper = self::getResourceElementForProperty( $property, true ); + if ( $property->getKey() == '_REDI' || $property->getKey() == '_URI' ) { $filterNamespace = true; if ( $property->getKey() == '_REDI' ) { @@ -193,11 +196,12 @@ ( $dataItem->getNamespace() != $diSubject->getNamespace() ) ) ) { continue; } - + $ed = self::getDataItemExpElement( $dataItem ); - + if ( !is_null( $ed ) ) { - if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getUri() === '' ) ) { + if ( $property->getKey() == '_CONC' && + $ed->getSubject()->getUri() === '' ) { // equivalent to anonymous class -> simplify description foreach ( $ed->getProperties() as $subp ) { if ( $subp->getUri() != self::getSpecialNsResource( 'rdf', 'type' )->getUri() ) { @@ -206,14 +210,19 @@ } } } - } elseif ( is_array( $pe ) ) { - foreach ( $pe as $extraPropertyElement ) { - $expData->addPropertyObjectValue( $extraPropertyElement, $ed ); - } + } elseif ( $property->getKey() == '_REDI' ) { + $expData->addPropertyObjectValue( $pe, $ed ); + $peUri = self::getSpecialPropertyResource( '_URI' ); + $expData->addPropertyObjectValue( $peUri, $ed ); } else { $expData->addPropertyObjectValue( $pe, $ed ); } } + + $edHelper = self::getDataItemHelperExpElement( $dataItem ); + if ( !is_null( $edHelper ) ) { + $expData->addPropertyObjectValue( $peHelper, $edHelper ); + } } } } @@ -620,7 +629,7 @@ * * For dataitems that do not have such a simplification, the method * returns null. - * + * * @note If a helper element is used, then it must be the same as * getDataItemHelperExpElement( $dataItem->getSortKeyDataItem() ). * Query conditions like ">" use sortkeys for values, and helper _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS [at] lists https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|