Skip to content
Snippets Groups Projects

Pagination für Onenewspage implementiert

Merged Dominik Hebeler requested to merge 202-onenewspage-zur-pagination-hinzufugen into development
3 files
+ 101
3
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -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;
}
}
Loading