X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fqtextstringcheck;h=a6c84fe44ba9775f434bc5ff3ac06aad64bc36a6;hb=4a6d70dd3122b15dd2446e7fc7ac2782f70f067f;hp=b2c101390589b01daf00d858c60f9d205d05ce83;hpb=fd6bf359d9051fe0c6d269a44bcc08cc53aa2fea;p=ypp-sc-tools.db-live.git diff --git a/yarrg/web/qtextstringcheck b/yarrg/web/qtextstringcheck index b2c1013..a6c84fe 100755 --- a/yarrg/web/qtextstringcheck +++ b/yarrg/web/qtextstringcheck @@ -62,16 +62,27 @@ my $chk= $m->fetch_comp("check_${what}"); my $mydbh; $dbh ||= ($mydbh= dbw_connect($ocean)); -my $sqlstmt= $chk->scall_method("sqlstmt"); -my $sth= $dbh->prepare($sqlstmt); -my @sqlstmt_qs= $sqlstmt =~ m/\?/g; +#print STDERR "qtsc string=\`$string'\n"; -#die "$sqlstmt @sqlstmt_qs"; +my ($sth, @sqlstmt_qs); +if ($chk->method_exists('sqlstmt')) { + my $sqlstmt= $chk->scall_method("sqlstmt"); + $sth= $dbh->prepare($sqlstmt); + @sqlstmt_qs= $sqlstmt =~ m/\?/g; +} my $emsg= ''; my @results; - -my @specs= $chk->attr('multiple') ? (split m#[/|,]#, $string) : ($string); +my @specs; +my $hooks = { Emsg => \$emsg, String => \$string, + Results => \@results, Specs => \@specs, + }; + +if ($chk->method_exists('preparse')) { + $chk->call_method('preparse', h => $hooks); +} else { + @specs= $chk->attr('multiple') ? (split m#[/|,]#, $string) : ($string); +} no warnings qw(exiting); @@ -103,8 +114,16 @@ foreach my $each (@specs) { push @results, $results->[0]; }; -$emsg='' if !defined $emsg; my $canontext= join ' | ', map { $_->[0] } @results; +if ($chk->method_exists('postquery')) { + $hooks->{Canon}= \$canontext; + $chk->call_method('postquery', h => $hooks); +} + +$emsg='' if !defined $emsg; +@results=() if length $emsg; + +#print STDERR "qtsc emsg=\`$emsg' results=\`@results'\n"; if ($format =~ /json/) { $r->content_type($ctype or $format);