Commit f25497fb authored by Dominik Hebeler's avatar Dominik Hebeler

Witch zur Pagination hinzugefügt.

Pagination umgestellt:
* Es werden nur noch Links für die nächste Suche generiert
* Links für die letzte Suche werden nicht mehr generiert. Stattdessen wird per Javascript die History um eine Seite zurückgesetzt.
parent 75a08edc
......@@ -1051,18 +1051,6 @@ class MetaGer
return $link;
}
public function lastSearchLink()
{
if (isset($this->last) && count($this->last['engines']) > 0) {
$requestData = $this->request->except(['page', 'out']);
$requestData['next'] = md5(serialize($this->last));
$link = action('MetaGerSearch@search', $requestData);
} else {
$link = "#";
}
return $link;
}
public function nextSearchLink()
{
if (isset($this->next) && isset($this->next['engines']) && count($this->next['engines']) > 0) {
......
......@@ -75,10 +75,6 @@ abstract class Searchengine
abstract public function loadResults($result);
public function getLast(MetaGer $metager, $result)
{
}
public function getNext(MetaGer $metager, $result)
{
......@@ -159,7 +155,6 @@ abstract class Searchengine
if ($body !== "") {
$this->loadResults($body);
$this->getNext($metager, $body);
$this->getLast($metager, $body);
$this->loaded = true;
Redis::hdel('search.' . $this->hash, $this->name);
return true;
......
......@@ -46,20 +46,6 @@ class Onenewspage extends Searchengine
}
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) {
......
......@@ -46,20 +46,6 @@ class Onenewspagegermany extends Searchengine
}
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) {
......
......@@ -44,20 +44,6 @@ class Onenewspagevideo extends Searchengine
}
}
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) {
......
......@@ -63,34 +63,6 @@ class Overture extends Searchengine
}
}
public function getLast(\App\MetaGer $metager, $result)
{
# Auslesen der Argumente für die nächste Suchseite:
$result = preg_replace("/\r\n/si", "", $result);
try {
$content = simplexml_load_string($result);
} catch (\Exception $e) {
abort(500, "$result is not a valid xml string");
}
$lastArgs = $content->xpath('//Results/PrevArgs');
if (isset($lastArgs[0])) {
$lastArgs = $lastArgs[0]->__toString();
} else {
$lastArgs = $content->xpath('//Results/ResultSet[@id="inktomi"]/PrevArgs');
if (isset($lastArgs[0])) {
$lastArgs = $lastArgs[0]->__toString();
} else {
return;
}
}
# Erstellen des neuen Suchmaschinenobjekts und anpassen des GetStrings:
$last = new Overture(simplexml_load_string($this->engine), $metager);
$last->getString = preg_replace("/&Keywords=.*?&/si", "&", $last->getString) . "&" . $lastArgs;
$last->hash = md5($last->host . $last->getString . $last->port . $last->name);
$this->last = $last;
}
public function getNext(\App\MetaGer $metager, $result)
{
# Auslesen der Argumente für die nächste Suchseite:
......
......@@ -43,4 +43,17 @@ class Witch extends Searchengine
}
}
public function getNext(\App\MetaGer $metager, $result)
{
if (count($this->results) <= 0) {
return;
}
$next = new Witch(simplexml_load_string($this->engine), $metager);
$offset = $metager->getPage() * 10;
$next->getString = preg_replace("/&cn=\d+/si", "&cn=$offset", $next->getString);
$next->hash = md5($next->host . $next->getString . $next->port . $next->name);
$this->next = $next;
}
}
......@@ -52,18 +52,6 @@ class Yandex extends Searchengine
}
}
public function getLast(\App\MetaGer $metager, $result)
{
if ($metager->getPage() <= 1) {
return;
}
$last = new Yandex(simplexml_load_string($this->engine), $metager);
$last->getString .= "&page=" . ($metager->getPage() - 1);
$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) {
......
......@@ -43,7 +43,7 @@
@endforeach
<nav aria-label="...">
<ul class="pager">
<li @if($metager->lastSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->lastSearchLink() }}">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->getPage() === 1) class="disabled" @endif><a href="@if($metager->getPage() === 1) # @else javascript:history.back() @endif">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul>
</nav>
......
......@@ -38,7 +38,7 @@
</div>
<nav aria-label="...">
<ul class="pager">
<li @if($metager->lastSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->lastSearchLink() }}">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->getPage() === 1) class="disabled" @endif><a href="@if($metager->getPage() === 1) # @else javascript:history.back() @endif">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul>
</nav>
......
......@@ -35,7 +35,7 @@
</div>
<nav aria-label="...">
<ul class="pager">
<li @if($metager->lastSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->lastSearchLink() }}">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->getPage() === 1) class="disabled" @endif><a href="@if($metager->getPage() === 1) # @else javascript:history.back() @endif">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul>
</nav>
......@@ -36,7 +36,7 @@
@endforeach
<nav aria-label="...">
<ul class="pager">
<li @if($metager->lastSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->lastSearchLink() }}">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->getPage() === 1) class="disabled" @endif><a href="@if($metager->getPage() === 1) # @else javascript:history.back() @endif">{{ trans('results.zurueck') }}</a></li>
<li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul>
</nav>
......
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