Commit 55b217e2 authored by Aria Givi's avatar Aria Givi
Browse files

Minisucher werden über XML-Object übergeben

parent eeb68af1
......@@ -36,8 +36,7 @@ class MetaGer
protected $addedHosts = [];
protected $startCount = 0;
protected $canCache = false;
public $subcollections = "";
# Daten über die Abfrage
# Daten über die Abfrage$
protected $ip;
protected $language;
protected $agent;
......@@ -535,7 +534,7 @@ class MetaGer
}
# Sonderregelung für alle Suchmaschinen, die zu den Minisuchern gehören. Diese können alle gemeinsam über einen Link abgefragt werden
$this->subcollections = [];
$subcollections = [];
$tmp = [];
// Es gibt den Schalter "minism=on" Dieser soll bewirken, dass alle Minisucher angeschaltet werden.
......@@ -545,7 +544,7 @@ class MetaGer
// Wir laden alle Minisucher
foreach ($sumas as $engine) {
if (isset($engine["minismCollection"])) {
$this->subcollections[] = $engine["minismCollection"]->__toString();
$subcollections[] = $engine["minismCollection"]->__toString();
}
}
# Nur noch alle eventuell angeschalteten Minisucher deaktivieren
......@@ -558,15 +557,15 @@ class MetaGer
// Wir schalten eine Teilmenge, oder aber gar keine an
foreach ($enabledSearchengines as $engine) {
if (isset($engine['minismCollection'])) {
$this->subcollections[] = $engine['minismCollection']->__toString();
$subcollections[] = $engine['minismCollection']->__toString();
} else {
$tmp[] = $engine;
}
}
}
$enabledSearchengines = $tmp;
if (sizeof($this->subcollections) > 0) {
$enabledSearchengines[] = $this->loadMiniSucher($xml, $this->subcollections);
if (sizeof($subcollections) > 0) {
$enabledSearchengines[] = $this->loadMiniSucher($xml, $subcollections);
}
if ($sumaCount <= 0) {
$this->errors[] = trans('metaGer.settings.noneSelected');
......@@ -585,7 +584,7 @@ class MetaGer
$engine->setResultHash($this->getHashCode());
}
} else {
$engines = $this->actuallyCreateSearchEngines($enabledSearchengines, $siteSearchFailed, $this->subcollections);
$engines = $this->actuallyCreateSearchEngines($enabledSearchengines, $siteSearchFailed);
}
# Wir starten alle Suchen
......@@ -746,6 +745,7 @@ class MetaGer
public function loadMiniSucher($xml, $subcollections)
{
$minisucherEngine = $xml->xpath('suma[@name="minism"]')[0];
$minisucherEngine["subcollections"] = implode(", ", $subcollections);
$subcollections = urlencode("(" . implode(" OR ", $subcollections) . ")");
$minisucherEngine["formData"] = str_replace("<<SUBCOLLECTIONS>>", $subcollections, $minisucherEngine["formData"]);
$minisucherEngine["formData"] = str_replace("<<COUNT>>", sizeof($subcollections) * 10, $minisucherEngine["formData"]);
......
......@@ -22,7 +22,6 @@ abstract class Searchengine
public $products = []; # Die geladenen Produkte
public $loaded = false; # wahr, sobald die Ergebnisse geladen wurden
public $cached = false;
public $subcollections = "";
public $ip; # Die IP aus der metager
public $gefVon; # Der HTML-Code für die Verlinkung des Suchanbieters
......@@ -52,9 +51,6 @@ abstract class Searchengine
$this->homepage = "https://metager.de";
}
# Minisucher speichern
$this->subcollections = $metager->subcollections;
# Speichert die XML der Engine
$this->engine = $engine->asXML();
......
......@@ -6,7 +6,6 @@ use App\Models\Searchengine;
class Minisucher extends Searchengine
{
public function __construct(\SimpleXMLElement $engine, \App\MetaGer $metager)
{
parent::__construct($engine, $metager);
......@@ -14,7 +13,6 @@ class Minisucher extends Searchengine
if($metager->getFokus() === "nachrichten"){
$this->getString .= "sort=" . $this->urlencode("documentDate desc");
}
}
public function loadResults($content)
......@@ -56,7 +54,7 @@ class Minisucher extends Searchengine
$additionalInformation = ['date' => $dateVal];
$minism = implode(", ", $this->subcollections);
$minism = simplexml_load_string($this->engine)["subcollections"];
$gefVon = "<a href=\"https://metager.de\" target=\"_blank\" rel=\"noopener\">Minisucher: $minism </a>";
$this->results[] = new \App\Models\Result(
......
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