# # This cgi script forms part of the processing for the container parent itemref component # The script is called from the javascript dialog box and it is responsible for performing # the actual search for the item required. use EPrints; use strict; my $session = EPrints::Session->new(); # use user table as authority list my $content = "text/xml"; $session->send_http_header( content_type=>$content ); my $name; # = $session->param( "_name" ); my $id; # = $session->param( "_id" ); my $search_text = $session->param( "q" ); my $prefix = $session->param( "prefix" ); my $base = $session->param( "base" ); my $text_field = $session->param( "field" ); my $id_field = $base.".".$base."id"; # field to use as obj id #print STDERR "##########################################################################\n"; #print STDERR "cgi lookup base is [$base] [$text_field]\n"; if ( $search_text =~ m/^[[:alpha:]]+/ ) { $name = $search_text; } elsif( $search_text =~ m/^[[:digit:]]+/ ) { $id = $search_text; } my $sql = "SELECT ".$base."id, $text_field FROM $base "; if ( EPrints::Utils::is_set( $name ) ) { $sql .= "where UPPER($text_field) LIKE UPPER( '\%".EPrints::Database::prep_like_value($name)."\%' ) "; } elsif ( EPrints::Utils::is_set( $id ) ) { $sql .= "where $id_field LIKE '".EPrints::Database::prep_like_value($id)."\%' "; } $sql.="ORDER BY $text_field LIMIT 40"; print < "; $session->terminate;