Browse code

Typ vystupu sa da nastavit v konfiguracnom subore

Cinan Rakosnik authored on 13/05/2013 at 00:23:42
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1 @@
0
+output = 'html'
0 1
\ No newline at end of file
... ...
@@ -3,8 +3,8 @@
3 3
 require_once "Restaurant.php";
4 4
 require_once "Output.php";
5 5
 require_once "Parser.php";
6
-require_once "outputs/EmailOutput.php";
7
-require_once "outputs/HtmlOutput.php";
6
+
7
+define('CONFIG_FILE', 'config.ini');
8 8
 
9 9
 $twenties = new Restaurant("Twenties", "http://www.twenties.sk/", array("Polievky" => '//*[@id="article"]/div[2]/p[1]'));
10 10
 $pulitzer = new Restaurant("Pulitzer", "http://www.pulitzer.sk",
... ...
@@ -15,8 +15,13 @@ $slovak = new Restaurant("Slovak pub", "http://www.arcaderestaurant.sk/articles/
15 15
         "Polievka" => '//*[@id="table2"]/tbody/tr[2]'));
16 16
 
17 17
 
18
-$htmlOutput = new HtmlOutput();
19
-$emailOutput= new EmailOutput();
20
-$parser     = new Parser($htmlOutput, array($twenties, $pulitzer, $slovak));
18
+$data = parse_ini_file(CONFIG_FILE);
19
+$outputType = ucfirst($data['output']);
20
+$outputClass = sprintf('%sOutput', $outputType);
21
+
22
+require_once sprintf("outputs/%s.php", $outputClass);
23
+$output = new $outputClass();
24
+
25
+$parser     = new Parser($output, array($twenties, $pulitzer, $slovak));
21 26
 $parser->parse();
22
-$htmlOutput->display();
23 27
\ No newline at end of file
28
+$output->display();
24 29
\ No newline at end of file