r420@llin: dpavlin | 2006-01-08 23:42:02 +0100
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 8 Jan 2006 22:41:45 +0000 (22:41 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 8 Jan 2006 22:41:45 +0000 (22:41 +0000)
 and fix search links for '' values

git-svn-id: svn+ssh://mjesec/home/dpavlin/svn/webpac2/trunk@376 07558da8-63fa-0310-ba24-9fe276d99e06

lib/WebPAC/Output/TT.pm

index f72ce43..8699e12 100644 (file)
@@ -196,19 +196,27 @@ filter to return links to search, usage in TT:
 
                                        my $s;
                                        if ($s_el > 0) {
-                                               $s = $item->{'search'}->[$i] || die "can't find value $i for type search in field $search";
+                                               $s = $item->{'search'}->[$i];
+                                               die "can't find value $i for type search in field $search" unless (defined($s));
                                        } else {
                                                $s = $item->{'search'}->[0];
                                        }
                                        #$s =~ s/([^\w.-])/sprintf("%%%02X",ord($1))/eg;
                                        $s = __quotemeta( $s );
 
-                                       my $d = $item->{'display'}->[$i] || die "can't find value $i for type display in field $display";
+                                       my $d = $item->{'display'}->[$i];
+                                               die "can't find value $i for type display in field $display" unless (defined($d));
 
                                        my $template_arg = '';
                                        $template_arg = qq{,'$template'} if ($template);
 
-                                       push @html, qq{<a href="#" onclick="return search_via_link('$search','$s'${template_arg})">$d</a>};
+                                       if ($s && ! $d) {
+                                               $d = $s;
+                                       } elsif (! $s && $d) {
+                                               $s = $d;
+                                       }
+
+                                       push @html, qq{<a href="#" onclick="return search_via_link('$search','$s'${template_arg})">$d</a>} if ($s && $d);
                                }
 
                                return join($delimiter, @html);