Skip to content

Commit d54c1ef

Browse files
committed
add kml output filename support
1 parent 87e80ce commit d54c1ef

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@
207207
"semanticmaps-kml-text": "The text associated with each page. Overridden by the additional queried properties if any.",
208208
"semanticmaps-kml-title": "The default title for results",
209209
"semanticmaps-kml-linkabsolute": "Should links be absolute (as opposed to relative)",
210+
"semanticmaps-kml-filename": "The filename for the KML file",
210211
"semanticmaps-kml-pagelinktext": "The text to use for the links to the page, in which $1 will be replaced by the page title",
211212
"semanticmaps-shapes-improperformat": "Improper formatting of $1. Please see documentation for formatting",
212213
"semanticmaps-shapes-missingshape": "No shapes found for $1. Please see documentation for available shapes",

src/SemanticMW/KmlPrinter.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ private function getKMLLink( QueryResult $res, int $outputMode ): string {
5858
$link->setParameter( $this->params['text'], 'text' );
5959
}
6060

61+
if ( $this->params['filename'] !== '' ) {
62+
$link->setParameter( $this->params['filename'], 'filename' );
63+
}
64+
6165
// Fix for offset-error in getQueryLink()
6266
// (getQueryLink by default sets offset to point to the next
6367
// result set, fix by setting it to 0 if now explicitly set)
@@ -104,6 +108,11 @@ public function getParamDefinitions( array $definitions ) {
104108
'default' => true,
105109
];
106110

111+
$definitions['filename'] = [
112+
'message' => 'semanticmaps-kml-filename',
113+
'default' => 'kml.kml',
114+
];
115+
107116
return $definitions;
108117
}
109118

@@ -126,6 +135,9 @@ public function getMimeType( QueryResult $queryResult ) {
126135
* @return string|boolean
127136
*/
128137
public function getFileName( QueryResult $queryResult ) {
138+
if ( $this->params['filename'] !== '' ) {
139+
return $this->params['filename'];
140+
}
129141
return 'kml.kml';
130142
}
131143

0 commit comments

Comments
 (0)