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
71de8e42
Commit
71de8e42
authored
7 years ago
by
Karl Hasselbring
Browse files
Options
Downloads
Patches
Plain Diff
Twitter-Icon wird jetzt in der Redesign-Version über den View eingeblendet
parent
9e225a25
No related branches found
Branches containing commit
No related tags found
1 merge request
!1365
Resolve "Filter Options for MetaGer"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
app/Models/Result.php
+36
-36
36 additions, 36 deletions
app/Models/Result.php
resources/views/layouts/result.blade.php
+3
-0
3 additions, 0 deletions
resources/views/layouts/result.blade.php
with
39 additions
and
36 deletions
app/Models/Result.php
+
36
−
36
View file @
71de8e42
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
resources/views/layouts/result.blade.php
+
3
−
0
View file @
71de8e42
...
...
@@ -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>
...
...
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