merge.php 859 Bytes
Newer Older
Orbmancer's avatar
Orbmancer committed
1
2
3
4
5
6
7
8
<?php

error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once 'model/Data.class.php';
require_once 'model/Tabs.class.php';

9
$td = $_POST['td'];
Orbmancer's avatar
Orbmancer committed
10
11
12

$levels = Data::loadXML($td);

Erwan Normand's avatar
Doc  
Erwan Normand committed
13
// Create the merged level
Erwan Normand's avatar
Erwan Normand committed
14
15
$finalTabs = new Tabs();
$finalTabs->fillBlank();
Orbmancer's avatar
Orbmancer committed
16

17
var_dump($levels);
Orbmancer's avatar
Orbmancer committed
18
19
20

foreach($levels as $level){
    $myContent = new Tabs();
Orbmancer's avatar
Orbmancer committed
21
    $myContent->importXML($level['data']);
22
    $finalTabs->setTab($myContent->getTab(), $level['x'], $level['y']);
Orbmancer's avatar
Orbmancer committed
23
24
}

Erwan Normand's avatar
Doc  
Erwan Normand committed
25
// Create the XML file
Erwan Normand's avatar
Erwan Normand committed
26
27
28
$finalFile = simplexml_load_file('data/level_layout.vvvvvv');
$finalFile->Data->contents = $finalTabs->toString();

Erwan Normand's avatar
Doc  
Erwan Normand committed
29
// Download the XML file
Erwan Normand's avatar
Erwan Normand committed
30
31
32
33
34
35
header('Content-type: text/xml');
header('Content-Disposition: attachment; filename=VVVVVV_level_merged.vvvvvvv');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
print($finalFile->asXML());