Савинцев Егор 🚶 (savintsev_egor) wrote in changelog,
Савинцев Егор 🚶
savintsev_egor
changelog

[ljcom] r10107: LJSUP-7758: AntiSpam S2

Committer: esavintcev
LJSUP-7758: AntiSpam S2
U   trunk/bin/upgrading/s2layers/smoothsailing/layout.s2
Modified: trunk/bin/upgrading/s2layers/smoothsailing/layout.s2
===================================================================
--- trunk/bin/upgrading/s2layers/smoothsailing/layout.s2	2011-02-24 09:33:22 UTC (rev 10106)
+++ trunk/bin/upgrading/s2layers/smoothsailing/layout.s2	2011-02-24 10:06:52 UTC (rev 10107)
@@ -506,6 +506,9 @@
     set text_poster_anonymous = "Anonymous";
     set text_format_entry_date_and_time = "%%dayord%%-%%mon%%-%%yyyy%% %%hh%%:%%min%% %%a%%m";
     set text_format_entry_time = "%%hh%%:%%min%% %%a%%m";
+    property use text_showspam;
+    property use text_hidespam;
+    property use text_spam_comment;
 }
 
 propgroup text_header = "Menu";
@@ -1683,17 +1686,27 @@
           """
           <div class="entryLinkbar"><ul>
           """;
+          var string comments_showspam = "";
+          if ($p.view == "entry") {
+              if ($p.showspam) {
+                  $comments_showspam = """<li><a href=\"$.comments.read_spam_url\">$*text_hidespam</a></li>""";
+              } else {
+                  $comments_showspam = """<li><a href=\"$.comments.read_spam_url\">$*text_showspam</a></li>""";
+              }
+          }
           if ($.comments.enabled) {
             if ($.itemid==int($*layout_guestbook_entryid)) {
-				print safe """<li><a href="$.comments.post_url">$*text_post_comment_guestbook</a></li>""";
+                print safe """<li><a href="$.comments.post_url">$*text_post_comment_guestbook</a></li>""";
+                print safe """$comments_showspam""";
             } else {
               if ($.comments.count > 0 or $.comments.screened) {
                 """<li><a href="$.comments.read_url">"""; print safe get_plural_phrase($.comments.count,"text_read_comments"); """</a></li>""";
+                """$comments_showspam""";
               }
               $printqr = true;
-				if (not $.comments.locked) {
-					"""<li>"""; $p->print_reply_link({"linktext" => $*text_post_comment, "target" => "qr$.journal.username$.itemid", "reply_url" => $.comments.post_url}); """</li>""";
-				}
+                if (not $.comments.locked) {
+                """<li>"""; $p->print_reply_link({"linktext" => $*text_post_comment, "target" => "qr$.journal.username$.itemid", "reply_url" => $.comments.post_url}); """</li>""";
+                }
             }
           }
           print safe """<li><a href="$.permalink_url">$*text_permalink</a></li>""";
@@ -1815,10 +1828,14 @@
 }
 
 function EntryPage::print_comments (Comment[] cs) {
+    var Page p = get_page();
     if (size $cs == 0) { return; }
     foreach var Comment c ($cs) {
         var int indent = ($c.depth - 1) * 25;
-        if ($c.full) {
+        if ($c.spam and not $p.showspam) {
+            """<div style='margin-left: ${indent}px;' id="$c.dom_id">\n""";
+            $this->print_comment_partial($c);
+        } elseif ($c.full) {
             """<div style='margin-left: ${indent}px;' id="$c.dom_id" class="ljcmt_full">\n""";
             $this->print_comment($c);
         } else {
@@ -1852,13 +1869,18 @@
 }
 
 function EntryPage::print_comment_partial(Comment comment) {
+    var Page p = get_page();
     """<a name="$comment.anchor"></a>
     <div class="commentHolder"><div class="commentText">""";
-    print "<a href=\"$comment.permalink_url\">"+($comment.subject==""?"<i>(no subject)</i>":"$comment.subject")+"</a> - ";
-    print (defined $comment.poster?"<span class=\"ljuser\" style=\"white-space:nowrap;\">$comment.poster</span>":"<i>Anonymous</i>");
-    var Link expand_link = $comment->get_link("expand_comments");
-    if ($comment.thread_url != "" and defined $expand_link) {
-        " " + $comment->expand_link();
+    if ($comment.spam and not $p.showspam) {
+        """<strong>$*text_spam_comment</strong>""";
+    } else {
+        print "<a href=\"$comment.permalink_url\">"+($comment.subject==""?"<i>(no subject)</i>":"$comment.subject")+"</a> - ";
+        print (defined $comment.poster?"<span class=\"ljuser\" style=\"white-space:nowrap;\">$comment.poster</span>":"<i>Anonymous</i>");
+        var Link expand_link = $comment->get_link("expand_comments");
+        if ($comment.thread_url != "" and defined $expand_link) {
+            " " + $comment->expand_link();
+        }
     }
     """</div></div>""";
 }

Tags: ljcom, s2, savintsev_egor
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments