Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r22433: LJSV-1979: Userpics on site scheme comme...

Committer: anazarov
LJSV-1979: Userpics on site scheme comment forms listed in "random" (not alphabetical) order
U   trunk/htdocs/tools/endpoints/getuserpics.bml
Modified: trunk/htdocs/tools/endpoints/getuserpics.bml
===================================================================
--- trunk/htdocs/tools/endpoints/getuserpics.bml	2012-07-12 15:24:49 UTC (rev 22432)
+++ trunk/htdocs/tools/endpoints/getuserpics.bml	2012-07-13 06:29:24 UTC (rev 22433)
@@ -17,27 +17,36 @@
     # get userpics
     my @userpics = LJ::Userpic->load_user_userpics($u);
 
-    my %upics = (); # info to return
-    $upics{pics} = {}; # upicid -> hashref of metadata
+    my $pics = {};
 
     foreach my $upic (@userpics) {
         next if $upic->inactive;
 
         my $id = $upic->id;
-        $upics{pics}{$id} = {
-            url => $upic->url,
-            state => $upic->state,
-            width => $upic->width,
-            height => $upic->height,
-            comment => LJ::strip_html($upic->comment),
-            id => $id,
+
+        $pics->{$id} = {
+            url      => $upic->url,
+            state    => $upic->state,
+            width    => $upic->width,
+            height   => $upic->height,
+            comment  => LJ::strip_html($upic->comment),
+            id       => $id,
             keywords => [ map { LJ::strip_html($_) } $upic->keywords],
+            keyword  => scalar $upic->keywords,
         };
     }
 
-    $upics{ids} = [keys %{$upics{pics}}];
     sleep 1 if $LJ::IS_DEV_SERVER;
 
-    return LJ::JSON->to_json(\%upics);
+    return LJ::JSON->to_json({
+        pics => $pics,
+        ids  => [
+            map {
+                $_->{'id'}
+            } sort {
+                $a->{'keyword'} cmp $b->{'keyword'}
+            } values %$pics
+        ],
+    });
 }
 _code?>

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