# Utilities1
# Copyright for URLibService (c) 1995 - 2019,
# by Gerald Banon. All rights reserved.
# checking the use of MultipleSubmit in cgi scripts only - done in this file by GJFB in 2012-12-16
package provide dpi.inpe.br/banon/1998/08.02.08.56 2.1
# ----------------------------------------------------------------------
# DirectoryContent
# build a list of all the files contained in a directory and its childs
# bound == {} means no limit to the number of files
# otherwise $bound is the maximum number of files returned
# Example:
# DirectoryContent docContent $docPath $docPath
if {[info tclversion] <= 8.3} {
proc DirectoryContent {listName homePath dir {bound {}}} {
upvar $listName list
# set fileList [glob -nocomplain $dir/.* $dir/*]
# set fileList [lrange $fileList 2 end] ;# drop . ..
set fileList [glob -nocomplain -- $dir/* $dir/.?*]
set index [lsearch -exact $fileList $dir/..]
set fileList [lreplace $fileList $index $index]
foreach file $fileList {
if [file isdirectory $file] {
DirectoryContent list $homePath $file $bound
} else {
if {![string equal {} $bound] && [llength $list] > $bound} {
# return -code return
return
}
regsub $homePath/ $file {} file
lappend list $file
}
}
}
} else {
proc DirectoryContent {listName homePath dir {bound {}}} {
global tcl_platform
upvar $listName list
set fileList [glob -nocomplain -- $dir/*] ;# in Windows, file name beginning with . are captured by glob, but not in Linux
if {$tcl_platform(platform) == "unix"} {
# added by GJFB in 2011-10-10 to capture in Linux, file name like .htaccess
set fileList2 [glob -nocomplain -- $dir/.?*]
set index [lsearch -exact $fileList2 $dir/..]
set fileList2 [lreplace $fileList2 $index $index]
set fileList [concat $fileList $fileList2]
}
foreach file $fileList {
if [file isdirectory $file] {
DirectoryContent list $homePath $file $bound
} else {
if {![string equal {} $bound] && [llength $list] > $bound} {
# return -code return
return
}
regsub $homePath/ $file {} file
lappend list $file
}
}
}
}
# set fileList {}
# set path "C:/Users/Gerald Banon/URLib 2/col/dpi.inpe.br/banon/1998/08.02.08.56/doc"
# DirectoryContent fileList $path $path 200
# DirectoryContent fileList $path $path
# puts $fileList
# DirectoryContent - end
# ----------------------------------------------------------------------
# ComputeNOD
# Compute the Number Of Days (NOD) since January 1, 1970 up to $date
# date format is of type: yyyy.mm.dd[.hh.mm.ss]
# used to compute the statistics of a repository
# used by StartService, ComputeStatistics, GetHistogram and Statistics
proc ComputeNOD {date} {
set monthAbbreviation(01) Jan
set monthAbbreviation(02) Feb
set monthAbbreviation(03) Mar
set monthAbbreviation(04) Apr
set monthAbbreviation(05) May
set monthAbbreviation(06) Jun
set monthAbbreviation(07) Jul
set monthAbbreviation(08) Aug
set monthAbbreviation(09) Sep
set monthAbbreviation(10) Oct
set monthAbbreviation(11) Nov
set monthAbbreviation(12) Dec
foreach {Y m d} [split $date .] {break}
set hour [clock format 0 -format %H:%M]
# return [expr [clock scan "$monthAbbreviation($m) $d $hour $Y"] / 3600 / 24]
return [expr [clock scan "$hour $monthAbbreviation($m) $d, $Y"] / (3600 * 24)]
}
# ComputeNOD - end
# ----------------------------------------------------------------------
# DirectoryMTime
# Returns the content modification time of a directory
# time is in second
# flag == 0 means no limit to the number of files
# if the limit (in one directory) is reached then it returns empty
# alternateTargetFile is the alternate target file for dynamic page
# for example: if the target file name is start.html then the
# alternateTargetFile is @start.html
# info tclversion is because of glob
if {[info tclversion] <= 8.3} {
proc DirectoryMTime {dir {flag 0} {time 0} {alternateTargetFile {}}} {
# runs with start and post
# global tcl_platform
set pwd [pwd]
if ![file isdirectory $dir] {return {}}
if [catch {cd $dir} err] {
puts stderr $err
return
}
# set fileList [glob -nocomplain .* *]
# set fileList [lrange $fileList 2 end] ;# drop . ..
set fileList [glob -nocomplain -- * .?*]
set index [lsearch -exact $fileList {..}]
set fileList [lreplace $fileList $index $index]
set index [lsearch -exact $fileList {.htaccess}]
set fileList [lreplace $fileList $index $index] ;# drop .htaccess
set index [lsearch -exact $fileList {.htaccess2}]
set fileList [lreplace $fileList $index $index] ;# drop .htaccess2
set index [lsearch -exact $fileList $alternateTargetFile]
set fileList [lreplace $fileList $index $index] ;# drop alternate target file
set index [lsearch -exact $fileList {tmp}]
set fileList [lreplace $fileList $index $index] ;# drop tmp - useful for ConvertPRN2PDF (in iconet.com.br/banon/2006/01.28.22.05)
if {$flag && [llength $fileList] > 2000} {
cd $pwd
return {}
}
foreach file $fileList {
# problem with a file named:
# ~$unzip.doc
# we get the message:
# user "$unzip.doc" doesn't exist
# when running [file isdirectory $file]
# with $file == ~$unzip.doc
#
# this problem occurs with 8.0 and not with 8.3
## for that reason we put a catch
if [file isdirectory $file] {
set time [DirectoryMTime [file join $dir $file] $flag $time $alternateTargetFile]
} else {
if ![file exists ./$file] {continue} ;# accent problem after migration (for example from Windows) - glob might recognize some accent that the operational system might not (e.g., glob may recognize Portugu??sLanguage.tcl as PortuguêsLanguage.tcl - this last name is not recognized by the operational system)
if [string equal {} $time] {
set time [file mtime ./$file] ;# ./ is needed in a case like ~$unzip.doc
} else {
set time [Max $time [file mtime ./$file]] ;# ./ is needed in a case like ~$unzip.doc
}
}
}
cd $pwd
return $time
}
} else {
proc DirectoryMTime {dir {flag 0} {time 0} {alternateTargetFile {}}} {
# runs with start and post
# global tcl_platform
set pwd [pwd]
if ![file isdirectory $dir] {return {}}
if [catch {cd $dir} err] {
puts stderr $err
return
}
set fileList [glob -nocomplain *]
set index [lsearch -exact $fileList {.htaccess}]
set fileList [lreplace $fileList $index $index] ;# drop .htaccess
set index [lsearch -exact $fileList {.htaccess2}]
set fileList [lreplace $fileList $index $index] ;# drop .htaccess2
set index [lsearch -exact $fileList $alternateTargetFile]
set fileList [lreplace $fileList $index $index] ;# drop alternate target file
set index [lsearch -exact $fileList @errorLog]
set fileList [lreplace $fileList $index $index] ;# drop @errorLog - useful for Administrator page for setting field value attributes (iconet.com.br/banon/2007/01.01.16.00)
set index [lsearch -exact $fileList {tmp}]
set fileList [lreplace $fileList $index $index] ;# drop tmp - useful for ConvertPRN2PDF (in iconet.com.br/banon/2006/01.28.22.05)
if {$flag && [llength $fileList] > 2000} {
cd $pwd
return {}
}
foreach file $fileList {
# problem with a file named:
# ~$unzip.doc
# we get the message:
# user "$unzip.doc" doesn't exist
# when running [file isdirectory $file]
# with $file == ~$unzip.doc
#
# this problem occurs with 8.0 and not with 8.3
## for that reason we put a catch
if [file isdirectory $file] {
set time [DirectoryMTime [file join $dir $file] $flag $time $alternateTargetFile]
} else {
# if ![file exists ./$file] {continue} ;# accent problem after migration (for example from Windows) - glob might recognize some accent that the operational system might not (e.g., glob may recognize Portugu??sLanguage.tcl as PortuguêsLanguage.tcl - this last name is not recognized by the operational system)
set properytList [ReturnFileProperties $dir/$file mtime] ;# added by GJFB in 2015-01-14 to solve the accent problem (see ReturnFileProperties)
array set propertyArray $properytList
if [string equal {} $time] {
# set time [file mtime ./$file] ;# ./ is needed in a case like ~$unzip.doc
set time $propertyArray(mtime)
} else {
# set time [Max $time [file mtime ./$file]] ;# ./ is needed in a case like ~$unzip.doc
set time [Max $time $propertyArray(mtime)]
}
}
}
cd $pwd
return $time
}
}
# puts [DirectoryMTime "c:/Users/Gerald Banon/URLib 2/col/dpi.inpe.br/banon-pc3@80/2009/11.10.13.03/doc"]
# puts [DirectoryMTime c:/tmp]
# DirectoryMTime - end
# ----------------------------------------------------------------------
# RepositoryMTime
# flag == 0 means no limit for the number of files
# (see DirectoryMTime)
# returns the most recent mtime among the doc part of the current repository
# and among the doc part of all its parents (if any)
proc RepositoryMTime {rep homePath {flag 0}} {
# runs with post
set repList [CreateCitedRepositoryList $rep]
lappend repList $rep
set max 0
foreach repository $repList {
Load $homePath/col/$repository/service/targetFile targetFile
set seconds [DirectoryMTime $homePath/col/$repository/doc $flag 0 @$targetFile]
if {$seconds == {}} {continue}
set max [Max $max $seconds]
set seconds [DirectoryMTime $homePath/col/$repository/agreement $flag] ;# added by GJFB in 2011-10-01
if {$seconds == {}} {continue}
set max [Max $max $seconds]
}
return $max
}
# RepositoryMTime - end
# ----------------------------------------------------------------------
# StringMin
# Find the min of two string
# example:
# StringMin 2000.01.15 2000.01.16
# used in Statistics (statistics.tcl)
proc StringMin {x y} {
set i [string compare $x $y]
if {$i == -1} {return $x} else {return $y}
}
# puts [StringMin 2000.01.15 2000.01.16]
# => 2000.01.15
# StringMin - end
# ----------------------------------------------------------------------
# Store
# Store to the disk the value of a tcl variable
# force value is 0 or 1; 1 means to force storage even for a
# read only site (used to store the Apache configuration files)
# example:
# Store referMetadata $homePath/col/$metadataRep/doc/@metadata.refer auto 0 w 0 iso8859-1
# encodingName is used in Submit (see submit.tcl), and urlibScript/getWordOccurrence.tcl only
proc Store {
varName filePath {translation auto} {nonewline 0} {access w} {force 0}
{encodingName {}} {trialNumber 1}
} {
# global env
# global homePath
if 0 {
if {[info exists env(DOCUMENT_ROOT)] && \
[file exists $env(DOCUMENT_ROOT)/readOnlySite] && \
!$force} {return}
if {[info exists homePath] && \
[file exists $homePath/readOnlySite] && \
!$force} {return}
}
upvar $varName var
if [catch {open $filePath $access} fileId] {
if {$trialNumber < 10} {
if [info exists x] {unset x}
after 100 {set x 1}; vwait x ;# wait 100 ms
incr trialNumber
# Store $varName $filePath $translation $nonewline $access $force $trialNumber
Store var $filePath $translation $nonewline $access $force $encodingName $trialNumber ;# fixed by GJFB in 2010-08-04
} else {
# puts "Store: cannot open $filePath $access: $fileId"
# puts stderr $fileId ;# give up - this command results in the error: "can not find channel named "stderr"" while executing CreateTclPage. It should be commented or catched
catch {puts stderr $fileId} ;# give up
}
} else {
if [string equal {} $encodingName] {
fconfigure $fileId -translation $translation
} else {
fconfigure $fileId -translation $translation -encoding $encodingName
}
if $nonewline {
puts -nonewline $fileId $var
} else {
puts $fileId $var
}
close $fileId
}
}
# Store - end
# ----------------------------------------------------------------------
# StoreWithBackup
# example: StoreWithBackup fileContent $col/$loBiMiRep/doc/@siteList.txt
# stores in:
# $col/$loBiMiRep/doc/@siteList.txt and
# $col/$loBiMiRep/doc/@siteListBackup.txt
proc StoreWithBackup {varName filePath {translation auto} {nonewline 0} {access w}} {
upvar $varName var
set backupPath [file rootname $filePath]Backup[file extension $filePath]
Store var $backupPath $translation $nonewline $access ;# backup - if this store fails because the computer stops, file with filePath remains unchanged
# Store var $filePath $translation $nonewline $access ;# if this store fails because the computer stops, file with backupPath can be used as backup
file copy -force $backupPath $filePath ;# if this copy fails because the computer stops, file with backupName can be used as backup
}
# StoreWithBackup - end
# ----------------------------------------------------------------------
# Grep
# pattern is a regular expression
# nocase value is {} or -nocase
proc Grep {pattern inputList {nocase {}}} {
set outputList ""
regsub -all {\.} $pattern {\.} pattern ;# . -> \.
regsub -all {\?} $pattern {\?} pattern ;# ? -> \?
# regsub -all {\(} $pattern {\(} pattern ;# ( -> \(
# regsub -all {\)} $pattern {\)} pattern ;# ) -> \)
foreach listElement $inputList {
# if [catch {eval regexp $nocase -- $pattern $listElement} flag] {break} ;# couldn't compile regular expression pattern: parentheses () not balanced
# if [catch {eval regexp $nocase -- $pattern [list $listElement]} flag] {break} ;# couldn't compile regular expression pattern: parentheses () not balanced
if [catch {eval regexp $nocase -- [list $pattern $listElement]} flag] {break} ;# couldn't compile regular expression pattern: parentheses () not balanced
# if [catch {eval [list regexp $nocase -- $pattern $listElement]} flag] {break} ;# couldn't compile regular expression pattern: parentheses () not balanced
if $flag {
lappend outputList $listElement
}
}
return $outputList
}
# puts [Grep {^b} {bs b absi wsr bba}]
# => bs b bba
# puts [Grep {^?} {bs b ?absi wsr bba}]
# => ?absi
# Grep - end
# ----------------------------------------------------------------------
# TestContentType
# type value is:
# Access Icon or
# Banner (@enBanner.html|@pt-BRBanner.html) or
# Banner Sequence or
# Bibliography Data Base (@reference.bib) or
# Copyright or
# External Contribution (used in ComputeVersionState (utilitiesStart.tcl)) or
# Index or
# Metadata (metadata.cgi) or
# Mirror (mirror.cgi) or others
proc TestContentType {rep type {colPath {}}} {
# runs with post and cgi
global repositoryProperties
if [info exists repositoryProperties] {
# post
if [info exists repositoryProperties($rep,type)] {
set contentType $repositoryProperties($rep,type)
} else {
# set contentType {} ;# commented by GJFB in 2018-12-25
Load $colPath/col/$rep/service/type contentType ;# added by GJFB in 2018-12-25 - now needed in UpdateCollection only
}
} else {
# cgi
Load $colPath/col/$rep/service/type contentType
}
return [regexp ^$type$ $contentType]
}
# TestContentType - end
# ----------------------------------------------------------------------
# CreateAbbreviation
# pattern example: ^v
proc CreateAbbreviation {pattern} {
global abbreviationArray
set fieldList [array names field::conversionTable ?*] ;# ?* to drop {}
set fieldList [Grep $pattern $fieldList]
foreach field $fieldList {
set firstLetters [ExtractFirstCharacters fieldList $field]
set abbreviationArray($field) $firstLetters
}
return $fieldList
}
# CreateAbbreviation - end
# ----------------------------------------------------------------------
# ExtractFirstCharacters
# Extract the first significant characters of a pattern of a list
# used in CreateAbbreviation (see mirrot.tcl) and StartService
proc ExtractFirstCharacters {listName pattern} {
upvar $listName list
set list2 $list
set i 0
set firstLetters ""
while {[llength $list2] > 1} {
if {[string compare $firstLetters $pattern] == 0} {
set firstLetters $pattern,
break
}
set firstLetters [string range $pattern 0 $i]
regsub -- {-$} $firstLetters {} firstLetters ;# because of e-mail address
set list2 [Grep ^$firstLetters $list2]
incr i
}
return $firstLetters
}
if 0 {
source ../../../1999/05.03.22.11/doc/mirror/enFieldName.tcl
foreach {index value} [array get field::conversionTable] {
set inverseTable($value) $index
}
set fieldList [array names field::conversionTable ?*] ;# ?* to drop {}
foreach value [lsort -dictionary [array names inverseTable ?*]] {
set firstLetters [ExtractFirstCharacters fieldList $inverseTable($value)]
puts $inverseTable($value)
puts $firstLetters
}
puts [ExtractFirstCharacters fieldList academicdepartment]
# => aca
}
# ExtractFirstCharacters - end
# ----------------------------------------------------------------------
# GetAccessDate
proc GetAccessDate {accessDate} {
# set seconds [GetSeconds]
set seconds [clock seconds]
set year [clock format $seconds -format %Y]
set month [clock format $seconds -format %b]
set day [clock format $seconds -format %d]
return [subst $accessDate]
}
# GetAccessDate - end
# ----------------------------------------------------------------------
# GetStatisticsDate
proc GetStatisticsDate {statisticsDate} {
global env
if [file exists $env(DOCUMENT_ROOT)/col/$env(LOBIMIREP)/doc/@wordOccurrence] {
set seconds [file mtime $env(DOCUMENT_ROOT)/col/$env(LOBIMIREP)/doc/@wordOccurrence]
} else {
# set seconds [GetSeconds]
set seconds [clock seconds]
}
set year [clock format $seconds -format %Y]
set month [clock format $seconds -format %b]
set day [clock format $seconds -format %d]
return [subst $statisticsDate]
}
# GetStatisticsDate - end
# ----------------------------------------------------------------------
# GetSeconds
# not used
proc GetSeconds2 {} {
# runs with start and post
global environmentArray
set seconds [clock seconds]
if {[info exists environmentArray(spDaylightTime)] && \
$environmentArray(spDaylightTime)} {
set seconds [expr $seconds + 3600]
}
return $seconds
}
# GetSeconds - end
# ----------------------------------------------------------------------
# ReturnTimeOutReference
proc ReturnTimeOutReference {} {
global tcl_platform
if [string equal {windows} $tcl_platform(platform)] {
return [expr int(333 * 6)] ;# 1 / 3 second * 6 (gabriela using Get (when calling ResolveIBI to find the appropriate metadata repository))
} else {
return [expr int(333 * 3)] ;# 1 / 3 second * 3 (because of mtc-m17 when searching for ar cea and y 2007)
}
}
# ReturnTimeOutReference - end
# ----------------------------------------------------------------------
# Submit
proc Submit {sock line {async 1} {clicks {}}} {
# global x y ;# for unix
global eval
global errorTrace ;# set in post and start
global homePath
# set errorTrace 1
if [string equal {} $clicks] {set clicks [clock clicks]}
if {[info exists errorTrace] && $errorTrace} {
# 1
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (1 - $sock - $clicks): beginning communication with the server: $eval(server,$sock)\nthe query is: $line\nasync value is: $async\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
if $async {
set command [lindex $line 0]
# timeOut
set timeOut [ReturnTimeOutReference]
# timeOutArray
set timeOutArray(GetEntry) [expr 4 * $timeOut] ;# time out reference is not enought to display some entries using GetEntry (in LoopOverEntries) - mtc-m13.sid.inpe.br - sid.inpe.br/jeferson/2004/09.17.11.26 - 41225 Kbytes
set timeOutArray(UpdateHostCollectionFieldValue) [expr 4 * $timeOut] ;# time out reference is not enought when migrating from one local collection to another
# timeOut2
ConditionalSet timeOut2 timeOutArray($command) $timeOut
global x$clicks
if [info exists x$clicks] {unset x$clicks}
fileevent $sock writable "set x$clicks 0"
# after $timeOut2 "set x$clicks 1"
after 200 "set x$clicks 1" ;# 100 ms - after 100 ms produces an unaccessible reference (200 ms is to access mtc-m17 from banon-pc2 at home)
vwait x$clicks
if {[info exists errorTrace] && $errorTrace} {
# 2
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (2 - $sock - $clicks): testing if $sock is writable\nx$clicks value is: [set x$clicks]\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
if [set x$clicks] {
close $sock
return -code error -errorinfo "writing time out at $eval(server,$sock)"
# return -code return -errorinfo {writing time out}
}
unset x$clicks ;# free memory
}
# set xxx Submit(1)-$clicks
# Store xxx C:/tmp/bbb.txt binary 0 a
if [string equal {ComputeAccess} [lindex $line 0]] {
puts $sock $line
# flush $sock ;# not needed because of fconfigure $s -buffering line (in StartCommunication)
# Read return line count and the result.
gets $sock lines
set result {}
while {$lines > 0} {
gets $sock x
append result $x\n
incr lines -1
}
set code [lindex $result 0]
set x [lindex $result 1]
# Cleanup the end of the stack
regsub "\[^\n]+$" [lindex $result 2] "*Remote Server $eval(server,$sock)*" stack
set ec [lindex $result 3]
return -code $code -errorinfo $stack -errorcode $ec $x
} else {
# Clear channel
# to test these codes, uncomment the line with the comment: clearing channel (see ReturnSiteContainingTheOriginal in utilitiesStart.tcl and FindSiteContainingTheOriginal in this file)
# none of the codes below are completly satisfactory
if 0 {
global y
if [info exists y] {unset y}
fileevent $sock readable {set y 1}
after 100 {set y 0} ;# it is assumed that the channel can be cleared in 100 ms
vwait y
if $y {gets $sock garbage}
} else {
fconfigure $sock -blocking 0
gets $sock garbage
fconfigure $sock -blocking 1
}
# Clear channel - end
if {[info exists errorTrace] && $errorTrace} {
# 3
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (3 - $sock - $clicks): putting the query to $sock\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
# set xxx Submit(2)-$clicks
# Store xxx C:/tmp/bbb.txt binary 0 a
puts $sock $line
# set xxx Submit(3)-$clicks
# Store xxx C:/tmp/bbb.txt binary 0 a
if {[info exists errorTrace] && $errorTrace} {
# 4
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (4 - $sock - $clicks): the query has been put to $sock\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
# set xxx "$clicks 2"
# Store xxx C:/tmp/bbb.txt binary 0 a
if 1 {
# must be 1 otherwise gets below hangs, for example, when Submit is called from Execute within Info within UpdateAccessFile within InstallRepository within Run-ir
# if $async #
# set y 0 ;# doesn't work properly with this line (mosaic)
# after 1000 {set y 1}; vwait y
global y$clicks
if [info exists y$clicks] {unset y$clicks}
fileevent $sock readable "set y$clicks 0" ;# otherwise hangs when displaying all entries (and others)
if $async {after $timeOut2 "set y$clicks 1"} ;# doesn't work properly (vwait below hangs) when the command is PostponeOneClickCount (issuing a rep-) and the ip is 127.0.0.1 in a wrong way
if 0 {
while {![info exist y$clicks]} {
set x 0; after 10 {set x 1}; vwait x
}
} else {
# after $timeOut2 "set y$clicks 1"
# set xxx Submit(4)-$clicks
# Store xxx C:/tmp/bbb.txt binary 0 a
vwait y$clicks
# set xxx Submit(5)-$clicks
# Store xxx C:/tmp/bbb.txt binary 0 a
}
if $async {after cancel "set y$clicks 1"}
if {[info exists errorTrace] && $errorTrace} {
# 5
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (5 - $sock - $clicks): testing if $sock is readable\ny$clicks value is: [set y$clicks]\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
if [set y$clicks] {
# time-out
close $sock
return -code error -errorinfo "reading time out at $eval(server,$sock)"
# return -code return -errorinfo {reading time out}
}
unset y$clicks ;# added by GJFB in 2013-07-19 - free memory
# tcl didn't receive a readable event after StartApacheServer was
# executed when running under UNIX platform (see CreateRepMetadataRep)
}
# global y
# fileevent $sock readable "set y 0"; vwait y ;# otherwise hangs when displaying all
if {[info exists errorTrace] && $errorTrace} {
# 6
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (6 - $sock - $clicks): getting the reply from $sock\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
if [regexp {^Run-exit \d+} $line] {file delete $homePath/@executeLog$clicks}
}
gets $sock line
# set xxx [list $sock $line]
# Store xxx C:/tmp/bbb.txt auto 0 a
# puts [list $sock eof = [eof $sock]
]
if {[info exists errorTrace] && $errorTrace} {
# 7
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Submit (7 - $sock - $clicks): returning the reply: $line\n"
Store log $homePath/@errorLog auto 0 a
file delete $homePath/@executeLog$clicks
}
# set xxx "$clicks 3"
# Store xxx C:/tmp/bbb.txt binary 0 a
# unset eval ;# added by GJFB in 2013-07-19
# if [info exists eval] {unset eval} ;# added by GJFB in 2013-07-19 - free memory - commented by GJFB in 2017-03-17 to avoid deleting data of other running processes (otherwise, for example, gjfb.home:1905/8JMKD3MGP3W34P/3NFKNR8 doesn't return the identified item an Journal Article) because GetReply return immediatly (see the first two "if") and no reply is created)
if [info exists eval(server,$sock)] {unset eval(server,$sock)} ;# added by GJFB in 2017-03-17 to avoid deleting data of other running processes - same coder as in CleanUp
if [info exists eval(token,$sock)] {unset eval(token,$sock)} ;# added by GJFB in 2017-03-17 to avoid deleting data of other running processes - same coder as in CleanUp
return $line
}
}
# Submit - end
# ----------------------------------------------------------------------
# Execute
# site may coded in any form (e.g., banon-pc3 or banon-pc3:80 or {banon-pc3 800} or 153.163.2.174 or 153.163.2.174:80 or {153.163.2.174 800})
# if site is not a virtual host, otherwise just the new coding is allowed (e.g., {banon-pc3 802} or {153.163.2.174 802})
# example:
# set metadata2List [Execute $serverAddressWithIP [list GetMetadata $callingRep-0,metadatalastupdate]]
# encodingName value is for example iso8859-1 or utf-8
## utf-8 is used in FindAbsolutePath (not more in use) when executing GetTargetFile (in the communication with plutao)
## doesn't work when opening sid.inpe.br/mtc-m15@80/2006/12.06.11.48 (located at mtc-m15)
## set targetFile [Execute $serverAddress2 [list GetTargetFile $currentRep] 1 utf-8] ;# solves the accent problem - communication from banon-pc3 to plutao - see Get- - done by GJFB in 2010-07-09
## returning to old code - done by GJFB in 2010-10-26
## works with http://banon-pc3/rep/dpi.inpe.br/plutao@80/2009/07.13.14.44
## works when opening sid.inpe.br/mtc-m15@80/2006/12.06.11.48 (located at mtc-m15)
## set encodingName [Execute $serverAddress2 [list GetEncodingName]]
## set targetFile [Execute $serverAddress2 [list GetTargetFile $currentRep] 1 $encodingName]
# returnEmptyFlag value is 0 or 1,
# 1 means to return empty when the communication with the server (site) doesn't start
# 0 means to produce an error
proc Execute {site command {async 1} {encodingName {}} {returnEmptyFlag 0}} {
global env
global errorTrace ;# set in post
global homePath
global serverAddress
global serverAddressWithIP
global errorInfo
set clicks [clock clicks]
if $async {
if {[info exists env(SERVER_NAME)] && [info exists env(IP_ADDR)]} {
# the calling procedure is a cgi script
set async2 [ResolveAsync $env(SERVER_NAME) $env(IP_ADDR) $site]
} else {
# the calling procedure is not a cgi script
if [info exists serverAddress] {
set async2 [ResolveAsync [lindex $serverAddress 0] [lindex $serverAddressWithIP 0] $site]
} else {
# case of processMail (newpassword@dpi.inpe.br)
set async2 1
}
}
} else {
set async2 0
}
# puts $site
# puts "" ;# to have the previous puts displayed
foreach {serverName urlibPort} [ReturnCommunicationAddress $site] {break}
# sometimes the serverName may be 127.0.0.1 in a wrong way
# this already occured after a breakdown (with marte)
# it was not possible to solve this problem in Submit because vwait hangs
if {[string equal {127.0.0.1} $serverName] && [info exists serverAddressWithIP] && ![regexp {127.0.0.1} $serverAddressWithIP]} {return}
if {[info exists errorTrace] && $errorTrace} {
# 1
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Execute (1 - $clicks): starting communication with the server (using async value $async2): \[$serverName $urlibPort\]\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
# START COMMUNICATION
# set x 0; after 100 {set x 1}; vwait x ;# nice procedure - needed to recreate .keyRepositoryList.tcl in gabriela
# puts OK
# puts "" ;# to have the previous puts displayed
if [catch {StartCommunication $serverName $urlibPort $async2 $encodingName} localURLibClientSocketId] {
# puts OK-
# puts --$localURLibClientSocketId--
# puts "" ;# to have the previous puts displayed
# return
if {[info exists errorTrace ] && $errorTrace} {
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Execute (2 - $clicks): communication with server \[$serverName $urlibPort\] doesn't start: --$localURLibClientSocketId--\n"
Store log $homePath/@errorLog auto 0 a
file delete $homePath/@executeLog$clicks auto 0 a
}
if $returnEmptyFlag {return} ;# added by GJFB in 2013-02-24 in order to continue executing CreateOptionListForCopyright even though the communication with a server doesn't start
# return -code error -errorinfo "Execute (3): communication with server \[$serverName $urlibPort\] doesn't start while trying to execute the command:\n$command\n"
error "Execute (3): communication with server \[$serverName $urlibPort\] doesn't start (using async value $async2) while trying to execute the command:\n$command\nerrorInfo:\n--$errorInfo--\n"
}
# Store localURLibClientSocketId C:/tmp/bbb.txt auto 0 a
# puts OK2
# puts "" ;# to have the previous puts displayed
# set output [Submit $localURLibClientSocketId $command $async2]
if {[info exists errorTrace] && $errorTrace} {
# 4
set log "\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Execute (4 - $clicks): submitting the following command to $localURLibClientSocketId:\n$command\n"
Store log $homePath/@errorLog auto 0 a
Store log $homePath/@executeLog$clicks auto 0 a
}
# SUBMIT
if [catch {Submit $localURLibClientSocketId $command $async2 $clicks} output] {
catch {close $localURLibClientSocketId} ;# added by GJFB in 2012-12-29
set log "\n\[[clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]\] Execute (5): catch returns --$output-- while executing: \"Submit $localURLibClientSocketId $command $async2 $clicks\"\n"
Store log $homePath/@errorLog auto 0 a
# puts $log
return ;# if time out, return empty
}
close $localURLibClientSocketId
# Store localURLibClientSocketId C:/tmp/bbb.txt auto 0 a
# puts OK
return $output
}
# Execute - end
# ----------------------------------------------------------------------
# ResolveAsync
proc ResolveAsync {serverName ipAddress site} {
upvar command command
if [regexp -nocase "$serverName|$ipAddress" $site] {
# the call is to the local computer
set async 0 ;# needed with submit.tcl (CreateRepMetadataRep and UpdateRepMetadataRep)
} else {
# the call is to a remote computer
set command2 [lindex $command 0]
# asyncArray
set asyncArray(CreateRepMetadataRep) 0 ;# used in Submit (see submit.tcl)
set asyncArray(UpdateRepMetadataRep) 0 ;# used in Submit (see submit.tcl)
# set asyncArray(FindMetadataRep) 0 ;# used in Submit (see submit.tcl)
ConditionalSet async asyncArray($command2) 1
}
return $async
}
# ResolveAsync - end
# ----------------------------------------------------------------------
# Eval
# example:
# Eval UpdateVariables $metadataRep
# used by UpdateRobotstxtFile (called in cgi/script - Administrator Page)
proc Eval {args} {
# runs with start and post
global serverAddressWithIP
global applicationName
if {![info exists applicationName] || $applicationName == "start"} {
return [Execute $serverAddressWithIP $args 0] ;# not async
} else {
return [eval $args]
}
}
# Eval - end
# ----------------------------------------------------------------------
# CompareKey
# not used
proc CompareKey2 {a b} {
set a1 [lindex $a 1]
set b1 [lindex $b 1]
return [string compare $a1 $b1]
}
# CompareKey - end
# ----------------------------------------------------------------------
# CompareDate-
# compares based on rep-i
proc CompareDate- {a b} {
set a3 [lrange [file split [lindex $a 3]] 2 3]
set b3 [lrange [file split [lindex $b 3]] 2 3]
return [string compare $a3 $b3]
}
# CompareDate- - end
# ----------------------------------------------------------------------
# CompareDate+
# compares based on rep-i
proc CompareDate+ {a b} {
set a3 [lrange [file split [lindex $a 3]] 2 3]
set b3 [lrange [file split [lindex $b 3]] 2 3]
return [string compare $b3 $a3]
}
# CompareDate+ - end
# ----------------------------------------------------------------------
# CompareStamp
proc CompareStamp {a b} {
set a20 [lindex [lindex $a 2] 0] ;# metadataLastUpdate
set b20 [lindex [lindex $b 2] 0] ;# metadataLastUpdate
return [string compare $b20 $a20]
}
# CompareStamp - end
# ----------------------------------------------------------------------
# CompareLastUpdateStamp
proc CompareLastUpdateStamp {a b} {
set a50 [lindex [lindex $a 5] 0] ;# lastUpdate
set b50 [lindex [lindex $b 5] 0] ;# lastUpdate
return [string compare $b50 $a50]
}
# CompareLastUpdateStamp - end
# ----------------------------------------------------------------------
# CompareStamp2
# use by ReturnURLPropertyList only
proc CompareStamp2 {a b} {
set a20 [lindex [lindex [lindex $a 1] 0] 0] ;# metadataLastUpdate
set b20 [lindex [lindex [lindex $b 1] 0] 0] ;# metadataLastUpdate
return [string compare $b20 $a20]
}
# CompareStamp2 - end
# ----------------------------------------------------------------------
# CompareStampRep-i
# a and b are lists: site key metadataLastUpdate rep-i state
proc CompareStampRep-i {a b} {
if [catch {lindex $a 2} a2] {return 1} ;# metadataLastUpdate
set a23 [lappend a2 [lindex $a 3]] ;# metadataLastUpdate rep-i
if [catch {lindex $b 2} b2] {return 1} ;# metadataLastUpdate
set b23 [lappend b2 [lindex $b 3]] ;# metadataLastUpdate rep-i
return [string compare $b23 $a23]
}
# CompareStampRep-i - end
# ----------------------------------------------------------------------
# CompareStampRep-iState
# a and b are lists: site key metadataLastUpdate rep-i state
# [lindex $a 4] == state variable of GetMetadataRepositories
# [lindex $b 4] == state variable of GetMetadataRepositories
# state is 1 if the repository contains the original and 0 otherwise
proc CompareStampRep-iState {a b} {
set test [CompareStampRep-i $a $b]
if {$test == 0} {
return [expr [lindex $a 4] < [lindex $b 4]]
}
return $test
}
# CompareStampRep-iState - end
# ----------------------------------------------------------------------
# CompareKeyTitle
# created by GJFB in 2013-10-15
# a and b are lists: site key metadataLastUpdate rep-i state
# [lindex $a 1] == key variable of GetMetadataRepositories
# [lindex $b 1] == key variable of GetMetadataRepositories
# [lindex $a 5] == sortedFieldValue variable of GetMetadataRepositories
# [lindex $b 5] == sortedFieldValue variable of GetMetadataRepositories
proc CompareKeyTitle {a b} {
set a1 [lindex $a 1] ;# key (citation key)
set b1 [lindex $b 1] ;# key (citation key)
set test [string compare $a1 $b1]
if {$test == 0} {
set a5 [lindex $a 5] ;# sortedFieldValue (e.g., title)
set b5 [lindex $b 5] ;# sortedFieldValue (e.g., title)
# return [string compare $a5 $b5] ;# doesn't produce a dictionary-style comparison
return [expr [lindex [lsort -dictionary -indices [list $a5 $b5]] 1] * 2 - 1]
}
return $test
}
# CompareKeyTitle - end
# ----------------------------------------------------------------------
# CompareYearKeyTitle
# created by GJFB in 2014-08-10
# a and b are lists: site key metadataLastUpdate rep-i state sortedFieldValue
# [lindex $a 1] == key variable of GetMetadataRepositories
# [lindex $b 1] == key variable of GetMetadataRepositories
# [lindex $a 5] == sortedFieldValue variable of GetMetadataRepositories
# [lindex $b 5] == sortedFieldValue variable of GetMetadataRepositories
proc CompareYearKeyTitle {a b} {
set a1 [lindex $a 1] ;# key (citation key)
set b1 [lindex $b 1] ;# key (citation key)
if ![regexp {:(\d{4,}):} $a1 m yeara] {set yeara 0}
if ![regexp {:(\d{4,}):} $b1 m yearb] {set yearb 0}
set test1 [string compare $yearb $yeara]
if {$test1 == 0} {
set test2 [string compare $a1 $b1]
if {$test2 == 0} {
set a5 [lindex $a 5] ;# sortedFieldValue (e.g., title)
set b5 [lindex $b 5] ;# sortedFieldValue (e.g., title)
return [expr [lindex [lsort -dictionary -indices [list $a5 $b5]] 1] * 2 - 1]
}
return $test2
}
return $test1
}
# CompareYearKeyTitle - end
# ----------------------------------------------------------------------
# CompareDateYearKey
# created by GJFB in 2016-03-14
# a and b are lists: site key metadataLastUpdate rep-i state sortedFieldValue
# [lindex $a 1] == key variable of GetMetadataRepositories
# [lindex $b 1] == key variable of GetMetadataRepositories
# [lindex $a 5] == sortedFieldValue variable of GetMetadataRepositories
# [lindex $b 5] == sortedFieldValue variable of GetMetadataRepositories
proc CompareDateYearKey {a b} {
set a5 [lindex $a 5] ;# sortedFieldValue (date or issuedate)
set b5 [lindex $b 5] ;# sortedFieldValue (date or issuedate)
# puts [list $a5 $b5] ;# the output is at the bottom of the web page
if ![regexp {^\d{4,}.*} $a5 datea] {set datea 0}
if ![regexp {^\d{4,}.*} $b5 dateb] {set dateb 0}
set test1 [string compare $datea $dateb]
if {$test1 == 0} {
set a1 [lindex $a 1] ;# key (citation key)
set b1 [lindex $b 1] ;# key (citation key)
if ![regexp {:(\d{4,}):} $a1 m yeara] {set yeara 0}
if ![regexp {:(\d{4,}):} $b1 m yearb] {set yearb 0}
set test2 [string compare $yeara $yearb]
if {$test2 == 0} {
return [expr [lindex [lsort -dictionary -indices [list $b1 $a1]] 1] * 2 - 1]
}
return $test2
}
return $test1
}
if 0 {
# commented by GJFB n 2018-02-26
# not used
proc CompareDateKey {a b} {
set a5 [lindex $a 5] ;# sortedFieldValue (date or issuedate)
set b5 [lindex $b 5] ;# sortedFieldValue (date or issuedate)
# puts [list $a5 $b5] ;# the output is at the bottom of the web page
if ![regexp {^\d{4,}.*} $a5 datea] {set datea 0}
if ![regexp {^\d{4,}.*} $b5 dateb] {set dateb 0}
set test2 [string compare $datea $dateb]
if {$test2 == 0} {
set a1 [lindex $a 1] ;# key (citation key)
set b1 [lindex $b 1] ;# key (citation key)
return [expr [lindex [lsort -dictionary -indices [list $b1 $a1]] 1] * 2 - 1]
}
return $test2
}
}
# CompareDateYearKey - end
# ----------------------------------------------------------------------
# LoopOverEntries
# called by CreateOutput only
# flag value is 0 or 1
# 1 means that the number of entries found is greater than the specified maximum
# path example: ../
# numbering values are {} or {numbering prefix}; {} means to do no numbering
# outputFormat values are boolean or {html code} or a list of field names; used by briefTitleAuthorMisc and CreateDateTitleSite - default is used by briefTitleAuthorMisc
# cellBackgroundColors value is a list of two colors; for example: {#EEEEEE #E3E3E3}; used by CreateDateTitleSite
# pageFlag values are no or yes; used by CreateBriefTitleAuthorEntry
# includeReturnAddress values are yes or no; set in GetSearchResult and used in CreateBriefEntry (see update link)
# linkType used by CreateBriefTitleAuthorEntry (see CreateBriefTitleAuthorEntry)
# hideSimilarButton set in CreateOutput and used by CreateBriefEntry
# type is the output format, for example: brief
# targetValue is for example _blank, _self, ...
# dateFieldName is metadatalastupdate or issuedate (used by CreateDateTitleSite)
# siteFieldName is site or newspaper (used by CreateDateTitleSite)
# returnButton value is no or yes
# nameFormat value is short, familynamefirst or familynamelast (used by CreateBriefTitleAuthorEntry)
# nameSeparator value is a string like {; } or {
} (used by CreateBriefTitleAuthorEntry)
# originalRepForSimilarity value is a rep-i or empty
# imageFlag value is 0 or 1; 1 means to display the thumbnail (if any) - used by CreateFullEntry only
# alternateQuery value is empty or the content of the second query field
# queryFieldType value is first or second
proc LoopOverEntries {
query2String type numberOfEntries top path header
excludedFields {flag 0} {numbering {}} {outputFormat 1}
{cellBackgroundColors {#EEEEEE #E3E3E3}} {pageFlag no}
{includeReturnAddress yes} {linkType 0} {hideSimilarButton {no}}
{targetValue _blank} {dateFieldName metadatalastupdate}
{siteFieldName site} {returnButton no} {cssFileURL {}}
{nameFormat {short}} {nameSeparator {; }} {originalRepForSimilarity {}}
{imageFlag 1} {alternateQuery {}} {queryFieldType {first}}
} {
global env
global cgi
global searchResultList
global numberOfActiveSites
global currentRep ;# mirror repository
global numberOfSites ;# set in MultipleSubmit
global listOfInactiveSites ;# set in CreateOutput
global loCoInRepList ;# set in MultipleSubmit
global siteWarning
global singularSiteWarning
global singularSiteWarning2
global pluralSiteWarning
global pluralSiteWarning2
global searchWarning
global errorMessage ;# set in CreateOutput
global wrongPassword ;# set in CreateOutput
global administratorUserName ;# set in CreateOutput
global currentVariableFileName ;# set in enSearchResult.tcl (sourced in CreateOutput)
global currentProcedureName ;# set in MirrorSearch
# global currentFileName ;# set in MirrorSearch
global currentProcedureFileName ;# set in MirrorSearch
if 1 {
# should be set to 0 in the future
global {full reference} ;# on the verge of extinction since 2010-01-03
global {cover} ;# on the verge of extinction since 2010-01-03
global {access} ;# on the verge of extinction since 2010-01-03
global {access the files that comprise the document} ;# on the verge of extinction since 2010-01-03
global {download} ;# on the verge of extinction since 2010-01-03
global {download the files that comprise the document} ;# on the verge of extinction since 2010-01-03
global {copy} ;# changed to export in 2009-05-14
global {export} ;# on the verge of extinction since 2010-01-03
global {download the files that comprise the document and its metadata} ;# on the verge of extinction since 2010-01-03
global {retrieve} ;# on the verge of extinction since 2010-01-31
global {update the document and its metadata} ;# on the verge of extinction since 2010-01-31
global {update} ;# on the verge of extinction since 2010-01-31
global {duplicate the document} ;# on the verge of extinction since 2010-01-31
global {duplicate} ;# on the verge of extinction since 2010-01-31
global {review} ;# on the verge of extinction since 2010-01-03
global {statistics} ;# on the verge of extinction since 2010-01-03
global {Your work has been published? Select the vehicle type} ;# on the verge of extinction since 2010-01-31
global {Do you have an audiovisual material? Submit it} ;# on the verge of extinction since 2010-01-31
}
global {Update} ;# set in mirror/xxSearchResult.tcl
global {full document}
global {Empty Fields}
global {without cover} ;# not used from September 2003
global {Kbyte}
global {Kbytes}
global { looking up in $numberOfActiveSites out of $numberOfSites sites.}
global {The contributor of this data base is listed below.}
global {The contributor of this data base, extracted from $numberOfActiveSites
out of $numberOfSites sites, is listed below.}
global {The contributors of this data base are listed below.}
global {The contributors of this data base, extracted from $numberOfActiveSites
out of $numberOfSites sites, are listed below.}
global {The most recent reference is listed below.}
global {The $numberOfReferences most recent references are listed below, the first one being the most recent.}
global {There is no reference to be displayed for this data base.}
global {The most recent reference, extracted from $numberOfActiveSites
out of $numberOfSites sites, is listed below.}
global {The $numberOfReferences most recent references, extracted from $numberOfActiveSites
out of $numberOfSites sites, are listed below, the first one being the most recent.}
global {Eventually not all the expected references could be displayed because at least one site failed.}
global siteHelp
global ${top}Singular
global ${top}Plural
global topForContinue
global bodySystemLimit
global topFull
global bodyOutOfDate2
global {out-of-date reference}
global {unaccessible reference}
global {No}
global accessDate
global {Jan}
global {Feb}
global {Mar}
global {Apr}
global {May}
global {Jun}
global {Jul}
global {Aug}
global {Sep}
global {Oct}
global {Nov}
global {Dec}
# Migration 2011-01-15
## Migration 2007-01-28
# global {Posted in URLib repository:}
# global {Posted in:}
## Migration 2007-01-28 - end
# Migration 2011-01-15 - end
global {Available from:}
global {Access in:}
global {How to Make the Citation of this Document using the INPE Standard - BibINPE Format}
global {See also:}
# global {Electronic Document Format - BibINPE}
global {How to Make the In-Text Citation - by author/year}
global {and}
global {as proposed by}
global {may be found in the literature}
global {missing or emtpy field: }
global {incomplete reference}
global {not an BibINPE reference}
global {Is a Copy?} ;# used in CreateFullEntry only
global {yes} ;# used in CreateFullEntry only
global {no} ;# used in CreateFullEntry only
global {History} ;# used in CreateFullEntry only
global {Document Stage} ;# used in CreateFullEntry only
global {work-in-progress} ;# used in CreateFullEntry only
global {completed} ;# used in CreateFullEntry only
global {slides} ;# used in CreateFullBibINPEEntry only
global {Slides} ;# used in CreateFullBibINPEEntry only
global {Translation by} ;# used in CreateFullBibINPEEntry only
global {source Directory Content}
global {there are no files}
# global {agreement Directory Link} ;# used in CreateFullEntry only
# global {directory doesn't exist} ;# used in CreateFullEntry only
global {agreement Directory Content} ;# used in CreateFullEntry only
global {see directory content} ;# used in CreateFullEntry only
global mirrorHomePageRepository ;# set in MirrorSearch
global mirrorHomePageRep ;# defined in FindLanguage (utilities1.tcl)
global col ;# used by CreateReturnButton (set in CreateOutput)
global homePath ;# used when sourcing xxFillingInstructions.tcl
global extraCode
# global below are used with safe interpreter
global translationTable ;# set in mirror/xxSearchResult.tcl
upvar bgColor bgColor
upvar background background
upvar bgProperties bgProperties
upvar fontTag fontTag
upvar fontTag2 fontTag2
upvar display display
upvar language language
upvar shortVersionOfLanguage shortVersionOfLanguage
upvar languageRep1 languageRep1 ;# to access .css from topSearchPlural (for example)
upvar languageRep2 languageRep2
upvar submissionFormRep submissionFormRep ;# to access submission.js from topForContinue
upvar returnWarning returnWarning
upvar output2 output2 ;# set in this procedure and used in CreateOutput
upvar submissionFormLanguageRep submissionFormLanguageRep ;# for sourcing xxFillingInstructions.tcl
upvar submissionFormLanguage submissionFormLanguage ;# for sourcing xxFillingInstructions.tcl
upvar relatedFlag relatedFlag ;# set in CreateOutput; used in topForContinue
if [regexp {^brief} $type] {
# xxFillingInstructions.tcl is needed to translate the reference type for brief and briefTitleAuthorMisc
if ![info exists translationTable] {
# not within slave interperter
source ../$col/$languageRep2/doc/${language}FillingInstructions.tcl
}
}
# puts [CallTrace]
# continue (used by the Return Button - see mirrorget.tcl)
if $flag {
set continue no
} else {
set continue yes
}
# changing return button default
if ![info exists cgi(returnbutton)] {set cgi(returnbutton) no}
if [regexp {DisplayMultipleSearch|DisplaySearch} [CallTrace]] {
# set returnButton no ;# used below when doing substitution within the update line created by CreateBriefTitleAuthorEntry
# set targetFrame {} ;# used below when doing substitution within the update line created by CreateBriefTitleAuthorEntry
} else {
set returnButton $cgi(returnbutton)
if [info exists cgi(targetframe)] {set targetFrame $cgi(targetframe)}
}
# puts $cgi(targetframe)
if ![info exists cgi(languagebutton)] {set cgi(languagebutton) $language} ;# old sites don't define the language button (for example at "The Most Recent" button)
# localSite
set localSite $env(SERVER_NAME):$env(SERVER_PORT) ;# $env(HTTP_HOST) not used because can be shorter like sputnik:1909
# serverAddress
set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)]
# serverAddressWithIP
set serverAddressWithIP [list $env(IP_ADDR) $env(URLIB_PORT)]
## pID
# set pID [pid]
# requestURI
# keywords
set requestURI {} ;# used in subst [join $entry \n] when entry comes from CreateBriefEntry, CreateBriefTitleAuthorEntry or CreateFullEntry
if {[info exists cgi(query)] && (![info exists cgi(multiplesearch)] || !$cgi(multiplesearch))} {
# simple query (not a list of queries)
# cgi(multiplesearch) is set in GetSearchResult (its value is 1 when GetSearchResult is called by DisplayDuplicates)
regsub -all {\&} $cgi(query) {%26} query ;# & is an alias for "and" in queries
regsub -all {#} $query {%23} query ;# needed with queries incluing field names like #issn
lappend requestURI query=$query
set keywords [Execute $serverAddressWithIP [list ReturnWordListOfSearchExpression $cgi(query)]] ;# cgi(query) must not be a list, otherwise ReturnWordListOfSearchExpression returns an infinite loop error message
} else {
set keywords {}
}
# puts --$keywords--
lappend requestURI alternatequery=$alternateQuery
if [info exists cgi(query2)] {
regsub -all {\&} $cgi(query2) {%26} query2 ;# & is an alias for "and" in queries
regsub -all {#} $query2 {%23} query2 ;# needed with queries incluing field names like #issn
lappend requestURI query2=$query2
}
ConditionalSet accent cgi(accent) yes ;# used to highlight words
ConditionalSet case cgi(case) yes ;# used to highlight words
if [info exists cgi(languagebutton)] {lappend requestURI languagebutton=$cgi(languagebutton)}
# if [info exists cgi(returnbutton)] {lappend requestURI returnbutton=$cgi(returnbutton)}
lappend requestURI returnbutton=$returnButton
# if [info exists cgi(targetframe)] {lappend requestURI targetframe=$cgi(targetframe)}
if [info exists targetFrame] {lappend requestURI targetframe=$targetFrame}
if [info exists cgi(choice)] {lappend requestURI choice=$cgi(choice)}
if [info exists cgi(sort)] {lappend requestURI sort=$cgi(sort)}
if [info exists cgi(accent)] {lappend requestURI accent=$cgi(accent)}
if [info exists cgi(case)] {lappend requestURI case=$cgi(case)}
if [info exists cgi(outputformat)] {lappend requestURI outputformat=$cgi(outputformat)}
if [info exists cgi(linktype)] {lappend requestURI linktype=$cgi(linktype)}
if [info exists cgi(cssfileurl)] {lappend requestURI cssfileurl=$cgi(cssfileurl)}
if [info exists cgi(codedpassword1)] {lappend requestURI codedpassword1=$cgi(codedpassword1)}
if [info exists cgi(dontdisplaysearchresultwarning)] {lappend requestURI dontdisplaysearchresultwarning=$cgi(dontdisplaysearchresultwarning)}
if [info exists cgi(nameformat)] {lappend requestURI nameformat=$cgi(nameformat)}
if [info exists cgi(nameseparator)] {lappend requestURI nameseparator=$cgi(nameseparator)}
if [info exists cgi(continue)] {lappend requestURI continue=$cgi(continue)}
set requestURI [join $requestURI &]
regsub -all -- {\+} $requestURI {%2B} requestURI
regsub -all { } $requestURI {+} requestURI
regsub -all {<} $requestURI {%3c} requestURI
regsub -all {>} $requestURI {%3e} requestURI
set requestURI2 $requestURI ;# for no substitutions - used by ComputeRelatedLink - needed for search like: ref Journal and y 201[0-2]
set requestURI3 $requestURI ;# used by topForContinue to create the correct action (action2) of the "Display All" button - needed for search like: ref Journal and y 201[0-2] with more than 10 references
if {[info exists cgi(choice)] && [regexp {^(full|brief)$} $cgi(choice)]} {
# for 3 subst
regsub -all {\[} $requestURI {\\\\\\\\\\\\\[} requestURI ;# [ -> \\\\\\\[
regsub -all {\]} $requestURI {\\\\\\\\\\\\\]} requestURI ;# ] -> \\\\\\\]
regsub -all {\[} $requestURI3 {\\\\\[} requestURI3 ;# [ -> \\\[
regsub -all {\]} $requestURI3 {\\\\\]} requestURI3 ;# ] -> \\\]
} else {
# for 2 subst
regsub -all {\[} $requestURI {\\\\\[} requestURI ;# [ -> \\\[
regsub -all {\]} $requestURI {\\\\\]} requestURI ;# ] -> \\\]
}
# puts $top
if {[string equal {topSearch} $top]} {
set requestURI /col/$currentRep/doc/mirrorsearch.cgi?$requestURI
set requestURI2 /col/$currentRep/doc/mirrorsearch.cgi?$requestURI2 ;# used by ComputeRelatedLink
set requestURI3 /col/$currentRep/doc/mirrorsearch.cgi?$requestURI3 ;# used by topForContinue
} elseif {[string equal {topRecent} $top]} {
set requestURI /col/$currentRep/doc/mirror.cgi/Recent?$requestURI
set requestURI2 /col/$currentRep/doc/mirror.cgi/Recent?$requestURI2 ;# used by ComputeRelatedLink
} elseif {[string equal {topContributors} $top]} {
set requestURI /col/$currentRep/doc/mirror.cgi/Contributors?$requestURI
}
# puts $cgi(query)
# puts [array names cgi]
# puts $requestURI
# query2String (useful to restart a search in the case of an out-of-date
# reference)
# set query2String query2=$cgi(query)&choice2=$cgi(choice)&case2=$cgi(case)
# set query2String [eval $query2String]
set query2String [subst $query2String]
# puts $query2String
regsub -all -- {\+} $query2String {%2B} query2String
regsub -all { } $query2String {+} query2String
# accessdate
set accessDate [subst [GetAccessDate $accessDate]]
set numberOfReferences [llength $searchResultList]
# puts $numberOfReferences
# set searchResultList [join $searchResultList]
# puts [list $searchResultList
]
# LOOP OVER EACH ENTRY
set firstEntry 1
# puts --$searchResultList--
if [string equal {{}} $searchResultList] {
# puts "
empty search result" return ;# added by GJFB in 2010-09-09 (after an update, the similar list may be empty) } set output2 {} set i 0 # FOREACH # puts [fconfigure stdout] foreach searchResult $searchResultList { # puts 1 # set x 0; after 500 {set x 1}; vwait x ;# testing progressive loading # EXTRACT siteList citationKey metadataLastUpdate rep-i state sortedFieldValue foreach {siteList citationKey metadataLastUpdate rep-i state sortedFieldValue} $searchResult {break} # sortedFieldValue is not used in LoopOverEntries set site [lindex $siteList 0] # puts $site # puts "" ;# to have the previous puts displayed # puts [list ${rep-i} $metadataLastUpdate] # if [regexp {(.*):(.*)} $site m serverName serverPort] set remoteServerAddressWithIP [ReturnCommunicationAddress $site] foreach {serverName urlibPort} $remoteServerAddressWithIP {break} # if [catch \ {StartCommunication $serverName $urlibPort} \ localURLibClientSocketId] {continue} ;# catch is for unix # entry # puts [list $site == $serverAddress] # if {$site == "$serverAddress"} # if [string equal "$serverName $urlibPort" $serverAddress] { # currentRep is the current mirror repository set mirrorRep $currentRep } else { set mirrorRep {} } set cellBackgroundColor [lindex $cellBackgroundColors [expr $i%2]] ;# for the latest acquisitions # timeStamp set timeStamp [lindex $env(SERVICE_VERSION) 0] # the comments below are because includeReturnAddress must not be changed when working with search result page otherwise we don't execute again a search after an update # if {[info exists cgi(returnbutton)] && [string compare {no} $cgi(returnbutton)] == 0} { # set includeReturnAddress no ;# used with dynamic pages (for example: author index) # } # puts [info exists cgi(languagebutton)] set similarity $citationKey # EXTRA set extra [list $keywords $excludedFields 0 $env(REMOTE_ADDR) $numbering $outputFormat $cellBackgroundColor $timeStamp $pageFlag $includeReturnAddress $linkType $hideSimilarButton $targetValue $dateFieldName $siteFieldName $nameFormat $nameSeparator $accent $case $similarity $originalRepForSimilarity $imageFlag] # puts [list GetEntry ${rep-i} $mirrorRep $type $path $languageRep2 $extra] # SUBMIT # set entry [Submit $localURLibClientSocketId [list GetEntry ${rep-i} $mirrorRep $type $path $pID $extra]] ;# async # close $localURLibClientSocketId # if [catch {Execute $site [list GetEntry ${rep-i} $mirrorRep $type $path $pID $extra]} entry] {continue} # puts [list Execute $site [list GetEntry ${rep-i} $mirrorRep $type $path $languageRep2 $extra]] # puts "" ;# to have the previous puts displayed if [catch {Execute $site [list GetEntry ${rep-i} $mirrorRep $type $path $languageRep2 $extra]} entry] { # puts $entry # puts "" ;# to have the previous puts displayed # continue ;# commented by GJFB in 2013-09-15 to allow the display of the "unaccessible reference" message (useful when the command: socket -async mtc-m19.sid.inpe.br 800 returns the error: couldn't open socket: invalid argument) set entry {} ;# added by GJFB in 2013-09-15 to allow the display of the "unaccessible reference" message (useful when the command: socket -async mtc-m19.sid.inpe.br 800 returns the error: couldn't open socket: invalid argument) } # >>>1 the line below returns the error message # puts --$entry-- # set xxx --$entry-- # Store xxx C:/tmp/bbb.txt auto 0 a if [regexp {^<(.*)>$} $entry m errorMessage] { puts
[CallTrace]\n[join $errorMessage \n]# exit return } # puts --$entry-- if [catch {lindex $entry 0} metadataLastUpdate2] { puts $entry puts
[CallTrace]# exit return } # set entry [lindex $entry end] # Header # puts $header if $header { if $firstEntry { # display the commun search result # puts $numberOfEntries if [info exists cgi(query)] { set queryForDisplay [MountQueryForDisplay $cgi(query)] ;# used in subst below } if {$numberOfEntries == 1} { set output [subst [subst [subst [subst $${top}Singular]]]] } else { if {$flag && ![regexp Recent $top]} { # puts [subst $topForContinue] set output [subst [subst [subst $topForContinue]]] } else { # puts [subst [set ${top}Plural]] set output [subst [subst [subst [set ${top}Plural]]]] # set output [subst $${top}Plural] } } puts [SetFont $output] # puts \n # exit if {[info exists cgi(choice)] && $cgi(choice) == "site"} { # display the sites having the current repository set output $siteHelp puts $output } if {[info exists cgi(choice)] && [regexp {fullXML} $cgi(choice)]} { puts {} ;# "Courier New" doesn't work with some Netscape puts
} } set firstEntry 0 } # Header - end # puts ${rep-i}
# puts [list --$metadataLastUpdate-- --$metadataLastUpdate2--] if {(!$header || [string equal $metadataLastUpdate $metadataLastUpdate2]) || \ [info exists cgi(choice)] && $cgi(choice) == "site"} { set entry [lindex $entry end] set siteList2 {} # puts OK if {$numberOfSites != 1 && [info exists cgi(choice)] && \ [regexp {short|brief|site} $cgi(choice)]} { foreach site $siteList { lappend siteList2 "
<\;[ReturnHTTPHost $site]>\;" } } set siteList2 [join $siteList2] ## the if below is for Juliana's work (to allow the command subst) # if ![string equal {brief} $type] # regsub -all {\[} $entry {\[} entry ;# [ -> \[ regsub -all {\]} $entry {\]} entry ;# ] -> \] # regsub -all {\$} $entry {\$} entry ;# ] -> \] # # # encodingName set encodingName [Execute $remoteServerAddressWithIP [list GetEncodingName]] # puts $encodingName # puts $entry # set entry2 [encoding convertfrom $env(ENCODING_SYSTEM) [SetFont [subst [join $entry \n]]]] ;# uses query2String and siteList2 set entry2 [SetFont [join $entry \n]] ;# uses query2String and siteList2 # set entry2 [SetFont [subst [join $entry \n]]] ;# uses query2String and siteList2 if [string equal {utf-8} $encodingName] { set entry2 [encoding convertfrom utf-8 $entry2] ;# solves the accent problem - added by GJFB in 2010-11-16 - needed when displaying search result of plutao (see for example title of J8LNKAN8RW/38JE8FB in plutao (working with utf-8)) from banon-pc3 } # set entry2 [encoding convertfrom iso8859-1 [SetFont [subst [join $entry \n]]]] # puts $header if $header { # puts $entry # puts [join $entry \n] # >>>2 the line below returns the error message # catch {subst [join $entry \n]} xxx # catch {join $entry \n} xxx # puts $xxx # if {$i == 9} { # puts 2 # exit # } # puts $type if [regexp {^briefTitleAuthor} $type] { # briefTitleAuthor and briefTitleAuthorMisc puts $entry2 puts
# puts "" ;# to have the entry displayed at once if [info exists cgi(comment)] {puts $cgi(comment)} } else { if [regexp {^brief$} $type] { # brief # puts "
" # puts OK puts $entry2 # puts OK2 puts "" ;# to have the entry displayed at once # puts |
"
if {[info exists cgi(choice)] && $cgi(choice) == "fullbibtex"} {puts } puts $entry2 if {[info exists cgi(choice)] && $cgi(choice) == "fullbibtex"} {puts} puts |
"
# lappend output2 "
;# doesn't work properly with tcl pages (in this case, should be included in output2) # } } ;# end of foreach } # LoopOverEntries - end # ---------------------------------------------------------------------- # CreateOutput # Create output for MirrorSearch, CreateMirror, DisplaySearch and DisplayNumberOfEntries # (Contributors and The Most Recent) # if cgi(continue) exists when CreateOutput is called then # the maximumNumberOfEntries is ignored # Some argument examples: # $query == list GetMetadataRepositories $mirrorRep 3 $cgi(query) $cgi(accent) $cgi(case) 1 metadatalastupdate # $query2String == query2=$cgi(query)&choice2=$cgi(choice)&accent2=$cgi(accent)&case2=$cgi(case) # some option values are: # Recent, Contributors, Search ... # header value is 0 or 1 # 0 means drop the header (and footer - ... ) used with XML, GetSearchResult, ... # entryEvaluationFunctions value is 0 or 1 or a list of two unary operations (functions) and one binary operation # 0 means to ignore entry evaluation # 1 means just to return the number of entries (used by DisplayNumberOfEntries) # localSearch value is 0 or 1; 1 means to run just a local search (used to create local index - see StartService) # numbering value is {} or {numbering prefix}; {} means to do no numbering # outputFormat value is boolean or {html code} or a list of field names; used by briefTitleAuthorMisc and CreateDateTitleSite - default is used by briefTitleAuthorMisc # cellBackgroundColors value is a list of two colors; for example: {#EEEEEE #E3E3E3}; used by CreateDateTitleSite # page value is no or yes; used by CreateBriefTitleAuthorEntry # includeReturnAddress value is yes or no; set in GetSearchResult and used in CreateBriefEntry (see update link) # linkType used by CreateBriefTitleAuthorEntry (see CreateBriefTitleAuthorEntry) # passwordError value is 0 or 1; 1 means that a warning message must be displayed (set by the Form option) # targetValue is for example _blank, _self, ... # dateFieldName is metadatalastupdate or issuedate (used by CreateDateTitleSite) # siteFieldName is site or newspaper (used by CreateDateTitleSite) # returnButton value is no or yes # nameFormat value is short, familynamefirst or familynamelast (used by CreateBriefTitleAuthorEntry) # nameSeparator value is a string like {; } or { } (used by CreateBriefTitleAuthorEntry) proc CreateOutput { language languageRep1 languageRep2 query query2String option path {entryEvaluationFunctions 0} {maximumNumberOfEntries 10} {type brief} {header 1} {excludedFields {^$}} {localSearch 0} {numbering {}} {outputFormat 1} {cellBackgroundColors {#EEEEEE #E3E3E3}} {siteList {}} {page no} {includeReturnAddress yes} {linkType 0} {passwordError 0} {targetValue _blank} {dateFieldName metadatalastupdate} {siteFieldName site} {returnButton no} {cssFileURL {}} {nameFormat {short}} {nameSeparator {; }} } { global searchResultList global env global currentRep ;# mirror repository - used in subst, GetFrameName and MultipleSubmit - set by DisplaySearch for example global cgi global numberOfSites ;# set in MultipleSubmit global listOfSites ;# set in MultipleSubmit global numberOfSatisfiedQueries ;# set in this procedure and used in DisplayNumber global numberOfActiveSites ;# set in this procedure # global listOfActiveSites ;# set in MultipleSubmit global listOfInactiveSites ;# set in this procedure global siteWarning global singularSiteWarning global singularSiteWarning2 global pluralSiteWarning global pluralSiteWarning2 global searchWarning global errorMessage ;# used in LoopOverEntries global wrongPassword ;# used in LoopOverEntries global administratorUserName ;# used in LoopOverEntries global mirrorHomePageRepository ;# set in MirrorSearch global mirrorHomePageRep ;# defined in FindLanguage (utilities1.tcl) global numberOfEntries ;# used by DisplaySearch global col ;# used by CreateReturnButton (through LoopOverEntries) global homePath ;# used in enSearchResult.tcl, ... global currentVariableFileName ;# used in LoopOverEntries global currentProcedureName ;# set in MirrorSearch - needed when no references are found # global currentFileName ;# set in MirrorSearch - needed when no references are found global currentProcedureFileName ;# set in MirrorSearch - needed when no references are found global {full reference} ;# set in source xxSearchResult.tcl global {Password error. - Hidden entries not shown. } ;# set in source xxSearchResult.tcl global extraCode global {Eventually not all the expected references could be displayed because at least one site failed.} # global below are used with safe interpreter global bgColor background bgProperties fontTag fontTag2 global bodyForError global log global Return global Copy global topSearchSingular global topSearchPlural global No global { looking up in $numberOfActiveSites out of $numberOfSites sites.} # upvar environment environment ;# used in MultipleSubmit upvar submissionFormRep submissionFormRep ;# to access submission.js from topForContinue upvar submissionFormLanguageRep submissionFormLanguageRep ;# used in LoopOverEntries for sourcing xxFillingInstructions.tcl upvar submissionFormLanguage submissionFormLanguage ;# used in LoopOverEntries for sourcing xxFillingInstructions.tcl # extra code for copying to clipboard if {[info exists cgi(choice)] && [string equal {brief} $cgi(choice)]} { set extraCode { } } else { set extraCode {} } # shortVersionOfLanguage # used in subst in LoopOverEntries set shortVersionOfLanguage [string range $language 0 1] ;# pt-BR -> pt - used for the sherpa link only - added by GJFB in 2011-12-07 # puts [array get cgi] set top top$option ;# topRecent, topSearch, ... # localSite if [info exists env(SERVER_NAME)] { set localSite $env(SERVER_NAME):$env(SERVER_PORT) } else { # running with post # added by GJFB in 2015-08-22 # example: see "testing remote execution of DisplayNumberOfEntries" in cgi/test2 # not in use global serverAddress set localSite [ReturnHTTPHost $serverAddress] } # if {[string compare {} $cssFileURL] == 0} {set cssFileURL ../../../../../$languageRep1/doc/mirrorStandard.css} # puts {Content-Type: text/html} ;# needed when running a tcl page with safeflag == 0 # puts {} ;# needed when running a tcl page with safeflag == 0 # puts --$cssFileURL-- if [string equal {} $cssFileURL] {set cssFileURL http://$localSite/col/$languageRep1/doc/mirrorStandard.css} ;# default # puts $cssFileURL # puts [CallTrace] # puts $numbering # puts $currentRep # puts $query # puts # puts $query2String # puts [array get cgi] # puts $includeReturnAddress # puts $option set col ../../../../.. if ![info exists {full reference}] { # not within the slave interperter # source ../$col/$languageRep2/doc/mirror/${language}SearchResult.tcl source $homePath/col/$languageRep2/doc/mirror/${language}SearchResult.tcl } if 0 { if ![info exists bgColor] { # not within the slave interperter # bgColor, background and bgProperties foreach {bgColor background bgProperties fontTag fontTag2} [GetBg $languageRep1 $language] {break} } set background [subst $background] } # display # set display [subst [GetFrameName $mirrorHomePageRep]] set display [GetFrameName] # Compute siteList if {$type == "site"} { # the search is made over the local site and the sites # defined in the col/$env(LOCOINREP)/doc/@siteList.txt file set siteList [ComputeSiteList $env(LOCOINREP)] ;# see utilities1.tcl } elseif $localSearch { # set siteList $env(IP_ADDR):$env(SERVER_PORT) # set siteList [list [list $env(SERVER_NAME) $env(URLIB_PORT)]] set siteList [list [list $env(IP_ADDR) $env(URLIB_PORT)]] } # Compute siteList - end if ![info exists cgi(codedpassword1)] {set cgi(codedpassword1) {}} ;# added in 2010-07-08; needed for searching related entries of hidden entries # MULTIPLE SUBMIT # Store query C:/tmp/bbb.txt binary 0 a # puts $query # => list GetMetadataRepositories dpi.inpe.br/banon/1999/06.19.17.00 3 {ti carta} no no 0 metadatalastupdate repArray {} {} 11 {} # => list GetMetadataRepositories {} 4 {firstgr OBT and {metadatarepository, urlib.net/www/2012/08.10.20.21.38}} no no 1 metadatalastupdate repArray {} key 0 {} 0 # puts --$siteList-- if 0 { # doesn't work properly with tcl page because of possible multiple calls of CreateOutput # (for example, through multiple calls of DisplayNumberOfEntries) set searchResultList {} MultipleSubmit {} $query searchResultList 0 $siteList ;# level == 1 } else { # puts [list MultipleExecute $siteList $query 0 2] # set xxx [list MultipleExecute $siteList $query 0 2] # Store xxx C:/tmp/bbb.txt auto 0 a set scenario 0 set encodingName iso8859-1 ;# used to send queries # set searchResultList [MultipleExecute $siteList $query $scenario 2 $encodingName] ;# level 2 is for MultipleSubmit be able to reach currentRep foreach {searchResultList numberOfSatisfiedQueries listOfActiveSites} [MultipleExecute2 $siteList $query $scenario 2 $encodingName] {break} ;# level 2 is for MultipleSubmit be able to reach currentRep } # puts [list MultipleExecute $siteList $query 0 2] # puts # puts --$searchResultList-- # => {{vaio 19050} Pereira:2017:Of11Ma {2018:02.26.02.29.39 dpi.inpe.br/banon/1999/01.09.22.14 banon {D 2017}} urlib.net/www/2017/05.11.17.06.17-0 1 2} {{vaio 19050} Pereira:2017:Of8Ma {2018:02.26.02.28.55 dpi.inpe.br/banon/1999/01.09.22.14 banon {D 2017}} urlib.net/www/2017/05.07.20.29.25-0 1}-- # puts [llength $searchResultList] # set lll [llength $searchResultList] # Store lll C:/tmp/bbb.txt auto 0 a # Store searchResultList C:/tmp/bbb.txt auto 0 a # errorMessage if $passwordError { set errorMessage ${Password error. - Hidden entries not shown. } set wrongPassword yes } else { set errorMessage {} set wrongPassword no } # administrator name # regsub {@.*$} $env(SERVER_ADMIN) {} administratorUserName set administratorUserName administrator # set numberOfActiveSites $numberOfSatisfiedQueries set numberOfActiveSites [llength $listOfActiveSites] set listOfInactiveSites {} # puts $listOfSites # puts $listOfActiveSites # Store listOfSites C:/tmp/bbb.txt auto 0 a # Store listOfActiveSites C:/tmp/bbb.txt auto 0 a # listOfInactiveSites foreach site $listOfSites { foreach {serverName urlibPort} [ReturnCommunicationAddress $site] {break} if {[lsearch $listOfActiveSites "$serverName $urlibPort"] == -1} { lappend listOfInactiveSites "$serverName $urlibPort" } } if {$numberOfSites == 1} { set siteWarning "." ;# no translation needed set singularSiteWarning "\${The contributor of this data base is listed below.}" set pluralSiteWarning "\${The contributors of this data base are listed below.}" set singularSiteWarning2 "\${The most recent reference is listed below.}" set pluralSiteWarning2 "\${The \$numberOfReferences most recent references are listed below, the first one being the most recent.}" } else { set siteWarning "\${ looking up in \$numberOfActiveSites out of \$numberOfSites sites.}" set singularSiteWarning "\${The contributor of this data base, extracted from \$numberOfActiveSites out of \$numberOfSites sites, is listed below.}" set pluralSiteWarning "\${The contributors of this data base, extracted from \$numberOfActiveSites out of \$numberOfSites sites, are listed below.}" set singularSiteWarning2 "\${The most recent reference, extracted from \$numberOfActiveSites out of \$numberOfSites sites, is listed below.}" set pluralSiteWarning2 "\${The \$numberOfReferences most recent references, extracted from \$numberOfActiveSites out of \$numberOfSites sites, are listed below, the first one being the most recent.}" } set searchWarning "\${Eventually not all the expected references could be displayed because at least one site failed.}" if [regexp "^\{<(.*)>\}$" $searchResultList m errorMessage] { # the search expression has a syntax error if $header { if [info exists cgi(query)] { set output [subst [set bodyForError]] puts [SetFont $output] } else { # Recent puts [join $searchResultList] } return } else { # error [join $errorMessage \n] ;# doesn't work with some errorMessage error $errorMessage } } else { if ![info exists cgi(continue)] {set cgi(continue) no} # set xxx $cgi(continue) # Store xxx C:/tmp/bbb.txt auto 0 a # Store query C:/tmp/bbb.txt auto 0 a # Find numberOfEntries2 # used when CreateOutput is called from MirrorSearch # part of the fast mirror search code if {[string equal {no} $cgi(continue)] && \ [string equal {GetMetadataRepositories} [lindex $query 1]] && \ [lindex $query 3] == 3} { # query == list GetMetadataRepositories mirrorRep 3 set numberOfEntries2 0 foreach searchResult $searchResultList { # puts $searchResult set n 0 catch {foreach {1 2 3 4 5 n} $searchResult {break}} ;# searchResult may contain a list element in quotes followed by ":" instead of space (for example, when a computer issues an I/O error or a read-only file system) if ![string equal {} $n] { if [regexp {^\d+$} $n] { # n is integer incr numberOfEntries2 $n } else { # n is not integer if [string equal 1 $entryEvaluationFunctions] { ;# added by GJFB in 2017-07-12 - DisplayNumberOfEntries or DisplayCorrelationCoefficient in use # unexpected searchResult value (for example in the case of the cross communication problem) lappend log "CreateOutput: unexpected searchResult value: $searchResult\nthe query was: <$query>." return {} ;# added by GJFB in 2017-07-12 - return empty - used in DisplayNumber } else { error "CreateOutput: unexpected searchResult value: $searchResult\nthe query was: <$query>." ;# commented by GJFB in 2017-01-01 for testing # global replyName ;# added by GJFB in 2017-01-01 for testing - set in MultipleExecute # global $replyName ;# added by GJFB in 2017-01-01 for testing - set in MultipleExecute # set reply [set $replyName] ;# added by GJFB in 2017-01-01 for testing # unset $replyName ;# added by GJFB in 2017-01-01 for testing - previously in MultipleExecute # global replyTrace ;# added by GJFB in 2017-01-01 for testing - set in ConcatReplies error "CreateOutput: unexpected searchResult value: $searchResult\nthe query was: $query\nthe replyName was: $replyName\nits value was: $reply\nthe replyTrace was: $replyTrace" ;# added by GJFB in 2017-01-01 } } } # lappend log "CreateOutput: the searchResult value is: $searchResult\nthe query was: <$query>." ;# for testing log } # lappend log "xxx\n\n" ;# for testing log } # Find numberOfEntries2 - end if ![info exists cgi(fusion)] {set cgi(fusion) yes} # set xxx $cgi(fusion) # Store xxx C:/tmp/bbb.txt auto 0 a set returnWarning {} ;# capture the beginning of an error message returned by a site with problem if [string equal yes $cgi(fusion)] { # Make fusion of repeated entries # puts $searchResultList ;# >>> may return an error message # Store searchResultList C:/tmp/bbb.txt auto 0 a set searchResultList2 [lsort -command CompareStampRep-iState $searchResultList] ;# puts the original first (if any) when the stamps are the same set numberOfEntries [llength $searchResultList2] # Store numberOfEntries C:/tmp/bbb.txt auto 0 a set searchResultList {} for {set i 0} {$i < $numberOfEntries} {} { set searchResulti [lindex $searchResultList2 $i] ;# points to the original (if any) - otherwise to the faster site if [catch {list [lindex $searchResulti 0]} siteList] { # searchResulti has a wrong syntax (it probably contains an error message) regexp "^<(.*)>$" $searchResulti m returnWarning # set returnWarning "[lindex $returnWarning 0] $i" ;# keep just the first element of the error message set returnWarning "[lrange $returnWarning 0 1]" ;# keep just the first two elements of the error message - the first element now contains the server address - added by GJFB in 2013-01-06 (see ServeLocalCollection) incr i continue } set j [expr $i + 1] # in order to exit from the while below, it is assumed that searchResulti is never empty # and is a list with at least four elements (see CompareStampRep-i) # this is obtained through if {$reply != ""} within GetReply while {[CompareStampRep-i $searchResulti [lindex $searchResultList2 $j]] == 0} { set searchResultj [lindex $searchResultList2 $j] lappend siteList [lindex $searchResultj 0] incr j } set searchResult [lreplace $searchResulti 0 0 $siteList] lappend searchResultList $searchResult set i $j } # puts --$searchResultList-- # Store searchResultList C:/tmp/bbb.txt auto 0 a # puts $returnWarning # Make fusion of repeated entries - end } else { # Turn the site element a list element set searchResultList2 $searchResultList set searchResultList {} foreach searchResult $searchResultList2 { # set siteList [list [lindex $searchResult 0]] if [catch {list [lindex $searchResult 0]} siteList] { # searchResult has a wrong syntax (it probably contains an error message) regexp "^<(.*)>$" $searchResult m returnWarning set returnWarning [lindex $returnWarning 0] ;# keep just the first element of the error message continue } set searchResult2 [lreplace $searchResult 0 0 $siteList] lappend searchResultList $searchResult2 } # Turn the site element a list element - end } # Store searchResultList C:/tmp/bbb.txt auto 0 a # => {{{banon-pc3 800}} Nelson:2001:FoFlAm {2009:07.08.21.47.25 dpi.inpe.br/banon/1999/01.09.22.14 banon} dpi.inpe.br/banon/2001/03.25.16.16-5 0} {{{banon-pc3 800}} DaineseNoliAdam:2002:AnTrIn {2009:07.08.21.47.25 dpi.inpe.br/banon/1999/01.09.22.14 banon} dpi.inpe.br/banon/2001/03.25.16.16-16 0} {{{banon-pc3 800}} VenturaFons:2002:ReSeIm {2009:07.08.21.47.25 dpi.inpe.br/banon/1999/01.09.22.14 banon} dpi.inpe.br/banon/2001/03.25.16.16-10 0 7} # LLENGTH set numberOfEntries [llength $searchResultList] # Store numberOfEntries C:/tmp/bbb.txt auto 0 a # => 3 if {[info exists numberOfEntries2] && $numberOfEntries > $maximumNumberOfEntries} { # query == list GetMetadataRepositories mirrorRep 3 # part of the fast mirror search code set numberOfEntries $numberOfEntries2 } # Store numberOfEntries C:/tmp/bbb.txt auto 0 a # => 7 # Store entryEvaluationFunctions C:/tmp/bbb.txt auto 0 a # Return number of entries if [string equal 1 $entryEvaluationFunctions] {return $numberOfEntries} # Return number of entries - end if ![string equal 0 $entryEvaluationFunctions] { # entryEvaluationFunctions is a list of two unary operations (functions) and one binary operation # example of use: id NENDTJMTKW/37RKTD2 set function1 [lindex $entryEvaluationFunctions 0] set function2 [lindex $entryEvaluationFunctions 1] set operation [lindex $entryEvaluationFunctions 2] set sum1 0 set sum2 0 if 1 { foreach item $searchResultList { set sum1 [expr $sum1 + [apply $function1 $item]] set sum2 [expr $sum2 + [apply $function2 $item]] } return [apply $operation $sum1 $sum2] } else { # testing set item [lindex $searchResultList 0] set item2 [lindex $item 3] return [apply $function1 $item2] } } # puts --$searchResultList-- # puts [list $numberOfEntries $maximumNumberOfEntries $cgi(continue) $option] if ![info exists cgi(username)] {set cgi(username) {}} if ![info exists cgi(session)] {set cgi(session) {}} if ![info exists cgi(outputformat)] {set cgi(outputformat) {}} ;# added in 2010-10-06; needed by ComputeRelatedLink only ConditionalSet hideSimilarButton cgi(hidesimilarbutton) {no} ConditionalSet imageFlag cgi(imageflag) {1} ;# used to control the thumbnail display in CreateFullEntry ConditionalSet alternateQuery cgi(alternatequery) {} ;# used to display the second search (the green one) for continue ConditionalSet queryFieldType cgi(queryfieldtype) {} ;# used to display the second search (the green one) for continue # relatedFlag - used in LoopOverEntries - added by GJFB in 2010-11-02 set entrySearch [lindex $query 4] set relatedFlag [regexp {^related:(.*?):(.*?):(.*?):(.*?):(.*?):(.*?):} $entrySearch m metadataRep-i] set originalRepForSimilarity {} if {[info exists cgi(choice)] && $cgi(choice) != "fullXML" && [regexp no $cgi(continue)] && \ $numberOfEntries > $maximumNumberOfEntries || \ [string equal Recent $option]} { # display a limited number of references # puts [array get cgi] # set xxx [array get cgi] # set xxx $option # Store xxx C:/Users/gerald.banon/tmp/bbb auto 0 a if {[info exists cgi(sort)] && $cgi(sort) == "dateplus"} { # by date, most recent first set searchResultList [lsort -command CompareDate+ $searchResultList] } elseif {[info exists cgi(sort)] && [regexp {^page} $cgi(sort)]} { # by pages (page is accepted) - used by DisplaySearch to display summary set searchResultList [lsort -index 5 -integer $searchResultList] } elseif {[info exists cgi(sort)] && [regexp {^title$} $cgi(sort)]} { # by title set searchResultList [lsort -index 5 $searchResultList] } elseif {[info exists cgi(sort)] && [regexp {^issuedate$} $cgi(sort)]} { # by issuedate set searchResultList [lsort -index 5 -decreasing $searchResultList] } elseif {[info exists cgi(sort)] && [string equal {lastupdate} $cgi(sort)]} { # by lastupdate # used by xxAbout.html when calling ReturnTheMostRecentEntries CreateOutput LoopOverEntries GetEntry CreateDateTitleSite set searchResultList [lsort -command CompareLastUpdateStamp $searchResultList] } else { set entrySearch [lindex $query 4] # if [regexp {^related:(.*?):(.*?):(.*?):(.*?):(.*?):(.*?):} $entrySearch m metadataRep-i] # if $relatedFlag { # by similarity set originalRepForSimilarity ${metadataRep-i} ;# used by LoopOverEntries set searchResultList [lsort -real -decreasing -index 1 $searchResultList] ;# added by GJFB in 2010-11-02 } else { # by stamp (metadatalastupdate) set searchResultList [lsort -command CompareStamp $searchResultList] } } set searchResultList [lrange $searchResultList 0 [expr $maximumNumberOfEntries - 1]] LoopOverEntries $query2String $type $numberOfEntries $top $path $header $excludedFields 1 $numbering $outputFormat $cellBackgroundColors $page $includeReturnAddress $linkType $hideSimilarButton $targetValue $dateFieldName $siteFieldName $returnButton $cssFileURL $nameFormat $nameSeparator $originalRepForSimilarity $imageFlag $alternateQuery $queryFieldType if $header { # if {[info exists cgi(choice)] && $cgi(choice) == "fullbibtex"} if {[info exists cgi(choice)] && [regexp {fullXML} $cgi(choice)]} { puts puts } # puts "
|