Commit 848043c8 authored by Karl's avatar Karl

Pagination für die Bildersuchmaschinen eingefügt

parent d2dcd467
......@@ -30,24 +30,14 @@ class Europeana extends Searchengine
foreach ($results as $result) {
if (isset($result->edmPreview)) {
$title = $result->title[0];
if (preg_match("/(.+)\?.*/si", $result->guid, $match)) {
$link = $match[1];
} else {
$link = "";
}
$anzeigeLink = $link;
$descr = "";
/*if (preg_match("/(?:uri=)(.+)/si", urldecode($result->edmPreview[0]), $match)){
$image = $match[1];
} else {
$image = "";
}
echo $image . "
";*/
$image = urldecode($result->edmPreview[0]);
$image = urldecode($result->edmPreview[0]);
$this->counter++;
$this->results[] = new \App\Models\Result(
$this->engine,
......@@ -63,4 +53,17 @@ class Europeana extends Searchengine
}
}
}
public function getNext(\App\MetaGer $metager, $result)
{
$start = ($metager->getPage()) * 10 + 1;
$content = json_decode($result);
if ($start > $content->totalResults) {
return;
}
$next = new Europeana(simplexml_load_string($this->engine), $metager);
$next->getString .= "&start=" . $start;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
......@@ -46,4 +46,27 @@ class Flickr extends Searchengine
);
}
}
public function getNext(\App\MetaGer $metager, $result)
{
$page = $metager->getPage() + 1;
$result = preg_replace("/\r\n/si", "", $result);
$content = simplexml_load_string($result);
$results = $content->xpath('//photos')[0];
try {
$content = simplexml_load_string($result);
} catch (\Exception $e) {
abort(500, "$result is not a valid xml string");
}
if (!$content) {
return;
}
if ($page >= intval($results["pages"]->__toString())) {
return;
}
$next = new Flickr(simplexml_load_string($this->engine), $metager);
$next->getString .= "&page=" . $page;
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
......@@ -47,4 +47,16 @@ class Openclipart extends Searchengine
);
}
}
public function getNext(\App\MetaGer $metager, $result)
{
$content = json_decode($result);
if ($content->info->current_page > $content->info->pages) {
return;
}
$next = new Openclipart(simplexml_load_string($this->engine), $metager);
$next->getString .= "&page=" . ($metager->getPage() + 1);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
......@@ -47,4 +47,17 @@ class Pixabay extends Searchengine
);
}
}
public function getNext(\App\MetaGer $metager, $result)
{
$page = $metager->getPage() + 1;
$content = json_decode($result);
if ($page * 20 > $content->total) {
return;
}
$next = new Pixabay(simplexml_load_string($this->engine), $metager);
$next->getString .= "&page=" . $page;
$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