Onenewspagevideo.php 1.85 KB
Newer Older
1
2
3
<?php

namespace app\Models\parserSkripte;
4

5
6
use App\Models\Searchengine;

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

12
    private $offset = 0;
13
14
15
16
    public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
    {
        parent::__construct($engine, $metager);
    }
17

18
19
20
21
22
23
24
25
    public function loadResults($result)
    {
        $results = trim($result);
        foreach (explode("\n", $results) as $result) {
            $res = explode("|", $result);
            if (sizeof($res) < 3) {
                continue;
            }
26
27
28
29
30
            $title                 = $res[0];
            $link                  = $res[2];
            $anzeigeLink           = $link;
            $descr                 = $res[1];
            $additionalInformation = sizeof($res) > 3 ? ['date' => intval($res[3])] : [];
31

32
33
34
35
36
37
38
            $this->counter++;
            $this->results[] = new \App\Models\Result(
                $this->engine,
                $title,
                $link,
                $anzeigeLink,
                $descr,
39
                $this->displayName,$this->homepage,
40
41
                $this->counter,
                $additionalInformation
42
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 Onenewspagevideo(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
    }
}