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
901024f4
Commit
901024f4
authored
Sep 29, 2016
by
Phil Höfer
Browse files
WIP: combineResults separiert
parent
095b8416
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/MetaGerSearch.php
View file @
901024f4
...
...
@@ -28,7 +28,7 @@ class MetaGerSearch extends Controller
$metager
->
rankAll
();
# Ergebnisse der Suchmaschinen kombinieren:
$metager
->
combin
eResults
();
$metager
->
prepar
eResults
();
# Die Ausgabe erstellen:
return
$metager
->
createView
();
...
...
app/MetaGer.php
View file @
901024f4
...
...
@@ -156,28 +156,18 @@ class MetaGer
}
}
public
function
combin
eResults
()
public
function
prepar
eResults
()
{
foreach
(
$this
->
engines
as
$engine
)
{
if
(
isset
(
$engine
->
next
))
{
$this
->
next
[]
=
$engine
->
next
;
}
if
(
isset
(
$engine
->
last
))
{
$this
->
last
[]
=
$engine
->
last
;
}
foreach
(
$engine
->
results
as
$result
)
{
if
(
$result
->
valid
)
{
$this
->
results
[]
=
$result
;
}
}
foreach
(
$engine
->
ads
as
$ad
)
{
$this
->
ads
[]
=
$ad
;
}
foreach
(
$engine
->
products
as
$product
)
{
$this
->
products
[]
=
$product
;
}
}
$engines
=
$this
->
engines
;
// combine
$combinedResults
=
$this
->
combineResults
(
$engines
);
// sort
//$sortedResults = $this->sortResults($engines);
// filter
// augment (boost&adgoal)
// authorize
// misc (WiP)
uasort
(
$this
->
results
,
function
(
$a
,
$b
)
{
if
(
$a
->
getRank
()
==
$b
->
getRank
())
{
return
0
;
...
...
@@ -275,6 +265,30 @@ class MetaGer
}
public
function
combineResults
(
$engines
)
{
foreach
(
$engines
as
$engine
)
{
if
(
isset
(
$engine
->
next
))
{
$this
->
next
[]
=
$engine
->
next
;
}
if
(
isset
(
$engine
->
last
))
{
$this
->
last
[]
=
$engine
->
last
;
}
foreach
(
$engine
->
results
as
$result
)
{
if
(
$result
->
valid
)
{
$this
->
results
[]
=
$result
;
}
}
foreach
(
$engine
->
ads
as
$ad
)
{
$this
->
ads
[]
=
$ad
;
}
foreach
(
$engine
->
products
as
$product
)
{
$this
->
products
[]
=
$product
;
}
}
}
public
function
parseBoost
(
$results
)
{
foreach
(
$results
as
$result
)
{
...
...
Write
Preview
Markdown
is supported
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