# Copyright for the Uniform Repository Service (c) 1995 - 2020,
# by Gerald Banon. All rights reserved.
# Version 2.1
# search.tcl
# ----------------------------------------------------------------------
# Search
# used to find author names, journal names, ... in the green area of the submit form
# the search may occur in more than one site
proc Search {} {
if [catch {
set currentProcedureName Search
global searchResultList
global env
global col ;# used in Help
global homePath ;# used in SynchronizeRepository (sourceDisplayControl), Help and FindLanguage
global language ;# used by Help
global languageRep1 ;# used by Help
global submissionFormLanguageRep submissionFormLanguage ;# used by Help
global display
global localSite ;# used by Help
global serverAddressWithIP ;# used by SynchronizeRepository (sourceDisplayControl)
global loCoInRep ;# used by SynchronizeRepository (sourceDisplayControl)
global loBiMiRep ;# used while executing SynchronizeRepository (sourceDisplayControl)
global URLibServiceRepository ;# used while executing SynchronizeRepository (sourceDisplayControl)
puts {Content-Type: text/html}
puts {}
# array set environment [array get env] ;# used in MultipleSubmit
set col ../../../../..
# URLibServiceRepository
set URLibServiceRepository $env(URLIB_SERVICE_REP)
# mirrorHomePageRepository
set mirrorHomePageRepository dpi.inpe.br/banon/2000/01.23.20.24
source ../$col/$URLibServiceRepository/doc/utilities1.tcl
source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl
set pathInfo [file split $env(PATH_INFO)]
# currentRep (local mirror repository - contains @siteList.txt)
regsub -all { } [lrange $pathInfo 1 4] {/} currentRep
# display
set display [GetFrameName]
## serverAddress
# set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)]
# serverAddressWithIP
set serverAddressWithIP [list $env(IP_ADDR) $env(URLIB_PORT)]
# localSite
set localSite $env(SERVER_NAME):$env(SERVER_PORT)
# loCoInRep - used in displayControl.tcl
set loCoInRep $env(LOCOINREP)
# loBiMiRep - used in displayControl.tcl
set loBiMiRep $env(LOBIMIREP)
# http
set http http[expr [info exists env(HTTPS)]?{s}:{}]
# homePath (used in Help and FindLanguage)
set homePath $env(DOCUMENT_ROOT)
# Find the language and the language repository
foreach {language languageRep1 languageRep2 firstLanguageRep \
submissionFormRep submissionFormLanguage submissionFormLanguageRep} \
[FindLanguage $currentRep] {break}
# Find the language and the language repository - end
catch {source ../$col/$languageRep2/doc/mirror/${language}Submit.tcl} error
# puts $error
global "${languageRep2}::currentVariableFileName" ;# for reverse engineering
GetConversionTable $languageRep2 $language
global field::conversionTable
global "${languageRep2}::no name was found"
global "${languageRep2}::no e-mail was found"
global "${languageRep2}::search syntax error"
global "${languageRep2}::select a name"
global "${languageRep2}::select an e-mail"
global "${languageRep2}::search frame"
global "${languageRep2}::advanced user name search frame"
# referenceType2
set referenceType2 [lindex $pathInfo 5]
# referenceType
regsub {(.)([A-Z])} $referenceType2 {\1 \2} referenceType ;# ConferenceProceedings -> Conference Proceedings
regsub {(.)(or )} $referenceType {\1 \2} referenceType ;# Filmor Broadcast -> Film or Broadcast
# foreach {bgColor background bgProperties fontTag fontTag2} [GetBg $languageRep1 $language] {break}
# set background [subst $background]
if [info exists env(QUERY_STRING)] {
foreach {name value} [split $env(QUERY_STRING) &=] {
set cgi([DecodeURL $name]) [DecodeURL $value]
}
}
# puts [array names cgi]
if ![info exists cgi(query)] {set cgi(query) {}}
set submissionType $cgi(submissiontype) ;# used in Help
# help
set help [Help Search]
# Source displayControl.tcl
set enableOutput 1
eval $sourceDisplayControl
# Source displayControl.tc - end
if ![info exists searchBaseTable($referenceType)] {set searchBaseTable($referenceType) {metadataArray}}
if [string equal {metadataArray} $searchBaseTable($referenceType)] {
# metadataArray
if [info exists cgi(searchtype)] {
set warning "${select a name}..."
} else {
set cgi(searchtype) {%A author}
set warning ""
}
# enSubmit.tcl, pt-BRSubmit.tcl, ... must be updated when adding a new field
# searchOptionTable in displayControl.tcl must be updated also
set fieldList [Execute $serverAddressWithIP [list ReturnReferModel $referenceType]]
array set fieldArray [join $fieldList]
array set fieldTable [list $referenceType [list [list %A $fieldArray(%A)]]] ;# default
array set fieldTable [list {Journal Article} [list [list %A $fieldArray(%A)] {%B journal}]]
array set fieldTable [list {Conference Proceedings} [list [list %A $fieldArray(%A)] {%B conferencename}]]
array set fieldTable [list {Thesis} [list [list %A $fieldArray(%A)] {%E committee}]]
array set fieldTable [list {Electronic Source} [list [list %A $fieldArray(%A)] {%B journal} {%B conferencename}]]
foreach field $fieldTable($referenceType) {
set fieldName [lindex $field 0] ;# %A
set label [lindex $field 1] ;# author
set translatedCustomizedFieldName $conversionTable($label)
if {[string compare $field $cgi(searchtype)] == 0} {
append options "