Committer: vtroitsky
LJSUP-8484: skip and itemshow parameters added. Additionally return: skip, items, itemshow in case of format==list.U trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/ljprotocol.pl =================================================================== --- trunk/cgi-bin/ljprotocol.pl 2011-05-27 00:54:09 UTC (rev 19145) +++ trunk/cgi-bin/ljprotocol.pl 2011-05-27 03:02:23 UTC (rev 19146) @@ -368,6 +368,9 @@ my $page = $req->{page} + 0; # page to show - defaut my $view = $req->{view_ditemid} + 0; # ditemid - external comment id to show that page with it + my $skip = $req->{skip} + 0; + my $itemshow = $req->{itemshow} + 0; + my $expand = $req->{expand_strategy} ? $req->{expand_strategy} : 'default' ; return fail($err, 203, 'expand_strategy') unless ($expand =~ /^mobile|mobile_thread|expand_all|by_level|detailed|default$/); @@ -409,9 +412,9 @@ my @com = LJ::Talk::load_comments($journal, $u, "L", $itemid, $opts); my %extra; - $extra{top_items} = $opts->{out_items}; - $extra{top_item_first} = $opts->{out_itemfirst}; - $extra{top_item_last} = $opts->{out_itemlast}; + $extra{topitems} = $opts->{out_items}; + $extra{topitem_first} = $opts->{out_itemfirst}; + $extra{topitem_last} = $opts->{out_itemlast}; $extra{page_size} = $opts->{out_pagesize}; $extra{pages} = $opts->{out_pages}; $extra{page} = $opts->{out_page}; @@ -496,7 +499,14 @@ undef $item->{children}; } } - + + if($format eq 'list') { + $extra{items} = scalar(@comments); + $itemshow = $extra{items} unless ($itemshow && $itemshow <= $extra{items}); + @comments = splice(@comments, $skip, $itemshow); + $extra{skip} = $skip; + $extra{itemshow} = $itemshow; + } return { comments => \@comments,