Commit f42a6e8e authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '202-onenewspage-zur-pagination-hinzufugen' into 'development'

Pagination für Onenewspage implementiert

Closes #202

See merge request !322
parents a67a1941 3b4149d3
......@@ -6,8 +6,10 @@ use App\Models\Searchengine;
class Onenewspage extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
......@@ -38,6 +40,37 @@ class Onenewspage extends Searchengine
$this->counter
);
}
if (count($this->results) > $this->resultCount) {
$this->resultCount += count($this->results);
}
}
public function getLast(\App\MetaGer $metager, $result)
{
if ($metager->getPage() <= 1) {
return;
}
$last = new Onenewspage(simplexml_load_string($this->engine), $metager);
$last->resultCount = $this->resultCount;
$last->offset = $this->offset - $this->resultCount;
$last->getString .= "&o=" . $last->offset;
$last->hash = md5($last->host . $last->getString . $last->port . $last->name);
$this->last = $last;
}
public function getNext(\App\MetaGer $metager, $result)
{
if (count($this->results) <= 0) {
return;
}
$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;
}
}
......@@ -7,8 +7,10 @@ use App\Models\Searchengine;
class Onenewspagegermany extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
......@@ -38,6 +40,37 @@ class Onenewspagegermany extends Searchengine
}
}
if (count($this->results) > $this->resultCount) {
$this->resultCount += count($this->results);
}
}
public function getLast(\App\MetaGer $metager, $result)
{
if ($metager->getPage() <= 1) {
return;
}
$last = new Onenewspagegermany(simplexml_load_string($this->engine), $metager);
$last->resultCount = $this->resultCount;
$last->offset = $this->offset - $this->resultCount;
$last->getString .= "&o=" . $last->offset;
$last->hash = md5($last->host . $last->getString . $last->port . $last->name);
$this->last = $last;
}
public function getNext(\App\MetaGer $metager, $result)
{
if (count($this->results) <= 0) {
return;
}
$next = new Onenewspagegermany(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;
}
}
......@@ -6,8 +6,10 @@ use App\Models\Searchengine;
class Onenewspagevideo extends Searchengine
{
public $results = [];
public $results = [];
public $resultCount = 0;
private $offset = 0;
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
......@@ -37,6 +39,36 @@ class Onenewspagevideo extends Searchengine
$this->counter
);
}
if (count($this->results) > $this->resultCount) {
$this->resultCount += count($this->results);
}
}
public function getLast(\App\MetaGer $metager, $result)
{
if ($metager->getPage() <= 1) {
return;
}
$last = new Onenewspagevideo(simplexml_load_string($this->engine), $metager);
$last->resultCount = $this->resultCount;
$last->offset = $this->offset - $this->resultCount;
$last->getString .= "&o=" . $last->offset;
$last->hash = md5($last->host . $last->getString . $last->port . $last->name);
$this->last = $last;
}
public function getNext(\App\MetaGer $metager, $result)
{
if (count($this->results) <= 0) {
return;
}
$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;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment