Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php |
— | — | @@ -154,28 +154,31 @@ |
155 | 155 | if ( $property->isUserDefined() ) { |
156 | 156 | $pe = self::getResourceElementForProperty( $property ); |
157 | 157 | $peHelper = self::getResourceElementForProperty( $property, true ); |
158 | | - |
| 158 | + |
159 | 159 | foreach ( $dataItems as $dataItem ) { |
160 | 160 | $ed = self::getDataItemExpElement( $dataItem ); |
161 | | - |
162 | 161 | if ( !is_null( $ed ) ) { |
163 | 162 | $expData->addPropertyObjectValue( $pe, $ed ); |
164 | 163 | } |
165 | | - |
| 164 | + |
166 | 165 | $edHelper = self::getDataItemHelperExpElement( $dataItem ); |
167 | | - |
168 | 166 | if ( !is_null( $edHelper ) ) { |
169 | 167 | $expData->addPropertyObjectValue( $peHelper, $edHelper ); |
170 | 168 | } |
171 | 169 | } |
172 | 170 | } else { // pre-defined property, only exported if known |
173 | 171 | $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; |
176 | 176 | } |
177 | 177 | |
178 | 178 | $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 | + |
180 | 183 | if ( $property->getKey() == '_REDI' || $property->getKey() == '_URI' ) { |
181 | 184 | $filterNamespace = true; |
182 | 185 | if ( $property->getKey() == '_REDI' ) { |
— | — | @@ -193,11 +196,12 @@ |
194 | 197 | ( $dataItem->getNamespace() != $diSubject->getNamespace() ) ) ) { |
195 | 198 | continue; |
196 | 199 | } |
197 | | - |
| 200 | + |
198 | 201 | $ed = self::getDataItemExpElement( $dataItem ); |
199 | | - |
| 202 | + |
200 | 203 | if ( !is_null( $ed ) ) { |
201 | | - if ( ( $property->getKey() == '_CONC' ) && ( $ed->getSubject()->getUri() === '' ) ) { |
| 204 | + if ( $property->getKey() == '_CONC' && |
| 205 | + $ed->getSubject()->getUri() === '' ) { |
202 | 206 | // equivalent to anonymous class -> simplify description |
203 | 207 | foreach ( $ed->getProperties() as $subp ) { |
204 | 208 | if ( $subp->getUri() != self::getSpecialNsResource( 'rdf', 'type' )->getUri() ) { |
— | — | @@ -206,14 +210,19 @@ |
207 | 211 | } |
208 | 212 | } |
209 | 213 | } |
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 ); |
214 | 218 | } else { |
215 | 219 | $expData->addPropertyObjectValue( $pe, $ed ); |
216 | 220 | } |
217 | 221 | } |
| 222 | + |
| 223 | + $edHelper = self::getDataItemHelperExpElement( $dataItem ); |
| 224 | + if ( !is_null( $edHelper ) ) { |
| 225 | + $expData->addPropertyObjectValue( $peHelper, $edHelper ); |
| 226 | + } |
218 | 227 | } |
219 | 228 | } |
220 | 229 | } |
— | — | @@ -620,7 +629,7 @@ |
621 | 630 | * |
622 | 631 | * For dataitems that do not have such a simplification, the method |
623 | 632 | * returns null. |
624 | | - * |
| 633 | + * |
625 | 634 | * @note If a helper element is used, then it must be the same as |
626 | 635 | * getDataItemHelperExpElement( $dataItem->getSortKeyDataItem() ). |
627 | 636 | * Query conditions like ">" use sortkeys for values, and helper |