LJSUP-7813: New thread expander in S2, minimalism
[livejournal.git] / htdocs / talkread.bml
blob34659da534188b8a93ff326e5293ccb2fd2a0274
1 <?page
2 body<=
3 <?_code
4     use strict;
5     use vars qw($r_head $r_title %GET %ML $r_bodyopts);
7     # load package for formatting current music
8     use LJ::LastFM;
10     use LJ::Talk;
12     # make refs to both title and head, that work in cached or non-cached contexts
13     # $_[0] is a pre-request scratch area.
14     $r_head = "";
15     $r_title = "";
16     my $head = $_[0] ? \$_[0]->{'head'} : \$r_head;
17     my $title = $_[0] ? \$_[0]->{'title'} : \$r_title;
18     my $bodyopts = $_[0] ? \$_[0]->{'bodyopts'} : \$r_bodyopts;
20     return LJ::server_down_html() if $LJ::SERVER_DOWN;
22     ## workaround mail client bug when don't understand quoted-printable.
23     ## Only correct 'journal' if 'itemid' was also broken, to avoid the
24     ## unlikely clash with a journal name.
25     if ($GET{'itemid'} =~ s/^3D//)
26     {
27         $GET{'journal'} =~ s/^3D//;
28         $GET{'thread'} =~ s/^3D//;
29     }
31     LJ::Request->notes("codepath" => "bml.talkread");
33     my $uri = BML::get_uri();
34     my $itemid;
35     my $old_url = 0;
37     if ($uri =~ m!/(\d+)\.html$!) {
38         $itemid = $1;
39         $GET{'itemid'} = $itemid;
40         $GET{'journal'} = LJ::Request->notes("_journal");
41         BML::set_language_scope("/talkread.bml");
42     } else {
43         $old_url = 1;
44     }
46     my $init = LJ::Talk::init(\%GET);
47     return "<?h1 $ML{'Error'} h1?><?p $init->{'error'} p?>" if $init->{'error'};
49     my $u = $init->{'journalu'};
50     return $ML{'talk.error.nojournal'} unless $u;
52     my $ditemid = $init->{'ditemid'} + 0;
54     if ($old_url && $GET{'journal'}) {
55         # FIXME: add args
56         my %args = %GET;
57         delete $args{'journal'};
58         delete $args{'itemid'};
59         my $args = "";
60         if (%args) {
61             $args = "?" . join("&", map { LJ::eurl($_) . "=" . LJ::eurl($args{$_}) } keys %args);
62         }
63         return BML::redirect($u->journal_base . "/$ditemid.html$args");
64     }
66     # redirect if account was renamed
67     if ($u->{'journaltype'} eq "R") {
68         LJ::load_user_props($u, "renamedto");
69         if ($u->{'renamedto'} ne "") {
70             return BML::redirect(LJ::journal_base($u->{'renamedto'}) . "/$ditemid.html");
71         }
72     }
74     # now check for init->error, since we know the account wasn't renamed
75     return "<?h1 $ML{'Error'} h1?><?p $init->{'error'} p?>" if $init->{'error'};
77     LJ::Request->notes("journalid" => $u->{'userid'});
79     my $thread = $init->{'thread'};
80     my $dthread = $init->{'dthread'};
81     $itemid = $init->{'itemid'} + 0;
83     my $stylemine = $init->{'style'} eq "mine" ? "style=mine" : "";
84     my $formatlight = $GET{'format'} eq 'light' ? 'format=light' : '';
86     my $item = LJ::Talk::get_journal_item($u, $itemid);
88     if ($init->{'oldurl'} && $item) {
89         $init->{'anum'} = $item->{'anum'};
90         $init->{'ditemid'} = $init->{'itemid'} * 256 + $item->{'anum'};
91         $ditemid = $init->{'ditemid'} + 0;
92     }
94     my $entry = LJ::Entry->new($u, ditemid => $ditemid);
96     $u->preload_props("opt_blockrobots", "adult_content", "admin_content_flag") if $u->is_visible;
97     if (!$u->is_visible || $u->should_block_robots || ($entry && $entry->should_block_robots)) {
98         $$head .= LJ::robot_meta_tags();
99     }
101     $$head .= $LJ::SHARE_THIS_URL_GEN->(journal => $u->username)
102        unless $LJ::DISABLED{'sharethis'};
104     my %meta = (
105         'title'       => LJ::Text->drop_html($entry->subject_raw),
106         'description' => LJ::Text->drop_html($entry->event_raw),
107     );
109     $$head .= qq[
110         <meta name="title" value="$meta{'title'}"/>
111         <meta name="description" value="$meta{'description'}"/>
112     ];
114     unless ($item && $item->{'anum'} == $init->{'anum'}) {
115         LJ::Request->pnotes ('error' => 'e404');
116         LJ::Request->pnotes ('remote' => LJ::get_remote());
117         BML::return_error_status(404);
118         return;
119     }
121     my $talkurl = LJ::journal_base($u) . "/$ditemid.html";
123     ### load users
124     my ($up);  # $up = user posted journal item
125     LJ::load_userids_multiple([ $item->{'posterid'} => \$up, ], [ $u ]);
127     LJ::text_out(\$u->{'name'});
129     my $remote = LJ::get_remote();
131     ### set viewall/viewsome
132     my $viewall = 0;
133     my $viewsome = 0;
134     if ($GET{viewall} && LJ::check_priv($remote, 'canview', 'suspended')) {
135         LJ::statushistory_add(
136             $u->{'userid'},
137             $remote->{'userid'},
138             "viewall",
139             "entry: $u->{'user'}, itemid: $item->{'itemid'}, statusvis: " . $u->statusvis
140         );
141         $viewall = LJ::check_priv($remote, 'canview', '*');
142         $viewsome = $viewall || LJ::check_priv($remote, 'canview', 'suspended');
143     }
145     ### check for deleted/suspended/security
146     unless ($viewsome) {
148         # check suspended user
149         if ($u->is_suspended || $up->is_suspended) {
150             LJ::Request->pnotes ('error' => 'suspended');
151             LJ::Request->pnotes ('remote' => LJ::get_remote());
152             BML::return_error_status(404);
153             return;
154         }
156         # check deleted
157         if ($u->is_deleted) {
158             LJ::Request->pnotes ('error' => 'deleted');
159             LJ::Request->pnotes ('remote' => LJ::get_remote());
160             BML::return_error_status(404);
161             return;
162         }
164         if ( $up->is_deleted
165           && !$LJ::JOURNALS_WITH_PROTECTED_CONTENT{$up->username} )
166         {
167             my ($purge_comments, $purge_community_entries)
168                 = split /:/, $up->prop("purge_external_content");
170             if ($purge_community_entries) {
171                 LJ::Request->pnotes ('error' => 'deleted');
172                 LJ::Request->pnotes ('remote' => LJ::get_remote());
173                 BML::return_error_status(404);
174                 return;
175             }
176         }
178         # check suspended entry
179         if ($entry && $entry->is_suspended_for($remote)) {
180             LJ::Request->pnotes ('error' => 'suspended_post');
181             LJ::Request->pnotes ('remote' => LJ::get_remote());
182             BML::return_error_status(404);
183             return;
184         }
185     }
187     unless ($viewall) {
188         ###  Check security before viewing this post
189         my $errtxt;
190         return $errtxt unless LJ::Talk::check_viewable($remote, $item, \%GET, \$errtxt);
191     }
193     my $props = $item->{'props'};
194     my $nocomments_old = $viewall ?
195                          0 :
196                          $u->{'opt_showtalklinks'} eq "N" ? 1 : $props->{'opt_nocomments'};
197     my $comments_shown = $viewall || $entry->comments_shown;
198     my $allow_commenting = $entry->posting_comments_allowed;
200     # See if we should inject QuickReply javascript
201     LJ::load_user_props($remote, "opt_no_quickreply");
203     LJ::run_hooks("need_res_for_journals", $u);
204     my $graphicpreviews_obj = LJ::graphicpreviews_obj();
205     $graphicpreviews_obj->need_res($u);
207     my $ret = "";
209     LJ::need_res(qw(
210         js/thread_expander.js
211         js/journal.js
212     ));
214     if (($remote && !$remote->{'opt_no_quickreply'}) && $allow_commenting) {
215         # quickreply js libs
216         LJ::need_res(qw(
217             js/json.js
218             js/template.js
219             js/ippu.js
220             js/lj_ippu.js
221             js/userpicselect.js
222             js/hourglass.js
223             js/inputcomplete.js
224             stc/ups.css
225             stc/lj_base.css
226             js/datasource.js
227             js/selectable_table.js
228         )) unless $LJ::DISABLED{userpicselect} || !$remote->get_cap('userpicselect');
230         LJ::need_res(qw(
231             js/quickreply.js
232         ));
233     }
234     
235     if($remote) {
236         LJ::need_string(qw/ 
237                             comment.cancel
238                             comment.delete
239                             comment.delete.q
240                             comment.delete.all
241                             comment.delete.all.sub
242                             comment.delete.no.options
243                             comment.ban.user
244                             comment.mark.spam
245                             comment.mark.spam.title
246                             comment.mark.spam.subject
247                             comment.mark.spam.button
248                             comment.delete/);
249     }
251     my $showmultiform = $remote &&
252                         ($remote->{'user'} eq $u->{'user'} ||
253                          $remote->{'user'} eq $up->{'user'} ||
254                          $remote->can_manage($u));
256     my $multiform_selects = 0;  # are there select boxes?  don't show form if not.
258     my $event = $item->{'event'};
259     my $suspend_msg = $entry && $entry->should_show_suspend_msg_to($remote) ? 1 : 0;
260     my $no_cut_expand = !$GET{cut_expand} && $GET{page} && $GET{page} > 1 ? 1 : 0;
261     
262     if($no_cut_expand) {
263        $talkurl .= '?page=' . $GET{page} . '&cut_expand=1';
264     }
266     LJ::CleanHTML::clean_event(
267         \$event,
268         {
269             preformatted        => $props->{'opt_preformatted'},
270             suspend_msg         => $suspend_msg,
271             unsuspend_supportid => $suspend_msg ? $entry->prop("unsuspend_supportid") : 0, 
272             cuturl              => $talkurl, 
273             expand_cut          => !$no_cut_expand,
274         }
275     );
276     LJ::expand_embedded($u, $ditemid, $remote, \$event);
277     BML::ebml(\$event);
279     # make the title
280     {
281         my $subject = $item->{'subject'} || $event;
282         # yes, the 3 param to text_trim is chars, and length returns bytes, but
283         # it works, as bytes >= chars:
284         $subject = LJ::CleanHTML::clean_and_trim_subject(\$subject, length($item->{'subject'}) || 40);
285         $$title = "$u->{'user'}: $subject";
286         # prevent BML tags interpretation inside post body
287         $$title =~ s/<\?/&lt;?/g;
288         $$title =~ s/\?>/?&gt;/g;
289     }
291     $ret .= "<p>";
292     $ret .= "<table><tr valign='middle'>";
294     my $userpic = $entry->userpic;
295     LJ::run_hook('notify_event_displayed', $entry);
297     if ($userpic) {
298         my $alt = $up->{'name'};
299         if ($props->{'picture_keyword'}) {
300             $alt .= ": $props->{'picture_keyword'}";
301         }
302         LJ::text_out(\$alt);
303         $alt = LJ::ehtml($alt);
304         my ($w, $h) = $userpic->dimensions;
305         $ret .= "<td><img src='" . $userpic->url . "' width='$w' height='$h' align='absmiddle' hspace='3' title='$alt' alt=''></td>";
306     }
308     $ret .= "<td>";
309     if (!LJ::u_equals($u, $up)) {
310         $ret .= BML::ml(
311             "talk.somebodywrote_comm",
312             {
313                 realname => LJ::ehtml($up->{'name'}),
314                 userlink => LJ::ljuser($up),
315                 commlink => LJ::ljuser($u)
316             }
317         );
318     } else {
319         $ret .= BML::ml(
320             "talk.somebodywrote",
321             {
322                 realname => LJ::ehtml($up->{'name'}),
323                 userlink => LJ::ljuser($up)
324             }
325         );
326     }
328     my $etime = $item->{'eventtime'};
329     $etime =~ s!(\d\d\d\d)-(\d\d)-(\d\d)!LJ::date_to_view_links($u, $&)!e;
330     $ret .= "<br /><font size='-1'>@ $etime</font>";
331     $ret .= "</td></tr></table>";
333     ## standout bar
334     $ret .= LJ::Talk::link_bar({ 'u' => $u, 'up' => $up, 'headref' => $head, 'remote' => $remote, 'itemid' => $ditemid, });
336     if ($u->is_locked) {
337         $ret .= "<div class='warningbar warning-background' style='text-align: center; margin: 5px auto;'>$ML{'statusvis_message.locked'}</div>";
338     } elsif ($u->is_memorial) {
339         $ret .= "<div class='warningbar warning-background' style='text-align: center; margin: 5px auto;'>$ML{'statusvis_message.memorial'}</div>";
340     } elsif ($u->is_readonly) {
341         $ret .= "<div class='warningbar warning-background' style='text-align: center; margin: 5px auto;'>$ML{'statusvis_message.readonly'}</div>";
342     }
344     ### dump the log entry, unless we're browsing a thread.
345     my %current;
347     if ($props->{'current_mood'} || $props->{'current_moodid'}) {
348         my $themeid = $up->{'moodthemeid'};
349         my $moodid = $props->{'current_moodid'};
350         my $mood = $props->{'current_mood'};
352         my $moodname;
353         my $moodpic;
355         # favor custom mood over system mood
356         if (my $val = $mood) {
357             LJ::CleanHTML::clean_subject(\$val);
358             $moodname = $val;
359         }
361         if (my $val = $moodid) {
362             $moodname ||= LJ::mood_name($val);
363             my %pic;
364             if (LJ::get_mood_picture($themeid, $val, \%pic)) {
365                 $moodpic = "<img src=\"$pic{'pic'}\" align='absmiddle' " . 
366                            LJ::mood_size_attributes(%pic) . 
367                            " vspace='1' alt='' /> ";
368             }
369         }
371         $current{'Mood'} = "$moodpic$moodname";
372     }
374     if ($props->{'current_music'}) {
375         $current{'Music'} = $props->{'current_music'};
376         LJ::CleanHTML::clean_subject(\$current{'Music'});
377     }
379     if ($props->{'current_location'} || $props->{'current_coords'}) {
380         my $loc = eval {
381             LJ::Location->new(
382                 coords   => $props->{'current_coords'},
383                 location => $props->{'current_location'}
384             )
385         };
386         $current{'Location'} = $loc->as_html_current if $loc;
387     }
389     ### custom friend groups
390     my $group_names = $entry->group_names;
391     $current{'Groups'} = $group_names if $group_names;
393     my $logtags = LJ::Tags::get_logtags($u, $itemid);
394     if ($logtags->{$itemid} && %{$logtags->{$itemid}}) {
395         my $base = LJ::journal_base($u);
396         $current{'Tags'} = join(
397             ', ',
398             map { "<a href='$base/tag/" . LJ::eurl($_) . "'>" . LJ::ehtml($_) . "</a>" }
399             sort values %{$logtags->{$itemid}}
400         );
401     }
403     $ret .= "<div style='margin-left: 30px'>";
405     ### copyright
406     if (LJ::is_enabled('show_copyright', $u)) {
407         if ($props->{'copyright'} eq 'C' and $item->{'security'} eq "public") {
408             $ret .= '<div class="copyrighted">&Oslash; ' . BML::ml("talk.copyright") . '</div>';
409         }
410     }
412     if (%current)
413     {
414         $ret .= "<table border=0>\n";
415         foreach (sort keys %current) {
416             my $curkey = "talk.curname_" . $_;
417             my $curname = BML::ml($curkey);
418             $curname = "<b>Current $_:</b>" unless $curname;
419          
420             $ret .= "<tr><td align=right>$curname</td>";
421          
422             if ($_ eq 'Music') {
423                 $ret .= "<td>" . LJ::LastFM::format_current_music_string($current{$_}) . "</td></tr>\n";
424             } else {
425                 $ret .= "<td>$current{$_}</td></tr>\n";
426             }
427         }
428         $ret .= "</table><p>\n";
429     }
431     ### security indicator
432     my $sec = "";
433     if ($item->{'security'} eq "private") {
434         $sec = BML::fill_template("securityprivate");
435     } elsif ($item->{'security'} eq "usemask") {
436         if ($item->{'allowmask'} == 0) { # custom security with no group -- essentially private
437             $sec = BML::fill_template("securityprivate");
438         } elsif ($item->{'allowmask'} > 1 && $u && $u->equals($remote)) { # custom group -- only show to journal owner
439             $sec = BML::fill_template("securitygroups");
440         } else { # friends only or custom group showing to non journal owner
441             $sec = BML::fill_template("securityprotected");
442         }
443     }
445     $sec .= "<br />\n" unless $sec eq "" or $item->{'subject'};
446     $ret .= $sec;
448     ###
449     if ($item->{'subject'}) {
450         my $subject = $item->{'subject'};
451         if ($GET{'nohtml'}) {
452             # quote all non-LJ tags
453             $subject =~ s{<(?!/?lj)(.*?)>} {&lt;$1&gt;}gi;
454         }
455         LJ::CleanHTML::clean_subject(\$subject);
456         BML::ebml(\$subject);
457         $ret .= "<font face='Arial,Helvetica' size='+1'><i><b>$subject</b></i></font><br />\n";
458     }
460     if ($GET{'nohtml'}) {
461         # quote all non-LJ tags
462         $event =~ s{<(?!/?lj)(.*?)>} {&lt;$1&gt;}gi;
463     }
464     $ret .= $event;
465     $ret .= "</div>";
467     $ret .= "<br style='clear: both' /><hr width='100%' size='2' align='center' />";
469     my $qotd = 0;
470     $qotd = $entry->prop("qotdid") if $entry;
472     my @verticals = $entry->verticals_list_for_ad;
473     if (@verticals) {
474         $LJ::REQ_GLOBAL{verticals_of_first_public_post} = join(",", @verticals);
475     }
477     my $ad = LJ::get_ads ({
478         location        => 'bml.talkread.ebox',
479         nowrap          => 1,
480         journalu        => $u, 
481         vertical        => $LJ::REQ_GLOBAL{verticals_of_first_public_post}, 
482         interests_extra => $qotd ? { qotd => $qotd } : {},
483         s1_view         => 'entry',
484     });
486     if ($ad) {
487         $ret .= $ad;
488         $ret .= "<hr width='100%' size='2' align='center' />";
489     }
491     # .............
493     my $LJ_cmtinfo = {  # data structure to give to javascript for commentmanage
494         form_auth => LJ::form_auth(1),
495         journal   => $u->{user},
496         canAdmin  => ($remote && $remote->can_manage($u)) ? 1 : 0,
497         remote    => $remote ? $remote->{user} : "",
498         is_s1     => 1,
499     };
501     my $output = {};
503     my $comments = LJ::Talk::get_thread_html(
504         $u,
505         $up,
506         $entry,
507         $thread,
508         {
509             page          => $GET{page},
510             expand        => $GET{expand},
511             view          => $GET{view},
512             format        => $GET{format},
513             style         => $init->{style},
514             viewsome      => $viewsome,
515             viewall       => $viewall,
516             LJ_cmtinfo    => $LJ_cmtinfo,
517             showmultiform => $showmultiform,
518             talkid        => $GET{talkid},
519             mode          => $GET{mode},
520             show_collapse_link => 0,
521         },
522         $output
523     );
525     return $output->{error} if $output->{error};
526     
527     my $page = $output->{page};
528     my $pages = $output->{pages};
529     $multiform_selects ||= $output->{multiform_selects};
531     ########## make the navcrap
532     my $navcrap = '';
533     if ($pages > 1) {
534         $navcrap .= "<table style='font-weight: bold'>";
535         $navcrap .= "<tr><td align='center' colspan='3'>";
536         $navcrap .= BML::ml('ljlib.pageofpages', {'page' => $page, 'total' => $pages});
537         $navcrap .= "</td></tr>";
538         my $left = "&lt;&lt;";
539         if ($page > 1) { $left = "<a href='" . BML::self_link({ 'page' => $page-1 }) . "#comments'>$left</a>"; }
541         my $right = "&gt;&gt;";
542         if ($page < $pages) { $right = "<a href='" . BML::self_link({ 'page' => $page+1 }) . "#comments'>$right</a>"; }
544         $navcrap .= "<tr><td style='font-size: 85%' align='center'>$left</td><td style='font-size: 85%' align='center'>";
546         for (my $i = 1; $i <= $pages; $i++) {
547             my $link = "[$i]";
548             if ($i != $page) {
549                 $link = "<a href='" . BML::self_link({ 'page' => $i }) . "#comments'>$link</a>";
550             } else {
551                 $link = "<span style='font-size: 130%; font-weight: bolder'>$link</span>";
552             }
553             $navcrap .= "$link ";
554             if ($i == 11)  { $navcrap .= "<br />"; }
555             elsif ($i > 10 && $i % 10 == 0) { $navcrap .= "<br />"; }
556         }
558         $navcrap .= "</td><td style='font-size: 85%' align='center'>$right</td></tr>";
559         $navcrap .= "</table>\n";
560         $navcrap = BML::fill_template("standout", { 'DATA' => $navcrap });
561     }
562     ####### end navcrap
564     if ($comments_shown)
565     {
566         $ret .= "<div id='Comments'>";
567         $ret .= "<a name='comments'></a>";
568         $ret .= "<p>$navcrap</p>" if $navcrap;
569         my $readlink;
570             my $replycount = $entry->prop("replycount");
571             my $readlink_text = BML::ml("talk.commentsread.counted", { replycount => $replycount });
572             my $comments_count = BML::ml("talk.comments.counted", { replycount => $replycount });
573         
574             if (($dthread && $pages == 1) || ($GET{mode} eq 'showspam')) {
575             my $readurl = LJ::Talk::talkargs($talkurl, $stylemine, $formatlight);
576             $readlink = "(<a href='$readurl#comments'>$readlink_text</a>)";
577         } elsif ($replycount > 0) {
578             $readlink = "($comments_count)";
579         }
580         $readlink .= ' - ' if $readlink && $allow_commenting;
582         my $posturl = LJ::Talk::talkargs($talkurl, "mode=reply", $stylemine, $formatlight);
583         my $showspamurl = LJ::Talk::talkargs($talkurl, "mode=showspam", $stylemine, $formatlight);
584         my $hidespamurl = LJ::Talk::talkargs($talkurl, "", $stylemine, $formatlight);
585         my $spam_counter = $entry->prop('spam_counter') || 0;
586         
587         my $readspamlink = '';
588         if ($remote && $spam_counter > 0 && ($remote->can_manage($u) || $remote->can_moderate($u))) {
589             if ($GET{mode} eq 'showspam') {
590                 $readspamlink = "(" . BML::ml('talk.hidespam', { spam_counter => $spam_counter }) . ")";
591             } else {
592                 $readspamlink = "(<a href='$showspamurl'>" . BML::ml('talk.showspam', { spam_counter => $spam_counter }) . "</a>)";
593             }
594         }
595         $readspamlink .= ' - ' if $readspamlink && $allow_commenting;
597         my $stylemine = $GET{'style'} eq 'mine' ? 1 : 0;
599         my $viewing_thread;
600         if (defined $GET{'thread'}) {
601             $viewing_thread = $GET{'thread'};
602         }
603         $ret .= LJ::create_qr_div($u, $ditemid, $stylemine, $GET{'prop_picture_keyword'}, $viewing_thread);
605         $ret .= "<form style='display: inline' method='post' action='$LJ::SITEROOT/talkmulti.bml' name='multiform' " .
606                       "onsubmit='return multiformSubmit(this, {" .
607                       "no_action: \"" . LJ::ejs($ML{'.multi.no.action'}) . "\"," .
608                       "no_comments: \"" . LJ::ejs($ML{'.multi.no.comments'}) . "\"," .
609                       "conf_delete: \"" . LJ::ejs($ML{'.confirm.action'}) . "\"" .
610                 "})'>";
612         # Quick Reply when posting a new top level comment
613         # requires setup when logged in.
614         $ret .= "<p class='lesstop' align='center'><b>$readlink$readspamlink";
615         if ($allow_commenting) {
616             if ($remote) {
617                 # See if we want to force them to change their password
618                 my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
619                 if ($bp) {
620                     $ret .= "(<a href='$bp'>" . BML::ml('talk.replytothis') . " </a>)";
621                 } else {
622                     $ret .= "(" . LJ::make_qr_link('top', '', BML::ml('talk.commentpost'), $posturl) . "</a>)";
623                 }
624             } else {
625                 $ret .= "(<a href='$posturl'>" . BML::ml('talk.commentpost') . "</a>)";
626             }
627         }
629         my $rated_count = "";
630         if (LJ::is_eventrate_enable($u)) {
631             my ($we_like_this_title, $i_like_this_title) = map { $ML{$_} } qw(we_like_this_title i_like_this_title);
633             $rated_count = " (<a class=\"we_like_this we_like_this_".$ditemid."\" href=\"/$LJ::SITEROOT/alleventrates.bml?journal=".$u->{'user'}."&amp;itemid=$ditemid\" onclick=\"return ILikeThis.showList(event,this,'$ditemid','".$u->{'user'}."')\" title=\"$we_like_this_title\">".LJ::get_eventratescounters($u->{'userid'}, $ditemid)."</a>)";
635             if ($remote) {
636                 $rated_count .= " (<a href=\"#\" class=\"i_like_this i_like_this_".$ditemid."\" onclick=\"return ILikeThis.rate(event,this,'$ditemid','".$u->{'user'}."')\" title=\"$i_like_this_title\">+1";
637                 if (LJ::get_eventrates( 
638                        journalid => $u->{'userid'},
639                        itemid    => $ditemid,
640                        userids   => [ $remote->{'userid'} ], ))
641                 {
642                     $rated_count .= "<i class=\"i_like_this_already\">/</i>";
643                 }
644                 $rated_count .= "</a>)";
645             } else {
646                 $rated_count .= " (<a href=\"$LJ::SITEROOT/login.bml?ret=1\" class=\"i_like_this i_like_this_".$ditemid."\" title=\"$i_like_this_title\">+1</a>)";
647             }
648         }
650         $ret .= $rated_count;
651         $ret .= "</b></p>";
652         $ret .= "<div align='center'>" . LJ::make_qr_target('top') . "</div>" if $remote;
654         $ret .= LJ::html_hidden("ditemid", $ditemid);
655         $ret .= LJ::html_hidden("journal", $u->{'user'});
657         # Print out each comment
658         if (@$comments > 0)
659         {
660             $ret .= $_->{html} foreach @$comments;
662             my $do_commentmanage_js = 1;
663             if ($LJ::DISABLED{'commentmanage'}) {
664                 if (ref $LJ::DISABLED{'commentmanage'} eq "CODE") {
665                     $do_commentmanage_js = $LJ::DISABLED{'commentmanage'}->($remote);
666                 } else {
667                     $do_commentmanage_js = 0;
668                 }
669             }
671             if ($do_commentmanage_js) {
672                 LJ::need_res('js/commentmanage.js');
673                 my $js_screen_color = "\"" . LJ::ejs(BML::get_template_def("screenedbarcolor") || BML::get_template_def("emcolor")) . "\"";
674                 my $js_normal_color = "\"" . LJ::ejs(BML::get_template_def("emcolor")) . "\"";
675                 $$head .= '<script type="text/javascript">var LJ_cmtinfo = ' . LJ::js_dumper($LJ_cmtinfo) . ";\n" .
676                           "function userhook_screen_comment_ARG (dIid) { setStyle('cmtbar'+dIid, 'background', $js_screen_color); }\n".
677                           "function userhook_unscreen_comment_ARG (dIid) { setStyle('cmtbar'+dIid, 'background', $js_normal_color); }\n".
678                           "</script>\n";
679             }
681             $ret .= "<hr /><p class='lesstop' align='center'><b>$readlink$readspamlink";
682             if ($allow_commenting) {
683                 if ($remote) {
684                     # See if we want to force them to change their password
685                     my $bp = LJ::bad_password_redirect({ 'returl' => 1 });
686                     if ($bp) {
687                         $ret .= "(<a href='$bp'>" . BML::ml('talk.replytothis') . " </a>)";
688                     } else {
689                         $ret .= "(" . LJ::make_qr_link('bottom', '', BML::ml('talk.commentpost'), $posturl) . "</a>)";
690                     }
691                 } else {
692                     $ret .= "(<a href='$posturl'>" . BML::ml('talk.commentpost') . "</a>)";
693                 }
694             }
695             $ret .= $rated_count;
696             $ret .= "</b></p>";
697             $ret .= "<div align='center'>" . LJ::make_qr_target('bottom') . "</div>" if $remote;
699             if ($showmultiform && $multiform_selects) {
700                 $ret .= "<p>$ML{'.talkmulti.des'} ";
701                 my $args = BML::get_query_string;
702                 $args = '?' . $args if $args;
703                 $ret .= LJ::html_hidden( returnto => $talkurl . $args );
704                 if (LJ::is_enabled('spam_button') && $GET{mode} eq 'showspam') {
705                     $ret .= LJ::html_select(
706                         { 'name' => 'mode' },
707                         '' => $ML{'.talkmulti.please'},
708                         $ML{'.talkmulti.selected'} => [
709                             'unspam' => $ML{'.talkmulti.unspam'},
710                             'deletespam' => $ML{'.talkmulti.deletespam'},
711                         ],
712                         $ML{'.talkmulti.all'} => [
713                             'all:unspam' => $ML{'.talkmulti.unspam'},
714                             'all:deletespam' => $ML{'.talkmulti.deletespam'},
715                         ],
716                     );
717                 } else {
718                     $ret .= LJ::html_select(
719                         { 'name' => 'mode' },
720                         '' => $ML{'.talkmulti.please'},
721                         $ML{'.talkmulti.selected'} => [
722                             'unscreen'   => $ML{'.talkmulti.unscreen'},
723                             'screen'     => $ML{'.talkmulti.screen'},
724                             'delete'     => $ML{'.talkmulti.delete'},
725                             'deletespam' => $ML{'.talkmulti.deletespam'},
726                         ],
727                         $ML{'.talkmulti.all'} => [
728                             'all:screen'   => $ML{'.talkmulti.screen'},
729                             'all:unscreen' => $ML{'.talkmulti.unscreen'},
730                         ],
731                     );
732                 }
733                 $ret .= " " . LJ::html_submit('', $ML{'.talkmulti.submit'});
734                 $ret .= "</p>";
735             }
736          
737             my $ad = LJ::get_ads({ location => 'bml.talk.bottom', journalu => $u, s1_view => 'entry', });
738             if ($ad) {
739                 $ret .= "<hr width='100%' size='2' align='center' />" if $showmultiform && $multiform_selects;
740                 $ret .= qq[<div style='width: 768px; margin: auto;'>$ad</div>];
741             }
742         }
744         $ret .= "</form>";
745      
746         if ($navcrap) {
747             $ret .= "<p>$navcrap</p>";
748         }
750         $ret .= "</div>";
751     }
753     BML::noparse();
754     return $ret;
756 _code?>
757 <=body
758 windowtitle=><?_code return $_[0] ? $_[0]->{'title'} : $r_title _code?>
759 head=><?_code return $_[0] ? $_[0]->{'head'} : $r_head _code?>
760 bodyopts=><?_code return $_[0]->{'bodyopts'}; _code?>
761 page?><?_c <LJDEP>
762 link: htdocs/talkpost.bml, htdocs/talkread.bml, htdocs/delcomment.bml
763 img: htdocs/img/dot.gif, htdocs/img/delcomment.gif
764 </LJDEP> _c?>