r97358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97357‎ | r97358 | r97359 >
Date:02:17, 17 September 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r97324; fixed serialization
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Time.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php
@@ -227,22 +227,41 @@
228228 return $result;
229229 }
230230
 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+
231250 public function serializeToArray() {
232251 $results = array();
233252
234253 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+ );
244263 }
245264
246 - $results[$diWikiPage->getSerialization()] = $result;
 265+ $results[$diWikiPage->getTitle()->getFullText()] = $result;
247266 }
248267
249268 return $results;
Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Time.php
@@ -171,6 +171,27 @@
172172 public function getSecond() {
173173 return $this->m_seconds;
174174 }
 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+ }
175196
176197 /**
177198 * Get the data in the specified calendar model. This might require

Follow-up revisions

RevisionCommit summaryAuthorDate
r97359Follow up to r97358;jeroendedauw02:27, 17 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97324some work on ask apijeroendedauw19:23, 16 September 2011