Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
427d9b0d
Commit
427d9b0d
authored
Sep 28, 2016
by
Karl
Browse files
checkSpecialSearches ist jetzt unterteilt
parent
0f4775c6
Changes
1
Show whitespace changes
Inline
Side-by-side
app/MetaGer.php
View file @
427d9b0d
...
...
@@ -858,7 +858,15 @@ class MetaGer
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
))
{
$this
->
site
=
$match
[
2
];
$this
->
q
=
$match
[
1
]
.
$match
[
3
];
...
...
@@ -866,9 +874,10 @@ class MetaGer
if
(
$request
->
has
(
'site'
))
{
$this
->
site
=
$request
->
input
(
'site'
);
}
}
#
Host
Blacklist
ing
# Wenn die Suchanfrage um das Schlüsselwort "-host:*" ergänzt ist, sollen bestimmte Hosts nicht eingeblendet werden
public
function
searchCheck
HostBlacklist
()
{
while
(
preg_match
(
"/(.*)(^|\s)-host:(\S+)(.*)/si"
,
$this
->
q
,
$match
))
{
$this
->
hostBlacklist
[]
=
$match
[
3
];
$this
->
q
=
$match
[
1
]
.
$match
[
4
];
...
...
@@ -881,9 +890,10 @@ class MetaGer
$hostString
=
rtrim
(
$hostString
,
", "
);
$this
->
warnings
[]
=
trans
(
'metaGer.formdata.hostBlacklist'
,
[
'host'
=>
$hostString
]);
}
}
#
Domain
Blacklist
ing
# Wenn die Suchanfrage um das Schlüsselwort "-domain:*" ergänzt ist, sollen bestimmte Domains nicht eingeblendet werden
public
function
searchCheck
DomainBlacklist
()
{
while
(
preg_match
(
"/(.*)(^|\s)-domain:(\S+)(.*)/si"
,
$this
->
q
,
$match
))
{
$this
->
domainBlacklist
[]
=
$match
[
3
];
$this
->
q
=
$match
[
1
]
.
$match
[
4
];
...
...
@@ -896,9 +906,10 @@ class MetaGer
$domainString
=
rtrim
(
$domainString
,
", "
);
$this
->
warnings
[]
=
trans
(
'metaGer.formdata.domainBlacklist'
,
[
'domain'
=>
$domainString
]);
}
}
#
Stopwords
# Alle mit "-" gepräfixten Worte sollen aus der Suche ausgeschlossen werden.
public
function
searchCheck
Stopwords
()
{
while
(
preg_match
(
"/(.*)(^|\s)-(\S+)(.*)/si"
,
$this
->
q
,
$match
))
{
$this
->
stopWords
[]
=
$match
[
3
];
$this
->
q
=
$match
[
1
]
.
$match
[
4
];
...
...
@@ -911,8 +922,10 @@ class MetaGer
$stopwordsString
=
rtrim
(
$stopwordsString
,
", "
);
$this
->
warnings
[]
=
trans
(
'metaGer.formdata.stopwords'
,
[
'stopwords'
=>
$stopwordsString
]);
}
}
# Phrasensuche
public
function
searchCheckPhrase
()
{
$p
=
""
;
$tmp
=
$this
->
q
;
while
(
preg_match
(
"/(.*)
\"
(.+)
\"
(.*)/si"
,
$tmp
,
$match
))
{
...
...
@@ -972,7 +985,6 @@ class MetaGer
}
else
{
return
null
;
}
}
public
function
hasProducts
()
...
...
@@ -990,9 +1002,7 @@ class MetaGer
foreach
(
$this
->
products
as
$product
)
{
$return
[]
=
get_object_vars
(
$product
);
}
#die(var_dump($return));
return
$return
;
}
public
function
canCache
()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment