Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_KMLPrinter.php |
— | — | @@ -23,43 +23,43 @@ |
24 | 24 | * @return array |
25 | 25 | */ |
26 | 26 | public function getResultText( /* SMWQueryResult */ $res, $outputmode ) { |
27 | | - $validator = new Validator( $this->getName(), false ); |
28 | | - |
29 | | - $validator->setParameters( $this->m_params, $this->getParameterInfo() ); |
30 | | - |
31 | | - $validator->validateParameters(); |
32 | | - |
33 | | - $fatalError = $validator->hasFatalError(); |
34 | | - |
35 | | - if ( $fatalError !== false ) { |
36 | | - return '<span class="errorbox">' . |
37 | | - htmlspecialchars( wfMsgExt( 'validator-fatal-error', 'parsemag', $fatalError->getMessage() ) ) . |
38 | | - '</span>'; |
39 | | - } |
40 | | - |
41 | | - $params = $validator->getParameterValues(); |
42 | | - |
43 | 27 | if ( $outputmode == SMW_OUTPUT_FILE ) { |
44 | | - return $this->getKML( $res, $outputmode, $params ); |
| 28 | + return $this->getKML( $res, $outputmode ); |
45 | 29 | } |
46 | 30 | else { |
47 | | - return $this->getLink( $res, $outputmode, $params ); |
| 31 | + return $this->getLink( $res, $outputmode ); |
48 | 32 | } |
49 | 33 | } |
50 | 34 | |
51 | 35 | /** |
| 36 | + * @see SMWResultPrinter::handleParameters |
| 37 | + * |
| 38 | + * @since 1.0 |
| 39 | + * |
| 40 | + * @param array $params |
| 41 | + * @param $outputmode |
| 42 | + */ |
| 43 | + protected function handleParameters( array $params, $outputmode ) { |
| 44 | + $this->m_params = $params; |
| 45 | + } |
| 46 | + |
| 47 | + /** |
52 | 48 | * Returns a list of parameter definitions. |
53 | 49 | * |
54 | 50 | * @since 0.7.4 |
55 | 51 | * |
56 | 52 | * @return array |
57 | 53 | */ |
58 | | - protected function getParameterInfo() { |
59 | | - $params = array(); |
| 54 | + public function getParameters() { |
| 55 | + global $egMapsDefaultLabel, $egMapsDefaultTitle; |
60 | 56 | |
61 | | - $params[] = new Parameter( 'text' ); |
62 | | - $params[] = new Parameter( 'title' ); |
| 57 | + $params = array_merge( parent::getParameters(), $this->exportFormatParameters() ); |
63 | 58 | |
| 59 | + $params['text'] = new Parameter( 'text', Parameter::TYPE_STRING, $egMapsDefaultLabel ); |
| 60 | + //$params['text']->setDescription(); |
| 61 | + |
| 62 | + $params['title'] = new Parameter( 'title', Parameter::TYPE_STRING, $egMapsDefaultTitle ); |
| 63 | + |
64 | 64 | $params[] = new Parameter( 'linkabsolute', Parameter::TYPE_BOOLEAN, true ); |
65 | 65 | |
66 | 66 | $params['pagelinktext'] = new Parameter( 'pagelinktext', Parameter::TYPE_STRING, wfMsg( 'semanticmaps-default-kml-pagelink' ) ); |
— | — | @@ -74,17 +74,16 @@ |
75 | 75 | * |
76 | 76 | * @param SMWQueryResult $res |
77 | 77 | * @param integer $outputmode |
78 | | - * @param array $params |
79 | 78 | * |
80 | 79 | * @return string |
81 | 80 | */ |
82 | | - protected function getKML( SMWQueryResult $res, $outputmode, array $params ) { |
83 | | - $queryHandler = new SMQueryHandler( $res, $outputmode, $params['linkabsolute'], $params['pagelinktext'], false ); |
84 | | - $queryHandler->setText( $params['text'] ); |
85 | | - $queryHandler->setTitle( $params['title'] ); |
| 81 | + protected function getKML( SMWQueryResult $res, $outputmode ) { |
| 82 | + $queryHandler = new SMQueryHandler( $res, $outputmode, $this->m_params['linkabsolute'], $this->m_params['pagelinktext'], false ); |
| 83 | + $queryHandler->setText( $this->m_params['text'] ); |
| 84 | + $queryHandler->setTitle( $this->m_params['title'] ); |
86 | 85 | $queryHandler->setSubjectSeparator( '' ); |
87 | 86 | |
88 | | - $formatter = new MapsKMLFormatter( $params ); |
| 87 | + $formatter = new MapsKMLFormatter( $this->m_params ); |
89 | 88 | $formatter->addPlacemarks( $queryHandler->getLocations() ); |
90 | 89 | |
91 | 90 | return $formatter->getKML(); |
— | — | @@ -97,18 +96,17 @@ |
98 | 97 | * |
99 | 98 | * @param SMWQueryResult $res |
100 | 99 | * @param integer $outputmode |
101 | | - * @param array $params |
102 | 100 | * |
103 | 101 | * @return string |
104 | 102 | */ |
105 | | - protected function getLink( SMWQueryResult $res, $outputmode, array $params ) { |
| 103 | + protected function getLink( SMWQueryResult $res, $outputmode ) { |
106 | 104 | $searchLabel = $this->getSearchLabel( $outputmode ); |
107 | 105 | $link = $res->getQueryLink( $searchLabel ? $searchLabel : wfMsgForContent( 'semanticmaps-kml-link' ) ); |
108 | 106 | $link->setParameter( 'kml', 'format' ); |
109 | 107 | |
110 | | - $link->setParameter( $params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute' ); |
| 108 | + $link->setParameter( $this->m_params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute' ); |
111 | 109 | |
112 | | - $link->setParameter( $params['pagelinktext'], 'pagelinktext' ); |
| 110 | + $link->setParameter( $this->m_params['pagelinktext'], 'pagelinktext' ); |
113 | 111 | |
114 | 112 | if ( array_key_exists( 'limit', $this->m_params ) ) { |
115 | 113 | $link->setParameter( $this->m_params['limit'], 'limit' ); |