Index: trunk/extensions/SemanticMediaWiki/includes/dataitems/SMW_DI_Time.php |
— | — | @@ -171,13 +171,42 @@ |
172 | 172 | public function getSecond() { |
173 | 173 | return $this->m_seconds; |
174 | 174 | } |
175 | | - |
| 175 | + |
176 | 176 | /** |
| 177 | + * Creates and returns a new instance of SMWDITime from a MW timestamp. |
| 178 | + * |
| 179 | + * @since 1.8 |
| 180 | + * |
| 181 | + * @param string $timestamp must be in format |
| 182 | + * |
| 183 | + * @return SMWDITime|false |
| 184 | + */ |
| 185 | + public static function newFromTimestamp( $timestamp ) { |
| 186 | + $timestamp = wfTimestamp( TS_MW, (string)$timestamp ); |
| 187 | + |
| 188 | + if ( $timestamp === false ) { |
| 189 | + return false; |
| 190 | + } |
| 191 | + |
| 192 | + return new self( |
| 193 | + SMWDITime::CM_GREGORIAN, |
| 194 | + substr( $timestamp, 0, 4 ), |
| 195 | + substr( $timestamp, 4, 2 ), |
| 196 | + substr( $timestamp, 6, 2 ), |
| 197 | + substr( $timestamp, 8, 2 ), |
| 198 | + substr( $timestamp, 10, 2 ), |
| 199 | + substr( $timestamp, 12, 2 ) |
| 200 | + ); |
| 201 | + } |
| 202 | + |
| 203 | + /** |
177 | 204 | * Returns a MW timestamp representatation of the value. |
178 | 205 | * |
179 | 206 | * @since 1.6.2 |
180 | 207 | * |
181 | 208 | * @param $outputtype |
| 209 | + * |
| 210 | + * @return mixed |
182 | 211 | */ |
183 | 212 | public function getMwTimestamp( $outputtype = TS_UNIX ) { |
184 | 213 | return wfTimestamp( |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -487,9 +487,6 @@ |
488 | 488 | * A function to describe the allowed parameters of a query using |
489 | 489 | * any specific format - most query printers should override this |
490 | 490 | * function. |
491 | | - * |
492 | | - * TODO: refactor non-printer params up to the query processor |
493 | | - * and do all param handling there. |
494 | 491 | * |
495 | 492 | * @since 1.6.2 |
496 | 493 | * |
— | — | @@ -544,6 +541,18 @@ |
545 | 542 | $params['searchlabel'] = new Parameter( 'searchlabel' ); |
546 | 543 | $params['searchlabel']->setDefault( false, false ); |
547 | 544 | $params['searchlabel']->setMessage( 'smw-paramdesc-searchlabel' ); |
| 545 | + |
| 546 | + $params['intro'] = new Parameter( 'intro' ); |
| 547 | + $params['intro']->setMessage( 'smw_paramdesc_intro' ); |
| 548 | + $params['intro']->setDefault( '' ); |
| 549 | + |
| 550 | + $params['outro'] = new Parameter( 'outro' ); |
| 551 | + $params['outro']->setMessage( 'smw_paramdesc_outro' ); |
| 552 | + $params['outro']->setDefault( '' ); |
| 553 | + |
| 554 | + $params['default'] = new Parameter( 'default' ); |
| 555 | + $params['default']->setMessage( 'smw_paramdesc_default' ); |
| 556 | + $params['default']->setDefault( '' ); |
548 | 557 | |
549 | 558 | return $params; |
550 | 559 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_Time.php |
— | — | @@ -148,17 +148,7 @@ |
149 | 149 | |
150 | 150 | // Check if it's parseable by wfTimestamp when it's not a year (which is wrongly interpreted). |
151 | 151 | if ( strlen( $value ) != 4 && wfTimestamp( TS_MW, $value ) !== false ) { |
152 | | - $timeStamp = wfTimestamp( TS_MW, $value ); |
153 | | - |
154 | | - $this->m_dataitem = new SMWDITime( |
155 | | - SMWDITime::CM_GREGORIAN, |
156 | | - substr( $timeStamp, 0, 4 ), |
157 | | - substr( $timeStamp, 4, 2 ), |
158 | | - substr( $timeStamp, 6, 2 ), |
159 | | - substr( $timeStamp, 8, 2 ), |
160 | | - substr( $timeStamp, 10, 2 ), |
161 | | - substr( $timeStamp, 12, 2 ) |
162 | | - ); |
| 152 | + $this->m_dataitem = SMWDITime::newFromMwTimestamp( wfTimestamp( TS_MW, $value ) ); |
163 | 153 | } |
164 | 154 | elseif ( $this->parseDateString( $value, $datecomponents, $calendarmodel, $era, $hours, $minutes, $seconds, $timeoffset ) ) { |
165 | 155 | if ( ( $calendarmodel === false ) && ( $era === false ) && ( count( $datecomponents ) == 1 ) && ( intval( end( $datecomponents ) ) >= 100000 ) ) { |
Index: trunk/extensions/SemanticMediaWiki/includes/queryprinters/SMW_QueryPrinter.php |
— | — | @@ -297,13 +297,11 @@ |
298 | 298 | $this->params = $params; |
299 | 299 | $this->m_params = $params; // Compat, change made in 1.6.3/1.7 |
300 | 300 | |
301 | | - if ( array_key_exists( 'intro', $params ) ) { $this->mIntro = $params['intro']; } |
302 | | - if ( array_key_exists( 'outro', $params ) ) { $this->mOutro = $params['outro']; } |
303 | | - |
304 | | - if ( array_key_exists( 'searchlabel', $params ) ) { |
305 | | - $this->mSearchlabel = $params['searchlabel'] === false ? null : $params['searchlabel']; |
306 | | - } |
| 301 | + $this->mIntro = $params['intro']; |
| 302 | + $this->mOutro = $params['outro']; |
307 | 303 | |
| 304 | + $this->mSearchlabel = $params['searchlabel'] === false ? null : $params['searchlabel']; |
| 305 | + |
308 | 306 | switch ( $params['link'] ) { |
309 | 307 | case 'head': case 'subject': |
310 | 308 | $this->mLinkFirst = true; |
— | — | @@ -319,7 +317,7 @@ |
320 | 318 | break; |
321 | 319 | } |
322 | 320 | |
323 | | - if ( array_key_exists( 'default', $params ) ) { $this->mDefault = str_replace( '_', ' ', $params['default'] ); } |
| 321 | + $this->mDefault = str_replace( '_', ' ', $params['default'] ); |
324 | 322 | |
325 | 323 | if ( $params['headers'] == 'hide' ) { |
326 | 324 | $this->mShowHeaders = SMW_HEADERS_HIDE; |
— | — | @@ -471,44 +469,28 @@ |
472 | 470 | * formats, like 'list' and 'table', for use in their getParameters() |
473 | 471 | * functions |
474 | 472 | * |
| 473 | + * @deperecated since 1.8, removal in 1.10 |
| 474 | + * |
475 | 475 | * @since 1.5.0 |
476 | 476 | * |
477 | 477 | * @return array of Parameter |
478 | 478 | */ |
479 | 479 | protected function textDisplayParameters() { |
480 | | - $params = array(); |
481 | | - |
482 | | - $params['intro'] = new Parameter( 'intro' ); |
483 | | - $params['intro']->setMessage( 'smw_paramdesc_intro' ); |
484 | | - $params['intro']->setDefault( '' ); |
485 | | - |
486 | | - $params['outro'] = new Parameter( 'outro' ); |
487 | | - $params['outro']->setMessage( 'smw_paramdesc_outro' ); |
488 | | - $params['outro']->setDefault( '' ); |
489 | | - |
490 | | - $params['default'] = new Parameter( 'default' ); |
491 | | - $params['default']->setMessage( 'smw_paramdesc_default' ); |
492 | | - $params['default']->setDefault( '' ); |
493 | | - |
494 | | - return $params; |
| 480 | + return array(); |
495 | 481 | } |
496 | 482 | |
497 | 483 | /** |
498 | 484 | * Return an array describing the parameters of the export formats |
499 | 485 | * like 'rss' and 'csv', for use in their getParameters() functions |
500 | 486 | * |
| 487 | + * @deperecated since 1.8, removal in 1.10 |
| 488 | + * |
501 | 489 | * @since 1.5.0 |
502 | 490 | * |
503 | 491 | * @return array |
504 | 492 | */ |
505 | 493 | protected function exportFormatParameters() { |
506 | | - $params = array(); |
507 | | - |
508 | | - $params['searchlabel'] = new Parameter( 'searchlabel' ); |
509 | | - $params['searchlabel']->setMessage( 'smw_paramdesc_searchlabel' ); |
510 | | - $params['searchlabel']->setDefault( false, false ); |
511 | | - |
512 | | - return $params; |
| 494 | + return array(); |
513 | 495 | } |
514 | 496 | |
515 | 497 | /** |
— | — | @@ -575,9 +557,6 @@ |
576 | 558 | * any specific format - most query printers should override this |
577 | 559 | * function. |
578 | 560 | * |
579 | | - * TODO: refactor non-printer params up to the query processor |
580 | | - * and do all param handling there. |
581 | | - * |
582 | 561 | * @since 1.5 |
583 | 562 | * |
584 | 563 | * @return array of Parameter |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -134,9 +134,11 @@ |
135 | 135 | |
136 | 136 | $result = self::newTypeIdValue( $typeId, false, $caption, $property ); |
137 | 137 | $result->setDataItem( $dataItem ); |
| 138 | + |
138 | 139 | if ( $caption !== false ) { |
139 | 140 | $result->setCaption( $caption ); |
140 | 141 | } |
| 142 | + |
141 | 143 | return $result; |
142 | 144 | } |
143 | 145 | |