-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
234d289
commit df4d72c
Showing
1 changed file
with
21 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 < [email protected] > | ||
*/ | ||
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,45 +73,43 @@ 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 ); | ||
} | ||
|
||
/** | ||
* @see SMWResultPrinter::getParamDefinitions | ||
* | ||
* @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; | ||
} | ||
} |