Skip to content

Add custom kml filename support#847

Merged
JeroenDeDauw merged 2 commits intoProfessionalWiki:masterfrom
hcooper:master
Apr 2, 2026
Merged

Add custom kml filename support#847
JeroenDeDauw merged 2 commits intoProfessionalWiki:masterfrom
hcooper:master

Conversation

@hcooper
Copy link
Copy Markdown
Contributor

@hcooper hcooper commented Mar 24, 2026

Currently the filename of the outputted kml file is hard coded to kml.kml.

This change makes it possible to provide a custom filename.

Still defaults to kml.kml.

image

Summary by CodeRabbit

  • New Features

    • KML export now lets you specify a custom download filename for exported KML files.
    • If no filename is provided, a sensible default name is used to keep downloads predictable.
  • Localization

    • Added an English label/description for the KML filename setting so it appears correctly in the UI.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2558dd27-bbc6-4c21-9f36-a7233030d88b

📥 Commits

Reviewing files that changed from the base of the PR and between a79b761 and bb86f4b.

📒 Files selected for processing (2)
  • i18n/qqq.json
  • src/SemanticMW/KmlPrinter.php
✅ Files skipped from review due to trivial changes (1)
  • i18n/qqq.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/SemanticMW/KmlPrinter.php

📝 Walkthrough

Walkthrough

Adds a new exported filename parameter to the KML printer (defaults to empty), uses it when non-empty for generated filenames and KML links (ensuring a .kml suffix), and introduces English and qqq i18n entries for semanticmaps-kml-filename.

Changes

Cohort / File(s) Summary
KML printer
src/SemanticMW/KmlPrinter.php
Adds exported filename parameter (message: semanticmaps-kml-filename, default empty string); getFileName() returns configured filename when non-empty (appends .kml if missing), otherwise returns literal kml.kml; getKMLLink() appends filename query parameter only when non-empty.
i18n (English)
i18n/en.json
Adds semanticmaps-kml-filename: "The filename for the KML file".
i18n (context)
i18n/qqq.json
Adds semanticmaps-kml-filename entry with `{{doc-paramdesc

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add custom kml filename support' directly and clearly summarizes the main change: adding a new filename parameter to the KML printer that allows custom naming of exported KML files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/SemanticMW/KmlPrinter.php`:
- Around line 61-63: The filename presence check is inconsistent; replace the
`!empty` predicate with the same explicit check used elsewhere so both branches
use the same logic (e.g. require isset($this->params['filename']) and compare
!== ''), and then call $link->setParameter($this->params['filename'],
'filename') only when that check passes; update the block that currently uses
`!empty($this->params['filename'])` so it matches the other branch's check to
avoid differing behavior for values like '0'.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f78c0f0-79cb-43aa-b2bf-20ba25b2c5ee

📥 Commits

Reviewing files that changed from the base of the PR and between 87e80ce and 5b5a4c5.

📒 Files selected for processing (2)
  • i18n/en.json
  • src/SemanticMW/KmlPrinter.php

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/SemanticMW/KmlPrinter.php (1)

111-114: Avoid duplicating the default filename literal.

'kml.kml' is defined here and again in getFileName(). A shared class constant reduces drift risk.

