r88919 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88918‎ | r88919 | r88920 >
Date:19:46, 26 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
fixed param handling in KML printer
Modified paths:
  • /trunk/extensions/SemanticMaps/includes/queryprinters/SM_KMLPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMaps/includes/queryprinters/SM_KMLPrinter.php
@@ -23,43 +23,43 @@
2424 * @return array
2525 */
2626 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 -
4327 if ( $outputmode == SMW_OUTPUT_FILE ) {
44 - return $this->getKML( $res, $outputmode, $params );
 28+ return $this->getKML( $res, $outputmode );
4529 }
4630 else {
47 - return $this->getLink( $res, $outputmode, $params );
 31+ return $this->getLink( $res, $outputmode );
4832 }
4933 }
5034
5135 /**
 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+ /**
5248 * Returns a list of parameter definitions.
5349 *
5450 * @since 0.7.4
5551 *
5652 * @return array
5753 */
58 - protected function getParameterInfo() {
59 - $params = array();
 54+ public function getParameters() {
 55+ global $egMapsDefaultLabel, $egMapsDefaultTitle;
6056
61 - $params[] = new Parameter( 'text' );
62 - $params[] = new Parameter( 'title' );
 57+ $params = array_merge( parent::getParameters(), $this->exportFormatParameters() );
6358
 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+
6464 $params[] = new Parameter( 'linkabsolute', Parameter::TYPE_BOOLEAN, true );
6565
6666 $params['pagelinktext'] = new Parameter( 'pagelinktext', Parameter::TYPE_STRING, wfMsg( 'semanticmaps-default-kml-pagelink' ) );
@@ -74,17 +74,16 @@
7575 *
7676 * @param SMWQueryResult $res
7777 * @param integer $outputmode
78 - * @param array $params
7978 *
8079 * @return string
8180 */
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'] );
8685 $queryHandler->setSubjectSeparator( '' );
8786
88 - $formatter = new MapsKMLFormatter( $params );
 87+ $formatter = new MapsKMLFormatter( $this->m_params );
8988 $formatter->addPlacemarks( $queryHandler->getLocations() );
9089
9190 return $formatter->getKML();
@@ -97,18 +96,17 @@
9897 *
9998 * @param SMWQueryResult $res
10099 * @param integer $outputmode
101 - * @param array $params
102100 *
103101 * @return string
104102 */
105 - protected function getLink( SMWQueryResult $res, $outputmode, array $params ) {
 103+ protected function getLink( SMWQueryResult $res, $outputmode ) {
106104 $searchLabel = $this->getSearchLabel( $outputmode );
107105 $link = $res->getQueryLink( $searchLabel ? $searchLabel : wfMsgForContent( 'semanticmaps-kml-link' ) );
108106 $link->setParameter( 'kml', 'format' );
109107
110 - $link->setParameter( $params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute' );
 108+ $link->setParameter( $this->m_params['linkabsolute'] ? 'yes' : 'no', 'linkabsolute' );
111109
112 - $link->setParameter( $params['pagelinktext'], 'pagelinktext' );
 110+ $link->setParameter( $this->m_params['pagelinktext'], 'pagelinktext' );
113111
114112 if ( array_key_exists( 'limit', $this->m_params ) ) {
115113 $link->setParameter( $this->m_params['limit'], 'limit' );

Status & tagging log