-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshark.php
66 lines (48 loc) · 1.63 KB
/
shark.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
62
63
64
65
66
<?php
require_once './classes/Parser.php';
require_once './classes/MapReader.php';
require_once './classes/Config.php';
require_once './classes/FileWriter.php';
require_once './classes/HTMLRenderer.php';
require_once './classes/Log.php';
const TAG ='Shark';
$ditafiles = array();
// load config from build file -- config file contains all information required to build docs
// FIXME - INI/Build file needs to be passed in via command line
$buildfile = "sample.ini";
Config::$config = parse_ini_file($buildfile);
if (Config::$config == false)
{
Log::Fatal(TAG, "Failed to load configuration from build file '$buildfile'");
exit (-1);
}
$doc_root = getcwd(); // save where we are
Config::$config['doc_root'] = $doc_root;
$reader = new MapReader();
$ditafiles = $reader->start($ditamap);
chdir($doc_root); // make sure we go back to the doc root
// select a renderer based on output type requested
$render_type = strtoupper($render_type); // we will compare on upper case
switch ($render_type) {
case 'HTML':
$renderer = new HTMLRenderer();
$writer = new FileWriter();
break;
case 'PDF':
//$renderer = new PDFRenderer($this);
break;
case 'DATABASE':
//$renderer = new DatabaseRenderer($this);
break;
default:
Log::Fatal(TAG, "That output type is not supported, so cannot create renderer.");
exit (-1);
break;
}
$parser = new Parser($renderer);
foreach ($ditafiles as $ditafile){
$document = $parser->parse($ditafile);
$renderer->clear();
$writer->write($ditafile, $document); // write document out, note ditafile is the input file as we need this to work out the output file name
}
?>