Commit dc9bfc51 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Merge branch '1214-use-yahoo-on-metager-org' into 'development'

Resolve "Use Yahoo on metager.org"

Closes #1214

See merge request !1997
parents 52adeff1 f6aa62cd
......@@ -556,9 +556,10 @@ class MetaGer
# Check if this engine should only be active when filter is used
if ($suma->{"filter-opt-in"}) {
# This search engine should only be used when a parameter filter of it is used
# and no other search engine can provide this filter
$validTmp = false;
foreach ($this->parameterFilter as $filterName => $filter) {
if (!empty($filter->sumas->{$sumaName})) {
if (count((array)$filter->sumas) === 1 && !empty($filter->sumas->{$sumaName})) {
$validTmp = true;
break;
}
......
......@@ -3,6 +3,7 @@
namespace app\Models\parserSkripte;
use App\Models\Searchengine;
use LaravelLocalization;
use Log;
class Overture extends Searchengine
......@@ -12,11 +13,33 @@ class Overture extends Searchengine
public function __construct($name, \stdClass $engine, \App\MetaGer $metager)
{
parent::__construct($name, $engine, $metager);
$this->checkLanguage();
# We need some Affil-Data for the advertisements
$this->getString = $this->generateGetString($this->query);
$this->getString .= $this->getOvertureAffilData($metager->getUrl());
$this->updateHash();
}
private function checkLanguage()
{
if (LaravelLocalization::getCurrentLocale() === 'en') {
$supported_default_languages = [
"en_US" => "us",
"en_GB" => "gb",
"en_IE" => "ie",
"en_AU" => "au",
"en_NZ" => "nz",
];
$preferred_language = request()->getPreferredLanguage(\array_keys($supported_default_languages));
if (\array_key_exists($preferred_language, $supported_default_languages)) {
$this->engine->{"get-parameter"}->mkt = $supported_default_languages[$preferred_language];
}
}
}
public function loadResults($result)
{
$result = preg_replace("/\r\n/si", "", $result);
......@@ -137,6 +160,21 @@ class Overture extends Searchengine
$affil_data = 'ip=' . $this->ip;
$affil_data .= '&ua=' . $this->useragent;
$affilDataValue = $this->urlEncode($affil_data);
$serve_domain = "https://metager.de/";
if (LaravelLocalization::getCurrentLocale() === "en") {
$serve_domain = "https://metager.org/";
}
if (\preg_match("/https:\/\/.*\.review\.metager\.de\//", $url)) {
$url = \preg_replace("/https:\/\/.*\.review\.metager\.de\//", $serve_domain, $url);
}
if (\strpos($url, "https://metager3.de") === 0) {
$url = str_replace("https://metager3.de", $serve_domain, $url);
}
# Wir benötigen die ServeUrl:
$serveUrl = $this->urlEncode($url);
......
......@@ -94,6 +94,7 @@ return [
"filter.market.ea" => "Englisch (Australien)",
"filter.market.ec" => "Englisch (Kanada)",
"filter.market.ei" => "Englisch (Indien)",
"filter.market.eir" => "Englisch (Irland)",
"filter.market.ein" => "Englisch (Indonesien)",
"filter.market.em" => "Englisch (Malaysia)",
"filter.market.enz" => "Englisch (Neuseeland)",
......
......@@ -94,6 +94,7 @@ return [
"filter.market.ea" => "English (Australia)",
"filter.market.ec" => "English (Canada)",
"filter.market.ei" => "English (India)",
"filter.market.eir" => "English (Ireland)",
"filter.market.ein" => "English (Indonesia)",
"filter.market.em" => "English (Malaysia)",
"filter.market.enz" => "English (New Zealand)",
......
Supports Markdown
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