]> git.mxchange.org Git - friendica.git/commitdiff
more $item data
authorFabrixxm <fabrix.xm@gmail.com>
Thu, 20 Sep 2012 07:46:49 +0000 (09:46 +0200)
committerFabrixxm <fabrix.xm@gmail.com>
Thu, 20 Sep 2012 07:46:49 +0000 (09:46 +0200)
- add $item.categories and $item.folders to object/Item.php
- add $item.hastags and $item.mentions to object/Item.php
- add $item.total_comments_num and $item.total_comments_text to object/Item.php (those are set for top_level item also with no comments)
- move get_cats_and_terms() to include/text.php

include/conversation.php
include/text.php
object/Item.php

index 664f81f3bcfc569867ad132a2d2e9e282ae00cb4..fc4b85e79439109974f2c051ac24b838b0554ead 100644 (file)
@@ -351,69 +351,6 @@ function visible_activity($item) {
 }
 
 
-/**
- * returns 
- * [
- *    //categories [
- *          {
- *               'name': 'category name',
- *              'removeurl': 'url to remove this category',
- *             'first': 'is the first in this array? true/false',
- *               'last': 'is the last in this array? true/false',
- *           } ,
- *           ....
- *       ],
- *       // folders [
- *               'name': 'folder name',
- *               'removeurl': 'url to remove this folder',
- *               'first': 'is the first in this array? true/false',
- *               'last': 'is the last in this array? true/false',
- *           } ,
- *           ....       
- *       ]
- *   ]
- */
-function get_cats_and_terms($item) {
-    $categories = array();
-    $folders = array();
-
-    $matches = false; $first = true;
-    $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
-    if($cnt) {
-        foreach($matches as $mtch) {
-            $categories[] = array(
-                'name' => xmlify(file_tag_decode($mtch[1])),
-                'removeurl' => $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])),
-                'first' => $first,
-                'last' => false
-            );
-            $first = false;
-        }
-    }
-    if (count($categories)) $categories[count($categories)-1]['last'] = true;
-    
-
-
-    $matches = false; $first = true;
-    $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
-    if($cnt) {
-        foreach($matches as $mtch) {
-            $folders[] = array(
-                'name' => xmlify(file_tag_decode($mtch[1])),
-                'removeurl' => $a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])),
-                'first' => $first,
-                'last' => false
-            );
-            $first = false;
-        }
-    }
-
-    if (count($folders)) $folders[count($folders)-1]['last'] = true;
-    
-    return array($categories, $folders);
-}
-
-
 /**
  * Recursively prepare a thread for HTML
  */
index 878ce80e9b8e8dee5f98b4f8517a37a92442f76a..9b55078cbefe78033cd27a7cd4c82ea607140944 100644 (file)
@@ -1071,6 +1071,72 @@ function prepare_text($text) {
 }}
 
 
+/**
+ * returns 
+ * [
+ *    //categories [
+ *          {
+ *               'name': 'category name',
+ *              'removeurl': 'url to remove this category',
+ *             'first': 'is the first in this array? true/false',
+ *               'last': 'is the last in this array? true/false',
+ *           } ,
+ *           ....
+ *       ],
+ *       // folders [
+ *               'name': 'folder name',
+ *               'removeurl': 'url to remove this folder',
+ *               'first': 'is the first in this array? true/false',
+ *               'last': 'is the last in this array? true/false',
+ *           } ,
+ *           ....       
+ *       ]
+ *   ]
+ */
+function get_cats_and_terms($item) {
+    $a = get_app();
+    $categories = array();
+    $folders = array();
+
+    $matches = false; $first = true;
+    $cnt = preg_match_all('/<(.*?)>/',$item['file'],$matches,PREG_SET_ORDER);
+    if($cnt) {
+        foreach($matches as $mtch) {
+            $categories[] = array(
+                'name' => xmlify(file_tag_decode($mtch[1])),
+                'url' =>  "#",
+                'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&cat=' . xmlify(file_tag_decode($mtch[1])):""),
+                'first' => $first,
+                'last' => false
+            );
+            $first = false;
+        }
+    }
+    if (count($categories)) $categories[count($categories)-1]['last'] = true;
+    
+
+
+    $matches = false; $first = true;
+    $cnt = preg_match_all('/\[(.*?)\]/',$item['file'],$matches,PREG_SET_ORDER);
+    if($cnt) {
+        foreach($matches as $mtch) {
+            $folders[] = array(
+                'name' => xmlify(file_tag_decode($mtch[1])),
+                 'url' =>  "#",
+                'removeurl' => ((local_user() == $item['uid'])?$a->get_baseurl() . '/filerm/' . $item['id'] . '?f=&term=' . xmlify(file_tag_decode($mtch[1])):""),
+                'first' => $first,
+                'last' => false
+            );
+            $first = false;
+        }
+    }
+
+    if (count($folders)) $folders[count($folders)-1]['last'] = true;
+    
+    return array($categories, $folders);
+}
+
+
 /**
  * return atom link elements for all of our hubs
  */
index d40a384f56b1c0ff502d1118a586aa342e0dae2b..04d52a896e31624ce61df193622dd47673a9786e 100644 (file)
@@ -143,10 +143,20 @@ class Item extends BaseObject {
                $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_google($locate));
 
                $tags=array();
+               $hashtags = array();
+               $mentions = array();
                foreach(explode(',',$item['tag']) as $tag){
                        $tag = trim($tag);
-                       if ($tag!="") $tags[] = bbcode($tag);
-               }
+                       if ($tag!="") {
+                               $t = bbcode($tag);
+                               $tags[] = $t;
+                               if($t[0] == '#')
+                                       $hashtags[] = $t;
+                               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']) : '');
@@ -195,11 +205,17 @@ class Item extends BaseObject {
 
                $body = prepare_body($item,true);
 
+        list($categories, $folders) = get_cats_and_terms($item);
+
                $tmp_item = array(
                        'template' => $this->get_template(),
                        
                        'type' => implode("",array_slice(explode("/",$item['verb']),-1)),
                        'tags' => $tags,
+            'hashtags' => $hashtags,
+            'mentions' => $mentions,
+            'categories' => $categories,
+            'folders' => $folders,            
                        'body' => template_escape($body),
                        'text' => strip_tags(template_escape($body)),
                        'id' => $this->get_id(),
@@ -266,6 +282,11 @@ class Item extends BaseObject {
                        }
                }
                
+        if ($this->is_toplevel()) {
+            $result['total_comments_num'] = $total_children;
+            $result['total_comments_text'] = tt('comment', 'comments', $total_children);
+        }
+        
                $result['private'] = $item['private'];
                $result['toplevel'] = ($this->is_toplevel() ? 'toplevel_item' : '');