From: Michael Vogel Date: Sat, 30 Jun 2012 07:25:22 +0000 (+0200) Subject: Removing of the title if it is the same (or part) from the body. Helps against auto... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bcca817b9ab8f0a9dc0af56d55a3a347056a4494;p=friendica.git Removing of the title if it is the same (or part) from the body. Helps against auto generated titles from tumblr. --- diff --git a/include/items.php b/include/items.php index aed0a8e684..87d6ab4794 100755 --- a/include/items.php +++ b/include/items.php @@ -280,6 +280,29 @@ function construct_activity_target($item) { return ''; } +function title_is_body($title, $body) { + + $title = strip_tags($title); + $title = trim($title); + $title = str_replace(array("\n", "\r", "\t", " "), array("","","",""), $title); + + $body = strip_tags($body); + $body = trim($body); + $body = str_replace(array("\n", "\r", "\t", " "), array("","","",""), $body); + + if (strlen($title) < strlen($body)) + $body = substr($body, 0, strlen($title)); + + if (($title != $body) and (substr($title, -3) == "...")) { + $pos = strrpos($title, "..."); + if ($pos > 0) { + $title = substr($title, 0, $pos); + $body = substr($body, 0, $pos); + } + } + + return($title == $body); +} @@ -306,8 +329,10 @@ function get_atom_elements($feed,$item) { $res['body'] = unxmlify($item->get_content()); $res['plink'] = unxmlify($item->get_link(0)); - //$debugfile = tempnam("/home/ike/log", "item-res-"); - //file_put_contents($debugfile, serialize($res)); + // removing the content of the title if its identically to the body + // This helps with auto generated titles e.g. from tumblr + if (title_is_body($res["title"], $res["body"])) + $res['title'] = ""; if($res['plink']) $base_url = implode('/', array_slice(explode('/',$res['plink']),0,3));