♻️ Proposed refactor
 class KmlPrinter extends FileExportPrinter {
+	private const DEFAULT_KML_FILENAME = 'kml.kml';
@@
 		$definitions['filename'] = [
 			'message' => 'semanticmaps-kml-filename',
-			'default' => 'kml.kml',
+			'default' => self::DEFAULT_KML_FILENAME,
 		];
@@
 	public function getFileName( QueryResult $queryResult ) {
 		if ( $this->params['filename'] !== '' ) {
 			return $this->params['filename'];
 		}
-		return 'kml.kml';
+		return self::DEFAULT_KML_FILENAME;
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/SemanticMW/KmlPrinter.php` around lines 111 - 114, Replace the duplicated
literal 'kml.kml' with a single class constant to avoid drift: add a constant
like DEFAULT_FILENAME = 'kml.kml' to the KmlPrinter class, then use that
constant in the $definitions['filename'] default and in getFileName() (replace
occurrences of 'kml.kml' with self::DEFAULT_FILENAME) so both places reference
the same identifier.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/SemanticMW/KmlPrinter.php`:
- Around line 111-114: Replace the duplicated literal 'kml.kml' with a single
class constant to avoid drift: add a constant like DEFAULT_FILENAME = 'kml.kml'
to the KmlPrinter class, then use that constant in the $definitions['filename']
default and in getFileName() (replace occurrences of 'kml.kml' with
self::DEFAULT_FILENAME) so both places reference the same identifier.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5434f679-5f4a-4106-baa3-f4df6c0a3054

📥 Commits

Reviewing files that changed from the base of the PR and between 5b5a4c5 and d54c1ef.

📒 Files selected for processing (2)
  • i18n/en.json
  • src/SemanticMW/KmlPrinter.php
✅ Files skipped from review due to trivial changes (1)
  • i18n/en.json

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/SemanticMW/KmlPrinter.php (1)

111-114: Consider centralizing the default filename constant.

Line 113 introduces 'kml.kml', but the same default is also hardcoded in getFileName. A shared class constant would avoid future drift.

Refactor sketch
 class KmlPrinter extends FileExportPrinter {
+	private const DEFAULT_KML_FILENAME = 'kml.kml';
@@
 		$definitions['filename'] = [
 			'message' => 'semanticmaps-kml-filename',
-			'default' => 'kml.kml',
+			'default' => self::DEFAULT_KML_FILENAME,
 		];
@@
-		return 'kml.kml';
+		return self::DEFAULT_KML_FILENAME;
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/SemanticMW/KmlPrinter.php` around lines 111 - 114, Replace the two
hardcoded defaults by introducing a single class-level constant (e.g.
DEFAULT_FILENAME) and use it wherever the default filename is needed: update the
$definitions['filename'] default array entry (the assignment that sets 'default'
=> 'kml.kml') to reference the new constant, and update the getFileName method
to return that same constant when no filename is provided; ensure the constant
is defined in the KmlPrinter class and used in both places to prevent drift.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/SemanticMW/KmlPrinter.php`:
- Around line 111-114: Replace the two hardcoded defaults by introducing a
single class-level constant (e.g. DEFAULT_FILENAME) and use it wherever the
default filename is needed: update the $definitions['filename'] default array
entry (the assignment that sets 'default' => 'kml.kml') to reference the new
constant, and update the getFileName method to return that same constant when no
filename is provided; ensure the constant is defined in the KmlPrinter class and
used in both places to prevent drift.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 141ab2cd-0110-46a1-80c1-7ac8accd642a

📥 Commits

Reviewing files that changed from the base of the PR and between d54c1ef and 1ec68ea.

📒 Files selected for processing (2)
  • i18n/en.json
  • src/SemanticMW/KmlPrinter.php
✅ Files skipped from review due to trivial changes (1)
  • i18n/en.json

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/SemanticMW/KmlPrinter.php (1)

111-114: Avoid duplicating the default filename literal.

'kml.kml' is now defined here and again in the fallback return path. Consider a class constant to keep this single-sourced.

Proposed refactor
 class KmlPrinter extends FileExportPrinter {
+	private const DEFAULT_KML_FILENAME = 'kml.kml';
@@
 		$definitions['filename'] = [
 			'message' => 'semanticmaps-kml-filename',
-			'default' => 'kml.kml',
+			'default' => self::DEFAULT_KML_FILENAME,
 		];
@@
 	public function getFileName( QueryResult $queryResult ) {
 		if ( $this->params['filename'] !== '' ) {
 			return $this->params['filename'];
 		}
-		return 'kml.kml';
+		return self::DEFAULT_KML_FILENAME;
 	}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/SemanticMW/KmlPrinter.php` around lines 111 - 114, The literal 'kml.kml'
is duplicated in the file; introduce a class constant (e.g. DEFAULT_FILENAME) in
the KmlPrinter class and replace both occurrences: set
$definitions['filename']['default'] to self::DEFAULT_FILENAME and use
self::DEFAULT_FILENAME in the fallback return path (and any other places
referencing the literal) so the default filename is single-sourced and
maintainable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/SemanticMW/KmlPrinter.php`:
- Around line 111-114: The literal 'kml.kml' is duplicated in the file;
introduce a class constant (e.g. DEFAULT_FILENAME) in the KmlPrinter class and
replace both occurrences: set $definitions['filename']['default'] to
self::DEFAULT_FILENAME and use self::DEFAULT_FILENAME in the fallback return
path (and any other places referencing the literal) so the default filename is
single-sourced and maintainable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cc7ea9ae-87a5-4052-be29-c3d14a6db1e6

📥 Commits

Reviewing files that changed from the base of the PR and between 1ec68ea and a79b761.

📒 Files selected for processing (2)
  • i18n/en.json
  • src/SemanticMW/KmlPrinter.php
✅ Files skipped from review due to trivial changes (1)
  • i18n/en.json

- Change default from 'kml.kml' to '' so the filename parameter only
  affects link URLs and Content-Disposition when explicitly set,
  preserving existing behavior for all current users
- Enforce .kml extension on custom filenames to prevent misleading
  download names (e.g. 'data.html' → 'data.html.kml')
- Add missing qqq.json message documentation for translators

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@JeroenDeDauw JeroenDeDauw merged commit f61bc4e into ProfessionalWiki:master Apr 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants