Search Results
body<=
\%state, country => \%country });
$ret = "";
$ret .= "\n";
$ret .= "
\n";
# by country
$ret .= "";
$ret .= "";
my $total = scalar(keys %{$count{'country'}});
my $count = 0;
my $col = 0;
foreach (sort { $country{$a} cmp $country{$b} } keys %{$count{'country'}})
{
$count++;
$ret .= "- $country{$_} ($count{'country'}->{$_})
\n";
if ($col==0 && $count > ($total/2)) { $ret .= " | "; $col = 1; }
}
$ret .= " |
\n";
return $ret;
}
my $remote = LJ::get_remote();
unless (LJ::check_priv($remote, "betatest", "directory") ||
LJ::get_cap($remote, "directory") ||
(@filters == 1 && $filters[0] eq "int" && $GET{'opt_format'} eq "simple"))
{
return $ML{'.error.accounttype'};
}
unless (LJ::Dir::do_search($dbr, $dbdir, \%FORM, \@matches, \%info)) {
return "";
}
# opt_format and opt_sort might've been modified by do_search,
# filling in appropriate defaults based on other parameters
my $opt_format = $FORM{'opt_format'};
my $opt_sort = $FORM{'opt_sort'};
$info{'allwhat'} ||= "users";
if ($info{'searching'}) {
my ($uri, $args) = (BML::get_uri(), BML::get_query_string());
$uri .= '?' . $args if $args;
$head .= "\n";
return "$ML{'.search.title'}$ML{'.search.monkey'}
";
}
if ($POST{'com_do'} || $GET{'com_do'}) {
$ret .= "<< $ML{'.search.new'}\n";
} else {
$ret .= "<< $ML{'.search.new'}
\n";
}
unless (@{$info{'english'}}) {
push @{$info{'english'}}, "wish to be listed in the public directory";
}
$ret .= "Below are all $info{'allwhat'} that ";
my $count_preds = @{$info{'english'}};
### remove consecutive "are"s
my $last_are = 0;
foreach (@{$info{'english'}}) {
if (/^are /) {
if ($last_are) {
s/^are //;
}
$last_are = 1;
} else {
$last_are = 0;
}
}
my $last = pop @{$info{'english'}};
if (@{$info{'english'}}) {
$ret .= join(", ", map { LJ::ehtml($_) } @{$info{'english'}}) . ", and ";
}
$ret .= LJ::ehtml($last) . ".\n";
if ($info{'overflow'}) {
$ret .= BML::ml(".search.overflow", {'count' => $info{'count'}});
}
if ($count_preds == 1 && $GET{'int_like'}) {
my $intid = $dbr->selectrow_array("SELECT intid FROM interests WHERE interest=?",
undef, $GET{'int_like'});
LJ::run_hooks("interests_bml", {
'intid' => $intid,
'int' => $interest,
'ret' => \$ret,
}) if $intid;
}
########## make the navcrap
my $navcrap;
$navcrap .= "".BML::ml(".navcrap.matches", {'count' => $info{'count'}})."";
if ($info{'count'}) {
if ($info{'pages'} > 1) {
$navcrap .= "
";
$navcrap .= BML::ml(".navcrap.xofy", {'curpage' => $info{'page'}, 'totpages' => $info{'pages'}, 'reca' => $info{'first'}, 'recb' => $info{'last'}});
$navcrap .= "
";
my $left = "<<";
if ($info{'page'} > 1) { $left = " $info{'page'}-1 }) . "\">$left"; }
my $right = ">>";
if ($info{'page'} < $info{'pages'}) { $right = " $info{'page'}+1 }) . "\">$right"; }
$navcrap .= $left . " ";
for (my $i=1; $i<=$info{'pages'}; $i++) {
my $link = "[$i]";
if ($i != $info{'page'}) { $link = " $i }) . "\">$link"; }
else { $link = "$link"; }
$navcrap .= "$link ";
}
$navcrap .= "$right";
}
$navcrap .= " standout?>\n";
} else {
$navcrap .= " standout?>\n";
}
####### end navcrap
$ret .= $navcrap . "
";
unless ($info{'count'}) { return $ret; }
if ($opt_sort eq "loc") {
LJ::load_codes({ state => \%state, country => \%country });
}
if ($opt_format eq "simple")
{
my $showloc = $GET{'opt_sort'} eq "loc" ? 1 : 0;
my %last = ();
$ret .= "
\n";
foreach my $rec (@matches)
{
if ($showloc) {
if ($last{'country'} ne $rec->{'country'} ||
$last{'state'} ne $rec->{'state'} ||
$last{'city'} ne $rec->{'city'}) {
foreach (qw(country state city)) { $last{$_} = $rec->{$_}; }
my $country = $country{$rec->{'country'}};
my ($state, $city);
if ($rec->{'state'}) {
$state = ", " . ($rec->{'country'} eq "US" ? $state{$rec->{'state'}} : $rec->{'state'});
}
if ($rec->{'city'}) {
$city = ", $rec->{'city'}";
}
$ret .= "
";
}
}
$ret .= "{'user'}\">";
if ($rec->{'journaltype'} eq "C") {
$ret .= "";
} else {
$ret .= "";
}
$ret .= " ";
$ret .= "{'user'}/\">$rec->{'user'} - " . LJ::ehtml($rec->{'name'}) . ", Updated ";
$ret .= LJ::ago_text($rec->{'secondsold'});
$ret .= "
\n";
}
$ret .= "
\n";
}
if ($opt_format eq "com")
{
$ret .= "\n";
}
if ($opt_format eq "pics")
{
my $showloc = $GET{'opt_sort'} eq "loc" ? 1 : 0;
my %last = ();
my %pic;
my @picids = map { [$_, $_->{'defaultpicid'}] } @matches;
LJ::load_userpics(\%pic, \@picids);
my $count = 0;
my $pos = 0;
my $more_to_show = 0;
$ret .= "\n";
foreach my $rec (@matches)
{
if ($pos==5) { $ret .= "\n"; }
$pos++; $pos %= 5;
if ($showloc) {
if ($last{'country'} ne $rec->{'country'} ||
$last{'state'} ne $rec->{'state'} ||
$last{'city'} ne $rec->{'city'}) {
foreach (qw(country state city)) { $last{$_} = $rec->{$_}; }
my $country = $country{$rec->{'country'}};
my ($state, $city);
if ($rec->{'state'}) {
$state = ", " . ($rec->{'country'} eq "US" ? $state{$rec->{'state'}} : $rec->{'state'});
}
if ($rec->{'city'}) {
$city = ", $rec->{'city'}";
}
if ($pos > 1) { $ret .= ""; $pos = 1; }
$ret .= "
";
$ret .= "
";
$ret .= "\n";
}
}
if ($pos==1) { $ret .= "\n"; }
my $picid = $rec->{'defaultpicid'};
my $updateago = LJ::ago_text($rec->{'secondsold'});
my $img;
if ($picid) {
$img = "{'userid'}\" ALT=\"$_->{'user'}\" WIDTH=$pic{$picid}->{'width'} HEIGHT=$pic{$picid}->{'height'} BORDER=0>
";
}
$ret .= "";
$ret .= $img;
$ret .= LJ::ljuser($rec->{'user'});
$ret .= " $Ml{'.update'} $updateago | \n";
}
$ret .= "
\n";
}
if ($info{'pages'} > 1) { $ret .= $navcrap; }
return $ret;
_code?>
<=body
head<=
<=head
page?>