From 9aa564450419f9581f6b97e06f6541cb1fed7351 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 11 Feb 2012 08:33:09 +0000 Subject: [PATCH] colours don't scale either D: numbers then... --- core/util.inc.php | 11 +++++++++++ ext/comment/theme.php | 40 +++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/core/util.inc.php b/core/util.inc.php index de63a676..69822c94 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -372,6 +372,17 @@ function theme_file($filepath) { } +function hsl_rainbow() { + $ct = Array(); + $s = 100; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + $s = 100; $l = 50; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + $s = 50; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + $s = 100; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + $s = 100; $l = 50; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + $s = 50; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} + return $ct; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * CAPTCHA abstraction * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/ext/comment/theme.php b/ext/comment/theme.php index 23608ad4..e4b63f04 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -1,6 +1,7 @@ ct)) { - $ct = Array(); - $s = 100; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $s = 100; $l = 50; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $s = 50; $l = 25; for($h= 0; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $s = 100; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $s = 100; $l = 50; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $s = 50; $l = 25; for($h=30; $h<360; $h+=60) {$ct[] = "hsl($h, $s%, $l%);";} - $this->ct = $ct; + $this->ct = hsl_rainbow(); } if(!array_key_exists($ip, $this->anon_map)) { $this->anon_map[$ip] = $this->ct[$this->anon_cid++ % count($this->ct)]; @@ -71,11 +65,12 @@ class CommentListTheme extends Themelet { $hidden = $comment_count - $comment_limit; $comment_html .= '

showing '.$comment_limit.' of '.$comment_count.' comments

'; $comments = array_slice($comments, -$comment_limit); - $this->anon_id = -1; + $this->show_anon_id = false; } else { - $this->anon_id = 1; + $this->show_anon_id = true; } + $this->anon_id = 1; foreach($comments as $comment) { $comment_html .= $this->comment_to_html($comment); } @@ -113,7 +108,7 @@ class CommentListTheme extends Themelet { */ public function display_recent_comments($comments) { global $page; - $this->anon_id = -1; + $this->show_anon_id = false; $html = ""; foreach($comments as $comment) { $html .= $this->comment_to_html($comment, true); @@ -128,7 +123,7 @@ class CommentListTheme extends Themelet { */ public function display_image_comments(Image $image, $comments, $postbox) { global $page; - $this->anon_id = 1; + $this->show_anon_id = true; $html = ""; foreach($comments as $comment) { $html .= $this->comment_to_html($comment); @@ -172,15 +167,22 @@ class CommentListTheme extends Themelet { if($i_uid == $config->get_int("anon_id")) { $anoncode = ""; - if($this->anon_id >= 0) { - $anoncode = ''.$this->anon_id.''; - $this->anon_id++; - } $style = ""; - if($user->can("view_ip")) { - $style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'"; + $anoncode2 = ""; + if($this->show_anon_id) { + $anoncode = ''.$this->anon_id.''; } - $h_userlink = "" . $h_name . $anoncode . ""; + if($user->can("view_ip")) { + #$style = " style='color: ".$this->get_anon_colour($comment->poster_ip).";'"; + if(!array_key_exists($comment->poster_ip, $this->anon_map)) { + $this->anon_map[$comment->poster_ip] = $this->anon_id; + } + if($this->anon_map[$comment->poster_ip] != $this->anon_id) { + $anoncode2 = '('.$this->anon_map[$comment->poster_ip].')'; + } + } + $h_userlink = "" . $h_name . $anoncode . $anoncode2 . ""; + $this->anon_id++; } else { $h_userlink = ''.$h_name.'';