sunnyman's (sunnyman) wrote in changelog,
sunnyman's
sunnyman
changelog

[ljcom] r12351: LJSUP-13092: Non-cyrillic users can't sw...

Committer: vtroitsky
LJSUP-13092: Non-cyrillic users can't switch to custom rating
U   trunk/cgi-bin/LJ/Widget/HomepageEN.pm
Modified: trunk/cgi-bin/LJ/Widget/HomepageEN.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/HomepageEN.pm	2012-07-25 15:33:55 UTC (rev 12350)
+++ trunk/cgi-bin/LJ/Widget/HomepageEN.pm	2012-07-25 15:56:49 UTC (rev 12351)
@@ -148,8 +148,69 @@
         LJ::Widget::ExtBlock->render(id=>'homepage.gazeta') : '';
 
     ## Ratings
-    $result{personalstats} = LJ::PersonalStats->get_result_html($remote, { widget => 1, unique_journals => 1, rating_country => $GET->{rating}, length => 25 }, '/ratings/posts/', { homepage => 1 });
+    #    $result{personalstats} = LJ::PersonalStats->get_result_html($remote, { widget => 1, unique_journals => 1, rating_country => $GET->{rating}, length => 25 }, '/ratings/posts/', { homepage => 1 });
 
+        my $rating_top_journals_sort = LJ::Request->cookie('rating_top_journals_sort');
+        $rating_top_journals_sort = 'visitors' unless defined $rating_top_journals_sort;
+
+        my $rating_show_custom = ! LJ::Request->cookie('rating_full');
+        $rating_show_custom = 1 unless defined $rating_show_custom;
+        $rating_show_custom = ( $rating_show_custom ? 1 : 0 );
+
+        ## 'rating_full' and 'rating_top_journals_sort' cookie specify ratings sort order and usually are set or changed by JavaScript,
+        ## in case JS is disabled in browser or it does not support JS, set them by Set-Cookie response header.
+        my $set_sort_cookie   = 0;
+        my $set_rating_cookie = 0;
+
+        if (defined $GET->{'rating'}) {
+            my %get_rating = map { lc($_) => 1 } split /\s+/, $GET->{'rating'};
+
+        #    if ($get_rating{'ua'}) {
+        #        LJ::PersonalStats::Ratings->set_view_ua_ratings(1);
+        #    }
+        #    elsif ($get_rating{'cyr'}) {
+        #        LJ::PersonalStats::Ratings->set_view_ua_ratings(0);
+        #    }
+
+            if ($get_rating{'custom'}) {
+                $rating_show_custom = 1;
+                $set_rating_cookie  = 1;
+            }
+            elsif ($get_rating{'all'}) {
+                $rating_show_custom = 0;
+                $set_rating_cookie  = 1;
+            }
+
+            if ($get_rating{'authority'}) {
+                $rating_top_journals_sort = 'authority';
+                $set_sort_cookie    = 1;
+            }
+            elsif ($get_rating{'visitors'}) {
+                $rating_top_journals_sort = 'visitors';
+                $set_sort_cookie    = 1;
+            }
+        }
+
+        my $entries_top = LJ::PersonalStats::Ratings::Posts::Top->new( {
+            # 'country'         => STRING (cyr | noncyr | ua)
+            'sort'             => 'visitors',
+            'length'           => 25,
+            ( $rating_show_custom ? ('length_reserve' => 500) : () ),
+            'filter_commpromo' => ( $rating_show_custom ? 0 : 1 ),
+            'filter_selfpromo' => ( $rating_show_custom ? 0 : 1 ),
+            'filter_featured'  => 0,
+            'filter_blacklist' => 0,
+            'unique_journals'  => ( $rating_show_custom ? 0 : 1 ),
+        } );
+
+        $result{personalstats} = $entries_top->template_output( {
+            'homepage'           => 1,
+            'widget'             => 1,
+            'rating_show_custom' => $rating_show_custom,
+        } );
+
+
+
     ## Widget RatingTop10
     $result{widget_ratingtop10_comms} = LJ::Widget::RatingTopJournals->render(what => 'communities', country => 'noncyr');
 

Tags: ljcom, pm, sunnyman, vtroitsky
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