Index: trunk/extensions/SemanticResultFormats/SemanticResultFormats.php |
— | — | @@ -20,8 +20,17 @@ |
21 | 21 | die( 'Not an entry point.' ); |
22 | 22 | } |
23 | 23 | |
24 | | -define( 'SRF_VERSION', '1.6.2' ); |
| 24 | +// Show a warning if Semantic MediaWiki is not loaded. |
| 25 | +if ( ! defined( 'SMW_VERSION' ) ) { |
| 26 | + die( '<b>Error:</b> You need to have <a href="http://semantic-mediawiki.org/wiki/Semantic_MediaWiki">Semantic MediaWiki</a> installed in order to use <a href="http://www.mediawiki.org/wiki/Extension:Semantic Result Formats">Semantic Result Formats</a>.<br />' ); |
| 27 | +} |
25 | 28 | |
| 29 | +if ( version_compare( SMW_VERSION, '1.6.2 alpha', '<' ) ) { |
| 30 | + die( '<b>Error:</b> This version of Semantic Result Formats requires Semantic MediaWiki 1.6.3 or above; use Semantic Result Formats <= 1.6.2 for older versions of SMW.' ); |
| 31 | +} |
| 32 | + |
| 33 | +define( 'SRF_VERSION', '1.6.3 alpha' ); |
| 34 | + |
26 | 35 | // Require the settings file. |
27 | 36 | require dirname( __FILE__ ) . '/SRF_Settings.php'; |
28 | 37 | |
Index: trunk/extensions/SemanticResultFormats/Timeline/SRF_Timeline.php |
— | — | @@ -22,38 +22,27 @@ |
23 | 23 | protected $m_tlbands = ''; // array of band IDs (MONTH, YEAR, ...) |
24 | 24 | protected $m_tlpos = ''; // position identifier (start, end, today, middle) |
25 | 25 | |
26 | | - protected function readParameters( $params, $outputmode ) { |
27 | | - parent::readParameters( $params, $outputmode ); |
28 | | - |
29 | | - if ( array_key_exists( 'timelinestart', $params ) ) { |
30 | | - $this->m_tlstart = smwfNormalTitleDBKey( $params['timelinestart'] ); |
31 | | - } |
32 | | - if ( array_key_exists( 'timelineend', $params ) ) { |
33 | | - $this->m_tlend = smwfNormalTitleDBKey( $params['timelineend'] ); |
34 | | - } |
| 26 | + /** |
| 27 | + * @see SMWResultPrinter::handleParameters |
| 28 | + * |
| 29 | + * @since 1.6.3 |
| 30 | + * |
| 31 | + * @param array $params |
| 32 | + * @param $outputmode |
| 33 | + */ |
| 34 | + protected function handleParameters( array $params, $outputmode ) { |
| 35 | + parent::handleParameters( $params, $outputmode ); |
35 | 36 | |
36 | | - if ( array_key_exists( 'timelinesize', $params ) ) { |
37 | | - $this->m_tlsize = htmlspecialchars( str_replace( ';', ' ', strtolower( trim( $params['timelinesize'] ) ) ) ); |
| 37 | + $this->m_tlstart = smwfNormalTitleDBKey( $params['timelinestart'] ); |
| 38 | + $this->m_tlend = smwfNormalTitleDBKey( $params['timelineend'] ); |
| 39 | + $this->m_tlbands = $params['timelinebands']; |
| 40 | + $this->m_tlpos = strtolower( trim( $params['timelineposition'] ) ); |
| 41 | + |
38 | 42 | // str_replace makes sure this is only one value, not mutliple CSS fields (prevent CSS attacks) |
39 | 43 | // / FIXME: this is either unsafe or redundant, since Timeline is Wiki-compatible. If the JavaScript makes user inputs to CSS then it is bad even if we block this injection path. |
40 | | - } else { |
41 | | - $this->m_tlsize = '300px'; |
42 | | - } |
43 | | - |
44 | | - if ( array_key_exists( 'timelinebands', $params ) ) { |
45 | | - // check for band parameter, should look like "DAY,MONTH,YEAR" |
46 | | - $this->m_tlbands = preg_split( '/[,][\s]*/u', trim( $params['timelinebands'] ) ); |
47 | | - } else { |
48 | | - $this->m_tlbands = array( 'MONTH', 'YEAR' ); // / TODO: check what default the JavaScript uses |
49 | | - } |
50 | | - |
51 | | - if ( array_key_exists( 'timelineposition', $params ) ) { |
52 | | - $this->m_tlpos = strtolower( trim( $params['timelineposition'] ) ); |
53 | | - } else { |
54 | | - $this->m_tlpos = 'middle'; |
55 | | - } |
| 44 | + $this->m_tlsize = htmlspecialchars( str_replace( ';', ' ', strtolower( $params['timelinesize'] ) ) ); |
56 | 45 | } |
57 | | - |
| 46 | + |
58 | 47 | public function getName() { |
59 | 48 | return wfMsg( 'srf_printername_' . $this->mFormat ); |
60 | 49 | } |
— | — | @@ -70,16 +59,7 @@ |
71 | 60 | if ( ( $pr->getMode() == SMWPrintRequest::PRINT_PROP ) && ( $pr->getTypeID() == '_dat' ) ) { |
72 | 61 | $dataValue = $pr->getData(); |
73 | 62 | |
74 | | - // SMW >= 1.6 |
75 | | - if ( method_exists ( $dataValue, 'getDataItem' ) ) { |
76 | | - $date_value = $dataValue->getDataItem()->getLabel(); |
77 | | - } // SMW 1.5.x |
78 | | - elseif ( method_exists ( $dataValue, 'getValueKey' ) ) { |
79 | | - $date_value = $dataValue->getValueKey(); |
80 | | - } // SMW < 1.5 |
81 | | - else { |
82 | | - $date_value = $dataValue->getXSDValue(); |
83 | | - } |
| 63 | + $date_value = $dataValue->getDataItem()->getLabel(); |
84 | 64 | |
85 | 65 | if ( ( $this->m_tlend == '' ) && ( $this->m_tlstart != '' ) && |
86 | 66 | ( $this->m_tlstart != $date_value ) ) { |
— | — | @@ -395,12 +375,28 @@ |
396 | 376 | public function getParameters() { |
397 | 377 | $params = parent::getParameters(); |
398 | 378 | |
399 | | - $params[] = array( 'name' => 'timelinebands', 'type' => 'enum-list', 'description' => wfMsg( 'srf_paramdesc_timelinebands' ), 'values' => array( 'DECADE', 'YEAR', 'MONTH', 'WEEK', 'DAY', 'HOUR', 'MINUTE' ) ); |
400 | | - $params[] = array( 'name' => 'timelineposition', 'type' => 'enumeration', 'description' => wfMsg( 'srf_paramdesc_timelineposition' ), 'values' => array( 'start', 'middle', 'end' ) ); |
401 | | - $params[] = array( 'name' => 'timelinestart', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_timelinestart' ) ); |
402 | | - $params[] = array( 'name' => 'timelineend', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_timelineend' ) ); |
403 | | - $params[] = array( 'name' => 'timelinesize', 'type' => 'string', 'description' => wfMsg( 'srf_paramdesc_timelinesize' ) ); |
| 379 | + $params['timelinesize'] = new Parameter( 'timelinesize' ); |
| 380 | + $params['timelinesize']->setDefault( '300px' ); |
| 381 | + $params['timelinesize']->setMessage( 'srf_paramdesc_timelinesize' ); |
| 382 | + |
| 383 | + $params['timelineposition'] = new Parameter( 'timelineposition' ); |
| 384 | + $params['timelineposition']->setDefault( 'middle' ); |
| 385 | + $params['timelineposition']->setMessage( 'srf_paramdesc_timelineposition' ); |
| 386 | + $params['timelineposition']->addCriteria( new CriterionInArray( 'start', 'middle', 'end' ) ); |
404 | 387 | |
| 388 | + $params['timelinestart'] = new Parameter( 'timelinestart' ); |
| 389 | + $params['timelinestart']->setDefault( '' ); |
| 390 | + $params['timelinestart']->setMessage( 'srf_paramdesc_timelinestart' ); |
| 391 | + |
| 392 | + $params['timelineend'] = new Parameter( 'timelineend' ); |
| 393 | + $params['timelineend']->setDefault( '' ); |
| 394 | + $params['timelineend']->setMessage( 'srf_paramdesc_timelineend' ); |
| 395 | + |
| 396 | + $params['timelinebands'] = new ListParameter( 'timelinebands' ); |
| 397 | + $params['timelinebands']->setDefault( array( 'MONTH', 'YEAR' ) ); |
| 398 | + $params['timelinebands']->setMessage( 'srf_paramdesc_timelinebands' ); |
| 399 | + $params['timelinebands']->addCriteria( new CriterionInArray( 'DECADE', 'YEAR', 'MONTH', 'WEEK', 'DAY', 'HOUR', 'MINUTE' ) ); |
| 400 | + |
405 | 401 | return $params; |
406 | 402 | } |
407 | 403 | |