Qip.php 973 Bytes
Newer Older
1
2
3
4
<?php

namespace app\Models\parserSkripte;
use App\Models\Searchengine;
5
use Log;
6
7
8
9
10

class Qip extends Searchengine 
{
	public $results = [];

11
	function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager)
12
13
14
15
	{
		parent::__construct($engine, $metager);
	}

16
	public function loadResults ($result)
17
	{
18
19
20
21
22
23
		$result = preg_replace("/\r\n/si", "", $result);
		try {
			$content = simplexml_load_string($result);
		} catch (\Exception $e) {
			abort(500, "$result is not a valid xml string");
		}
24
		
25
26
27
28
29
30
		if(!$content)
		{
			return;
		}
		$results = $content->xpath('//channel/item');
		foreach($results as $result)
31
		{
32
33
			$title = $result->{"title"}->__toString();
			$link = $result->{"link"}->__toString();
34
			$anzeigeLink = $link;
35
			$descr = $result->{"description"}->__toString();
36
37
38
39
40
41
42
43
44
			$this->counter++;
			$this->results[] = new \App\Models\Result(
				$this->engine,
				$title,
				$link,
				$anzeigeLink,
				$descr,
				$this->gefVon,
				$this->counter
45
			);
46
47
		}
	}
48
}