Commit 95f9abd6 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

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 3b4149d3
...@@ -1051,18 +1051,6 @@ class MetaGer ...@@ -1051,18 +1051,6 @@ class MetaGer
return $link; 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() public function nextSearchLink()
{ {
if (isset($this->next) && isset($this->next['engines']) && count($this->next['engines']) > 0) { if (isset($this->next) && isset($this->next['engines']) && count($this->next['engines']) > 0) {
......
...@@ -75,10 +75,6 @@ abstract class Searchengine ...@@ -75,10 +75,6 @@ abstract class Searchengine
abstract public function loadResults($result); abstract public function loadResults($result);
public function getLast(MetaGer $metager, $result)
{
}
public function getNext(MetaGer $metager, $result) public function getNext(MetaGer $metager, $result)
{ {
...@@ -159,7 +155,6 @@ abstract class Searchengine ...@@ -159,7 +155,6 @@ abstract class Searchengine
if ($body !== "") { if ($body !== "") {
$this->loadResults($body); $this->loadResults($body);
$this->getNext($metager, $body); $this->getNext($metager, $body);
$this->getLast($metager, $body);
$this->loaded = true; $this->loaded = true;
Redis::hdel('search.' . $this->hash, $this->name); Redis::hdel('search.' . $this->hash, $this->name);
return true; return true;
......
...@@ -46,20 +46,6 @@ class Onenewspage extends Searchengine ...@@ -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) public function getNext(\App\MetaGer $metager, $result)
{ {
if (count($this->results) <= 0) { if (count($this->results) <= 0) {
......
...@@ -46,20 +46,6 @@ class Onenewspagegermany extends Searchengine ...@@ -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) public function getNext(\App\MetaGer $metager, $result)
{ {
if (count($this->results) <= 0) { if (count($this->results) <= 0) {
......
...@@ -44,20 +44,6 @@ class Onenewspagevideo extends Searchengine ...@@ -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) public function getNext(\App\MetaGer $metager, $result)
{ {
if (count($this->results) <= 0) { if (count($this->results) <= 0) {
......
...@@ -63,34 +63,6 @@ class Overture extends Searchengine ...@@ -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) public function getNext(\App\MetaGer $metager, $result)
{ {
# Auslesen der Argumente für die nächste Suchseite: # Auslesen der Argumente für die nächste Suchseite:
......
...@@ -43,4 +43,17 @@ class Witch extends Searchengine ...@@ -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 ...@@ -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) public function getNext(\App\MetaGer $metager, $result)
{ {
if (count($this->results) <= 0) { if (count($this->results) <= 0) {
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
@endforeach @endforeach
<nav aria-label="..."> <nav aria-label="...">
<ul class="pager"> <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> <li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul> </ul>
</nav> </nav>
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
</div> </div>
<nav aria-label="..."> <nav aria-label="...">
<ul class="pager"> <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> <li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul> </ul>
</nav> </nav>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</div> </div>
<nav aria-label="..."> <nav aria-label="...">
<ul class="pager"> <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> <li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul> </ul>
</nav> </nav>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
@endforeach @endforeach
<nav aria-label="..."> <nav aria-label="...">
<ul class="pager"> <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> <li @if($metager->nextSearchLink() === "#") class="disabled" @endif><a href="{{ $metager->nextSearchLink() }}">{{ trans('results.weiter') }}</a></li>
</ul> </ul>
</nav> </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