]> git.mxchange.org Git - friendica.git/commitdiff
Now the third most likely languages are shown.
authorMichael Vogel <icarus@dabo.de>
Wed, 9 Jan 2013 19:54:18 +0000 (20:54 +0100)
committerMichael Vogel <icarus@dabo.de>
Wed, 9 Jan 2013 19:54:18 +0000 (20:54 +0100)
In "vier" the tag line is now suppressed. It saves a little bit of space - and is redundant.

include/items.php
mod/item.php
object/Item.php
view/theme/vier/style.css

index 7eb090136f6bd2d9c3fc5c36dd20f83e9319613c..6e856f96028354babdbd641d18613708a0ada5c7 100755 (executable)
@@ -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);
index 2ed1b812a48cb22cc51ed31dfcb40e58e906dede..8399b796dcd7e048b91bee005a07bf3b009b0e9e 100644 (file)
@@ -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);
                }
index 0ea9954b0a5a2489ad4c6f2228326ab7c5bbc734..e5aaecacd7a77f8027bed3668c73a20c4fffe21a 100644 (file)
@@ -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);
index f97fc2f59091c4e51916b6c3af7aaad057e0842c..dcf8d34253c29696bf41d5a4030024d5ba2632ae 100644 (file)
@@ -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;