Skip to content
Snippets Groups Projects
Commit e2111be1 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch 'development' into 'master'

Development

See merge request !1036
parents 1c7e852e 14d1e633
No related branches found
No related tags found
3 merge requests!1061Development,!1046Patch,!1036Development
......@@ -95,10 +95,8 @@ class MetaGer
foreach ($this->results as $result) {
$viewResults[] = get_object_vars($result);
}
# Wir müssen natürlich noch den Log für die durchgeführte Suche schreiben:
$this->createLogs();
if ($this->fokus === "bilder") {
switch ($this->out) {
case 'results':
......@@ -166,6 +164,10 @@ class MetaGer
->with('metager', $this)
->with('resultcount', sizeof($viewResults));
break;
case 'atom10':
return response()->view('metager3resultsatom10', ['results' => $viewResults,'eingabe' => $this->eingabe,'metager' => $this,'resultcount' => sizeof($viewResults)])
->header('Content-Type', 'application/xml');
break;
case 'result-count':
# Wir geben die Ergebniszahl und die benötigte Zeit zurück:
return sizeof($viewResults) . ";" . round((microtime(true) - $this->starttime), 2);
......@@ -235,6 +237,9 @@ class MetaGer
#Adgoal Implementation
$this->results = $this->parseAdgoal($this->results);
#Amazon Affiliate (MetaGers tag ist: metager04-21)
$this->results = $this->parseAmazon($this->results);
$counter = 0;
$firstRank = 0;
......@@ -433,6 +438,34 @@ class MetaGer
return $results;
}
public function parseAmazon($results)
{
$amazonTag = "metager04-21";
foreach ($results as $result) {
$link = $result->anzeigeLink;
if (strpos($link, "http") !== 0) {
$link = "http://" . $link;
}
$info = parse_url($link);
if(isset($info["host"])){
$host = $info['host'];
$newurl = $link;
if(strpos($host, "amazon") !== FALSE){
# This is Probably an Amazon Link. We'll add our tag as get parameter
if(isset($info["query"])){
$newurl .= "&tag=metager04-21";
}else{
$newurl .= "?tag=metager04-21";
}
}
$result->link = $newurl;
$result->partnershop = true;
}
}
return $results;
}
public function authorize($key)
{
......@@ -1013,7 +1046,7 @@ class MetaGer
$this->out = $request->input('out', "html");
# Standard output format html
if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "rss20" && $this->out !== "rich") {
if ($this->out !== "html" && $this->out !== "json" && $this->out !== "results" && $this->out !== "results-with-style" && $this->out !== "result-count" && $this->out !== "rss20" && $this->out !== "atom10" && $this->out !== "rich") {
$this->out = "html";
}
# Wir schalten den Cache aus, wenn die Ergebniszahl überprüft werden soll
......
<?xmlversion = "1.0"encoding = "UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"
xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
xmlns:mg="http://metager.de/opensearch/">
<title>{!! htmlspecialchars($eingabe, ENT_XML1, 'UTF-8'); !!} - MetaGer</title>
<link href="{{ url()->full() }}"/>
<updated>{{ date('c') }}</updated>
<opensearch:totalResults>{{ $resultcount }}</opensearch:totalResults>
<opensearch:Query role="request" searchTerms="{{ htmlspecialchars($eingabe, ENT_QUOTES) }}"/>
<link rel="next" href="{{htmlspecialchars($metager->nextSearchLink() ,ENT_QUOTES)}}" type="application/atom+xml"/>
<id>urn:uuid:1d634a8c-2764-424f-b082-6c96494b7240</id>
@foreach($metager->getResults() as $result)
<entry>
<title>{!! htmlspecialchars($result->titel, ENT_XML1, 'UTF-8'); !!}</title>
<link href="{!! htmlspecialchars($result->link, ENT_XML1, 'UTF-8'); !!}" />
<mg:anzeigeLink>{!! htmlspecialchars($result->anzeigeLink, ENT_XML1, 'UTF-8'); !!}</mg:anzeigeLink>
<content type="text">
{!! htmlspecialchars($result->longDescr, ENT_XML1, 'UTF-8'); !!}
</content>
</entry>
@endforeach
</feed>
<!-- Muster zu finden unter http://www.opensearch.org/Specifications/OpenSearch/1.1#Example_of_OpenSearch_response_elements_in_RSS_2.0 -->
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment