Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions doc/config.sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,17 @@ config:
- My Category 2
ext-ns-file-repo-compat: true
include-history: false
# Multi-wiki output: define which Confluence spaces go into which import file.
# Each top-level key becomes a separate output file: output-{WikiName}.xml
# Under 'spaces', map each Confluence space key to the target namespace prefix
# inside that wiki. Use "" for NS_MAIN (no prefix), or e.g. "MyNS:" for a
# custom namespace. Cross-space links automatically use the source-space key
# as namespace (e.g. a page in SpaceA linking to SpaceB produces [[B:PageB]]).
wikis:
WikiA:
spaces:
A: "" # Space A → NS_MAIN in WikiA
C: "MyNS:" # Space C → MyNS: namespace in WikiA
WikiB:
spaces:
B: "" # Space B → NS_MAIN in WikiB
37 changes: 37 additions & 0 deletions src/Composer/ConfluenceComposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ class ConfluenceComposer extends ComposerBase implements IOutputAwareInterface,
/** @var string */
private $dest = '';

/** @var bool */
private $multiWikiOutputEnabled = false;

/**
* Config from `wikis` key: wikiName → [ 'spaces' => [ spaceKey => targetNsPrefix ] ]
*
* @var array
*/
private $wikisConfig = [];

/**
* @param array $config
* @param Workspace $workspace
Expand All @@ -47,6 +57,10 @@ public function __construct( $config, Workspace $workspace, DataBuckets $buckets
if ( isset( $config['config'] ) ) {
$this->advancedConfig = $config['config'];
}
if ( isset( $this->advancedConfig['wikis'] ) && is_array( $this->advancedConfig['wikis'] ) ) {
$this->wikisConfig = $this->advancedConfig['wikis'];
$this->multiWikiOutputEnabled = true;
}
}

/**
Expand All @@ -68,6 +82,11 @@ public function setDestinationPath( string $dest ): void {
* @return void
*/
public function buildXML( Builder $builder ) {
if ( $this->multiWikiOutputEnabled ) {
$this->buildXMLMultiWiki();
return;
}

$processors = [
new Files(
$builder, $this->buckets, $this->workspace,
Expand All @@ -85,4 +104,22 @@ public function buildXML( Builder $builder ) {

$this->customBuckets->saveToWorkspace( $this->workspace );
}

/**
* Build the full multi-wiki XML output by delegating to MultiWikiComposer.
*
* @return void
*/
private function buildXMLMultiWiki(): void {
$multiWikiComposer = new MultiWikiComposer(
$this->wikisConfig,
$this->buckets,
$this->workspace,
$this->advancedConfig,
$this->output,
$this->dest,
$this->customBuckets
);
$multiWikiComposer->compose();
}
}
Loading
Loading