]> git.mxchange.org Git - friendica.git/blob - include/conversation.php
we need a profile url. Something.
[friendica.git] / include / conversation.php
1 <?php
2
3 /**
4  * "Render" a conversation or list of items for HTML display.
5  * There are two major forms of display:
6  *      - Sequential or unthreaded ("New Item View" or search results)
7  *      - conversation view
8  * The $mode parameter decides between the various renderings and also
9  * figures out how to determine page owner and other contextual items 
10  * that are based on unique features of the calling module.
11  *
12  */
13
14 function conversation(&$a, $items, $mode, $update) {
15
16         require_once('bbcode.php');
17
18         $profile_owner = 0;
19         $page_writeable      = false;
20
21         if($mode === 'network') {
22                 $profile_owner = local_user();
23                 $page_writeable = true;
24         }
25
26         if($mode === 'profile') {
27                 $profile_owner = $a->profile['profile_uid'];
28                 $page_writeable = can_write_wall($a,$profile_owner);
29         }
30
31         if($mode === 'display') {
32                 $profile_owner = $a->profile['uid'];
33                 $page_writeable = can_write_wall($a,$profile_owner);
34         }
35
36         if($update)
37                 $return_url = $_SESSION['return_url'];
38         else
39                 $return_url = $_SESSION['return_url'] = $a->cmd;
40
41
42         // find all the authors involved in remote conversations
43         // We will use a local profile photo if they are one of our contacts
44         // otherwise we have to get the photo from the item owner's site
45
46         $author_contacts = extract_item_authors($items,local_user());
47
48
49         $cmnt_tpl    = load_view_file('view/comment_item.tpl');
50         $like_tpl    = load_view_file('view/like.tpl');
51         $noshare_tpl = load_view_file('view/like_noshare.tpl');
52         $tpl         = load_view_file('view/wall_item.tpl');
53         $wallwall    = load_view_file('view/wallwall_item.tpl');
54
55         $alike = array();
56         $dlike = array();
57         
58         if(count($items)) {
59
60                 if($mode === 'network-new' || $mode === 'search') {
61
62                         // "New Item View" on network page or search page results 
63                         // - just loop through the items and format them minimally for display
64
65                         $tpl = load_view_file('view/search_item.tpl');
66                         $droptpl = load_view_file('view/wall_fake_drop.tpl');
67
68                         foreach($items as $item) {
69
70                                 $comment     = '';
71                                 $owner_url   = '';
72                                 $owner_photo = '';
73                                 $owner_name  = '';
74                                 $sparkle     = '';
75
76                                 if($mode === 'search') {
77                                         if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE))) 
78                                                 && ($item['id'] != $item['parent']))
79                                                 continue;
80                                         $nickname = $item['nickname'];
81                                 }
82                                 else
83                                         $nickname = $a->user['nickname'];
84                         
85                                 $profile_name   = ((strlen($item['author-name']))   ? $item['author-name']   : $item['name']);
86                                 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
87                                 $profile_link   = ((strlen($item['author-link']))   ? $item['author-link']   : $item['url']);
88
89                                 $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
90
91                                 if(strlen($item['author-link'])) {
92                                         if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
93                                                 $profile_link = $redirect_url;
94                                                 $sparkle = ' sparkle';
95                                         }
96                                         elseif(isset($author_contacts[$item['author-link']])) {
97                                                 $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']];
98                                                 $sparkle = ' sparkle';
99                                         }
100                                 }
101
102                                 $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
103                                 $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
104                                 if($coord) {
105                                         if($location)
106                                                 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
107                                         else
108                                                 $location = '<span class="smalltext">' . $coord . '</span>';
109                                 }
110
111                                 $drop = '';
112                                 $dropping = false;
113
114                                 if((intval($item['contact-id']) && $item['contact-id'] == remote_user()) || ($item['uid'] == local_user()))
115                                         $dropping = true;
116
117                     $drop = replace_macros((($dropping)? $droptpl : $fakedrop), array('$id' => $item['id'], '$delete' => t('Delete')));
118
119
120
121                                 $drop = replace_macros($droptpl,array('$id' => $item['id']));
122                                 $lock = '<div class="wall-item-lock"></div>';
123                                 
124                                 $o .= replace_macros($tpl,array(
125                                         '$id' => $item['item_id'],
126                                         '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
127                                         '$profile_url' => $profile_link,
128                                         '$item_photo_menu' => item_photo_menu($item),
129                                         '$name' => $profile_name,
130                                         '$sparkle' => $sparkle,
131                                         '$lock' => $lock,
132                                         '$thumb' => $profile_avatar,
133                                         '$title' => $item['title'],
134                                         '$body' => smilies(bbcode($item['body'])),
135                                         '$ago' => relative_date($item['created']),
136                                         '$location' => $location,
137                                         '$indent' => '',
138                                         '$owner_url' => $owner_url,
139                                         '$owner_photo' => $owner_photo,
140                                         '$owner_name' => $owner_name,
141                                         '$drop' => $drop,
142                                         '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $nickname . '/' . $item['id'] . '">' . t('View in context') . '</a>'
143                                 ));
144
145                         }
146
147                         return $o;
148                 }
149
150
151
152
153                 // Normal View
154
155
156                 // Figure out how many comments each parent has
157                 // (Comments all have gravity of 6)
158                 // Store the result in the $comments array
159
160                 $comments = array();
161                 foreach($items as $item) {
162                         if(intval($item['gravity']) == 6) {
163                                 if(! x($comments,$item['parent']))
164                                         $comments[$item['parent']] = 1;
165                                 else
166                                         $comments[$item['parent']] += 1;
167                         }
168                 }
169
170                 // map all the like/dislike activities for each parent item 
171                 // Store these in the $alike and $dlike arrays
172
173                 foreach($items as $item) {
174                         like_puller($a,$item,$alike,'like');
175                         like_puller($a,$item,$dlike,'dislike');
176                 }
177
178                 $comments_collapsed = false;
179                 $blowhard = 0;
180                 $blowhard_count = 0;
181
182                 foreach($items as $item) {
183
184                         $comment = '';
185                         $template = $tpl;
186                         $commentww = '';
187                         $sparkle = '';
188                         $owner_url = $owner_photo = $owner_name = '';
189
190                         // We've already parsed out like/dislike for special treatment. We can ignore them now
191
192                         if(((activity_match($item['verb'],ACTIVITY_LIKE)) 
193                                 || (activity_match($item['verb'],ACTIVITY_DISLIKE))) 
194                                 && ($item['id'] != $item['parent']))
195                                 continue;
196
197                         $toplevelpost = (($item['id'] == $item['parent']) ? true : false);
198
199
200                         // Take care of author collapsing and comment collapsing
201                         // If a single author has more than 3 consecutive top-level posts, squash the remaining ones.
202                         // If there are more than two comments, squash all but the last 2.
203
204                         if($toplevelpost) {
205
206                                 $item_writeable = (($item['writable'] || $item['self']) ? true : false);
207
208                                 if($blowhard == $item['cid'] && (! $item['self']) && ($mode != 'profile')) {
209                                         $blowhard_count ++;
210                                         if($blowhard_count == 3) {
211                                                 $o .= '<div class="icollapse-wrapper fakelink" id="icollapse-wrapper-' . $item['parent'] 
212                                                         . '" onclick="openClose(' . '\'icollapse-' . $item['parent'] . '\');" >' 
213                                                         . t('See more posts like this') . '</div>' . '<div class="icollapse" id="icollapse-' 
214                                                         . $item['parent'] . '" style="display: none;" >';
215                                         }
216                                 }
217                                 else {
218                                         $blowhard = $item['cid'];                                       
219                                         if($blowhard_count >= 3)
220                                                 $o .= '</div>';
221                                         $blowhard_count = 0;
222                                 }
223
224                                 $comments_seen = 0;
225                                 $comments_collapsed = false;
226                         }
227                         else
228                                 $comments_seen ++;
229
230
231                         $show_comment_box = ((($page_writeable) && ($item_writeable) && ($comments_seen == $comments[$item['parent']])) ? true : false);
232
233                         if(($comments[$item['parent']] > 2) && ($comments_seen <= ($comments[$item['parent']] - 2)) && ($item['gravity'] == 6)) {
234                                 if(! $comments_collapsed) {
235                                         $o .= '<div class="ccollapse-wrapper fakelink" id="ccollapse-wrapper-' . $item['parent'] 
236                                                 . '" onclick="openClose(' . '\'ccollapse-' . $item['parent'] . '\');" >' 
237                                                 . sprintf( t('See all %d comments'), $comments[$item['parent']]) . '</div>'
238                                                 . '<div class="ccollapse" id="ccollapse-' . $item['parent'] . '" style="display: none;" >';
239                                         $comments_collapsed = true;
240                                 }
241                         }
242                         if(($comments[$item['parent']] > 2) && ($comments_seen == ($comments[$item['parent']] - 1))) {
243                                 $o .= '</div>';
244                         }
245
246                         $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
247
248                         $lock = ((($item['private']) || (($item['uid'] == local_user()) && (strlen($item['allow_cid']) || strlen($item['allow_gid']) 
249                                 || strlen($item['deny_cid']) || strlen($item['deny_gid']))))
250                                 ? '<div class="wall-item-lock"><img src="images/lock_icon.gif" class="lockview" alt="' . t('Private Message') . '" onclick="lockview(event,' . $item['id'] . ');" /></div>'
251                                 : '<div class="wall-item-lock"></div>');
252
253
254                         // Top-level wall post not written by the wall owner (wall-to-wall)
255                         // First figure out who owns it. 
256
257                         $osparkle = '';
258
259                         if(($toplevelpost) && (! $item['self']) && ($mode !== 'profile')) {
260
261                                 if($item['type'] === 'wall') {
262
263                                         // On the network page, I am the owner. On the display page it will be the profile owner.
264                                         // This will have been stored in $a->page_contact by our calling page.
265                                         // Put this person on the left of the wall-to-wall notice.
266
267                                         $owner_url = $a->page_contact['url'];
268                                         $owner_photo = $a->page_contact['thumb'];
269                                         $owner_name = $a->page_contact['name'];
270                                         $template = $wallwall;
271                                         $commentww = 'ww';      
272                                 }
273                                 if(($item['type'] === 'remote') && (strlen($item['owner-link'])) && ($item['owner-link'] != $item['author-link'])) {
274
275                                         // Could be anybody. 
276
277                                         $owner_url = $item['owner-link'];
278                                         $owner_photo = $item['owner-avatar'];
279                                         $owner_name = $item['owner-name'];
280                                         $template = $wallwall;
281                                         $commentww = 'ww';
282                                         // If it is our contact, use a friendly redirect link
283                                         if((link_compare($item['owner-link'],$item['url'])) 
284                                                 && ($item['network'] === 'dfrn')) {
285                                                 $owner_url = $redirect_url;
286                                                 $osparkle = ' sparkle';
287                                         }
288                                 }
289                         }
290
291
292                         $likebuttons = '';
293
294                         if($page_writeable) {
295                                 if($toplevelpost) {
296                                         $likebuttons = replace_macros((($item['private']) ? $noshare_tpl : $like_tpl),array(
297                                                 '$id' => $item['id'],
298                                                 '$likethis' => t("I like this \x28toggle\x29"),
299                                                 '$nolike' => t("I don't like this \x28toggle\x29"),
300                                                 '$share' => t('Share'),
301                                                 '$wait' => t('Please wait') 
302                                         ));
303                                 }
304
305                                 if(($show_comment_box) || (($show_comment_box == false) && ($item['last-child']))) {
306                                         $comment = replace_macros($cmnt_tpl,array(
307                                                 '$return_path' => '', 
308                                                 '$jsreload' => (($mode === 'display') ? $_SESSION['return_url'] : ''),
309                                                 '$type' => (($mode === 'profile') ? 'wall-comment' : 'net-comment'),
310                                                 '$id' => $item['item_id'],
311                                                 '$parent' => $item['parent'],
312                                                 '$profile_uid' =>  $profile_owner,
313                                                 '$mylink' => $a->contact['url'],
314                                                 '$mytitle' => t('This is you'),
315                                                 '$myphoto' => $a->contact['thumb'],
316                                                 '$comment' => t('Comment'),
317                                                 '$submit' => t('Submit'),
318                                                 '$ww' => (($mode === 'network') ? $commentww : '')
319                                         ));
320                                 }
321                         }
322
323                         $edpost = ((($profile_owner == local_user()) && ($toplevelpost) && (intval($item['wall']) == 1))
324                                         ? '<a class="editpost" href="' . $a->get_baseurl() . '/editpost/' . $item['id'] 
325                                                 . '" title="' . t('Edit') . '"><img src="images/pencil.gif" /></a>'
326                                         : '');
327                         $drop = replace_macros(load_view_file('view/wall_item_drop.tpl'), array('$id' => $item['id'], '$delete' => t('Delete')));
328
329                         $photo = $item['photo'];
330                         $thumb = $item['thumb'];
331
332                         // Post was remotely authored.
333
334                         $diff_author    = ((link_compare($item['url'],$item['author-link'])) ? false : true);
335
336                         $profile_name   = (((strlen($item['author-name']))   && $diff_author) ? $item['author-name']   : $item['name']);
337                         $profile_avatar = (((strlen($item['author-avatar'])) && $diff_author) ? $item['author-avatar'] : $thumb);
338
339                         if($mode === 'profile') {
340                                 if(local_user() && ($item['contact-uid'] == local_user()) && ($item['network'] === 'dfrn') && (! $item['self'] )) {
341                         $profile_link = $redirect_url;
342                     $sparkle = ' sparkle';
343                     }
344                                 else {
345                                         $profile_link = $item['url'];
346                                         $sparkle = '';
347                                 }
348                         }
349                         elseif(strlen($item['author-link'])) {
350                                 $profile_link = $item['author-link'];
351                                 if(link_compare($item['author-link'],$item['url']) && ($item['network'] === 'dfrn') && (! $item['self'])) {
352                                         $profile_link = $redirect_url;
353                                         $sparkle = ' sparkle';
354                                 }
355                                 elseif(isset($author_contacts[$item['author-link']])) {
356                                         $profile_link = $a->get_baseurl() . '/redir/' . $author_contacts[$item['author-link']];
357                                         $sparkle = ' sparkle';
358                                 }
359                         }
360                         else 
361                                 $profile_link = $item['url'];
362
363                         $like    = ((x($alike,$item['id'])) ? format_like($alike[$item['id']],$alike[$item['id'] . '-l'],'like',$item['id']) : '');
364                         $dislike = ((x($dlike,$item['id'])) ? format_like($dlike[$item['id']],$dlike[$item['id'] . '-l'],'dislike',$item['id']) : '');
365
366                         $location = (($item['location']) ? '<a target="map" title="' . $item['location'] 
367                                 . '" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
368                         $coord = (($item['coord']) ? '<a target="map" title="' . $item['coord'] 
369                                 . '" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
370                         if($coord) {
371                                 if($location)
372                                         $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
373                                 else
374                                         $location = '<span class="smalltext">' . $coord . '</span>';
375                         }
376
377                         $indent = (($toplevelpost) ? '' : ' comment');
378
379                         if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
380                                 $indent .= ' shiny'; 
381
382                         // Build the HTML
383
384                         $tmp_item = replace_macros($template,array(
385                                 '$id' => $item['item_id'],
386                                 '$linktitle' => sprintf( t('View %s\'s profile'), $profile_name),
387                                 '$olinktitle' => sprintf( t('View %s\'s profile'), $owner_name),
388                                 '$to' => t('to'),
389                                 '$wall' => t('Wall-to-Wall'),
390                                 '$vwall' => t('via Wall-To-Wall:'),
391                                 '$profile_url' => $profile_link,
392                                 '$item_photo_menu' => item_photo_menu($item),
393                                 '$name' => $profile_name,
394                                 '$thumb' => $profile_avatar,
395                                 '$osparkle' => $osparkle,
396                                 '$sparkle' => $sparkle,
397                                 '$title' => $item['title'],
398                                 '$body' => smilies(bbcode($item['body'])),
399                                 '$ago' => relative_date($item['created']),
400                                 '$lock' => $lock,
401                                 '$location' => $location,
402                                 '$indent' => $indent,
403                                 '$owner_url' => $owner_url,
404                                 '$owner_photo' => $owner_photo,
405                                 '$owner_name' => $owner_name,
406                                 '$plink' => get_plink($item),
407                                 '$edpost' => $edpost,
408                                 '$drop' => $drop,
409                                 '$vote' => $likebuttons,
410                                 '$like' => $like,
411                                 '$dislike' => $dislike,
412                                 '$comment' => $comment
413                         ));
414
415                         $arr = array('item' => $item, 'output' => $tmp_item);
416                         call_hooks('display_item', $arr);
417
418                         $o .= $arr['output'];
419
420                 }
421         }
422
423
424         // if author collapsing is in force but didn't get closed, close it off now.
425
426         if($blowhard_count >= 3)
427                 $o .= '</div>';
428
429         return $o;
430
431
432
433
434
435 if(! function_exists('extract_item_authors')) {
436 function extract_item_authors($arr,$uid) {
437
438         if((! $uid) || (! is_array($arr)) || (! count($arr)))
439                 return array();
440         $urls = array();
441         foreach($arr as $rr) {
442                 if(! in_array("'" . dbesc($rr['author-link']) . "'",$urls))
443                         $urls[] = "'" . dbesc($rr['author-link']) . "'";
444         }
445
446         // pre-quoted, don't put quotes on %s
447         if(count($urls)) {
448                 $r = q("SELECT `id`,`network`,`url` FROM `contact` WHERE `uid` = %d AND `url` IN ( %s )  AND `self` = 0 AND `blocked` = 0 ",
449                         intval($uid),
450                         implode(',',$urls)
451                 );
452                 if(count($r)) {
453                         $ret = array();
454                         $authors = array();
455                         foreach($r as $rr){
456                                 if ($rr['network']=='dfrn')
457                                         $ret[$rr['url']] = $rr['id'];
458                                 $authors[$r['url']]= $rr;
459                         }
460                         $a->authors = $authors;
461                         return $ret;
462                 }
463         }
464         return array();         
465 }}
466
467 if(! function_exists('item_photo_menu')){
468 function item_photo_menu($item){
469         $a = get_app();
470         
471         if (!isset($a->authors)){
472                 $rr = q("SELECT `id`, `network`, `url` FROM `contact` WHERE `uid`=%d AND `self`=0 AND `blocked`=0 ", intval(local_user()));
473                 $authors = array();
474                 foreach($rr as $r) $authors[$r['url']]= $r;
475                 $a->authors = $authors;
476         }
477         
478         $contact_url="";
479         $pm_url="";
480
481         $status_link="";
482         $photo_link="";
483         $profile_link   = ((strlen($item['author-link']))   ? $item['author-link'] : $item['url']);
484         $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ;
485
486         // $item['contact-uid'] is only set on profile page and indicates the uid of the user who owns the profile.
487
488         $profile_owner = ((x($item,'contact-uid')) && intval($item['contact-uid']) ? intval($item['contact-uid']) : 0); 
489
490         // So we are checking that this is a logged in user on some page that *isn't* a profile page
491         // OR a profile page where the viewer owns the profile. 
492         // Then check if we can use a sparkle (redirect) link to the profile by virtue of it being our contact
493         // or a friend's contact that we both have a connection to. 
494
495         if((local_user() && ($profile_owner == 0)) 
496                 || ($profile_owner && $profile_owner == local_user())) {
497
498                 if(strlen($item['author-link']) && link_compare($item['author-link'],$item['url'])) {
499                         $redir = $redirect_url;
500                         $cid = $item['cid'];
501                 }
502                 elseif(isset($a->authors[$item['author-link']])) {
503                         $redir = $a->get_baseurl() . '/redir/' . $a->authors[$item['author-link']]['id'];
504                         $cid = $a->authors[$item['author-link']]['id'];
505                 }
506
507                 if((isset($cid)) && (! $item['self'])) {
508                         $contact_url = $a->get_baseurl() . '/contacts/' . $cid;
509                         if($item['network'] === 'dfrn') {
510                                 $status_link = $redir . "?url=status";
511                                 $profile_link = $redir . "?url=profile";
512                                 $photos_link = $redir . "?url=photos";
513                                 $pm_url = $a->get_baseurl() . '/message/new/' . $cid;
514                         }
515                 }
516         }
517
518
519         $menu = Array(
520                 t("View status") => $status_link,
521                 t("View profile") => $profile_link,
522                 t("View photos") => $photos_link,               
523                 t("Edit contact") => $contact_url,
524                 t("Send PM") => $pm_url,
525         );
526         
527         
528         $args = array($item, &$menu);
529         
530         call_hooks('item_photo_menu', $args);
531         
532         $o = "";
533         foreach($menu as $k=>$v){
534                 if ($v!="") $o .= "<li><a href='$v'>$k</a></li>\n";
535         }
536         return $o;
537 }}
538
539 if(! function_exists('like_puller')) {
540 function like_puller($a,$item,&$arr,$mode) {
541
542         $url = '';
543         $sparkle = '';
544         $verb = (($mode === 'like') ? ACTIVITY_LIKE : ACTIVITY_DISLIKE);
545
546         if((activity_match($item['verb'],$verb)) && ($item['id'] != $item['parent'])) {
547                 $url = $item['author-link'];
548                 if((local_user()) && (local_user() == $item['uid']) && ($item['network'] === 'dfrn') && (! $item['self']) && (link_compare($item['author-link'],$item['url']))) {
549                         $url = $a->get_baseurl() . '/redir/' . $item['contact-id'];
550                         $sparkle = ' class="sparkle" ';
551                 }
552                 if(! ((isset($arr[$item['parent'] . '-l'])) && (is_array($arr[$item['parent'] . '-l']))))
553                         $arr[$item['parent'] . '-l'] = array();
554                 if(! isset($arr[$item['parent']]))
555                         $arr[$item['parent']] = 1;
556                 else    
557                         $arr[$item['parent']] ++;
558                 $arr[$item['parent'] . '-l'][] = '<a href="'. $url . '"'. $sparkle .'>' . $item['author-name'] . '</a>';
559         }
560         return;
561 }}
562
563 // Format the like/dislike text for a profile item
564 // $cnt = number of people who like/dislike the item
565 // $arr = array of pre-linked names of likers/dislikers
566 // $type = one of 'like, 'dislike'
567 // $id  = item id
568 // returns formatted text
569
570 if(! function_exists('format_like')) {
571 function format_like($cnt,$arr,$type,$id) {
572         $o = '';
573         if($cnt == 1)
574                 $o .= (($type === 'like') ? sprintf( t('%s likes this.'), $arr[0]) : sprintf( t('%s doesn\'t like this.'), $arr[0])) . EOL ;
575         else {
576                 $spanatts = 'class="fakelink" onclick="openClose(\'' . $type . 'list-' . $id . '\');"';
577                 $o .= (($type === 'like') ? 
578                                         sprintf( t('<span  %1$s>%2$d people</span> like this.'), $spanatts, $cnt)
579                                          : 
580                                         sprintf( t('<span  %1$s>%2$d people</span> don\'t like this.'), $spanatts, $cnt) ); 
581                 $o .= EOL ;
582                 $total = count($arr);
583                 if($total >= MAX_LIKERS)
584                         $arr = array_slice($arr, 0, MAX_LIKERS - 1);
585                 if($total < MAX_LIKERS)
586                         $arr[count($arr)-1] = t('and') . ' ' . $arr[count($arr)-1];
587                 $str = implode(', ', $arr);
588                 if($total >= MAX_LIKERS)
589                         $str .= sprintf( t(', and %d other people'), $total - MAX_LIKERS );
590                 $str = (($type === 'like') ? sprintf( t('%s like this.'), $str) : sprintf( t('%s don\'t like this.'), $str));
591                 $o .= "\t" . '<div id="' . $type . 'list-' . $id . '" style="display: none;" >' . $str . '</div>';
592         }
593         return $o;
594 }}