Skip to content
Snippets Groups Projects
Commit 65d011cc authored by Karl Hasselbring's avatar Karl Hasselbring
Browse files

Merge branch '272-zu-viele-bilderergebnisse-auf-einer-seite' into 'development'

Pagination für die Bildersuchmaschinen eingefügt

Closes #272

See merge request !470
parents d9c8e8da 848043c8
No related branches found
No related tags found
2 merge requests!473Development,!470Pagination für die Bildersuchmaschinen eingefügt
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment