-
Notifications
You must be signed in to change notification settings - Fork 0
/
convert.php
61 lines (53 loc) · 1.63 KB
/
convert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
$GLOBALS['config']['config'] = array();
$GLOBALS['config']['tmpFolder'] = './tmp/';
$GLOBALS['config']['outputFolder'] = './output/';
$GLOBALS['config']['scale'] = 1;
include("src/functions.php");
include('src/preziobject.php');
include('src/objectfactory.php');
if ($argc != 2){
print("Help");
print("Call: ".$argv[0]." inputFile");
}
else{
$inputFile = $argv[1];
if(file_exists($inputFile) == false){
print("InputFile does not exist");
exit(1);
}
$GLOBALS['contentPath'] = $GLOBALS['config']['tmpFolder'].basename($inputFile,'.zip').'/content/';
if(is_dir($GLOBALS['contentPath']) == false){
if(unzip($inputFile,$GLOBALS['config']['tmpFolder'],false,true) == false){
print("Unzip failed");
exit(1);
}
}
$xmlDoc = simplexml_load_file($GLOBALS['contentPath'].'/data/content.xml');
$output_Handle = fopen($GLOBALS['config']['outputFolder'].'index.html','w+');
fwrite($output_Handle, file_get_contents('src/templates/head.html'));
// CSS
//fwrite($output_Handle,'<style type="text/css">');
//fwrite($output_Handle, $xmlDoc->style);
//fwrite($output_Handle,'</style>');
//fwrite($output_Handle,'<div style="position:absolute;">');
$objects = $xmlDoc->{'zui-table'}->object;
$collecedObjects = array();
$minX = 0;
$minY = 0;
foreach($objects as $obj){
$o = ObjectFactory::get($obj);
$collecedObjects[] = $o;
$minX = min($minX,$o->x);
$minY = min($minY,$o->y);
//print_r($o);
}
foreach($collecedObjects as $o){
$o->x = $o->x + abs($minX);
$o->y = $o->y + abs($minY);
fwrite($output_Handle, $o);
}
//fwrite($output_Handle,'</div>');
fwrite($output_Handle, file_get_contents('src/templates/foot.html'));
}
?>