- Timestamp:
- 10/18/13 17:26:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dns.cgi
r516 r533 131 131 $webvar{searchsubs} =~ s/[^yn]//g if $webvar{searchsubs}; 132 132 133 $session->param($webvar{page}.'startwith', $webvar{startwith}) if defined($webvar{startwith}); 134 $session->param($webvar{page}.'filter', $webvar{filter}) if defined($webvar{filter}); 133 # pagination 134 my $perpage = 15; # Just In Case 135 $perpage = $dnsdb->{perpage} if $dnsdb->{perpage}; 136 my $offset = ($webvar{offset} ? $webvar{offset} : 0); 137 138 ## set up "URL to self" (whereami edition) 139 # @#$%@%@#% XHTML - & in a URL must be escaped. >:( 140 my $uri_self = $ENV{REQUEST_URI}; 141 $uri_self =~ s/\&([a-z])/\&\;$1/g; 142 143 # le sigh. and we need to strip any previous action 144 $uri_self =~ s/\&action=[^&]+//g; 145 146 # much magic happens. if startwith or a search string change (to, from, or 147 # across, in the request vs whatever's in the session) then the offset should 148 # be reset to 0 so that the first/prev/next/last widget populates correctly, 149 # and so that the list of whatever we're looking at actually shows things 150 # (since we may have started on page 42 of 300 with a LOOOOONG list, but we 151 # now only need 3 pages for the filtered list). 152 # while we're at it, plonk these into the session for safekeeping. 153 if (defined($webvar{startwith})) { 154 if ($webvar{startwith} ne $session->param($webvar{page}.'startwith')) { 155 $uri_self =~ s/\&offset=[^&]//; 156 $offset = 0; 157 } 158 $session->param($webvar{page}.'startwith', $webvar{startwith}); 159 } 160 if (defined($webvar{filter})) { 161 if ($webvar{filter} ne $session->param($webvar{page}.'filter')) { 162 $uri_self =~ s/\&offset=[^&]//; 163 $offset = 0; 164 } 165 $session->param($webvar{page}.'filter', $webvar{filter}) 166 } 135 167 $session->param($webvar{page}.'searchsubs', $webvar{searchsubs}) if defined($webvar{searchsubs}); 136 168 169 # and now that the search/filter criteria for this page are set, put them in some globals for actual use. 137 170 my $startwith = $session->param($webvar{page}.'startwith'); 138 171 my $filter = $session->param($webvar{page}.'filter'); … … 143 176 push @filterargs, "^[$startwith]" if $startwith; 144 177 push @filterargs, $filter if $filter; 145 146 ## set up "URL to self" (whereami edition)147 # @#$%@%@#% XHTML - & in a URL must be escaped. >:(148 my $uri_self = $ENV{REQUEST_URI};149 $uri_self =~ s/\&([a-z])/\&\;$1/g;150 151 # le sigh. and we need to strip any previous action152 $uri_self =~ s/\&action=[^&]+//g;153 178 154 179 # and search filter options. these get stored in the session, but discarded … … 166 191 167 192 ## end uri_self monkeying 168 169 # pagination170 my $perpage = 15; # Just In Case171 $perpage = $dnsdb->{perpage} if $dnsdb->{perpage};172 my $offset = ($webvar{offset} ? $webvar{offset} : 0);173 193 174 194 # NB: these must match the field name and SQL ascend/descend syntax respectively … … 314 334 changepage(%args); 315 335 } 316 317 } 336 # add offset back *into* $uri_self if we're also currently looking at a live record list. 337 if ($webvar{page} eq 'reclist' && $webvar{defrec} eq 'n') { 338 $uri_self .= "\&offset=$offset"; 339 } 340 } # done action=chgroup 318 341 } # handle global webvar{action}s 319 342 … … 1059 1082 $page->param(perpage => $perpage); 1060 1083 1061 my $domlist = $dnsdb->getZoneList(revrec => 'n', curgroup => $curgroup );1084 my $domlist = $dnsdb->getZoneList(revrec => 'n', curgroup => $curgroup, offset => $offset); 1062 1085 my $rownum = 0; 1063 1086 foreach my $dom (@{$domlist}) { … … 1828 1851 my @childlist; 1829 1852 1853 # some magic to control bad offsets on group change 1854 my $grp_uri_self = $uri_self; 1855 $grp_uri_self =~ s/\&offset=[^&]+// unless ($webvar{page} eq 'reclist' && $webvar{defrec} eq 'n'); 1856 1830 1857 my $grptree = HTML::Template->new(filename => 'templates/grptree.tmpl'); 1831 1858 $dnsdb->getChildren($root, \@childlist, 'immediate'); … … 1836 1863 $row{grpname} = $dnsdb->groupName($_); 1837 1864 $row{grpnum} = $_; 1838 $row{whereami} = $ uri_self;1865 $row{whereami} = $grp_uri_self; 1839 1866 $row{curgrp} = ($_ == $cur); 1840 1867 $row{expanded} = $dnsdb->isParent($_, 'group', $cur, 'group'); … … 2066 2093 my $parent = shift; 2067 2094 2068 # Fix display/UI bug where if you are not on the first page of the list, and2069 # you add a search term or click one of the "starts with" links, you end up2070 # on a page showing nothing.2071 # For bonus points, this reverts to the original offset on clicking the "All" link (mostly)2072 if ($offset ne 'all') {2073 $offset-- while ($offset * $perpage) >= $pgcount;2074 }2075 2076 2095 $page->param(ntot => $pgcount); 2077 2096 $page->param(nfirst => (($offset eq 'all' ? 0 : $offset)*$perpage+1)); … … 2132 2151 my $zonelist = $dnsdb->getZoneList(childlist => $childlist, curgroup => $curgroup, revrec => $webvar{revrec}, 2133 2152 filter => ($filter ? $filter : undef), startwith => ($startwith ? $startwith : undef), 2134 offset => $ webvar{offset}, sortby => $sortby, sortorder => $sortorder2153 offset => $offset, sortby => $sortby, sortorder => $sortorder 2135 2154 ); 2136 2155 # probably don't need this, keeping for reference for now
Note:
See TracChangeset
for help on using the changeset viewer.