X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fquery_route;h=b2c52b158f3b7c6531b48fbf9b0b34677ed56df8;hb=c2c600fb1b0bbe2627ac95e4dfe5e502780d986f;hp=8f6d99c49d29ed353f5f2fcdf6d88dc55180afac;hpb=9d01242d0991d15f7ea84454264c868e1c4ed8ad;p=ypp-sc-tools.db-test.git diff --git a/yarrg/web/query_route b/yarrg/web/query_route index 8f6d99c..b2c52b1 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -35,10 +35,15 @@ <%args> $quri +$dbh +$prselector $routestring => ''; +$someresults +$emsgokorprint -<%perl> +<%perl> +my $emsg; my @archipelagoes; my @islandids; my %islandid2; @@ -46,24 +51,33 @@ my %islandid2; my $qa= \%ARGS; +

Specify route

+ +% $prselector->('ShowStalls'); + %#---------- textbox, user enters route as string ---------- % if (!$qa->{Dropdowns}) { -

Specify route

- Enter route (islands, or archipelagoes, separated by |s or commas; abbreviations are OK):
-<&| qtextstring, qa => $qa, thingstring => 'routestring' &> +<&| qtextstring, qa => $qa, dbh => $dbh, + thingstring => 'routestring', emsgstore => \$emsg, + perresult => sub { + my ($canonname, $island, $arch) = @_; + push @islandids, $island; + push @archipelagoes, defined $island ? undef : $arch; + } + &> size=80 % } else { #---------- dropdowns, user selects from menus ---------- <%perl> -my ($sth,$row);; +my ($sth,$row); my @archlistdata; my %islandlistdata; $islandlistdata{'none'}= [ [ "none", "Select island..." ] ]; @@ -81,8 +95,6 @@ my $optionlistmap= sub { return $out; }; -my $dbh= dbw_connect($qa->{Ocean}); - $sth= $dbh->prepare("SELECT DISTINCT archipelago FROM islands ORDER BY archipelago;"); $sth->execute(); @@ -111,8 +123,6 @@ foreach my $arch (keys %islandlistdata) { $optionlistmap->($islandlistdata{$arch}, ''); } -$dbh->rollback(); - <&| script &> @@ -161,36 +171,9 @@ function ms_Setarch(dd) {
<%perl> -#========== result computations ========== - -my $results_head; -$results_head= sub { - print "

Results

\n"; - $results_head= sub { }; -}; +#========== results ========== -#---------- result computation - textstring ---------- -if (!$qa->{Dropdowns}) { - if (length $routestring) { - $results_head->(); - my ($emsg,$canonstring,$results)= $m->comp('qtextstringcheck', - what => 'routestring', - ocean => $qa->{Ocean}, - string => $routestring, - format => 'return' - ); - if (length $emsg) { - print encode_entities($emsg); - } else { - foreach my $entry (@$results) { - push @islandids, $entry->[1]; - push @archipelagoes, - defined $entry->[1] ? undef : $entry->[2]; - } - } - } - -} else { #---------- results - dropdowns ---------- +$emsgokorprint->($emsg) or @islandids=(); my $argorundef= sub { my ($dd,$base) = @_; @@ -207,7 +190,7 @@ for my $dd (0..$qa->{Dropdowns}-1) { my $ii= $islandid2{$island}; my $iarch= $ii->{Arch}; if ($iarch ne $arch) { - $results_head->(); + $someresults->(); Specified archipelago <% $arch %> but island <% $ii->{Name} %> @@ -220,12 +203,14 @@ for my $dd (0..$qa->{Dropdowns}-1) { push @islandids, $island; } -}#---------- result processing, common stuff % if (@islandids) { -% $results_head->(); - -<& routetrade, islandids => \@islandids, archipelagoes => \@archipelagoes &> - +% $someresults->(); +<& routetrade, + dbh => $dbh, + islandids => \@islandids, + archipelagoes => \@archipelagoes, + qa => $qa + &> % }