Первый фоллен на хелле (wildkin) wrote in changelog,
Первый фоллен на хелле
wildkin
changelog

[livejournal] r19251: LJSUP-9027: Error with select tags with ...

Committer: dnikolaev
LJSUP-9027: Error with select tags with capitals letters

U   trunk/htdocs/friends/add.bml
Modified: trunk/htdocs/friends/add.bml
===================================================================
--- trunk/htdocs/friends/add.bml	2011-06-08 06:00:14 UTC (rev 19250)
+++ trunk/htdocs/friends/add.bml	2011-06-08 06:07:08 UTC (rev 19251)
@@ -284,11 +284,22 @@
          foreach (values %$tags) { 
              next unless $_->{display};
              next unless $_->{name} =~ /\S/;
-             $user_tags_map->{ LJ::FriendsTags->normalize_tag($_->{name}) } += $_->{uses};
+             my $normalized_tag = LJ::FriendsTags->normalize_tag($_->{name});
+            
+             my $tag_data = $user_tags_map->{$normalized_tag};
+             unless ($tag_data) {
+                 $tag_data = {};
+                 $user_tags_map->{$normalized_tag} = $tag_data;
+             }
+             $tag_data->{total_uses} += $_->{uses};
+             if (!$tag_data->{name} || $tag_data->{uses} < $_->{uses}) {
+                 $tag_data->{name} = $_->{name};
+                 $tag_data->{uses} = $_->{uses};
+             }
          }
          foreach (keys %$user_tags_map) {
-             my $uses = $user_tags_map->{$_};
-             $user_tags_map->{$_} = ($uses < 2 ? '' : ($uses > 999 ? '(999+)' : "($uses)"));
+             my $uses = $user_tags_map->{$_}->{total_uses};
+             $user_tags_map->{$_}->{total_uses} = ($uses < 2 ? '' : ($uses > 999 ? '(999+)' : "($uses)"));
          }
      }
 
@@ -319,7 +330,14 @@
 
      {
          foreach (@$friend_tags_list) {
-             $body .= '<li><span><a target="_blank" href="' . $u->journal_base . '/tag/' . LJ::eurl($_) . '">' . LJ::ehtml($_) . '</a> ' . (exists $user_tags_map->{$_} ? $user_tags_map->{$_} : '(-)') . '<i title="' . $ML{'.tags.cross.tooltip'} . '" class="i-pending-close"></i></span>' . (--$not_last ? '<b>,</b>' : '<b class="i-pending-users-comma">,</b>') . '</li>';
+             my $tag_data = $user_tags_map->{$_};
+             my $tag_href = $tag_data ?
+                                $u->journal_base . '/tag/' . LJ::eurl($tag_data->{name}) :
+                                '#';
+             $body .= '<li><span><a target="_blank" href="' . $tag_href . '">' . LJ::ehtml($_) . '</a> ' .
+                      ($tag_data ? $tag_data->{total_uses} : '(-)') .
+                      '<i title="' . $ML{'.tags.cross.tooltip'} . '" class="i-pending-close"></i></span>' .
+                      (--$not_last ? '<b>,</b>' : '<b class="i-pending-users-comma">,</b>') . '</li>';
              $friend_tags_map->{$_} = 1;
          }
      }
@@ -338,7 +356,12 @@
          my @tags = sort grep { !$friend_tags_map->{$_} } keys %$user_tags_map;
          my $not_last = scalar(@tags);
          foreach my $tag (@tags) {
-             $body .= '<li><span><a target="_blank" href="' . $u->journal_base . '/tag/' . LJ::eurl($tag) . '">' . LJ::ehtml($tag) . '</a> ' . $user_tags_map->{$tag} . '<i title="' . $ML{'.tags.cross.tooltip'} . '" class="i-pending-close"></i></span>' . (--$not_last ? '<b>,</b>' : '<b class="i-pending-users-comma">,</b>') . '</li>';
+             my $tag_data = $user_tags_map->{$tag};
+             my $tag_href = $u->journal_base . '/tag/' . LJ::eurl($tag_data->{name});
+             $body .= '<li><span><a target="_blank" href="' . $tag_href . '">' . LJ::ehtml($tag) . '</a> ' .
+             $tag_data->{total_uses} .
+             '<i title="' . $ML{'.tags.cross.tooltip'} . '" class="i-pending-close"></i></span>' .
+             (--$not_last ? '<b>,</b>' : '<b class="i-pending-users-comma">,</b>') . '</li>';
          }
      }
 

Tags: bml, livejournal, wildkin
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