Skip to content
Snippets Groups Projects
Commit 427d9b0d authored by Karl's avatar Karl
Browse files

checkSpecialSearches ist jetzt unterteilt

parent 0f4775c6
Branches
No related tags found
1 merge request!1365Resolve "Filter Options for MetaGer"
...@@ -858,7 +858,15 @@ class MetaGer ...@@ -858,7 +858,15 @@ class MetaGer
public function checkSpecialSearches(Request $request) public function checkSpecialSearches(Request $request)
{ {
# Site Search $this->searchCheckSitesearch($request);
$this->searchCheckHostBlacklist();
$this->searchCheckDomainBlacklist();
$this->searchCheckStopwords();
$this->searchCheckPhrase();
}
public function searchCheckSitesearch($request)
{
if (preg_match("/(.*)\bsite:(\S+)(.*)/si", $this->q, $match)) { if (preg_match("/(.*)\bsite:(\S+)(.*)/si", $this->q, $match)) {
$this->site = $match[2]; $this->site = $match[2];
$this->q = $match[1] . $match[3]; $this->q = $match[1] . $match[3];
...@@ -866,9 +874,10 @@ class MetaGer ...@@ -866,9 +874,10 @@ class MetaGer
if ($request->has('site')) { if ($request->has('site')) {
$this->site = $request->input('site'); $this->site = $request->input('site');
} }
}
# Host Blacklisting public function searchCheckHostBlacklist()
# Wenn die Suchanfrage um das Schlüsselwort "-host:*" ergänzt ist, sollen bestimmte Hosts nicht eingeblendet werden {
while (preg_match("/(.*)(^|\s)-host:(\S+)(.*)/si", $this->q, $match)) { while (preg_match("/(.*)(^|\s)-host:(\S+)(.*)/si", $this->q, $match)) {
$this->hostBlacklist[] = $match[3]; $this->hostBlacklist[] = $match[3];
$this->q = $match[1] . $match[4]; $this->q = $match[1] . $match[4];
...@@ -881,9 +890,10 @@ class MetaGer ...@@ -881,9 +890,10 @@ class MetaGer
$hostString = rtrim($hostString, ", "); $hostString = rtrim($hostString, ", ");
$this->warnings[] = trans('metaGer.formdata.hostBlacklist', ['host' => $hostString]); $this->warnings[] = trans('metaGer.formdata.hostBlacklist', ['host' => $hostString]);
} }
}
# Domain Blacklisting public function searchCheckDomainBlacklist()
# Wenn die Suchanfrage um das Schlüsselwort "-domain:*" ergänzt ist, sollen bestimmte Domains nicht eingeblendet werden {
while (preg_match("/(.*)(^|\s)-domain:(\S+)(.*)/si", $this->q, $match)) { while (preg_match("/(.*)(^|\s)-domain:(\S+)(.*)/si", $this->q, $match)) {
$this->domainBlacklist[] = $match[3]; $this->domainBlacklist[] = $match[3];
$this->q = $match[1] . $match[4]; $this->q = $match[1] . $match[4];
...@@ -896,9 +906,10 @@ class MetaGer ...@@ -896,9 +906,10 @@ class MetaGer
$domainString = rtrim($domainString, ", "); $domainString = rtrim($domainString, ", ");
$this->warnings[] = trans('metaGer.formdata.domainBlacklist', ['domain' => $domainString]); $this->warnings[] = trans('metaGer.formdata.domainBlacklist', ['domain' => $domainString]);
} }
}
# Stopwords public function searchCheckStopwords()
# Alle mit "-" gepräfixten Worte sollen aus der Suche ausgeschlossen werden. {
while (preg_match("/(.*)(^|\s)-(\S+)(.*)/si", $this->q, $match)) { while (preg_match("/(.*)(^|\s)-(\S+)(.*)/si", $this->q, $match)) {
$this->stopWords[] = $match[3]; $this->stopWords[] = $match[3];
$this->q = $match[1] . $match[4]; $this->q = $match[1] . $match[4];
...@@ -911,8 +922,10 @@ class MetaGer ...@@ -911,8 +922,10 @@ class MetaGer
$stopwordsString = rtrim($stopwordsString, ", "); $stopwordsString = rtrim($stopwordsString, ", ");
$this->warnings[] = trans('metaGer.formdata.stopwords', ['stopwords' => $stopwordsString]); $this->warnings[] = trans('metaGer.formdata.stopwords', ['stopwords' => $stopwordsString]);
} }
}
# Phrasensuche public function searchCheckPhrase()
{
$p = ""; $p = "";
$tmp = $this->q; $tmp = $this->q;
while (preg_match("/(.*)\"(.+)\"(.*)/si", $tmp, $match)) { while (preg_match("/(.*)\"(.+)\"(.*)/si", $tmp, $match)) {
...@@ -972,7 +985,6 @@ class MetaGer ...@@ -972,7 +985,6 @@ class MetaGer
} else { } else {
return null; return null;
} }
} }
public function hasProducts() public function hasProducts()
...@@ -990,9 +1002,7 @@ class MetaGer ...@@ -990,9 +1002,7 @@ class MetaGer
foreach ($this->products as $product) { foreach ($this->products as $product) {
$return[] = get_object_vars($product); $return[] = get_object_vars($product);
} }
#die(var_dump($return));
return $return; return $return;
} }
public function canCache() public function canCache()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment