in response to
didaio's
s2flexisquares post.
function Comment::print_linkbar() {
var string link_seperator = "";
# initialize array/hashes
var string[] link_keyseq = [""];
var string{} link_url = {"" => ""};
var string{} link_caption = {"" => ""};
var string{} link_image = {"" => ""};
var string print = "";
# gather current linkbar
foreach var string link_key ($.link_keyseq) {
var Link link = $this->get_link($link_key);
$link_url{$link_key} = $link.url;
$link_caption{$link_key} = $link.caption;
$link_image{$link_key} = $link.icon.url;
$link_keyseq[size($link_keyseq)] = $link_key; # add this to new link_keyseq array
}
# set new linkbar images
var Color delete_comment = $*entry_bgcolor;
var Color screen_comment = $*entry_bgcolor;
var Color unscreen_comment = "#ffaaaa";
var Color freeze_thread = $*entry_bgcolor;
var Color unfreeze_thread = "#aaaaff";
$link_image = {
"delete_comment" => palimg_tint("boxer/delete.gif", $delete_comment),
"screen_comment" => palimg_tint("boxer/screen.gif", $screen_comment),
"unscreen_comment" => palimg_tint("boxer/unscreen.gif", $unscreen_comment),
"freeze_thread" => palimg_tint("boxer/freeze.gif", $freeze_thread),
"unfreeze_thread" => palimg_tint("boxer/unfreeze.gif", $unfreeze_thread),
};
# loop thru linkbar and add links to print var
foreach var string link_key ($link_keyseq) {
# if we can do performed action, url will be present
if($link_url{$link_key} != "") {
$print = $print + """
""";
# if image url available, use it
if($link_image{$link_key} != "") {
# build an id for the image
var string id = "";
# if we're screening, add screen handle ("sus_#", where '#' is the comment talkid) to image
if($link_key->contains("screen")) {
$id = "sus_";
}
# if we're freezing, add freeze handle ("fuf_#", where '#' is the comment talkid) to image
if($link_key->contains("freeze")) {
$id = "fuf_";
}
$id = "$id$.talkid";
$print = $print + """
""";
} else {
# else, just use text
$print = $print + "$link_caption{$link_key}";
}
# add a seperator
$print = $print + "$link_seperator";
}
}
# hack off last seperator
$print = $print->substr(0, $print->length() - $link_seperator->length());
# we're done! let's print it!
print $print;
}
function EntryPage::print_comment (Comment comment) {
# set colors for comments
var Color color_comment_bar_screened = "#ffaaaa";
var Color color_comment_bar_screened_fgcolor = "#000000";
var Color color_comment_bar_frozen = "#aaaaff";
var Color color_comment_bar_frozen_fgcolor = "#000000";
var Color bgcolor = $*entrytitle_bgcolor;
var Color fgcolor = $*entry_fgcolor;
if($comment.screened) {
$bgcolor = $color_comment_bar_screened;
$fgcolor = $color_comment_bar_screened_fgcolor;
}
if($comment.frozen) {
$bgcolor = $color_comment_bar_frozen;
$fgcolor = $color_comment_bar_frozen_fgcolor;
}
var string subject = $comment.subject ? $comment.subject : """$*text_nosubject""";
var string poster = isnull $comment.poster ? $*text_poster_anonymous : $comment.poster->as_string();
var string reply = "";
var string parent = "";
var string thread = "";
$subject = """$subject""";
if($comment.subject_icon.url != "") {
$subject = "$comment.subject_icon $subject";
}
#Comment Userpic
"""
cmtbar$comment.talkid" style="background-color: $bgcolor; color: $fgcolor;">""";
if (defined $comment.userpic and $*show_entry_userpic) {
var int w = $comment.userpic.width;
var int h = $comment.userpic.height;
var string alt = $comment.metadata{"picture_keyword"};
if ($*comment_userpic_style == "small") {
$w = $w / 2;
$h = $h / 2;
}
if ($alt != "") {
$alt = ": " + $alt;
}
"""
""";
}
print $poster;
# use Comment::time_display()
print " on " + $comment->time_display();
"""
$subject
""";
if ($comment.metadata{"poster_ip"}) {
var string ip = $comment.metadata{"poster_ip"};
"""
$*text_comment_ipaddr($ip)
""";
}
# use Comment::print_text()
"""
"""; $comment->print_text(); """""";
var string alignlinks = "";
if ($*userpic_position == "left") {
$alignlinks = "right";
} else {
$alignlinks = "left";
}
"""
""";
$reply = $*text_comment_reply;
if ($comment.frozen) {
$reply = $*text_comment_frozen;
}
if ($.entry.comments.maxcomments) {
$reply = $*text_max_comments;
}
if ($comment.parent_url != "") {
$parent = """(
$*text_comment_parent) """;
}
if ($comment.thread_url != "") {
$thread = """(
$*text_comment_thread) """;
}
# print reply link
print "(";
if($reply == $*text_comment_reply) {
$comment->print_reply_link({"linktext" => $reply});
} else {
print $reply;
}
print ") ";
"""$parent$thread(
$*text_permalink)""";
"""
""";
if ($this.multiform_on) {
"""$*text_multiform_check""";
$comment->print_multiform_check();
}
$comment->print_linkbar();
"""
""";
# print reply container
$comment->print_reply_container();
"""
""";
}
function EntryPage::print_body() {
# set colors for comments
var Color color_comment_bar_screened = "#ffaaaa";
var Color color_comment_bar_screened_fgcolor = "#000000";
var Color color_comment_bar_frozen = "#aaaaff";
var Color color_comment_bar_frozen_fgcolor = "#000000";
# set new linkbar images
var Color delete_comment = $*entry_bgcolor;
var Color screen_comment = $*entry_bgcolor;
var Color unscreen_comment = "#ffaaaa";
var Color freeze_thread = $*entry_bgcolor;
var Color unfreeze_thread = "#aaaaff";
var string{} link_image = {
"delete_comment" => palimg_tint("boxer/delete.gif", $delete_comment),
"screen_comment" => palimg_tint("boxer/screen.gif", $screen_comment),
"unscreen_comment" => palimg_tint("boxer/unscreen.gif", $unscreen_comment),
"freeze_thread" => palimg_tint("boxer/freeze.gif", $freeze_thread),
"unfreeze_thread" => palimg_tint("boxer/unfreeze.gif", $unfreeze_thread),
};
# change bgcolor/fgcolor and images of screened comments
set_handler("screen_comment_#", [
[ "set_image", "sus_#", $link_image{"unscreen_comment"}, ],
[ "style_bgcolor", "cmtbar#", "$color_comment_bar_screened", ],
[ "style_color", "cmtbar#", "$color_comment_bar_screened_fgcolor", ],
]);
set_handler("unscreen_comment_#", [
[ "set_image", "sus_#", $link_image{"screen_comment"}, ],
[ "style_bgcolor", "cmtbar#", "$*entrytitle_bgcolor", ],
[ "style_color", "cmtbar#", "$*entry_fgcolor", ],
]);
# change bgcolor/fgcolor and images of frozen comments
set_handler("freeze_comment_#", [
[ "set_image", "fuf_#", $link_image{"unfreeze_thread"}, ],
[ "style_bgcolor", "cmtbar#", "$color_comment_bar_frozen", ],
[ "style_color", "cmtbar#", "$color_comment_bar_frozen_fgcolor", ],
]);
set_handler("unfreeze_comment_#", [
[ "set_image", "fuf_#", $link_image{"freeze_thread"}, ],
[ "style_bgcolor", "cmtbar#", "$*entrytitle_bgcolor", ],
[ "style_color", "cmtbar#", "$*entry_fgcolor", ],
]);
$this->print_entry($.entry);
if ($.multiform_on and $.entry.comments.enabled and $.comment_pages.total_subitems > 0) {
$this->print_multiform_start();
}
if ($.entry.comments.enabled) {
"""
""";
$.comment_pages->print();
# print reply link
"""
( """; $this->print_reply_link({"linktext" => $*text_post_comment, "target" => "topcomment"}); """ )""";
# print reply container
$this->print_reply_container({"target" => "topcomment"});
"""
""";
$this->print_comments($.comments);
if(size($.comments) > 0) {
"""
""";
$.comment_pages->print();
# print reply link
"""
( """; $this->print_reply_link({"linktext" => $*text_post_comment, "target" => "bottomcomment"}); """ )""";
# print reply container
$this->print_reply_container({"target" => "bottomcomment"});
"""
""";
}
"""
""";
}
if ($this.multiform_on and $.entry.comments.enabled and ($.entry.comments.count > 0 or $.entry.comments.screened)) {
"""
""";
$this->print_multiform_actionline();
$this->print_multiform_end();
"""
""";
$.comment_pages->print();
"""
""";
}
}