Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r16069: LJSV-144: when viewing city schools, spl...

Committer: ailyin
LJSV-144: when viewing city schools, split them to pages of 500 schools
on each. it is supposed to address the Moscow/Opera issue.

U   trunk/htdocs/schools/index.bml
Modified: trunk/htdocs/schools/index.bml
===================================================================
--- trunk/htdocs/schools/index.bml	2009-12-23 05:37:04 UTC (rev 16068)
+++ trunk/htdocs/schools/index.bml	2009-12-23 06:18:48 UTC (rev 16069)
@@ -59,7 +59,28 @@
         return $ret;
     };
 
+    my $self_link = sub {
+        my ($country, $state, $city) = @_;
 
+        return sub {
+            my ($page) = @_;
+
+            my $ret = "$LJ::SITEROOT/schools/";
+            
+            my @params;
+            
+            push @params, "ctc=".LJ::eurl($country) if $country;
+            push @params, "sc=".LJ::eurl($state) if $state;
+            push @params, "cc=".LJ::eurl($city) if $city;
+            push @params, "page=$page" if $page && $page != 1;
+
+            my $params = join('&', @params);
+            $ret .= '?' . $params if $params;
+
+            return $ret;
+        };
+    };
+
     my $add_school = sub {
         my ($country, $state, $city, $name, $remoterl, $class) = @_;
 
@@ -443,13 +464,29 @@
 
         $ret .= "<?h1 $ML{'.school.header'} h1?><?p $ML{'.school.select'} p?>";
 
+        my @sids = sort { $schools->{$a} cmp $schools->{$b} } keys %{$schools};
+
+        my $per_page = 500;
+
+        my %items = BML::paging(\@sids, $GET{'page'} || 1, $per_page);
+
+        my $navbar = LJ::paging_bar($items{'page'}, $items{'pages'}, {
+            'self_link' => $self_link->($ctc, $sc, $cc),
+        });
+
+        @sids = @{$items{'items'}};
+
+        $ret .= $navbar;
+
         $ret .= "<ul>";
-        foreach my $sid (sort { $schools->{$a} cmp $schools->{$b} } keys %{$schools}) {
+        foreach my $sid (@sids) {
             $ret .= "<li><a href='$LJ::SITEROOT/schools/?ctc=$ctc&sc=$esc&cc=$ecc&sid=$sid'>";
             $ret .= LJ::ehtml($schools->{$sid}) . "</a></li>\n";
         }
         $ret .= "</ul>";
 
+        $ret .= $navbar;
+
         $ret .= "<div id='addlink'><?p <i>$ML{'.dontseeschool'}</i><br />";
         $ret .= "<a href='$LJ::SITEROOT/schools/?ctc=$ectc&sc=$esc&cc=$ecc&add=1' onclick='return addschool()'>$ML{'.dontseeschool.add'}</a>";
         $ret .= " p?></div>";

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