Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php |
— | — | @@ -227,22 +227,41 @@ |
228 | 228 | return $result; |
229 | 229 | } |
230 | 230 | |
| 231 | + public function getDataItemSerialization( SMWDataItem $dataItem ) { |
| 232 | + switch ( $dataItem->getDIType() ) { |
| 233 | + case SMWDataItem::TYPE_NUMBER: |
| 234 | + $result = $dataItem->getNumber(); |
| 235 | + break; |
| 236 | + case SMWDataItem::TYPE_GEO: |
| 237 | + $result = $dataItem->getCoordinateSet(); |
| 238 | + break; |
| 239 | + case SMWDataItem::TYPE_TIME: |
| 240 | + $result = $dataItem->getMwTimestamp(); |
| 241 | + break; |
| 242 | + default: |
| 243 | + $result = $dataItem->getSerialization(); |
| 244 | + break; |
| 245 | + } |
| 246 | + |
| 247 | + return $result; |
| 248 | + } |
| 249 | + |
231 | 250 | public function serializeToArray() { |
232 | 251 | $results = array(); |
233 | 252 | |
234 | 253 | foreach ( $this->mResults as /* SMWDIWikiPage */ $diWikiPage ) { |
235 | | - switch ( $diWikiPage->getDIType() ) { |
236 | | - case SMWDataItem::TYPE_NUMBER: |
237 | | - $result = $diWikiPage->getNumber(); |
238 | | - break; |
239 | | - case SMWDataItem::TYPE_GEO: |
240 | | - $result = $diWikiPage->getCoordinateSet(); |
241 | | - break; |
242 | | - default: |
243 | | - $result = $diWikiPage->getSerialization(); |
| 254 | + $result = array(); |
| 255 | + |
| 256 | + foreach ( $this->mPrintRequests as /* SMWPrintRequest */ $printRequest ) { |
| 257 | + $resultAarray = new SMWResultArray( $diWikiPage, $printRequest, $this->mStore ); |
| 258 | + |
| 259 | + $result[$printRequest->getLabel()] = array_map( |
| 260 | + array( __class__, 'getDataItemSerialization' ), |
| 261 | + $resultAarray->getContent() |
| 262 | + ); |
244 | 263 | } |
245 | 264 | |
246 | | - $results[$diWikiPage->getSerialization()] = $result; |
| 265 | + $results[$diWikiPage->getTitle()->getFullText()] = $result; |
247 | 266 | } |
248 | 267 | |
249 | 268 | return $results; |
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Time.php |
— | — | @@ -171,6 +171,27 @@ |
172 | 172 | public function getSecond() { |
173 | 173 | return $this->m_seconds; |
174 | 174 | } |
| 175 | + |
| 176 | + /** |
| 177 | + * Returns a MW timestamp representatation of the value. |
| 178 | + * |
| 179 | + * @since 1.6.2 |
| 180 | + * |
| 181 | + * @param $outputtype |
| 182 | + */ |
| 183 | + public function getMwTimestamp( $outputtype = TS_UNIX ) { |
| 184 | + return wfTimestamp( |
| 185 | + $outputtype, |
| 186 | + implode( '', array( |
| 187 | + str_pad( $this->m_year, 4, '0', STR_PAD_LEFT ), |
| 188 | + str_pad( $this->m_month, 2, '0', STR_PAD_LEFT ), |
| 189 | + str_pad( $this->m_day, 2, '0', STR_PAD_LEFT ), |
| 190 | + str_pad( $this->m_hours, 2, '0', STR_PAD_LEFT ), |
| 191 | + str_pad( $this->m_minutes, 2, '0', STR_PAD_LEFT ), |
| 192 | + str_pad( $this->m_seconds, 2, '0', STR_PAD_LEFT ), |
| 193 | + ) ) |
| 194 | + ); |
| 195 | + } |
175 | 196 | |
176 | 197 | /** |
177 | 198 | * Get the data in the specified calendar model. This might require |