From df4d72c805776f5dfc5a4bcca1ebd4633e4e928f Mon Sep 17 00:00:00 2001 From: Jeroen De Dauw Date: Wed, 21 Nov 2018 00:42:02 +0100 Subject: [PATCH] Clean KmlPrinter --- src/SemanticMW/ResultPrinters/KmlPrinter.php | 64 +++++++------------- 1 file changed, 21 insertions(+), 43 deletions(-) diff --git a/src/SemanticMW/ResultPrinters/KmlPrinter.php b/src/SemanticMW/ResultPrinters/KmlPrinter.php index cad08191a..e9af82874 100644 --- a/src/SemanticMW/ResultPrinters/KmlPrinter.php +++ b/src/SemanticMW/ResultPrinters/KmlPrinter.php @@ -8,42 +8,27 @@ use SMWQueryResult; /** - * SMWResultPrinter class for printing a query result as KML. - * - * @file SM_KMLPrinter.php - * @ingroup SemanticMaps - * * @licence GNU GPL v2+ * @author Jeroen De Dauw < jeroendedauw@gmail.com > */ class KmlPrinter extends FileExportPrinter { /** - * Handler of the print request. - * * @param SMWQueryResult $res - * @param $outputmode + * @param int $outputMode * - * @return array + * @return string */ - public function getResultText( SMWQueryResult $res, $outputmode ) { - if ( $outputmode == SMW_OUTPUT_FILE ) { - return $this->getKML( $res, $outputmode ); - } else { - return $this->getKMLLink( $res, $outputmode ); + public function getResultText( SMWQueryResult $res, $outputMode ) { + if ( $outputMode == SMW_OUTPUT_FILE ) { + return $this->getKML( $res, $outputMode ); } + + return $this->getKMLLink( $res, $outputMode ); } - /** - * Returns the KML for the query result. - * - * @param SMWQueryResult $res - * @param integer $outputmode - * - * @return string - */ - private function getKML( SMWQueryResult $res, $outputmode ) { - $queryHandler = new QueryHandler( $res, $outputmode, $this->params['linkabsolute'] ); + private function getKML( SMWQueryResult $res, int $outputMode ): string { + $queryHandler = new QueryHandler( $res, $outputMode, $this->params['linkabsolute'] ); $queryHandler->setText( $this->params['text'] ); $queryHandler->setTitle( $this->params['title'] ); $queryHandler->setSubjectSeparator( '' ); @@ -55,14 +40,9 @@ private function getKML( SMWQueryResult $res, $outputmode ) { /** * Returns a link (HTML) pointing to a query that returns the actual KML file. - * - * @param SMWQueryResult $res - * @param integer $outputmode - * - * @return string */ - private function getKMLLink( SMWQueryResult $res, $outputmode ) { - $searchLabel = $this->getSearchLabel( $outputmode ); + private function getKMLLink( SMWQueryResult $res, int $outputMode ): string { + $searchLabel = $this->getSearchLabel( $outputMode ); $link = $res->getQueryLink( $searchLabel ? $searchLabel : wfMessage( 'semanticmaps-kml-link' )->inContentLanguage()->text() ); @@ -93,9 +73,9 @@ private function getKMLLink( SMWQueryResult $res, $outputmode ) { $link->setParameter( 20, 'limit' ); } - $this->isHTML = ( $outputmode == SMW_OUTPUT_HTML ); + $this->isHTML = ( $outputMode == SMW_OUTPUT_HTML ); - return $link->getText( $outputmode, $this->mLinker ); + return $link->getText( $outputMode, $this->mLinker ); } /** @@ -103,35 +83,33 @@ private function getKMLLink( SMWQueryResult $res, $outputmode ) { * * @param ParamDefinition[] $definitions * - * @return array of ParamDefinition|array + * @return array */ public function getParamDefinitions( array $definitions ) { global $egMapsDefaultLabel, $egMapsDefaultTitle; - $params = parent::getParamDefinitions( $definitions ); - - $params['text'] = [ + $definitions['text'] = [ 'message' => 'semanticmaps-kml-text', 'default' => $egMapsDefaultLabel, ]; - $params['title'] = [ + $definitions['title'] = [ 'message' => 'semanticmaps-kml-title', 'default' => $egMapsDefaultTitle, ]; - $params['linkabsolute'] = [ + $definitions['linkabsolute'] = [ 'message' => 'semanticmaps-kml-linkabsolute', 'type' => 'boolean', 'default' => true, ]; - $params['pagelinktext'] = [ + $definitions['pagelinktext'] = [ 'message' => 'semanticmaps-kml-pagelinktext', 'default' => wfMessage( 'semanticmaps-default-kml-pagelink' )->text(), ]; - return $params; + return $definitions; } /** @@ -167,9 +145,9 @@ public final function getName() { * @see SMWResultPrinter::handleParameters * * @param array $params - * @param $outputmode + * @param $outputMode */ - protected function handleParameters( array $params, $outputmode ) { + protected function handleParameters( array $params, $outputMode ) { $this->params = $params; } }