diff --git a/app/Models/parserSkripte/BASE.php b/app/Models/parserSkripte/BASE.php index e5c223e4537a1a7b65124a14c726b2a2e572ad30..aaee5b1f79e8f3a2096dbb32c75213822bd7d6b4 100644 --- a/app/Models/parserSkripte/BASE.php +++ b/app/Models/parserSkripte/BASE.php @@ -3,6 +3,7 @@ namespace app\Models\parserSkripte; use App\Models\Searchengine; +use Log; class BASE extends Searchengine { @@ -15,6 +16,47 @@ class BASE extends Searchengine public function loadResults($result) { - return; + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = simplexml_load_string($result); + if (!$content) { + return; + } + + $results = $content->xpath('//response/result'); + foreach ($results as $result) { + // searches for the fitting values of name as in + // <str name = "dctitle">Digitisation of library collections</str> + foreach ($result as $attribute) { + switch ((string) $attribute['name']) { + case 'dctitle': + $title = $attribute; + break; + case 'dclink': + $link = $attribute; + $anzeigeLink = $link; + break; + case 'dcdescription': + $descr = $attribute; + break; + } + } + if (isset($title) && isset($link) && isset($anzeigeLink) && isset($descr)) { + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter + ); + } + } + } catch (\Exception $e) { + Log::error("A problem occurred parsing results from $this->name"); + return; + } } }