Commit 33743bf9 authored by Karl Hasselbring's avatar Karl Hasselbring

Twitter-Icon wird jetzt in der Redesign-Version über den View eingeblendet

parent f7699a5c
...@@ -21,7 +21,7 @@ class Result ...@@ -21,7 +21,7 @@ class Result
public $proxyLink; # Der Link für die Seite über unseren Proxy-Service public $proxyLink; # Der Link für die Seite über unseren Proxy-Service
public $engineBoost = 1; # Der Boost für den Provider des Suchergebnisses 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 $host; # Der aus dem Link gelesene Host des Suchergebnisses
public $strippedHost; # Der Host in Form "foo.bar.de" public $strippedHost; # Der Host in Form "foo.bar.de"
public $strippedDomain; # Die Domain in Form "bar.de" public $strippedDomain; # Die Domain in Form "bar.de"
...@@ -31,24 +31,21 @@ class Result ...@@ -31,24 +31,21 @@ class Result
# Erstellt ein neues Ergebnis # Erstellt ein neues Ergebnis
public function __construct($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $gefVonLink, $sourceRank, $additionalInformation = []) public function __construct($provider, $titel, $link, $anzeigeLink, $descr, $gefVon, $gefVonLink, $sourceRank, $additionalInformation = [])
{ {
$provider = simplexml_load_string($provider); $provider = simplexml_load_string($provider);
$this->titel = strip_tags(trim($titel)); $this->titel = strip_tags(trim($titel));
if(stripos($anzeigeLink, "twitter.com")){ $this->link = trim($link);
$this->titel = '<i class="fa fa-twitter" aria-hidden="true"></i> ' . $this->titel;
}
$this->link = trim($link);
$this->anzeigeLink = trim($anzeigeLink); $this->anzeigeLink = trim($anzeigeLink);
$this->descr = strip_tags(trim($descr), '<p>'); $this->descr = strip_tags(trim($descr), '<p>');
$this->descr = preg_replace("/\n+/si", " ", $this->descr); $this->descr = preg_replace("/\n+/si", " ", $this->descr);
$this->longDescr = $this->descr; $this->longDescr = $this->descr;
if (strlen($this->descr) > 250) { if (strlen($this->descr) > 250) {
$this->descr = wordwrap($this->descr, 250); $this->descr = wordwrap($this->descr, 250);
$this->descr = substr($this->descr, 0, strpos($this->descr, "\n")); $this->descr = substr($this->descr, 0, strpos($this->descr, "\n"));
} }
$this->gefVon = trim($gefVon); $this->gefVon = trim($gefVon);
$this->gefVonLink = trim($gefVonLink); $this->gefVonLink = trim($gefVonLink);
$this->proxyLink = $this->generateProxyLink($this->link); $this->proxyLink = $this->generateProxyLink($this->link);
$this->sourceRank = $sourceRank; $this->sourceRank = $sourceRank;
if ($this->sourceRank <= 0 || $this->sourceRank > 20) { if ($this->sourceRank <= 0 || $this->sourceRank > 20) {
$this->sourceRank = 20; $this->sourceRank = 20;
...@@ -59,15 +56,15 @@ class Result ...@@ -59,15 +56,15 @@ class Result
} else { } else {
$this->engineBoost = 1; $this->engineBoost = 1;
} }
$this->valid = true; $this->valid = true;
$this->host = @parse_url($link, PHP_URL_HOST); $this->host = @parse_url($link, PHP_URL_HOST);
$this->strippedHost = $this->getStrippedHost($this->anzeigeLink); $this->strippedHost = $this->getStrippedHost($this->anzeigeLink);
$this->strippedDomain = $this->getStrippedDomain($this->strippedHost); $this->strippedDomain = $this->getStrippedDomain($this->strippedHost);
$this->strippedLink = $this->getStrippedLink($this->anzeigeLink); $this->strippedLink = $this->getStrippedLink($this->anzeigeLink);
$this->rank = 0; $this->rank = 0;
$this->partnershop = isset($additionalInformation["partnershop"]) ? $additionalInformation["partnershop"] : false; $this->partnershop = isset($additionalInformation["partnershop"]) ? $additionalInformation["partnershop"] : false;
$this->image = isset($additionalInformation["image"]) ? $additionalInformation["image"] : ""; $this->image = isset($additionalInformation["image"]) ? $additionalInformation["image"] : "";
$this->price = isset($additionalInformation["price"]) ? $additionalInformation["price"] : 0; $this->price = isset($additionalInformation["price"]) ? $additionalInformation["price"] : 0;
$this->additionalInformation = $additionalInformation; $this->additionalInformation = $additionalInformation;
} }
...@@ -115,18 +112,18 @@ class Result ...@@ -115,18 +112,18 @@ class Result
} else { } else {
# Wir überprüfen das Verhältnis von Kyrillischen Zeichen im Titel # Wir überprüfen das Verhältnis von Kyrillischen Zeichen im Titel
if (preg_match_all('/[А-Яа-яЁё]/u', $this->titel, $matches)) { if (preg_match_all('/[А-Яа-яЁё]/u', $this->titel, $matches)) {
$count = sizeof($matches[0]); $count = sizeof($matches[0]);
$titleSize = strlen($this->titel); $titleSize = strlen($this->titel);
$percKyr = $count / $titleSize; $percKyr = $count / $titleSize;
if ($percKyr > $maxRatio) { if ($percKyr > $maxRatio) {
return 5; return 5;
} }
} }
# Wir überprüfen das Verhältnis von Kyrillischen Zeichen in der Beschreibung # Wir überprüfen das Verhältnis von Kyrillischen Zeichen in der Beschreibung
if (preg_match_all('/[А-Яа-яЁё]/u', $this->descr, $matches)) { if (preg_match_all('/[А-Яа-яЁё]/u', $this->descr, $matches)) {
$count = sizeof($matches[0]); $count = sizeof($matches[0]);
$descrSize = strlen($this->descr); $descrSize = strlen($this->descr);
$percKyr = $count / $descrSize; $percKyr = $count / $descrSize;
if ($percKyr > $maxRatio) { if ($percKyr > $maxRatio) {
return 5; return 5;
} }
...@@ -142,9 +139,9 @@ class Result ...@@ -142,9 +139,9 @@ class Result
if (strpos($link, "http") !== 0) { if (strpos($link, "http") !== 0) {
$link = "http://" . $link; $link = "http://" . $link;
} }
$link = @parse_url($link, PHP_URL_HOST) . @parse_url($link, PHP_URL_PATH); $link = @parse_url($link, PHP_URL_HOST) . @parse_url($link, PHP_URL_PATH);
$tmpLi = $link; $tmpLi = $link;
$count = 0; $count = 0;
$tmpLink = ""; $tmpLink = "";
# Löscht verschiedene unerwünschte Teile aus $link und $tmpEingabe # Löscht verschiedene unerwünschte Teile aus $link und $tmpEingabe
$regex = [ $regex = [
...@@ -157,7 +154,7 @@ class Result ...@@ -157,7 +154,7 @@ class Result
"/-/si", # "-" "/-/si", # "-"
]; ];
foreach ($regex as $reg) { foreach ($regex as $reg) {
$link = preg_replace($regex, "", $link); $link = preg_replace($regex, "", $link);
$tmpEingabe = preg_replace($regex, "", $tmpEingabe); $tmpEingabe = preg_replace($regex, "", $tmpEingabe);
} }
foreach (str_split($tmpEingabe) as $char) { foreach (str_split($tmpEingabe) as $char) {
...@@ -183,13 +180,13 @@ class Result ...@@ -183,13 +180,13 @@ class Result
# Berechnet den Ranking-Boost durch das Vorkommen von Suchwörtern # Berechnet den Ranking-Boost durch das Vorkommen von Suchwörtern
private function calcSuchwortBoost($tmpEingabe) private function calcSuchwortBoost($tmpEingabe)
{ {
$maxRank = 0.1; $maxRank = 0.1;
$tmpTitle = $this->titel; $tmpTitle = $this->titel;
$tmpDescription = $this->descr; $tmpDescription = $this->descr;
$isWithin = false; $isWithin = false;
$tmpRank = 0; $tmpRank = 0;
$tmpEingabe = preg_replace("/\b\w{1,3}\b/si", "", $tmpEingabe); $tmpEingabe = preg_replace("/\b\w{1,3}\b/si", "", $tmpEingabe);
$tmpEingabe = preg_replace("/\s+/si", " ", $tmpEingabe); $tmpEingabe = preg_replace("/\s+/si", " ", $tmpEingabe);
foreach (explode(" ", trim($tmpEingabe)) as $el) { foreach (explode(" ", trim($tmpEingabe)) as $el) {
if (strlen($tmpTitle) === 0 || strlen($el) === 0 || strlen($tmpDescription) === 0) { if (strlen($tmpTitle) === 0 || strlen($el) === 0 || strlen($tmpDescription) === 0) {
...@@ -228,7 +225,10 @@ class Result ...@@ -228,7 +225,10 @@ class Result
# Persönliche URL Blacklist # Persönliche URL Blacklist
foreach ($metager->getUserUrlBlacklist() as $word) { 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 # Allgemeine URL und Domain Blacklist
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
<div class="result-header"> <div class="result-header">
<div class="result-headline"> <div class="result-headline">
<h2 class="result-title"> <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"> <a href="{{ $result->link }}" target="{{ $metager->getNewtab() }}" rel="noopener">
{!! $result->titel !!} {!! $result->titel !!}
</a> </a>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment