]> git.mxchange.org Git - friendica.git/blobdiff - object/Item.php
Preparations for a new tag structure. Tags are now stored in a dedicated table.
[friendica.git] / object / Item.php
index eef8a50581d773b39ea89e6a59fcb25c54997e15..215c987b19e73a9d806fe3358bdd284aaf973dc3 100644 (file)
@@ -115,10 +115,10 @@ class Item extends BaseObject {
                $drop = array(
                        'dropping' => $dropping,
                        'pagedrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $item['pagedrop'] : ''),
-                       'select' => t('Select'), 
+                       'select' => t('Select'),
                        'delete' => t('Delete'),
                );
-               
+
                $filer = (($conv->get_profile_owner() == local_user()) ? t("save to folder") : false);
 
                $diff_author    = ((link_compare($item['url'],$item['author-link'])) ? false : true);
@@ -133,7 +133,7 @@ class Item extends BaseObject {
                if($sp)
                        $sparkle = ' sparkle';
                else
-                       $profile_link = zrl($profile_link);                 
+                       $profile_link = zrl($profile_link);
 
                $normalised = normalise_link((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
                if(($normalised != 'mailbox') && (x($a->contacts,$normalised)))
@@ -148,7 +148,18 @@ class Item extends BaseObject {
                $tags=array();
                $hashtags = array();
                $mentions = array();
-               foreach(explode(',',$item['tag']) as $tag){
+
+               $taglist = q("select tag,link from tag where iid=%d", intval($item['id']));
+
+               foreach($taglist as $tag) {
+                       $tags[] = substr($tag["tag"], 0, 1)."<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
+                       if (substr($tag["tag"], 0, 1) == "#")
+                               $hashtags[] = "#<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
+                       elseif (substr($tag["tag"], 0, 1) == "@")
+                               $mentions[] = "@<a href=\"".$tag["link"]."\" target=\"external-link\">".substr($tag["tag"], 1)."</a>";
+               }
+
+               /*foreach(explode(',',$item['tag']) as $tag){
                        $tag = trim($tag);
                        if ($tag!="") {
                                $t = bbcode($tag);
@@ -158,8 +169,7 @@ class Item extends BaseObject {
                                elseif($t[0] == '@')
                                        $mentions[] = $t;
                        }
-
-               }        
+               }*/
 
                $like    = ((x($alike,$item['uri'])) ? format_like($alike[$item['uri']],$alike[$item['uri'] . '-l'],'like',$item['uri']) : '');
                $dislike = ((x($dlike,$item['uri'])) ? format_like($dlike[$item['uri']],$dlike[$item['uri'] . '-l'],'dislike',$item['uri']) : '');
@@ -212,9 +222,34 @@ class Item extends BaseObject {
 
                localize_item($item);
 
+               if ($item["postopts"]) {
+                       //$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);
 
-        list($categories, $folders) = get_cats_and_terms($item);
+               list($categories, $folders) = get_cats_and_terms($item);
 
                if($a->theme['template_engine'] === 'internal') {
                        $body_e = template_escape($body);
@@ -235,7 +270,7 @@ class Item extends BaseObject {
 
                $tmp_item = array(
                        'template' => $this->get_template(),
-                       
+
                        'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
                        'tags' => $tags,
             'hashtags' => $hashtags,
@@ -245,7 +280,7 @@ class Item extends BaseObject {
                        'has_cats' => ((count($categories)) ? 'true' : ''),
                        'has_folders' => ((count($folders)) ? 'true' : ''),
             'categories' => $categories,
-            'folders' => $folders,            
+            'folders' => $folders,
                        'body' => $body_e,
                        'text' => $text_e,
                        'id' => $this->get_id(),
@@ -285,7 +320,8 @@ class Item extends BaseObject {
                        'comment' => $this->get_comment_box($indent),
                        'previewing' => ($conv->is_preview() ? ' preview ' : ''),
                        'wait' => t('Please wait'),
-                       'thread_level' => $thread_level
+                       'thread_level' => $thread_level,
+                       'postopts' => $langstr
                );
 
                $arr = array('item' => $item, 'output' => $tmp_item);