<%perl> my @langshtml; if( $bg ) { my $langs = $dbh->selectall_arrayref("SELECT tag,realname FROM languages WHERE langid>0 ORDER BY tag"); my @langs = map { $_->[0] } @{ $langs }; my %mapping = map { $_->[0] => $_->[1] } @{ $langs }; my $format = '%s'; foreach my $curlang (@langs) { if($langarg eq $curlang) { push @langshtml, $curlang; next; } my $vislang = $curlang; $vislang =~ s/\s+/ /g; my $html = sprintf($format, &utils::armorurl($curlang), ";bg=$bg", $vislang); push @langshtml, $html; } # If we're in best guess mode but have no language arg... if( ! $langarg ) {
[ <% join(" | ",@langshtml) %> ]
<%perl> return; } } <%perl> my $types = $dbh->selectall_arrayref("select * from valsitypes where typeid!=0 order by descriptor"); my @types; push @types, "all"; push @types, map { $_->[1] } @{$types}; my @typeshtml; my $format = $bg ? '%s' : '%s'; foreach my $curtype (@types) { if($type eq $curtype) { push @typeshtml, $curtype; next; } my $vistype = $curtype; $vistype =~ s/\s+/ /g; my $html = sprintf($format, &utils::armorurl($curtype), defined($initial)?";initial=$initial":"", $vistype); push @typeshtml, $html; } <%method title> valsi Listing valsi listings % if( $bg ) % {

This is a "best guess" listing, meaning that only one of the definitions for each word will be shown.The best guess is determined by compiling user votes.

As a side effect, only words that have votes registered will be shown here.

% }
[ <% join(" | ",@typeshtml) %> ]
% if( $bg ) % {
[ <% join(" | ",@langshtml) %> ]
% }
<%perl> my @initialletters = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'x', 'z'); my @initialshtml; $format = $bg ? '%s' : '%s'; foreach my $curinitial (@initialletters) { if($curinitial eq $initial) { push @initialshtml, $curinitial; next; } my $html = sprintf($format, $curinitial, defined($type)?";type=".utils::armorurl($type):";type=all", $curinitial); push @initialshtml, $html; }
[ <% join(" | ",@initialshtml) %> ] % if(defined($type) && defined($initial)) { % if( $bg ) % { clear % } else { clear % } % }

% if(!defined($type) && !defined($initial)) { % if( $bg ) % {

Pick a word type, above. Or you can go to the all words list

% } else {

Pick a word type, above. Or you can go to the all words list

% } % if (defined($session{'username'})) {
You may also add a new word:
% } else {

If you were logged in you could also add new words from here.

% } % return; % } <%perl> my(@conditions,@args); if(defined($type) && $type ne "all") { push @conditions, "typeid=(SELECT typeid FROM valsitypes WHERE descriptor=?)"; push @args, $type; } if(defined($initial)) { push @conditions, "word LIKE '$initial%'"; } my $sql; if( $bg ) { if( defined($langarg) ) { my $langid=$dbh->selectrow_array("SELECT langid FROM languages WHERE tag=?", undef, $langarg); push @conditions, "d.langid=$langid"; } if ($#conditions >= 0) { $sql = "SELECT v.word, d.definitionnum, d.definitionid, d.langid FROM valsi v, definitions d, valsibestguesses vbg WHERE ".join(" AND ",@conditions)." AND v.valsiid = d.valsiid AND d.definitionid=vbg.definitionid ORDER BY v.word, d.definitionnum"; } else { $sql = "SELECT v.word, d.definitionnum, d.definitionid, d.langid FROM valsi v, definitions d WHERE v.valsiid != 0 AND v.valsiid = d.valsiid ORDER BY v.word, d.definitionnum"; } } else { if ($#conditions >= 0) { $sql = "SELECT * FROM valsi WHERE ".join(" AND ",@conditions)." ORDER BY word"; } else { $sql = "SELECT word FROM valsi WHERE valsiid!=0 ORDER BY word"; } } my $listingquery = $dbh->prepare($sql); $listingquery->execute(@args); my $count = $listingquery->rows; my $columns = 4; my $percolumn = POSIX::ceil($count/$columns); % for(my $column=0; $column<$columns; $column++) { % }
% my $thiscolcount=$percolumn; % while($listingquery->{Active} && defined(my $listingrow = $listingquery->fetchrow_hashref)) { % if( $bg ) % { % my $bgstring="?bg=1;langidarg=$listingrow->{'langid'}"; - <% $listingrow->{'word'} %> def #<% $listingrow->{'definitionnum'} %>
% } else { - <% $listingrow->{'word'} %>
% } % last unless --$thiscolcount; % }
<%init> our($dbh, %session); use POSIX; <%args> $type => undef $initial => undef $bg => undef $langarg => undef