From: Michael Vogel Date: Sat, 26 Sep 2015 09:55:59 +0000 (+0200) Subject: Adopt it to the new proposals for the agreement between Google and VG Media X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=99dc8f2deb01950851cfa7e6d1c0534567e62480;p=friendica-addons.git Adopt it to the new proposals for the agreement between Google and VG Media --- diff --git a/leistungsschutzrecht/leistungsschutzrecht.php b/leistungsschutzrecht/leistungsschutzrecht.php index c33c1f49..39eb4db1 100644 --- a/leistungsschutzrecht/leistungsschutzrecht.php +++ b/leistungsschutzrecht/leistungsschutzrecht.php @@ -26,13 +26,43 @@ function leistungsschutzrecht_getsiteinfo($a, &$siteinfo) { if (!leistungsschutzrecht_is_member_site($siteinfo["url"])) return; - $siteinfo["title"] = $siteinfo["url"]; - unset($siteinfo["text"]); + //$siteinfo["title"] = $siteinfo["url"]; + $siteinfo["text"] = leistungsschutzrecht_cuttext($siteinfo["text"]); unset($siteinfo["image"]); unset($siteinfo["images"]); unset($siteinfo["keywords"]); } +function leistungsschutzrecht_cuttext($text) { + $text = str_replace(array("\r", "\n"), array(" ", " "), $text); + + do { + $oldtext = $text; + $text = str_replace(" ", " ", $text); + } while ($oldtext != $text); + + $words = explode(" ", $text); + + $text = ""; + $count = 0; + $limit = 7; + + foreach ($words as $word) { + if ($text != "") + $text .= " "; + + $text .= $word; + + if (++$count >= $limit) { + if (sizeof($words) > $limit) + $text .= " ..."; + + break; + } + } + return $text; +} + function leistungsschutzrecht_fetchsites() { require_once("include/network.php");