From: Michael Vogel Date: Wed, 9 Jan 2013 19:54:18 +0000 (+0100) Subject: Now the third most likely languages are shown. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=82820d8e952dc648af572a55b6e205d448cfa138;p=friendica.git Now the third most likely languages are shown. In "vier" the tag line is now suppressed. It saves a little bit of space - and is redundant. --- diff --git a/include/items.php b/include/items.php index 7eb090136f..6e856f9602 100755 --- a/include/items.php +++ b/include/items.php @@ -898,8 +898,23 @@ function item_store($arr,$force_parent = false) { require_once('library/langdet/Text/LanguageDetect.php'); $naked_body = preg_replace('/\[(.+?)\]/','',$arr['body']); $l = new Text_LanguageDetect; - $lng = $l->detectConfidence($naked_body); - $arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); + //$lng = $l->detectConfidence($naked_body); + //$arr['postopts'] = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); + $lng = $l->detect($naked_body, 3); + + if (sizeof($lng) > 0) { + $postopts = ""; + + foreach ($lng as $language => $score) { + if ($postopts == "") + $postopts = "lang="; + else + $postopts .= ":"; + + $postopts .= $language.";".$score; + } + $arr['postopts'] = $postopts; + } } $arr['wall'] = ((x($arr,'wall')) ? intval($arr['wall']) : 0); diff --git a/mod/item.php b/mod/item.php index 2ed1b812a4..8399b796dc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -236,9 +236,23 @@ function item_post(&$a) { if (version_compare(PHP_VERSION, '5.3.0', '>=')) { $l = new Text_LanguageDetect; - $lng = $l->detectConfidence($naked_body); + //$lng = $l->detectConfidence($naked_body); + //$postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); - $postopts = (($lng['language']) ? 'lang=' . $lng['language'] . ';' . $lng['confidence'] : ''); + $lng = $l->detect($naked_body, 3); + + if (sizeof($lng) > 0) { + $postopts = ""; + + foreach ($lng as $language => $score) { + if ($postopts == "") + $postopts = "lang="; + else + $postopts .= ":"; + + $postopts .= $language.";".$score; + } + } logger('mod_item: detect language' . print_r($lng,true) . $naked_body, LOGGER_DATA); } diff --git a/object/Item.php b/object/Item.php index 0ea9954b0a..e5aaecacd7 100644 --- a/object/Item.php +++ b/object/Item.php @@ -213,8 +213,28 @@ class Item extends BaseObject { localize_item($item); if ($item["postopts"]) { - $langdata = explode(";", $item["postopts"]); - $langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; + //$langdata = explode(";", $item["postopts"]); + //$langstr = substr($langdata[0], 5)." (".round($langdata[1]*100, 1)."%)"; + $langstr = ""; + if (substr($item["postopts"], 0, 5) == "lang=") { + $postopts = substr($item["postopts"], 5); + + $languages = explode(":", $postopts); + + if (sizeof($languages) == 1) { + $languages = array(); + $languages[] = $postopts; + } + + foreach ($languages as $language) { + $langdata = explode(";", $language); + if ($langstr != "") + $langstr .= ", "; + + //$langstr .= $langdata[0]." (".round($langdata[1]*100, 1)."%)"; + $langstr .= round($langdata[1]*100, 1)."% ".$langdata[0]; + } + } } $body = prepare_body($item,true); diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index f97fc2f590..dcf8d34253 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -1091,6 +1091,7 @@ border-bottom: 1px solid #D2D2D2; max-width: 660px; word-wrap: break-word; line-height: 1.36; + padding-bottom: 6px; } .wall-item-container .wall-item-content img { @@ -1304,7 +1305,9 @@ border-bottom: 1px solid #D2D2D2; .wall-item-tags { padding-top: 1px; padding-bottom: 2px; + display: none; } + .tag { color: rgb(153,153,153); padding-left: 3px;