Onenewspage.php 1.66 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
use App\Models\Searchengine;

7
class Onenewspage extends Searchengine
8
{
9
10
    public $results     = [];
    public $resultCount = 0;
11

12
    private $offset = 0;
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
    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
    }

    public function loadResults($result)
    {
        $results = trim($result);

        foreach (explode("\n", $results) as $result) {
            $res = explode("|", $result);
            if (sizeof($res) < 3) {
                continue;
            }
            $title       = $res[0];
            $link        = $res[2];
            $anzeigeLink = $link;
            $descr       = $res[1];

            $this->counter++;
            $this->results[] = new \App\Models\Result(
                $this->engine,
                $title,
                $link,
                $anzeigeLink,
                $descr,
                $this->gefVon,
                $this->counter
            );
        }
43
44
45
46
47
48
49
50
51
52
53
        if (count($this->results) > $this->resultCount) {
            $this->resultCount += count($this->results);
        }

    }

    public function getNext(\App\MetaGer $metager, $result)
    {
        if (count($this->results) <= 0) {
            return;
        }
54

55
56
57
58
59
60
        $next              = new Onenewspage(simplexml_load_string($this->engine), $metager);
        $next->resultCount = $this->resultCount;
        $next->offset      = $this->offset + $this->resultCount;
        $next->getString .= "&o=" . $next->offset;
        $next->hash = md5($next->host . $next->getString . $next->port . $next->name);
        $this->next = $next;
61
62
    }
}