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
33743bf9
Commit
33743bf9
authored
Mar 05, 2018
by
Karl Hasselbring
Browse files
Twitter-Icon wird jetzt in der Redesign-Version über den View eingeblendet
parent
f7699a5c
Changes
2
Hide whitespace changes
Inline
Side-by-side
app/Models/Result.php
View file @
33743bf9
...
...
@@ -21,7 +21,7 @@ class Result
public
$proxyLink
;
# Der Link für die Seite über unseren Proxy-Service
public
$engineBoost
=
1
;
# Der Boost für den Provider des Suchergebnisses
public
$valid
=
true
;
# Ob das Ergebnis noch gültig ist (bool)
public
$valid
=
true
;
# Ob das Ergebnis noch gültig ist (bool)
public
$host
;
# Der aus dem Link gelesene Host des Suchergebnisses
public
$strippedHost
;
# Der Host in Form "foo.bar.de"
public
$strippedDomain
;
# Die Domain in Form "bar.de"
...
...
@@ -31,24 +31,21 @@ class Result
# Erstellt ein neues Ergebnis
public
function
__construct
(
$provider
,
$titel
,
$link
,
$anzeigeLink
,
$descr
,
$gefVon
,
$gefVonLink
,
$sourceRank
,
$additionalInformation
=
[])
{
$provider
=
simplexml_load_string
(
$provider
);
$this
->
titel
=
strip_tags
(
trim
(
$titel
));
if
(
stripos
(
$anzeigeLink
,
"twitter.com"
)){
$this
->
titel
=
'<i class="fa fa-twitter" aria-hidden="true"></i> '
.
$this
->
titel
;
}
$this
->
link
=
trim
(
$link
);
$provider
=
simplexml_load_string
(
$provider
);
$this
->
titel
=
strip_tags
(
trim
(
$titel
));
$this
->
link
=
trim
(
$link
);
$this
->
anzeigeLink
=
trim
(
$anzeigeLink
);
$this
->
descr
=
strip_tags
(
trim
(
$descr
),
'<p>'
);
$this
->
descr
=
preg_replace
(
"/
\n
+/si"
,
" "
,
$this
->
descr
);
$this
->
longDescr
=
$this
->
descr
;
$this
->
descr
=
strip_tags
(
trim
(
$descr
),
'<p>'
);
$this
->
descr
=
preg_replace
(
"/
\n
+/si"
,
" "
,
$this
->
descr
);
$this
->
longDescr
=
$this
->
descr
;
if
(
strlen
(
$this
->
descr
)
>
250
)
{
$this
->
descr
=
wordwrap
(
$this
->
descr
,
250
);
$this
->
descr
=
substr
(
$this
->
descr
,
0
,
strpos
(
$this
->
descr
,
"
\n
"
));
}
$this
->
gefVon
=
trim
(
$gefVon
);
$this
->
gefVon
=
trim
(
$gefVon
);
$this
->
gefVonLink
=
trim
(
$gefVonLink
);
$this
->
proxyLink
=
$this
->
generateProxyLink
(
$this
->
link
);
$this
->
proxyLink
=
$this
->
generateProxyLink
(
$this
->
link
);
$this
->
sourceRank
=
$sourceRank
;
if
(
$this
->
sourceRank
<=
0
||
$this
->
sourceRank
>
20
)
{
$this
->
sourceRank
=
20
;
...
...
@@ -59,15 +56,15 @@ class Result
}
else
{
$this
->
engineBoost
=
1
;
}
$this
->
valid
=
true
;
$this
->
host
=
@
parse_url
(
$link
,
PHP_URL_HOST
);
$this
->
strippedHost
=
$this
->
getStrippedHost
(
$this
->
anzeigeLink
);
$this
->
strippedDomain
=
$this
->
getStrippedDomain
(
$this
->
strippedHost
);
$this
->
strippedLink
=
$this
->
getStrippedLink
(
$this
->
anzeigeLink
);
$this
->
rank
=
0
;
$this
->
partnershop
=
isset
(
$additionalInformation
[
"partnershop"
])
?
$additionalInformation
[
"partnershop"
]
:
false
;
$this
->
image
=
isset
(
$additionalInformation
[
"image"
])
?
$additionalInformation
[
"image"
]
:
""
;
$this
->
price
=
isset
(
$additionalInformation
[
"price"
])
?
$additionalInformation
[
"price"
]
:
0
;
$this
->
valid
=
true
;
$this
->
host
=
@
parse_url
(
$link
,
PHP_URL_HOST
);
$this
->
strippedHost
=
$this
->
getStrippedHost
(
$this
->
anzeigeLink
);
$this
->
strippedDomain
=
$this
->
getStrippedDomain
(
$this
->
strippedHost
);
$this
->
strippedLink
=
$this
->
getStrippedLink
(
$this
->
anzeigeLink
);
$this
->
rank
=
0
;
$this
->
partnershop
=
isset
(
$additionalInformation
[
"partnershop"
])
?
$additionalInformation
[
"partnershop"
]
:
false
;
$this
->
image
=
isset
(
$additionalInformation
[
"image"
])
?
$additionalInformation
[
"image"
]
:
""
;
$this
->
price
=
isset
(
$additionalInformation
[
"price"
])
?
$additionalInformation
[
"price"
]
:
0
;
$this
->
additionalInformation
=
$additionalInformation
;
}
...
...
@@ -115,18 +112,18 @@ class Result
}
else
{
# Wir überprüfen das Verhältnis von Kyrillischen Zeichen im Titel
if
(
preg_match_all
(
'/[А-Яа-яЁё]/u'
,
$this
->
titel
,
$matches
))
{
$count
=
sizeof
(
$matches
[
0
]);
$count
=
sizeof
(
$matches
[
0
]);
$titleSize
=
strlen
(
$this
->
titel
);
$percKyr
=
$count
/
$titleSize
;
$percKyr
=
$count
/
$titleSize
;
if
(
$percKyr
>
$maxRatio
)
{
return
5
;
}
}
# Wir überprüfen das Verhältnis von Kyrillischen Zeichen in der Beschreibung
if
(
preg_match_all
(
'/[А-Яа-яЁё]/u'
,
$this
->
descr
,
$matches
))
{
$count
=
sizeof
(
$matches
[
0
]);
$count
=
sizeof
(
$matches
[
0
]);
$descrSize
=
strlen
(
$this
->
descr
);
$percKyr
=
$count
/
$descrSize
;
$percKyr
=
$count
/
$descrSize
;
if
(
$percKyr
>
$maxRatio
)
{
return
5
;
}
...
...
@@ -142,9 +139,9 @@ class Result
if
(
strpos
(
$link
,
"http"
)
!==
0
)
{
$link
=
"http://"
.
$link
;
}
$link
=
@
parse_url
(
$link
,
PHP_URL_HOST
)
.
@
parse_url
(
$link
,
PHP_URL_PATH
);
$tmpLi
=
$link
;
$count
=
0
;
$link
=
@
parse_url
(
$link
,
PHP_URL_HOST
)
.
@
parse_url
(
$link
,
PHP_URL_PATH
);
$tmpLi
=
$link
;
$count
=
0
;
$tmpLink
=
""
;
# Löscht verschiedene unerwünschte Teile aus $link und $tmpEingabe
$regex
=
[
...
...
@@ -157,7 +154,7 @@ class Result
"/-/si"
,
# "-"
];
foreach
(
$regex
as
$reg
)
{
$link
=
preg_replace
(
$regex
,
""
,
$link
);
$link
=
preg_replace
(
$regex
,
""
,
$link
);
$tmpEingabe
=
preg_replace
(
$regex
,
""
,
$tmpEingabe
);
}
foreach
(
str_split
(
$tmpEingabe
)
as
$char
)
{
...
...
@@ -183,13 +180,13 @@ class Result
# Berechnet den Ranking-Boost durch das Vorkommen von Suchwörtern
private
function
calcSuchwortBoost
(
$tmpEingabe
)
{
$maxRank
=
0.1
;
$tmpTitle
=
$this
->
titel
;
$maxRank
=
0.1
;
$tmpTitle
=
$this
->
titel
;
$tmpDescription
=
$this
->
descr
;
$isWithin
=
false
;
$tmpRank
=
0
;
$tmpEingabe
=
preg_replace
(
"/\b\w
{
1,3
}
\b/si"
,
""
,
$tmpEingabe
);
$tmpEingabe
=
preg_replace
(
"/\s+/si"
,
" "
,
$tmpEingabe
);
$isWithin
=
false
;
$tmpRank
=
0
;
$tmpEingabe
=
preg_replace
(
"/\b\w
{
1,3
}
\b/si"
,
""
,
$tmpEingabe
);
$tmpEingabe
=
preg_replace
(
"/\s+/si"
,
" "
,
$tmpEingabe
);
foreach
(
explode
(
" "
,
trim
(
$tmpEingabe
))
as
$el
)
{
if
(
strlen
(
$tmpTitle
)
===
0
||
strlen
(
$el
)
===
0
||
strlen
(
$tmpDescription
)
===
0
)
{
...
...
@@ -228,7 +225,10 @@ class Result
# Persönliche URL Blacklist
foreach
(
$metager
->
getUserUrlBlacklist
()
as
$word
)
{
if
(
strpos
(
strtolower
(
$this
->
link
),
$word
))
return
false
;
if
(
strpos
(
strtolower
(
$this
->
link
),
$word
))
{
return
false
;
}
}
# Allgemeine URL und Domain Blacklist
...
...
resources/views/layouts/result.blade.php
View file @
33743bf9
...
...
@@ -2,6 +2,9 @@
<div
class=
"result-header"
>
<div
class=
"result-headline"
>
<h2
class=
"result-title"
>
@if(stripos($result->anzeigeLink, "twitter.com") !== false)
<i
class=
"fa fa-twitter"
aria-hidden=
"true"
></i>
@endif
<a
href=
"{{ $result->link }}"
target=
"{{ $metager->getNewtab() }}"
rel=
"noopener"
>
{!! $result->titel !!}
</a>
...
...
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