private function strip($in) { $bb = new BBCode(); $tfe = new TextFormattingEvent($in); $bb->receive_event($tfe); return $tfe->stripped; }
protected function comment_to_html($comment, $trim = false) { global $user; $tfe = new TextFormattingEvent($comment->comment); // sending this event to all ~50 exts has a lot of overhead if (SPEED_HAX) { $bb = new BBCode(); $bb->receive_event($tfe); } else { send_event($tfe); } $i_uid = int_escape($comment->owner_id); $h_name = html_escape($comment->owner_name); $h_poster_ip = html_escape($comment->poster_ip); $h_timestamp = autodate($comment->posted); $h_comment = $trim ? substr($tfe->stripped, 0, 50) . "..." : $tfe->formatted; $i_comment_id = int_escape($comment->comment_id); $i_image_id = int_escape($comment->image_id); $anoncode = ""; if ($h_name == "Anonymous" && $this->anon_id >= 0) { $anoncode = "<sup>{$this->anon_id}</sup>"; $this->anon_id++; } $h_userlink = "<a href='" . make_link("user/{$h_name}") . "'>{$h_name}</a>{$anoncode}"; $stripped_nonl = str_replace("\n", "\\n", substr($tfe->stripped, 0, 50)); $stripped_nonl = str_replace("\r", "\\r", $stripped_nonl); $h_dellink = $user->is_admin() ? "<br>({$h_poster_ip}, {$h_timestamp}, <a " . "onclick=\"return confirm('Delete comment by {$h_name}:\\n{$stripped_nonl}');\" " . "href='" . make_link("comment/delete/{$i_comment_id}/{$i_image_id}") . "'>Del</a>)" : ""; if ($trim) { return "\n\t\t\t\t{$h_userlink}: {$h_comment}\n\t\t\t\t<a href='" . make_link("post/view/{$i_image_id}") . "'>>>></a>\n\t\t\t\t{$h_dellink}\n\t\t\t"; } else { //$avatar = ""; //if(!empty($comment->owner->email)) { // $hash = md5(strtolower($comment->owner->email)); // $avatar = "<img src=\"http://www.gravatar.com/avatar/$hash.jpg\"><br>"; //} $oe = $this->comments_shown++ % 2 == 0 ? "even" : "odd"; return "\n\t\t\t\t<a name='{$i_comment_id}'></a>\n\t\t\t\t<div class='{$oe} comment'>\n\t\t\t\t<!--<span class='timeago' style='float: right;'>{$h_timestamp}</span>-->\n\t\t\t\t{$h_userlink}: {$h_comment}\n\t\t\t\t{$h_dellink}\n\t\t\t\t</div>\n\t\t\t"; } }