From e0b3f7123ac7d4e2437a905d5e50da9798487ddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=20H=C3=B6fer?= <phil@suma-ev.de> Date: Wed, 10 Aug 2016 08:49:34 +0200 Subject: [PATCH] =?UTF-8?q?Pixabay=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/parserSkripte/Pixabay.php | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 app/Models/parserSkripte/Pixabay.php diff --git a/app/Models/parserSkripte/Pixabay.php b/app/Models/parserSkripte/Pixabay.php new file mode 100644 index 000000000..7753204e8 --- /dev/null +++ b/app/Models/parserSkripte/Pixabay.php @@ -0,0 +1,52 @@ +<?php + +namespace app\Models\parserSkripte; +use App\Models\Searchengine; +use Symfony\Component\DomCrawler\Crawler; + +class Pixabay extends Searchengine +{ + public $results = []; + + function __construct (\SimpleXMLElement $engine, \App\MetaGer $metager) + { + parent::__construct($engine, $metager); + } + + public function loadResults ($result) + { + $result = preg_replace("/\r\n/si", "", $result); + try { + $content = json_decode($result); + } catch (\Exception $e) { + abort(500, "$result is not a valid json string"); + } + + if(!$content) + { + return; + } + + $results = $content->hits; + foreach($results as $result) + { + $title = $result->tags; + $link = $result->pageURL; + $anzeigeLink = $link; + $descr = ""; + $image = $result->previewURL; + $this->counter++; + $this->results[] = new \App\Models\Result( + $this->engine, + $title, + $link, + $anzeigeLink, + $descr, + $this->gefVon, + $this->counter, + false, + $image + ); + } + } +} -- GitLab