X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fhtml2plain.php;h=1d5910d83bea975a11a02b2aef1e8c3eba01e68b;hb=abe31d7e60b2c6640abf799f807b8258bed10ab8;hp=3e4c0e8db061c0476b760fb77bd5f4ddf39a893d;hpb=680524f446ac356fe3742466378bce024959f8a2;p=friendica.git diff --git a/include/html2plain.php b/include/html2plain.php index 3e4c0e8db0..1d5910d83b 100644 --- a/include/html2plain.php +++ b/include/html2plain.php @@ -82,6 +82,9 @@ function collecturls($message) { $urls = array(); foreach ($result as $treffer) { + + $ignore = false; + // A list of some links that should be ignored $list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/", "//facebook.com/profile.php?id=", "//plus.google.com/", "//twitter.com/"); @@ -110,12 +113,6 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = str_replace("\r", "", $html); - // replace all hashtag addresses - if (get_config("system", "remove_hashtags_on_export")) { - $pattern = '/#(.*?)<\/a>/is'; - $message = preg_replace($pattern, '#$2', $message); - } - $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; @@ -182,15 +179,15 @@ function html2plain($html, $wraplength = 75, $compact = false) node2bbcode($doc, 'h6', array(), "\n\n*", "*\n"); // Problem: there is no reliable way to detect if it is a link to a tag or profile - //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', '', true); - node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true); + //node2bbcode($doc, 'a', array('href'=>'/(.+)/'), ' $1 ', ' ', true); + //node2bbcode($doc, 'a', array('href'=>'/(.+)/', 'rel'=>'oembed'), ' $1 ', '', true); //node2bbcode($doc, 'img', array('alt'=>'/(.+)/'), '$1', ''); //node2bbcode($doc, 'img', array('title'=>'/(.+)/'), '$1', ''); //node2bbcode($doc, 'img', array(), '', ''); if (!$compact) - node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '[img]$1', '[/img]'); + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), ' [img]$1', '[/img] '); else - node2bbcode($doc, 'img', array('src'=>'/(.+)/'), '', ''); + node2bbcode($doc, 'img', array('src'=>'/(.+)/'), ' ', ' '); node2bbcode($doc, 'iframe', array('src'=>'/(.+)/'), ' $1 ', '', true); @@ -215,12 +212,13 @@ function html2plain($html, $wraplength = 75, $compact = false) $message = html_entity_decode($message, ENT_QUOTES, 'UTF-8'); - if (!$compact) { + if (!$compact AND ($message != "")) { $counter = 1; foreach ($urls as $id=>$url) - if (strpos($message, $url) === false) - $message .= "\n".$url." "; - //$message .= "\n[".($counter++)."] ".$url; + if ($url != "") + if (strpos($message, $url) === false) + $message .= "\n".$url." "; + //$message .= "\n[".($counter++)."] ".$url; } $message = str_replace("\n«", "«\n", $message); @@ -235,4 +233,4 @@ function html2plain($html, $wraplength = 75, $compact = false) return(trim($message)); } - +?>