Browse code

Pridana nova restauracia Lochness

Cinan Rakosnik authored on 22/08/2013 at 09:33:06
Showing 2 changed files
... ...
@@ -4,6 +4,7 @@ require_once "Restaurant.php";
4 4
 require_once "Output.php";
5 5
 require_once "Parser.php";
6 6
 
7
+require_once "restaurants/Lochness.php";
7 8
 require_once "restaurants/Pulitzer.php";
8 9
 require_once "restaurants/Twenties.php";
9 10
 
... ...
@@ -17,6 +18,7 @@ require_once sprintf("outputs/%s.php", $outputClass);
17 17
 $output = new $outputClass();
18 18
 
19 19
 $restaurants[] = new Pulitzer();
20
+$restaurants[] = new Lochness();
20 21
 $restaurants[] = new Twenties();
21 22
 
22 23
 #todo http://www.irish-pub.sk/sk/denne-menu
23 24
new file mode 100644
... ...
@@ -0,0 +1,35 @@
0
+<?php
1
+class Lochness extends Restaurant {
2
+
3
+	function __construct() {
4
+		$day = date('N');
5
+		$row = 3*$day - 2;
6
+
7
+		parent::__construct(
8
+			"Lochness",
9
+			"http://www.lochnesspub.sk/category/obedove-menu/",
10
+			["Polievka aj zradlo" => "/html/body/div[3]/div/div/div[1]/table/tbody/tr[$row]"]
11
+		);
12
+	}
13
+
14
+	public function runCallbackParser($parentNode, iOutput $logger) {
15
+		$nodes = $parentNode->item(0)->childNodes;
16
+		if ($nodes->item(2) === NULL)
17
+		{
18
+			return '';
19
+		}
20
+
21
+		/** @var $meals DOMNode */
22
+		$meals = $nodes->item(2);
23
+		$i = 1;
24
+		foreach ($meals->childNodes as $elem)
25
+		{
26
+			$i++;
27
+			if ($i % 2) continue;
28
+
29
+			$logger->addMeal(trim($elem->nodeValue));
30
+		}
31
+
32
+		return TRUE;
33
+	}
34
+}