Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
427d9b0d
Commit
427d9b0d
authored
8 years ago
by
Karl
Browse files
Options
Downloads
Patches
Plain Diff
checkSpecialSearches ist jetzt unterteilt
parent
0f4775c6
Branches
Branches containing commit
No related tags found
1 merge request
!1365
Resolve "Filter Options for MetaGer"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/MetaGer.php
+21
-11
21 additions, 11 deletions
app/MetaGer.php
with
21 additions
and
11 deletions
app/MetaGer.php
+
21
−
11
View file @
427d9b0d
...
@@ -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
Blacklist
ing
public
function
searchCheck
HostBlacklist
()
# 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
Blacklist
ing
public
function
searchCheck
DomainBlacklist
()
# 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
searchCheck
Stopwords
()
# 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
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment