Commit a0f6e181 authored by Dominik Hebeler's avatar Dominik Hebeler

Added freshness filter for the last year

parent 343a5346
<?php
namespace App;
class DynamicEngineParameters {
// Returns a string notating the Date Range of the last year
// The value is used as Parameter for the Bing search engine
// freshness Parameter
public static function FreshnessYearBing() {
$now = \Carbon::now()->format("Y-m-d");
$lastYear = \Carbon::now()->subYear()->format("Y-m-d");
return $lastYear . ".." . $now;
}
}
\ No newline at end of file
......@@ -1078,7 +1078,6 @@ class MetaGer
# IPv4
return preg_replace("/(\d+)\.(\d+)\.\d+.\d+/s", "$1.$2.0.0", $ip);
}
die(var_dump($ip));
}
public function checkSpecialSearches(Request $request)
......@@ -1116,7 +1115,7 @@ class MetaGer
if (($request->filled($filter->{"get-parameter"}) && $request->input($filter->{"get-parameter"}) !== "off") ||
\Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"}) !== null
) { # If the filter is set via Cookie
$this->parameterFilter[$filterName] = $filter;
$this->parameterFilter[$filterName] = $filter;
$this->parameterFilter[$filterName]->value = $request->input($filter->{"get-parameter"}, '');
if (empty($this->parameterFilter[$filterName]->value)) {
$this->parameterFilter[$filterName]->value = \Cookie::get($this->getFokus() . "_setting_" . $filter->{"get-parameter"});
......
......@@ -81,6 +81,7 @@ abstract class Searchengine
$q = $query . " " . $q;
}
$tmpPara = false;
# Parse enabled Parameter-Filter
foreach ($metager->getParameterFilter() as $filterName => $filter) {
$inputParameter = $filter->value;
......@@ -88,10 +89,16 @@ abstract class Searchengine
if (empty($inputParameter) || empty($filter->sumas->{$name}->values->{$inputParameter})) {
continue;
}
$tmpPara = true;
$engineParameterKey = $filter->sumas->{$name}->{"get-parameter"};
$engineParameterValue = $filter->sumas->{$name}->values->{$inputParameter};
if(stripos($engineParameterValue, "dyn-") === 0){
$functionname = substr($engineParameterValue, stripos($engineParameterValue, "dyn-") + 4);
$engineParameterValue = \App\DynamicEngineParameters::$functionname();
}
$this->engine->{"get-parameter"}->{$engineParameterKey} = $engineParameterValue;
}
#dd($this->engine->{"get-parameter"});
$this->getString = $this->generateGetString($q);
$this->updateHash();
......
......@@ -81,6 +81,7 @@ return [
"filter.freshness.day" => "Letzte 24h",
"filter.freshness.week" => "Letzte Woche",
"filter.freshness.month" => "Letzter Monat",
"filter.freshness.year" => "Letztes Jahr",
"filter.market" => "Sprache",
"filter.market.ga" => "Deutsch (Österreich)",
......
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