]> git.mxchange.org Git - friendica.git/blobdiff - include/conversation.php
more enotify
[friendica.git] / include / conversation.php
index 29fa779024825373cd548887274da7f189ea7326..fae57c5655a76352c0835204ca95961508ba6400 100644 (file)
@@ -4,7 +4,7 @@
  * Render actions localized
  */
 function localize_item(&$item){
-       
+       $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
        if ($item['verb']=== ACTIVITY_LIKE || $item['verb']=== ACTIVITY_DISLIKE){
 
                $r = q("SELECT * from `item`,`contact` WHERE 
@@ -79,7 +79,43 @@ function localize_item(&$item){
                $item['body'] = sprintf( t('%1$s is now friends with %2$s'), $A, $B)."\n\n\n".$Bphoto;
 
        }
-        
+    if ($item['verb']===ACTIVITY_TAG){
+               $r = q("SELECT * from `item`,`contact` WHERE 
+               `item`.`contact-id`=`contact`.`id` AND `item`.`uri`='%s';",
+                dbesc($item['parent-uri']));
+               if(count($r)==0) return;
+               $obj=$r[0];
+               
+               $author  = '[url=' . $item['author-link'] . ']' . $item['author-name'] . '[/url]';
+               $objauthor =  '[url=' . $obj['author-link'] . ']' . $obj['author-name'] . '[/url]';
+               
+               switch($obj['verb']){
+                       case ACTIVITY_POST:
+                               switch ($obj['object-type']){
+                                       case ACTIVITY_OBJ_EVENT:
+                                               $post_type = t('event');
+                                               break;
+                                       default:
+                                               $post_type = t('status');
+                               }
+                               break;
+                       default:
+                               if($obj['resource-id']){
+                                       $post_type = t('photo');
+                                       $m=array();     preg_match("/\[url=([^]]*)\]/", $obj['body'], $m);
+                                       $rr['plink'] = $m[1];
+                               } else {
+                                       $post_type = t('status');
+                               }
+               }
+               $plink = '[url=' . $obj['plink'] . ']' . $post_type . '[/url]';
+               
+               $parsedobj = parse_xml_string($xmlhead.$item['object']);
+               
+               $tag = sprintf('#[url=%s]%s[/url]', $parsedobj->id, $parsedobj->content);
+               $item['body'] = sprintf( t('%1$s tagged %2$s\'s %3$s with %4$s'), $author, $objauthor, $plink, $tag );
+               
+       }
 
 }
 
@@ -136,6 +172,7 @@ function conversation(&$a, $items, $mode, $update) {
        $cmnt_tpl    = get_markup_template('comment_item.tpl');
        $tpl         = get_markup_template('wall_item.tpl');
        $wallwall    = get_markup_template('wallwall_item.tpl');
+       $hide_comments_tpl = get_markup_template('hide_comments.tpl');
 
        $alike = array();
        $dlike = array();
@@ -171,8 +208,11 @@ function conversation(&$a, $items, $mode, $update) {
                                }
                                else
                                        $nickname = $a->user['nickname'];
+                               
                        
                                $profile_name   = ((strlen($item['author-name']))   ? $item['author-name']   : $item['name']);
+                               if($item['author-link'] && (! $item['author-name']))
+                                       $profile_name = $item['author-link'];
 
                                $sp = false;
                                $profile_link = best_link_url($item,$sp);
@@ -254,7 +294,8 @@ function conversation(&$a, $items, $mode, $update) {
                                $arr = array('item' => $item, 'output' => $tmp_item);
                                call_hooks('display_item', $arr);
 
-                               $threads[$threadsid] .= $arr['output'];
+                               $threads[$threadsid]['id'] = $item['item_id'];
+                               $threads[$threadsid]['html'] .= $arr['output'];
 
                        }
 
@@ -337,7 +378,9 @@ function conversation(&$a, $items, $mode, $update) {
                                        $comments_collapsed = false;
                                        
                                        $threadsid++;
-                                       $threads[$threadsid] = "";
+                                       $threads[$threadsid]['id'] = $item['item_id'];
+                                       $threads[$threadsid]['html'] = "";
+
                                }
                                else {
                                        // prevent private email from leaking into public conversation
@@ -349,17 +392,25 @@ function conversation(&$a, $items, $mode, $update) {
                                $override_comment_box = ((($page_writeable) && ($item_writeable)) ? true : false);
                                $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
 
+
                                if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
                                        if(! $comments_collapsed) {
-                                               $threads[$threadsid] .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] 
-                                                       . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\'); $(\'#ccollapse-wrapper-' . $item['parent'] . '\').hide();" >' 
-                                                       . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'
-                                                       . '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
+
+                                               // IMPORTANT: the closing </div> in the hide_comments template
+                                               // is supplied below in code. 
+
+                                               $threads[$threadsid]['html'] .= replace_macros($hide_comments_tpl,array(
+                                                       '$id' => $item['parent'],
+                                                       '$num_comments' => sprintf( tt('%d comment','%d comments',$comments[$item['parent']]),
+                                                               $comments[$item['parent']]),
+                                                       '$display' => 'none',
+                                                       '$hide_text' => t('show more')
+                                               ));
                                                $comments_collapsed = true;
                                        }
                                }
                                if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
-                                       $threads[$threadsid] .= '</div>';
+                                       $threads[$threadsid]['html'] .= '</div>';
                                }
 
                                $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
@@ -466,6 +517,8 @@ function conversation(&$a, $items, $mode, $update) {
                                                'classdo' => (($item['starred']) ? "hidden" : ""),
                                                'classundo' => (($item['starred']) ? "" : "hidden"),
                                                'starred' =>  t('starred'),
+                                               'tagger' => t("add tag"),
+                                               'classtagger' => "",
                                        );
                                }
 
@@ -480,6 +533,10 @@ function conversation(&$a, $items, $mode, $update) {
 
                                $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
 
+                               if($item['author-link'] && (! $item['author-name']))
+                                       $profile_name = $item['author-link'];
+
+
                                $sp = false;
                                $profile_link = best_link_url($item,$sp);
                                if($sp)
@@ -520,12 +577,22 @@ function conversation(&$a, $items, $mode, $update) {
                                // 
                                localize_item($item);
 
+
+                               $tags=array();
+                               foreach(explode(',',$item['tag']) as $tag){
+                                       $tag = trim($tag);
+                                       if ($tag!="") $tags[] = bbcode($tag);
+                               }
+
+
                                // Build the HTML
 
                                $body = prepare_body($item,true);
-
+                               
 
                                $tmp_item = replace_macros($template,array(
+                                       '$type' => implode("",array_slice(split("/",$item['verb']),-1)),
+                                       '$tags' => $tags,
                                        '$body' => template_escape($body),
                                        '$id' => $item['item_id'],
                                        '$linktitle' => sprintf( t('View %s\'s profile @ %s'), $profile_name, ((strlen($item['author-link'])) ? $item['author-link'] : $item['url'])),
@@ -564,17 +631,12 @@ function conversation(&$a, $items, $mode, $update) {
                                $arr = array('item' => $item, 'output' => $tmp_item);
                                call_hooks('display_item', $arr);
 
-                               $threads[$threadsid] .= $arr['output'];
+                               $threads[$threadsid]['html'] .= $arr['output'];
                        }
                }
        }
 
 
-       // if author collapsing is in force but didn't get closed, close it off now.
-
-       /*if($blowhard_count >= 3)
-               $threads[$threadsid] .= '</div>';*/
-
        $page_template = get_markup_template("conversation.tpl");
        $o .= replace_macros($page_template, array(
                '$threads' => $threads,
@@ -740,6 +802,7 @@ function status_editor($a,$x, $notes_cid = 0) {
                $tpl = get_markup_template('jot-header.tpl');
        
                $a->page['htmlhead'] .= replace_macros($tpl, array(
+                       '$newpost' => 'true',
                        '$baseurl' => $a->get_baseurl(),
                        '$geotag' => $geotag,
                        '$nickname' => $x['nickname'],
@@ -747,6 +810,7 @@ function status_editor($a,$x, $notes_cid = 0) {
                        '$linkurl' => t('Please enter a link URL:'),
                        '$vidurl' => t("Please enter a video link/URL:"),
                        '$audurl' => t("Please enter an audio link/URL:"),
+                       '$term' => t('Tag term:'),
                        '$whereareu' => t('Where are you right now?'),
                        '$title' => t('Enter a title for this item') 
                ));