# Utilities3 # Copyright for URLibService (c) 1995 - 2021, # by Gerald Banon. All rights reserved. # used exclusively within the slave interperter (see CreateTclPage) # ---------------------------------------------------------------------- # DisplaySearch # used indirectly by CreatePage (createpage.tcl) # localSearch values are 0 or 1; 1 means to run just a local search (used to created local index - see StartService) # numbering values are {} or {numbering prefix}; {} means to do no numbering # siteList is the list of sites where to make the search; empty site list means the default list defined in $loBiMiRep/doc/@siteList.txt # item examples of siteList: # banon-pc2.dpi.inpe.br:1905 (old usage) # {banon-pc2.dpi.inpe.br 19050} # banon-pc2.dpi.inpe.br:80 (old usage) # {banon-pc2.dpi.inpe.br 800} # {150.163.2.174 800} # {sbsr.sid.inpe.br 802} # linkType used by CreateBriefTitleAuthorEntry (see CreateBriefTitleAuthorEntry) # displayEverything values are 0 or 1 # 0 means to display only the title # (not the entries); used to create lists of field values like author lists # used with value 0 just by DisplayMultipleSearch # sort values are key, dateplus, dateminus, page or title # outputFormat is used by briefTitleAuthor to control the misc variable # targetValue is for example _blank, _self, ... # mirrorRep useful to open the correct form when using update in a search result produced by DisplaySearch # (overwrite the current mirror, i.e., the mirror used when calling DisplaySearch) # if empty, the current mirror is used ## not used - targetFrame is for example _parent (useful to return to the update knowledgement in the correct frame after using update in a search result) # nameFormat value is short, familynamefirst or familynamelast (used by CreateBriefTitleAuthorEntry) # nameSeparator value is a string like {; } or {
} (used by CreateBriefTitleAuthorEntry) # latexOptionList values is a list of options among the following options: {createpdffile createeditedbook createpagelistfile}} # createpagelistfile option doesn't work with safe interp (because of package require http - see RunRemoteCGIScript) # multipleSearch value is 0 (default) or 1 # 0 means that entrySearch is a search expression # 1 means that entrySearch is a list of search expressions (1 is used in DisplayDuplicates) # imageFlag value is 0 or 1; 1 means to display the thumbnail (if any) # displayHiddenRecord value is 0 or 1; 1 means to display hidden records # searchInputValue is a search expression - set in URL (used in mirrorHomePage.html, CreateMirror, LoopOverEntries, GetEntry and CreateBriefEntry) # childIdentifier (ex: mirrorIdentifier) is an IBIp or IBIn - set in MirrorSearch and used in CreateBriefEntry # forceRecentFlag value is 0 (default) or 1 - 1 set in MirrorRecent is used to return to 'The most Recent' after clicking in Return (<) in the horizontal upper menu (see Get) # forceHistoryBackFlag value is 0 or 1 (default) - 0 set in UpdateBody (called in MountHTMLPage) - added by GJFB in 2023-07-14 proc DisplaySearch { searchExpression {accent no} {case no} {choice full} {title {}} {excludedFields {^$}} {localSearch 0} {numbering {}} {siteList {}} {page no} {linkType 0} {displayEverything 1} {sort key} {outputFormat 1} {targetValue _blank} {mirrorRep {}} {nameFormat {short}} {nameSeparator {; }} {latexOptionList {}} {multipleSearch {0}} {imageFlag 1} {displayHiddenRecord 0} {searchInputValue {}} {childIdentifier {}} {forceRecentFlag 0} {forceHistoryBackFlag 1} } { global numberOfEntries ;# set in CreateOutput global currentRep ;# mirror - used in LoopOverEntries by GetEntry - set and reset in this procedure global thisRepository ;# set in CreatePage or Submit # global homePath global storeTclPage ;# set by TestForTclPageUpdate # global dataList ;# set by XML2tcl global authorIndexCounter ;# set by CreateTclPageFile and used by DisplaySearch # global localSite # global tcl_platform global targetFileType ;# set by CreatePage or ProcessTclPage global serverAddressWithIP ;# set in Submit global preambleContent ;# set in DisplayMultipleSearch and DisplaySearch global documentContent ;# set in DisplayMultipleSearch and DisplaySearch global pageListContent ;# set in DisplayMultipleSearch and DisplaySearch # puts {Content-Type: text/html} # puts {} # puts --$siteList-- set currentRep2 $currentRep ;# mirror if ![info exists targetFileType] {set targetFileType {}} ;# needed when DisplaySearch is called in xxDocContent.html if ![string equal {} $mirrorRep] { # puts {Content-Type: text/html} # puts {} # puts [CallTrace] set currentRep $mirrorRep ;# used in LoopOverEntries by GetEntry } set entryList [GetSearchResult $searchExpression $accent $case \ $choice $sort $excludedFields \ $localSearch $numbering $outputFormat \ {} $siteList \ $page $linkType $targetValue \ metadatalastupdate site Search 0 \ $nameFormat $nameSeparator $multipleSearch \ $imageFlag $displayHiddenRecord $searchInputValue \ $childIdentifier $forceRecentFlag $forceHistoryBackFlag] ;# forceHistoryBackFlag added by GJFB in 2023-07-14 # puts {Content-Type: text/html} # puts {} # puts $entryList # Store entryList C:/tmp/bbb.txt binary 0 a # Create the contents of the LaTeX files @preamble.inc and @document.inc, and pageList file # @preamble.inc is used to produce edited book (see for example col/iconet.com.br/banon/2007/03.11.17.27/doc/ISMM2007book/book.tex) # @document.inc is used to produce edited book (see for example col/iconet.com.br/banon/2007/03.11.17.27/doc/ISMM2007book/book.tex) # pageList.txt is used to produce page numbering # entry schema (with choice == briefTitleAuthor) # TABLE,ALIGN {0 1 1} # TABLE,BORDER {0 1 3} # TABLE,CELLPADDING {0 1 5} # TABLE,CELLSPACING {0 1 7} # TABLE,class {0 1 9} # TABLE.TR.TD,class {0 2 0 2 0 1 1} # TABLE.TR.TD.A,HREF {0 2 0 2 0 2 0 1 1} # TABLE.TR.TD.A,TARGET {0 2 0 2 0 2 0 1 3} # TABLE.TR.TD.A.X {0 2 0 2 0 2 0 2 0 2} # TABLE.TR.TD.A.I {0 2 0 2 0 2 0 2 2 2} # TABLE.TR.TD.FONT,CLASS=titleAuthorFontRepository {0 2 0 2 0 2 2 1 1} # TABLE.TR.TD.FONT {0 2 0 2 0 2 2 2} # TABLE.TR.TD,class {0 2 0 2 1 1 1} # TABLE.TR.TD,VALIGN {0 2 0 2 1 1 3} # TABLE.TR.TD.X {0 2 0 2 1 2 1 2} if {(![string equal {} $latexOptionList] || [regexp -nocase {tex} $targetFileType]) && \ [regexp {TitleAuthor} $choice]} { set preambleLineList {} set documentLineList {} set latexEntryList {} ;# e.g., for Table of Contents # FOREACH foreach entry $entryList { parseXML::XML2tcl $entry 0 set url [parseXML::ExtractData {{0 2 0 2 0 2 0 1 1}}] set workTitle [parseXML::ExtractData {{0 2 0 2 0 2 0 2 0 2}}] set authorList [parseXML::ExtractData {{0 2 0 2 0 2 0 2 2 2}}] set repositoryID [parseXML::ExtractData {{0 2 0 2 0 2 2 2}}] # repository regsub {ID: } $repositoryID {} repository set page [parseXML::ExtractData {{0 2 0 2 1 2 1 2}}] # Compute latexEntry # e.g., for Table of Contents if [regexp -nocase {tex} $targetFileType] { set authorList2 [split $authorList {;}] # set authorList3 [FormatAuthorName $authorList2 {} {short familynamelast} 0] # set authorList4 [FormatAuthorList $authorList3 {,} {0} {0} {and}] # set authorList3 [FormatAuthorName $authorList2 {} {short} 0] ;# Banon, Gerald J. F. # set authorList3 [FormatAuthorName $authorList2 {} {short}] ;# Banon, G. J. F. set authorList3 [FormatAuthorName $authorList2 {} $nameFormat] ;# Banon, G. J. F. set authorList4 [FormatAuthorList $authorList3 {;}] regsub {\ } $page {} page # set latexEntry "\\begin{Entry}\\href{$url}{$workTitle\\\\*\\emph{$authorList4}}\\hfill $page\\end{Entry}\n" set latexEntry "\\begin{flushleft}\\vspace{-4pt}\\renewcommand{\\baselinestretch}{0.9}\\small \\begin{tabular}{b{10.5cm}b{1cm}}\\raggedright\\href{$url}{$workTitle}&\\href{$url}{\\hfill$page}\\\\ \\raggedright\\emph{$authorList4}&\\end{tabular}\n \\end{flushleft}" lappend latexEntryList $latexEntry } # Compute latexEntry - end # Update preambleLineList and documentLineList if {[lsearch $latexOptionList {createeditedbook}] != -1} { set authorList2 [split $authorList {;}] set names {} ;# for author index set authorList3 {} ;# for the table of contents foreach name $authorList2 { set name2 [string trim $name] append names "\\authorindex{[join [KeepInitials [list $name2]]]}" lappend authorList3 $name2 } lappend preambleLineList "\\includepreamble{$repository}" # line for the author index regsub {\. +([A-Z])\.} $names {.\\,\1.} names2 ;# Banon, J. F. G. -> Banon, J.\,F. G. regsub {\. +([A-Z])\.} $names2 {.\\,\1.} names2 ;# Banon, J.\,F. G. -> Banon, J.\,F.\,G. regsub {\. +([A-Z])\.} $names2 {.\\,\1.} names2 lappend preambleLineList "\\newcommand{\\authorR[Roman $authorIndexCounter]}{$names2}" # line for the table of contents # set authorList4 [FormatAuthorName $authorList3 {} familynamelast] set authorList4 [FormatAuthorName $authorList3 {} {short familynamelast} 0] set authorList5 [FormatAuthorList $authorList4 {,} {0} {0} {and}] regsub {\. +([A-Z])\.} $authorList5 {.\\,\1.} authorList6 ;# Gerald J. F. Banon -> Gerald J.\,F. Banon regsub {\. +([A-Z])\.} $authorList6 {.\\,\1.} authorList6 lappend preambleLineList "\\newcommand{\\authorListR[Roman $authorIndexCounter]}{$authorList6}" lappend preambleLineList "\\newcommand{\\repositoryR[Roman $authorIndexCounter]}{$repository}" incr authorIndexCounter lappend documentLineList "\\includedocument{$repository}" } # Update preambleLineList and documentLineList - end # Update pageListContent if {[lsearch $latexOptionList {createpagelistfile}] != -1} { # createpagelistfile # repName ## regexp "http://$localSite/col/(.*/.*/.*/.*)/doc/(.*)" $url m repName targetFile ## linkType must be 0 or 4 # regexp "col/(.*/.*/.*/.*)/doc/(.*)" $url m repName targetFile # linkType must be 8 regexp "http://urlib.net/(.*/.*/.*/.*)" $url m repName lappend pageListContent $repName } # Update pageListContent - end } # Update the contents of @preamble.inc and @document.inc # @preamble.inc and @document.inc are used in book.tex if {[lsearch $latexOptionList {createeditedbook}] != -1} { # set fileContent [join $preambleLineList \n] # Store fileContent $homePath/col/$thisRepository/doc/@preamble.inc auto 0 a # set fileContent [join $documentLineList \n] # Store fileContent $homePath/col/$thisRepository/doc/@document.inc auto 0 a lappend preambleContent [join $preambleLineList \n] lappend documentContent [join $documentLineList \n] } # Update the contents of @preamble.inc and @document.inc } # Create the contents of the LaTeX files @preamble.inc and @document.inc, and pageList file - end if [regexp -nocase {tex} $targetFileType] { # SUBST set currentRep $currentRep2 return "[subst $title]\n[join $latexEntryList \n]" } if [regexp {^brief$} $choice] { set output [join $entryList \n]
\n } else { set output [join $entryList
\n]
\n } if {$numberOfEntries == 0} { set currentRep $currentRep2 return } if ![string equal {} $title] { # SUBST if $displayEverything { set output "[subst $title]
\n$output" } else { set output [subst $title] } } set currentRep $currentRep2 return $output } # DisplaySearch - end # ---------------------------------------------------------------------- # Roman # used in content.tex proc Roman {i {capitalLetter 0}} { set result {} if $capitalLetter { set list {1000 M 900 CM 500 D 400 CD 100 C 90 XC 50 L 40 XL 10 X 9 IX 5 V 4 IV 1 I} } else { set list {1000 m 900 cm 500 d 400 cd 100 c 90 xc 50 l 40 xl 10 x 9 ix 5 v 4 iv 1 i} } foreach {value roman} $list { while {$i >= $value} { append result $roman incr i -$value } } return $result } # Roman - end # ---------------------------------------------------------------------- # DisplayLetterBar # used to display a letter bar # used in author index ## repName is the name of a repository containing the a.gif, a2.gif, b.gif, b2.gif, ... ## flagMessage example: Atalho para sobrenomes iniciados pela letra $firstLetter2 # fieldNameList content must not be abbreviated # Examples: # author # {author editor} proc DisplayLetterBar {searchExpression {accent no} {case no} {siteList {}} {fieldNameList {author}}} { global env global currentRep global siteMetadataRepList ;# set in MultipleSubmit global homePath # global cgi ;# commented by GJFB in 2015-06-18 global accentTable2 # array set environment [array get env] ;# used in MultipleSubmit when siteList == {} # mirrorRep set mirrorRep $currentRep ;# not used in GetMetadataRepositories # set query [list list GetMetadataRepositories $mirrorRep 1 $searchExpression $accent $case 0 metadatalastupdate repArray $cgi(codedpassword1)] ;# commented by GJFB in 2015-06-18 - getting hidden metadata repository is not used set query [list list GetMetadataRepositories $mirrorRep 1 $searchExpression $accent $case 0 metadatalastupdate repArray] ;# added by GJFB in 2015-06-18 - getting shown metadata repository is enough - no password needed # MULTIPLE SUBMIT set siteMetadataRepList {} MultipleSubmit {} $query siteMetadataRepList 0 $siteList set URLibServiceRepository $env(URLIB_SERVICE_REP) # source $homePath/col/$URLibServiceRepository/doc/accentTables.tcl ;# accentTable2 set firstLetterList {} foreach siteMetadataRep $siteMetadataRepList { foreach {site rep-i} $siteMetadataRep {break} foreach fieldName $fieldNameList { foreach creatorName [Execute $site [list GetFieldValue ${rep-i} $fieldName]] { regexp {^.} $creatorName firstLetter if [info exists accentTable2($firstLetter)] {set firstLetter $accentTable2($firstLetter)} set firstLetter [string toupper $firstLetter] lappend firstLetterList $firstLetter } } } return [lsort -unique $firstLetterList] } # DisplayLetterBar - end # ---------------------------------------------------------------------- # SetFirstCreatorFlag # used in DisplayMultipleSearch and DisplayShortCut only # returns the value is 0 or 1 # 1 means to work with the first creator whose group belongs to subsetOfGroups2 # code to be used to create firstCreatorFlag and the new fieldNameList (e.g., {author editor}) from subsetOfGroups2 and the current fieldNameList (e.g., {firstauthor firsteditor}) proc SetFirstCreatorFlag {subsetOfGroups2} { upvar fieldNameList fieldNameList set firstCreatorFlag 0 if ![string equal {} $subsetOfGroups2] { set firstCreatorFlag 1 ;# work with the first creator whose group belongs to subsetOfGroups2 set fieldNameList2 {} foreach fieldName $fieldNameList { if ![regsub {^first} $fieldName {} fieldName2] {set firstCreatorFlag 0; break} lappend fieldNameList2 $fieldName2 } if $firstCreatorFlag { set fieldNameList $fieldNameList2 ;# new fieldNameList without the prefix "first" } } return $firstCreatorFlag } # SetFirstCreatorFlag - end # ---------------------------------------------------------------------- # DisplayShortCut # used to display a short cut # used in summary # fieldNameList content must not be abbreviated # Examples: # type # {author editor} (not tested) # subsetOfGroups not in use and not tested # for subsetOfGroups2 see DisplayMultipleSearch proc DisplayShortCut { searchExpression {accent no} {case no} {siteList {}} {fieldNameList {type}} {subsetOfGroups {}} {subsetOfGroups2 {}} } { global currentRep upvar firstCreatorList firstCreatorList # safeFlag must be 0 (see utilities1.tcl) # puts [CallTrace] # => # call stack # 1: DisplayShortCut {firstgr CTE or firstgr COMP} no no {{gjfb 19050}} {firstauthor firsteditor} {} {{SPG} {LAC-CTE DSR-OBT}} # call stack - end set firstCreatorFlag [SetFirstCreatorFlag $subsetOfGroups2] ;# might drop the prefix "first" in fieldNameList # puts $firstCreatorFlag # => 1 set test 0 set siteInfoFlag 0 if $firstCreatorFlag { set firstCreatorList [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList $test $siteInfoFlag $subsetOfGroups $subsetOfGroups2 $firstCreatorFlag] # puts $firstCreatorList # => _Galvíncio,_Josiclêda_Domiciano {} _Aa,_Yy {} _Eras,_Eduardo_Rohde urlib.net/www/2012/02.06.20.03.37 array set firstCreatorArray $firstCreatorList set fieldValueList [lsort [array names firstCreatorArray]] } else { set fieldValueList [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList $test $siteInfoFlag] } # puts $fieldValueList # => _Aa,_Yy _Eras,_Eduardo_Rohde _Galvíncio,_Josiclêda_Domiciano set i 1 set output {} foreach item $fieldValueList { # lappend output "$item
\n" regsub -all {_} $item { } item2 ;# needed for field like author, editor, programmer, committee, ... set item2 [string trimleft $item2] ;# drop beginning blank space - added by GJFB in 2014-11-07 lappend output $i lappend output $item2 incr i } # puts $output # => 1 {Aa, Yy} 2 {Eras, Eduardo Rohde} 3 {Galvíncio, Josiclêda Domiciano} # lappend output "
\n" # set output [join $output {}] return $output } # DisplayShortCut - end # ---------------------------------------------------------------------- # DisplayMultipleSearch # called by CreatePage # used to display summary, author index, ... # searchExpression must be of the type # searchExpression2 is a second search expression used # example: # searchExpression == ref thesis # searchExpression2 == y 2008 # choice value may be, for example: briefTitleAuthor, briefTitleAuthorMisc # fieldNameList content must not be abbreviated # Examples: # author # {author editor} # example: DisplayMultipleSearch {type, * and ref conference} type # secondSearchExpression (if not empty) is used in place of searchExpression # when displaying the search for each item found by ComputeFieldValueList # used only when displayEverything == 1 # example: # searchExpression == ref Conference # fieldNameList == author # secondSearchExpression == {} # DisplayMultipleSearch returns the works of each conference paper author # example: # searchExpression == ref Thesis # fieldNameList == author # secondSearchExpression == y 2008 # DisplayMultipleSearch returns the 2008 works of each thesis author # siteList is the list of sites where to make the search; # if siteList is empty then the site list is given $currentRep/doc/@siteList.txt # if displayEverything is 0 or test is 1 then siteList is ignored (i.e., is equivalent to empty) # item examples of siteList: # banon-pc2.dpi.inpe.br:1905 (old usage) # {banon-pc2.dpi.inpe.br 19050} # banon-pc2.dpi.inpe.br:80 (old usage) # {banon-pc2.dpi.inpe.br 800} # {150.163.2.174 800} # {sbsr.sid.inpe.br 802} # displayEverything values are 0 or 1 # 0 means to display only the values of the field specified in fieldNameList # (not the entries); used to create lists of field values like author lists # linkType used by CreateBriefTitleAuthorEntry (see CreateBriefTitleAuthorEntry) # test is used as to exibit the value field list only # test value is 0 (default) or 1 # 1 means to exibit the field value list only (is much faster - used to check the list) # targetValue is for example _blank, _self, ... # sortedFieldName is the name of the field used in CreateOutput to sort the entries # examples of sortedFieldName are key (default), pages (page is accepted), title, date ... # outputFormat is used by briefTitleAuthorMisc to define a list of field names # among the field names: {e-mailaddress update affiliation abstract} # mirrorRep useful to open the correct form when using update in a search result produced by DisplaySearch # (overwrite the current mirror, i.e., the mirror used when calling DisplayMultipleSearch) # if empty, the current mirror is used ## not used - targetFrame is for example _parent (useful to return to the update knowledgement in the correct frame after using update in a search result) # nameFormat value is short, familynamefirst or familynamelast (used by CreateBriefTitleAuthorEntry) # nameSeparator value is a string like {; } or {
} (used by CreateBriefTitleAuthorEntry) # latexOptionList values is a list of options among the following options: {createpdffile createeditedbook createpagelistfile}} # createpagelistfile option doesn't work with safe interp (because of package require http - see RunRemoteCGIScript) # minimumNumberOfSearchResultToDisplay # value is a natural number (default is 1) # used only when displayEverything == 1 # command is a tcl command to modify the fieldValueSearch # command example: regsub {::} $fieldValueSearch {:*:} # fieldValueSearch is the search expression obtained by union # (using the operation or) of pair (field name, field value) # where field value is one of the field value found when running # the searchExpression # imageFlag value is 0 or 1; 1 means to display the thumbnail (if any) # subsetOfGroups value is a list of groups, example: {DPI DSR} # used with first group, for example, searching for firstgr DPI returns the entries # for which DPI is the first group within the groups DPI and DSR # not in use and not tested # subsetOfGroups2 value is empty or a list of group values, for example: {DPI DSR} or OBT # used to work with the first author which belongs to a given group or subset of groups # when subsetOfGroups2 is not empty, the fieldNameList must be at most: {firstauthor firsteditor} # searchInputValue is a search expression - set in URL (used in mirrorHomePage.html, CreateMirror, LoopOverEntries, GetEntry and CreateBriefEntry) # childIdentifier (ex: mirrorIdentifier) ia an IBIp or IBIn - set in MirrorSearch and used in CreateBriefEntry # forceRecentFlag value is 0 (default) or 1 - 1 set in MirrorRecent is used to return to 'The most Recent' after clicking in Return (<) in the horizontal upper menu (see Get) # referenceType not used # example of sequence of calls after pressing the Run button # Submit # ProcessTclPage # CreateTclPageFile # CreateTclPage # DisplayMultipleSearch (run within a tcl interpreter) # DisplaySearch # GetSearchResult # CreateOutput # LoopOverEntries # GetEntry (called via socket) # CreateBriefTitleAuthorEntry # CreatePage (called via http) proc DisplayMultipleSearch { searchExpression fieldNameList {accent no} {case no} {siteList {}} {page no} {choice briefTitleAuthor} {linkType 0} {displayEverything 1} {test 0} {title {\$fieldValue3 (\\\$numberOfEntries)
}} {letter {\$firstLetter

}} {targetValue _blank} {sortedFieldName {key}} {outputFormat {update e-mailaddress}} {mirrorRep {}} {referenceType {}} {year {}} {mappingDomainName {}} {attributeList {}} {nameFormat {short}} {nameSeparator {; }} {latexOptionList {}} {secondSearchExpression {}} {minimumNumberOfSearchResultToDisplay 1} {command {}} {imageFlag 1} {subsetOfGroups {}} {subsetOfGroups2 {}} {searchInputValue {}} {childIdentifier {}} {forceRecentFlag 0} } { global env # global homePath global currentRep global language languageRep1 languageRep2 # global errorLogPath ;# set in CreateTclPageFile global siteMetadataRepList ;# set in DisplayLetterBar or MultipleSubmit global numberOfEntries ;# set in CreateOutput global totalNumberOfEntries ;# used in CreateTclPage # global cgi ;# for the case of mappings between field values global serverAddressWithIP ;# for the case of mappings between field values global storeTclPage ;# set by TestForTclPageUpdate global thisRepository ;# set in CreatePage or Submit global authorIndexCounter ;# set by DisplayMultipleSearch and used by DisplaySearch global URLibServiceRepository ;# set by CreatePage or Submit global accentTable2 global log global preambleContent ;# set in DisplayMultipleSearch and DisplaySearch global documentContent ;# set in DisplayMultipleSearch and DisplaySearch global pageListContent ;# set in DisplayMultipleSearch and DisplaySearch global numberOfSites ;# set in MultipleSubmit global numberOfSatisfiedQueries ;# set in MultipleSubmit global translationTable ;# used in some titles global clientServerAddressWithIP ;# set in Get otherwise in CreateTclPage global progressKey ;# set in Get otherwise in CreateTclPage global writeUserCodedPassword upvar cgi cgi ;# for the case of mappings between field values # upvar displayTable2 displayTable2 ;# for the case of mappings between field values upvar displayTable displayTable ;# for the case of mappings between field values upvar boxTable boxTable ;# for the case of mappings between field values upvar optionTable2 optionTable2 ;# for the case of mappings between field values upvar attributeTable attributeTable # set xxx [CallTrace] # Store xxx C:/tmp/bbb.txt binary 0 a # => # searchSite set searchSite $env(SERVER_NAME):$env(SERVER_PORT) set currentRep2 $currentRep if ![string equal {} $mirrorRep] { set currentRep $mirrorRep ;# used in LoopOverEntries by GetEntry } set output {} # set latexOutput {} set totalNumberOfEntries 0 if $test { # a test # set output2 $fieldValueList # puts --$attributeList-- # => ---- # puts --$mappingDomainName-- # => --x-- set unifyingOrSettingFlag [expr ![string equal {} $attributeList] || ![string equal {} $mappingDomainName]] if $unifyingOrSettingFlag { # unifying or setting # puts --$siteList-- # puts --$searchExpression-- # => {index 0} set fieldValueList [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList 1 1] ;# added by GJFB in 2013-02-18 in order to get the number of duplicates set fieldValueList [lsort -dictionary -index 0 $fieldValueList] } else { # neither unifying nor setting set fieldValueList [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList 1] ;# added by GJFB in 2013-02-18 in order to get the number of duplicates set fieldValueList [lsort -unique -command CompareDiscardingAccentCase $fieldValueList] } # puts --$fieldValueList-- # => --{_Acta {gjfb 800}} {_Acta_Astronautica {gjfb 800}}-- # Mount fieldValueList2 # set fieldValueList {{a A} {b B1} {b B2} {c C1} {d D1} {e E1} {e E2} {e E3}} # set fieldValueList2 # => # {1 a A} {2 b {B1 B2}} {1 c C1} {1 d D1} {3 e {E1 E2 E3}} set fieldValueList2 {} set i 0 set itemSiteList {} if [info exists previousItem] {unset previousItem} foreach item $fieldValueList { if [info exists previousItem] { if [string equal [lindex $previousItem 0] [lindex $item 0]] { incr i lappend itemSiteList [lindex $item 1] } else { lappend fieldValueList2 [list $i [lindex $previousItem 0] [lsort -unique $itemSiteList]] set previousItem $item set i 1 set itemSiteList [list [lindex $previousItem 1]] } } else { set previousItem $item set i 1 set itemSiteList [list [lindex $previousItem 1]] } } if ![string equal {} $fieldValueList] { lappend fieldValueList2 [list $i [lindex $item 0] [lsort -unique $itemSiteList]] } # puts --$fieldValueList2-- # => --{1 _Acta {{gjfb 800}}} {1 _Acta_Astronautica {{gjfb 800}}}-- # Mount fieldValueList2 - end # puts $fieldNameList # => course if {![string equal {} $mappingDomainName] && [string equal {course} $fieldNameList]} { # for unifying field values and field name course - added by GJFB in 2021-07-28 to ajust searchExpression2 in the URL used the each blue box (see BGCOLOR=#AAAAEE) and display the right number of records set courseList {} foreach item $fieldValueList2 { foreach {i item itemSiteList} $item {break} lappend courseList $item } set iterationNumber 0 } # puts $courseList # => AST AST-CEA-SPG-INPE-MCTI-GOV-BR AST-SPG-INPE-BR SER-SRE-SPG-INPE-MCTI-GOV-BR regsub -all {\s} $siteList {+} siteList2 if ![info exists cgi(codedpassword1)] {set cgi(codedpassword1) {}} ;# codedpassword1 not yet tested foreach item $fieldValueList2 { foreach {i item itemSiteList} $item {break} ;# added by GJFB in 2013-02-18 because fieldValueList was changed to fieldValueList2 in the foreach set fieldValue $item regsub -all { and | or } $fieldValue { } fieldValue ;# 'and' & 'or' must not be part of the field value set searchList {} foreach fieldName $fieldNameList { if [string equal {keywords} $fieldName] { regsub -all { } $fieldValue {_} keywords set fieldValue2 _$keywords } else { set fieldValue2 $fieldValue } if [string equal {referencetype} $fieldName] { lappend searchList "$fieldName $fieldValue2," ;# referencetype Book, } else { lappend searchList "$fieldName $fieldValue2" } } # puts --$searchList-- # => --{course AST}-- if {![string equal {} $mappingDomainName] && [string equal {course} $fieldNameList]} { # for unifying field values and field name course - added by GJFB in 2021-07-28 to ajust searchExpression2 in the URL used the each blue box (see BGCOLOR=#AAAAEE) and display the right number of records set currentCourse [lindex $courseList $iterationNumber] if ![regexp -- {-} $currentCourse] { set otherCourse [lreplace $courseList $iterationNumber $iterationNumber] set searchList2 {} foreach course $otherCourse { if ![regexp $currentCourse $course] {continue} lappend searchList2 "course $course" } set searchList [list [join $searchList][expr [string equal {} $searchList2]?{}:{ and not \{[join $searchList2 { or }]\}}]] } incr iterationNumber } # puts --$searchList-- # => --{course AST} and not {course AST-CEA-SPG-INPE-MCTI-GOV-BR or course AST-SPG-INPE-BR}-- # => --{course AST-CEA-SPG-INPE-MCTI-GOV-BR}-- # searchExpression1 # set searchExpression1 "$searchExpression and ([join $searchList { or }])" # set searchExpression1 "$searchExpression and {[join $searchList { or }]}" ;# doesn't work when searchList is: journal Acta_&_astronautica(A) set searchExpression1 "$searchExpression and { [join $searchList { or }] }" # Try simplifying: k _* and keywords _linear_filter -> keywords _linear_filter if {[llength $fieldNameList] == 1} { set fieldName2 $fieldNameList if [regexp {^([^ ]+) +([^ ]+)$} [join $searchExpression] m fieldName3 fieldValue3] { set fieldName3 $fieldName3.* ;# k.* regsub -all {\*} $fieldValue3 {.*} fieldValue3 ;# _.* if {[regexp ^$fieldName3 $fieldName2] && \ [regexp ^$fieldValue3 $fieldValue2]} { # recompute searchExpression1 set searchExpression1 "[join $searchList { or }]" } } } # Try simplifying - end # searchExpression2 regsub -all { } $searchExpression1 {+} searchExpression2 regsub -all {<} $searchExpression2 {%3c} searchExpression2 ;# < -> %3c (binary scan < H2 x) regsub -all {>} $searchExpression2 {%3e} searchExpression2 ;# > -> %3e (binary scan > H2 x) regsub -all {\&} $searchExpression2 {%26} searchExpression2 ;# & -> %26 (binary scan & H2 x) # fieldValue2 set fieldValue2 $item foreach fieldName $fieldNameList { # if [regexp {^firstauthor|^author|^editor|^programmer|^committee} $fieldName] # if [regexp {^firstauthor|^firsteditor|^firstprogrammer|^firstcommittee|^author|^editor|^programmer|^committee} $fieldName] { regsub {,$} $fieldValue2 {} fieldValue2 ;# drop trailing comma break } } foreach fieldName $fieldNameList { # if [regexp {^firstauthor|^author|^editor|^programmer|^committee|^journal|^conferencename} $fieldName] # if [regexp {^firstauthor|^firsteditor|^firstprogrammer|^firstcommittee|^author|^editor|^programmer|^committee|^journal|^conferencename} $fieldName] { # see CreateRepArray regsub -all {_} $fieldValue2 { } fieldValue2 ;# Acta Astronautica set fieldValue2 [string trimleft $fieldValue2] ;# { Acta Astronautica} -> {Acta Astronautica} - added by GJFB in 2014-07-07 (now fieldValue2 may begin with _) break } } regsub -all {<} $fieldValue2 {\<} fieldValue2 regsub -all {>} $fieldValue2 {\>} fieldValue2 regsub -all {\&} $fieldValue2 {\&} fieldValue2 if [string equal {} $attributeList] { if [string equal {} $mappingDomainName] { # lappend output "$fieldValue2" # lappend output "$fieldValue2" lappend output "$fieldValue2" } else { # for unifying field values # e.g., mappingDomainName == x (could be anything not empty) # puts $searchExpression2 # => {index+0}+and+{+course+AST+} lappend output "     ($i)" # lappend output [encoding convertfrom utf-8 "    "] ;# solves the accent problem (e.g., with plutao) } } else { # for setting field value attributes # set line "$fieldValue2" ;# commented by GJFB in 2013-02-18 # set line "$fieldValue2 ($i)" ;# added by GJFB in 2013-02-18 - to let display records from any years set line "($i)$fieldValue2  " ;# added by GJFB in 2013-02-18 - to let display records from any years append line " " append line " " regsub -all {\(|\)} $item {} item2 ;# drop the parenthesis, xx(A) -> xxA, otherwise, because of upvar in SetWidgetValue, set xx(A) produces a "no such element in array" error message SetWidgetValue updateditemlist $item2 CHECKED append line " " foreach attributeName $attributeList { if [info exists displayTable($mappingDomainName,$attributeName)] { set fieldTypeNumber [lindex $displayTable($mappingDomainName,$attributeName) 0] regsub {^_} $item {} item3 ;# _Acta -> Acta - added by GJFB in 2014-07-07 (now item begins with _) # set inputValue year=$year,$mappingDomainName,$attributeName,$item set inputValue year=$year,$mappingDomainName,$attributeName,$item3 ;# added by GJFB in 2014-07-07 if [info exists attributeTable($inputValue)] { set cgi(attributeTable($inputValue)) $attributeTable($inputValue) } # value ConditionalSet value cgi(attributeTable($inputValue)) {} if [string equal {2.1} $fieldTypeNumber] { append line " " } elseif {[string equal {2.2} $fieldTypeNumber]} { append line foreach item2 $boxTable($mappingDomainName,$attributeName) { set value2 [lindex $item2 0] SetWidgetValue attributeTable($inputValue) $value2 CHECKED append line " " } append line
[string index $value2 0]
} elseif {[string equal {3} $fieldTypeNumber]} { set valueList {} foreach item2 $optionTable2($mappingDomainName,$attributeName) { lappend valueList [lindex $item2 1] } SetWidgetValue attributeTable($inputValue) $valueList SELECTED append line " } } } lappend output $line } } # puts --$attributeList-- if [string equal {} $attributeList] { if [string equal {} $mappingDomainName] { set output [join $output
\n] } else { # for unifying field values # e.g., mappingDomainName == x (could be anything not empty) set output "[join $output \n]
" } } else { # for setting field value attributes set output [join $output \n] set tableHeader append tableHeader {    } foreach attributeName $attributeList { append tableHeader "$attributeName" } append tableHeader set output "$tableHeader$output
" if 0 { # time consuming # Preserve the attributes of the hidden field values set hiddenInputList {} regsub -all {\%} "attributeTable\\(year=$year,$mappingDomainName,\[^,\]*,(.*)\\)" {\%} pattern set fieldValuePattern [lindex $searchExpression end] ;# A* # if ![info exists cgi(codedpassword1)] {set cgi(codedpassword1) {}} ;# codedpassword1 not yet tested foreach item [array names cgi attributeTable(*)] { if ![string equal {} $cgi($item)] { if [regexp $pattern $item m fieldValue] { # item satisfies year and mapping domain name if {[lsearch $fieldValueList $fieldValue] == -1} { # fieldValue (ex: _Acta_&_astronautica(A)) has not been found by ComputeFieldValueList # set output "$output\n$fieldValue--" if [string match *,$mappingDomainName,$fieldValuePattern $item] { # despite the fact that it matches the fieldValuePattern - we must check if it exists set query "$mappingDomainName, $fieldValue" set searchResult [FindMetadataRepositories $query 0 {} $cgi(codedpassword1) yes yes] if [string equal $numberOfSites $numberOfSatisfiedQueries] { # complete search if ![string equal {} $searchResult] { # it exists, therefore it must be preserved lappend hiddenInputList "" } } else { # incomplete search lappend hiddenInputList "" } } else { lappend hiddenInputList "" } } } else { lappend hiddenInputList "" } } } set output "$output\n[join $hiddenInputList \n]" # Preserve the attributes of the hidden field values - end } } } else { # not a test set firstCreatorFlag [SetFirstCreatorFlag $subsetOfGroups2] ;# might drop the prefix "first" in fieldNameList upvar firstCreatorList firstCreatorList ;# added by GJFB in 2014-12-20 to speed up execution - avoid calling again ComputeFieldValueList when using DisplayShortCut first if [info exists firstCreatorList] { array set firstCreatorArray $firstCreatorList set fieldValueList [lsort [array names firstCreatorArray]] } else { if $firstCreatorFlag { array set firstCreatorArray [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList 0 0 $subsetOfGroups $subsetOfGroups2 $firstCreatorFlag] set fieldValueList [lsort [array names firstCreatorArray]] } else { set fieldValueList [ComputeFieldValueList $searchExpression $fieldNameList $accent $case $siteList] } } set URLibServiceRepository $env(URLIB_SERVICE_REP) ## if ![string equal {} $latexOptionList] { # source $homePath/col/$URLibServiceRepository/doc/parseXML.tcl ## } # Create the contents of @preamble.inc and @document.inc # @preamble.inc and @document.inc are used in book.tex if {[lsearch $latexOptionList {createeditedbook}] != -1} { # file delete $homePath/col/$thisRepository/doc/@preamble.inc set authorIndexCounter 1 # file delete $homePath/col/$thisRepository/doc/@document.inc set preambleContent {} set documentContent {} } # Create the contents of @preamble.inc and @document.inc - end # Create pageListContent if {[lsearch $latexOptionList {createpagelistfile}] != -1} { set pageListContent {} } # Create pageListContent - end # FOREACH set previousLetter {} set i 1 ;# used in title when short cut is implemented set totalNumberOfSearches [llength $fieldValueList] foreach fieldValue $fieldValueList { regsub -all { and | or } $fieldValue { } fieldValue2 ;# 'and' & 'or' must not be part of the field value regsub {,$} $fieldValue {} fieldValue3 foreach fieldName $fieldNameList { # if [regexp {^firstauthor|^author|^editor|^programmer|^committee} $fieldName] # if [regexp {^firstauthor|^firsteditor|^firstprogrammer|^firstcommittee|^author|^editor|^programmer|^committee} $fieldName] { # see CreateRepArray regsub -all {_} $fieldValue3 { } fieldValue3 set fieldValue3 [string trimleft $fieldValue3] ;# drop beginning blank space - added by GJFB in 2014-11-07 - useful when picking the first letter below break } } set searchList {} if $firstCreatorFlag { foreach metadataRepository $firstCreatorArray($fieldValue) { lappend searchList "metadatarepository, $metadataRepository" } } else { foreach fieldName $fieldNameList { if [string equal {referencetype} $fieldName] { lappend searchList "$fieldName $fieldValue2," ;# referencetype Book, } else { lappend searchList "$fieldName $fieldValue2" } } } if $displayEverything { # set xxx --$fieldValue3-- # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be 0 (see utilities1.tcl) regexp {^.} $fieldValue3 firstLetter if [info exists accentTable2($firstLetter)] {set firstLetter $accentTable2($firstLetter)} set firstLetter [string toupper $firstLetter] if ![string equal $previousLetter $firstLetter] { # add first letter set firstLetter2 [string tolower $firstLetter] # set xxx --$firstLetter2-- # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be 0 (see utilities1.tcl) append output [subst [subst $letter]]\n set previousLetter $firstLetter } # return "$searchExpression and ([join $searchList { or }])" # set xxx "$searchExpression and ([join $searchList { or }])" # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be 0 (see utilities1.tcl) if {$storeTclPage && [regexp {TitleAuthor} $choice]} { # Update the content of @document.inc if {[lsearch $latexOptionList {createeditedbook}] != -1} { # set fileContent "\\part{$fieldValue}" # Store fileContent $homePath/col/$thisRepository/doc/@document.inc auto 0 a lappend documentContent "\\part{$fieldValue}" } # Update the content of @document.inc - end # Update pageListContent if {[lsearch $latexOptionList {createpagelistfile}] != -1} { # createpagelistfile lappend pageListContent {-} } # Update pageListContent - end } # set entry [DisplaySearch "$searchExpression and ([join $searchList { or }])" $accent $case # set fieldValueSearch [join $searchList { or }] if [string equal {} $secondSearchExpression] { set query $searchExpression } else { set query [subst [subst $secondSearchExpression]] ;# secondSearchExpression may contain $fieldValueSearch - subst is called twice because $fieldValueSearch is used in-between [] } # set xxx "$query and {$fieldValueSearch}" # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be 0 (see utilities1.tcl) # => ref Thesis and size * or {au [join [Select supervisor {ref Thesis and size * and {author Rödern,_George,}}] { or au }] and y 2008} and {author Rödern,_George,} # set command {set fieldValueSearch $fieldValueSearch} <==> set command {} if [string equal {} $command] { set searchExpressionForDisplaySearch "$query and {$fieldValueSearch}" } else { # command example: regsub {::} $fieldValueSearch {:*:} set searchExpressionForDisplaySearch "$query and {[eval $command]}" } # Store searchExpressionForDisplaySearch C:/tmp/bbb.txt binary 0 a ;# safeFlag must be 0 (see utilities1.tcl) # id NENDTJMTKW/34PHQJP or id 83LX3pFwXQZ52hzrGTdYCT/GJjhD and {firstauthor _Banon,_Gerald_Jean_Francis or firsteditor _Banon,_Gerald_Jean_Francis} # firstgr OBT and {author _Banon,_Gerald_Jean_Francis or editor _Banon,_Gerald_Jean_Francis} # firstgr OBT and {author _Banon,_Gerald_Jean_Francis or {editor _Banon,_Gerald_Jean_Francis and {referencetype, Edited Book or referencetype, Newspaper,}}} set entry [DisplaySearch $searchExpressionForDisplaySearch $accent $case \ $choice [subst [subst $title]] {^$} \ 0 {} $siteList \ $page $linkType $displayEverything \ $sortedFieldName $outputFormat $targetValue \ $currentRep $nameFormat $nameSeparator \ $latexOptionList 0 $imageFlag \ 0 $searchInputValue \ $childIdentifier $forceRecentFlag] if {$minimumNumberOfSearchResultToDisplay == 1 || [regexp -all {} $entry] >= $minimumNumberOfSearchResultToDisplay} { append output $entry } # Store progress in progressDir set progress [expr $i * 100 / $totalNumberOfSearches]% if [string equal {} $writeUserCodedPassword] { # Execute $serverAddressWithIP [list StoreProgress $progress $progressKey] 0 Execute $clientServerAddressWithIP [list StoreProgress $progress $progressKey] 0 } else { Execute $serverAddressWithIP [list Store2 $progress $thisRepository @progress.txt $writeUserCodedPassword] 0 } # Store progress in progressDir - end } else { # set searchResult [DisplaySearch "$searchExpression and ([join $searchList { or }])" $accent $case $choice "\[list \{$fieldValue3\} \$numberOfEntries\]" {^$} 0 {} $siteList $page $linkType $displayEverything $sortedFieldName $outputFormat $targetValue $currentRep] set searchResult [DisplaySearch "$searchExpression and {[join $searchList { or }]}" $accent $case \ $choice "\[list \{$fieldValue3\} \$numberOfEntries\]" {^$} \ 0 {} $siteList \ $page $linkType $displayEverything \ $sortedFieldName $outputFormat $targetValue \ $currentRep] if [string equal {} $searchResult] { # nothing found # if [info exists errorLogPath] # lappend log [clock format [clock seconds] -format "%d/%m/%y %H:%M"] # Store log $errorLogPath auto 0 a lappend log "The search expression was: $searchExpression and {[join $searchList { or }]} accent was: $accent case was: $case nothing found" # Store log $errorLogPath auto 0 a # } else { # something found lappend output $searchResult } } incr i ;# used in title when short cut is implemented incr totalNumberOfEntries $numberOfEntries } ;# end foreach if !$displayEverything { set output2 [lsort -index end -integer -decreasing $output] set output {} foreach item $output2 { set fieldValue [lindex $item 0] foreach fieldName $fieldNameList { # if [regexp {^firstauthor|^author|^editor|^programmer|^committee} $fieldName] # if [regexp {^firstauthor|^firsteditor|^firstprogrammer|^firstcommittee|^author|^editor|^programmer|^committee} $fieldName] { # see CreateRepArray regsub -all { } $fieldValue {_} fieldValue set fieldValue $fieldValue, ;# add comma break } } set searchList {} foreach fieldName $fieldNameList { lappend searchList "$fieldName $fieldValue" } # regsub -all { } "$searchExpression and ([join $searchList { or }])" {+} searchExpression2 regsub -all { } "$searchExpression and {[join $searchList { or }]}" {+} searchExpression2 # lappend output [join [lreplace $item end end "([lindex $item end])"]] lappend output [join [lreplace $item end end "([lindex $item end])"]] } set output [join $output
\n] } } set currentRep $currentRep2 return $output } # DisplayMultipleSearch - end # ---------------------------------------------------------------------- # DisplayNumberOfEntries # used indirectly by CreatePage (createpage.tcl) ## not used - useStoredValue value is 0 or 1; 1 means to use the previoulsy stored value (if any) # subsetOfGroups value is a list of groups, example: {DPI DSR} # used with first group, for example, searching for firstgr DPI returns the entries # for which DPI is the first group within the groups DPI and DSR # integerWithLink value is 0 or 1; 1 means to turn the integer a link (if the integer is different from zero) proc DisplayNumberOfEntries { searchExpression {accent no} {case no} {useStoredValue 1} {subsetOfGroups {}} {integerWithLink 1} } { global freezeSearchResult ;# set in a tcl page global frozenReferenceFormat ;# set in a tcl page global targetFileDirname ;# provided in CreateTclPage (dirname of the target file for thisRepository) global targetFileRootName ;# provided in CreateTclPage (rootname of the target file for thisRepository) global targetFileExtension ;# provided in CreateTclPage (extension of the target file for thisRepository) upvar serverAddressWithIP serverAddressWithIP upvar searchResultNumber i ;# to have the search result number saved in the upper scope upvar thisRepository thisRepository upvar writeUserCodedPassword writeUserCodedPassword set searchExpression2 [list $searchExpression] set numberOfEntries [DisplayNumber $searchExpression2 $accent $case $subsetOfGroups $integerWithLink DisplayNumberOfEntries] if {[info exists freezeSearchResult] && $freezeSearchResult} { incr i if {[ExtractNumber $numberOfEntries] == 0} { # added by GJFB in 2024-04-03 set url {} set fileName $targetFileDirname/@@$targetFileRootName$i$targetFileExtension Execute $serverAddressWithIP [list StoreURLContent2 $url $thisRepository $fileName $writeUserCodedPassword doc iso8859-1] 0 } else { set url [ExtractURL $numberOfEntries] if {[info exists frozenReferenceFormat] && [string equal {briefTitleAuthorMisc} $frozenReferenceFormat]} { # use briefTitleAuthorMisc format (full is default) # => http://bibdigital.sid.inpe.br/col/sid.inpe.br/bibdigital@80/2006/04.07.15.50.13/doc/mirrorsearch.cgi?query=referencetype,+Thesis+and+{course+MET-MET-SPG-INPE-MCTI-GOV-BR}+and+date,+2015&choice=full&languagebutton=pt-BR&returnbutton=no regsub {choice=full} $url {choice=briefTitleAuthorMisc\&outputformat=ref-year-cite\&continue=yes} url # => http://bibdigital.sid.inpe.br/col/sid.inpe.br/bibdigital@80/2006/04.07.15.50.13/doc/mirrorsearch.cgi?query=referencetype,+Thesis+and+{course+MET-MET-SPG-INPE-MCTI-GOV-BR}+and+date,+2015&choice=briefTitleAuthorMisc&outputformat=ref-year-cite&languagebutton=pt-BR&returnbutton=no } if {[info exists frozenReferenceFormat] && [string equal {fullBibINPE} $frozenReferenceFormat]} { # use fullBibINPE format (full is default) regsub {choice=full} $url {choice=fullBibINPE\&continue=yes} url } set fileName $targetFileDirname/@@$targetFileRootName$i$targetFileExtension # Execute $serverAddressWithIP [list StoreURLContent2 $url $thisRepository $fileName $writeUserCodedPassword] 0 ;# commented by GJFB in 2021-01-14 Execute $serverAddressWithIP [list StoreURLContent2 $url $thisRepository $fileName $writeUserCodedPassword doc iso8859-1] 0 ;# added by GJFB in 2021-01-14 - solves the accent problem at bibdigital (with utf-8 encoding system) - used when creating tcl page in col/sid.inpe.br/bibdigital/2021/01.13.23.23/doc/ regsub {href="[^"]*"} $numberOfEntries "href=\"@@$targetFileRootName$i$targetFileExtension\"" numberOfEntries } } return $numberOfEntries ;# numberOfEntries may be empty in case of a communication problem (as a result of CreateOutput that may produce an unexpected searchResult value) } # DisplayNumberOfEntries - end # ---------------------------------------------------------------------- # DisplayNumberOfEntries2 # returns just an integer value (without link) proc DisplayNumberOfEntries2 {searchExpression} { # upvar numberOfSearches numberOfSearches ;# must be set to 0 in the tcl page upvar totalNumberOfSearches totalNumberOfSearches ;# must be defined in the tcl page return [DisplayNumberOfEntries $searchExpression no no 1 {} 0] ;# may be empty in case of a communication problem (as a result of CreateOutput that may produce an unexpected searchResult value) } # ---------------------------------------------------------------------- # DisplayNumberOfEntries3 # execute DisplayNumberOfEntries remotly # example: see "testing remote execution of DisplayNumberOfEntries" in cgi/test2 # not in use proc DisplayNumberOfEntries3 { searchExpression accent case useStoredValue subsetOfGroups integerWithLink siteList_ currentRep_ language_ languageRep1_ languageRep2_ } { # runs with post global siteList global currentRep global language global languageRep1 global languageRep2 set siteList $siteList_ set currentRep $currentRep_ set language $language_ set languageRep1 $languageRep1_ set languageRep2 $languageRep2_ return [DisplayNumberOfEntries $searchExpression $accent $case $useStoredValue $subsetOfGroups $integerWithLink] ;# may be empty in case of a communication problem (as a result of CreateOutput that may produce an unexpected searchResult value) } # DisplayNumberOfEntries3 - end # ---------------------------------------------------------------------- # DisplayCorrelationCoefficient # used indirectly by CreatePage (createpage.tcl) ## not used - useStoredValue value is 0 or 1; 1 means to use the previoulsy stored value (if any) # integerWithLink value is 0 or 1; 1 means to turn the integer a link (if the integer is different from zero) # let #searchExpression the number of entries satisfying searchExpression # DisplayCorrelationCoefficient returns: # 100 * (#(searchExpression and searchExpressionA and searchExpressionB)) / (#(searchExpression and (searchExpressionA or searchExpressionB))) proc DisplayCorrelationCoefficient {searchExpression searchExpressionA searchExpressionB \ {accent no} {case no} {useStoredValue 1} {integerWithLink 1}} { set searchExpression2 [list $searchExpression $searchExpressionA $searchExpressionB] return [DisplayNumber $searchExpression2 $accent $case {} $integerWithLink DisplayCorrelationCoefficient] } # DisplayCorrelationCoefficient - end # ---------------------------------------------------------------------- # DisplayNumber # used indirectly by CreatePage (createpage.tcl) # integerWithLink value is 0 or 1; 1 means to turn the integer a link (if the integer is different from zero) # callingProcedure value is DisplayEntryEvaluation, DisplayNumberOfEntries or DisplayCorrelationCoefficient # subsetOfGroups value is a list of groups, example: {DPI DSR} # doesn't compute hidden records # entryEvaluationFunctions is empty or a is list of two unary operations (functions) and one binary operation # full is set as choice (uses as default) proc DisplayNumber { searchExpressionList accent case subsetOfGroups integerWithLink callingProcedure {entryEvaluationFunctions {}} } { global env global cgi global currentRep global language languageRep1 languageRep2 # global errorLogPath ;# set in CreateTclPageFile # global dirName ;# set in CreateTclPageFile global numberOfSites ;# set in MultipleSubmit global numberOfSatisfiedQueries ;# set in MultipleSubmit global log global searchResultArray ;# set in CreateTclPage (if searchResult.tcl exists) global siteList ;# set in CreateTclPage global serverAddressWithIP global thisRepository global writeUserCodedPassword # upvar 2 numberOfSearches numberOfSearches ;# must be set to 0 in the tcl page upvar 2 totalNumberOfSearches totalNumberOfSearches ;# must be defined in the tcl page # set xxx [CallTrace] # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be set to 0 in CreateTclPage set searchExpression [join $searchExpressionList { and }] regsub -all { } $searchExpression {+} searchExpression2 if 0 { lappend log "Trace from DisplayNumber: the search expression is <$searchExpression>" } # Store log $errorLogPath auto 0 a # set fileName "search-$searchExpressionA and $searchExpressionB" set itemName $searchExpression # regsub -all {\*} $fileName {star} fileName # regsub -all {\|} $fileName {pipe} fileName if [info exists searchResultArray($itemName)] { # Load $dirName/searchResult/$fileName output set output $searchResultArray($itemName) # set log "Trace from DisplayCorrelationCoefficient: non-authoritarive answer (cache value used)" # Store log $errorLogPath auto 0 a # if [info exists numberOfSearches] {incr numberOfSearches} } else { set cgi(accent) $accent set cgi(case) $case set cgi(query) $searchExpression if [regexp {DisplayNumberOfEntries|DisplayCorrelationCoefficient} $callingProcedure] { if 1 { # old code # faster set maximumNumberOfEntries 3 set entryEvaluationFunctions2 1 } else { # new code # not used # less specific set maximumNumberOfEntries 0 set function1 {x {return [ConstantFunction $x]}} set function2 {x {return [ConstantFunction $x]}} ;# could be any fucntion set operation {{x y} {return $x}} set entryEvaluationFunctions2 [list $function1 $function2 $operation] } } if [string equal {DisplayEntryEvaluation} $callingProcedure] { set maximumNumberOfEntries 0 set entryEvaluationFunctions2 $entryEvaluationFunctions } # format must be 2 not 3 (unless cgi(continue) is yes) - see "part of the fast mirror search code" in CreateOutput # set query [list list GetMetadataRepositories $currentRep 2 $cgi(query) $cgi(accent) $cgi(case) 1 metadatalastupdate] set query [list list GetMetadataRepositories $currentRep 3 $cgi(query) $cgi(accent) $cgi(case) \ 1 metadatalastupdate repArray {} \ pages $maximumNumberOfEntries $subsetOfGroups] # subsetOfGroups must be considered in CreateOutput ... set output [CreateOutput $language $languageRep1 $languageRep2 $query {} Search {} \ $entryEvaluationFunctions2 [expr $maximumNumberOfEntries - 1] brief 1 \ {^$} 0 {} 1 \ {#EEEEEE #E3E3E3} $siteList] # set xxx $searchExpressionList # Store xxx C:/tmp/bbb.txt auto 0 a # set xxx --$output-- # Store xxx C:/tmp/bbb.txt auto 0 a if 0 { lappend log "DisplayNumber: executing:\n[list CreateOutput $language $languageRep1 $languageRep2 $query {} Search {} 1 10 brief 1 {^$} 0 {} 1 {#EEEEEE #E3E3E3} $siteList]\nthe result was: \"$output\"" # Store log $errorLogPath auto 0 a } # 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] } # DisplayNumberOfEntries if [string equal {DisplayNumberOfEntries} $callingProcedure] { if [string equal {} $output] { ;# added by GJFB in 2017-07-12 - it is assumed that CreateOutput may produce an unexpected searchResult value (for example in the case of the cross communication problem) set numberOfSatisfiedQueries 0 ;# force to zero } else { if {![string equal 0 $output] && $integerWithLink} { if [string equal {} $subsetOfGroups] { # full is set as choice (uses as default) set output "$output" } else { regsub -all { } $subsetOfGroups {+} subsetOfGroups2 # full is set as choice (uses as default) set output "$output" } } } } # DisplayCorrelationCoefficient if [string equal {DisplayCorrelationCoefficient} $callingProcedure] { if ![string equal 0 $output] { set cgi(query) "[lindex $searchExpressionList 0] and ([lindex $searchExpressionList 1] or [lindex $searchExpressionList 2])" # format must be 2 not 3 (unless cgi(continue) is yes) - see "part of the fast mirror search code" in CreateOutput # set query [list list GetMetadataRepositories $currentRep 2 $cgi(query) $cgi(accent) $cgi(case) 1 metadatalastupdate] set query [list list GetMetadataRepositories $currentRep 3 $cgi(query) $cgi(accent) $cgi(case) \ 1 metadatalastupdate repArray {} \ pages 3] set output2 [CreateOutput $language $languageRep1 $languageRep2 $query {} Search {} \ 1 2 brief 1 \ {^$} 0 {} 1 \ {#EEEEEE #E3E3E3} $siteList] if 0 { lappend log "DisplayNumber: executing:\n[list CreateOutput $language $languageRep1 $languageRep2 $query {} Search {} 1]\nthe result was: \"$output2\"" # Store log $errorLogPath auto 0 a } set output [format %.0f [expr ceil((100. * $output) / $output2)]]% if $integerWithLink { set output "$output" } } else { set output 0% } } # DisplayCorrelationCoefficient - end if [string equal $numberOfSites $numberOfSatisfiedQueries] { # complete search set searchResultArray($itemName) $output # if [info exists numberOfSearches] {incr numberOfSearches} set numberOfSearches [llength [array names searchResultArray]] # set xxx "numberOfSearches = $numberOfSearches" # Store xxx C:/tmp/bbb.txt binary 0 a ;# safeFlag must be set to 0 in CreateTclPage if [info exists totalNumberOfSearches] { set progress [expr $numberOfSearches * 100 / $totalNumberOfSearches]% Execute $serverAddressWithIP [list Store2 $progress $thisRepository @progress.txt $writeUserCodedPassword] 0 } } else { # incomplete search lappend log "Trace from DisplayNumber: the search expression was <$searchExpression>." # Store log $errorLogPath auto 0 a lappend log "Trace from DisplayNumber: the number of satisfied queries was $numberOfSatisfiedQueries out of $numberOfSites." # Store log $errorLogPath auto 0 a } } return $output ;# may be empty in case of a communication problem (as a result of CreateOutput that may produce an unexpected searchResult value) } # DisplayNumber - end # ---------------------------------------------------------------------- # ExtractNumber # used to extract the number form the output of DisplayNumberOfEntries proc ExtractNumber {string} { if [string equal {} $string] { set number 0 ;# added by GJFB in 2017-07-12 - force to zero - it is assumed that CreateOutput may produce an unexpected searchResult value (for example in the case of the cross communication problem) } else { regsub -all {<[^>]*>} $string {} number } return $number } # ExtractNumber - end # ---------------------------------------------------------------------- # ExtractURL # used to extract the URL form the output of DisplayNumberOfEntries proc ExtractURL {string} { # regexp -nocase {]*)} $string m url if [regexp {href="([^"]*)"} $string m url] {return $url} } # ExtractURL - end # ---------------------------------------------------------------------- # ExecuteStore2 # used in tcl page to create xml file # examples: id CBnmVX32PXQZeBBx/Cb2ne, id J8LNKB5R7W/3K4L4J8 and id 8JMKD3MGPCW/3JRQ2P5 proc ExecuteStore2 {value fileName {access a}} { upvar serverAddressWithIP serverAddressWithIP upvar thisRepository thisRepository upvar writeUserCodedPassword writeUserCodedPassword Execute $serverAddressWithIP [list Store2 $value $thisRepository $fileName $writeUserCodedPassword doc auto 0 $access] 0 } # ExecuteStore2 - end # ---------------------------------------------------------------------- # DisplayNews # used to display news # if the current date is inside the time interval [from to] then # string1 (the news) is returned otherwise string2 is returned # from and to value is for example: "Aug 23 20:22:06 2003" # empty from value is equivalent to minus infinity # empty to value is equivalent to plus infinity proc DisplayNews {from to string1 {string2 {}}} { set date-time [clock seconds] if {[string compare {} $from] == 0} { set fromInSeconds 0 } else { if [catch {clock scan $from} fromInSeconds] { return <$fromInSeconds> } } if {[string compare {} $to] == 0} { if {$fromInSeconds < ${date-time}} { return $string1 } else { return $string2 } } else { if [catch {clock scan $to} toInSeconds] { return <$toInSeconds> } if {$fromInSeconds < ${date-time} && \ ${date-time} < $toInSeconds} { return $string1 } else { return $string2 } } } # puts [DisplayNews {Aug 22 20:22:06 2003} {Sep 23 20:22:06 2003} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {Sep 22 20:22:06 2003} {Sep 23 20:22:06 2003} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {Aug 22 20:22:06 2003} {Aug 23 20:22:06 2003} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {} {Sep 23 20:22:06 2003} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {} {Aug 23 20:22:06 2003} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {Sep 22 20:22:06 2003} {} {XIII SBSR
} {out-of-date
}] # puts [DisplayNews {Aug 22 20:22:06 2003} {} {XIII SBSR
} {out-of-date
}] # DisplayNews - end # ---------------------------------------------------------------------- # DisplayDuplicates # diplays the references that have the same citation keys proc DisplayDuplicates {year searchExpression siteList} { global currentRep ;# set in CreatePage or Submit and used MultipleSubmit global numberOfSatisfiedQueries2 ;# set in MultipleExecute2 set query [list list MultipleArrayGet repArray *:$year:*,citationkey] # MULTIPLE SUBMIT foreach {searchResultList numberOfSatisfiedQueries2} [MultipleExecute2 $siteList $query 0 2] {break} ;# level 2 is for MultipleSubmit be able to reach currentRep foreach item $searchResultList { # {AABE:2007:AbReMu,citationkey iconet.com.br/banon/2007/11.04.16.54.01-0} # {AABE:2007:AdBaCo,citationkey iconet.com.br/banon/2007/11.04.21.58.01-0} set name [lindex $item 0] ;# AABE:2007:AbReMu,citationkey set value [lindex $item 1] ;# iconet.com.br/banon/2007/11.04.16.54.01-0 if [info exists repArray($name)] { set repArray($name) [concat $repArray($name) $value] } else { set repArray($name) $value ;# AABE:2007:AbReMu,citationkey -> iconet.com.br/banon/2007/11.04.16.54.01-0 } } set i 0 set output {} foreach name [lsort [array names repArray]] { # each citation key if {[llength $repArray($name)] > 1} { set fullQuery {} foreach rep-i $repArray($name) { regexp {(.*)-(.*)} ${rep-i} m metadataRepository index if $index { set partialQuery "databaserepository, $metadataRepository and index, $index" } else { set partialQuery "metadatarepository, $metadataRepository and index, $index" } lappend fullQuery \{$partialQuery\} } set fullQuery [list [join $fullQuery { or }] $searchExpression] regsub {,citationkey} $name {} citationKey ;# AABE:2007:AbReMu set partialOutput [DisplaySearch $fullQuery no no \ brief "" {^$} \ 0 {} $siteList \ no 0 1 \ key 1 _blank \ {} {short} {; } \ {} 1] ;# multiple search if {[regexp -all {} $partialOutput] > 1} { incr i lappend output "$i - $citationKey" lappend output $partialOutput } } } if !$i {lappend output {there are no duplicates}} return [join $output \n
\n] } # DisplayDuplicates - end # ---------------------------------------------------------------------- # CreateAccessHistogram # patternList value examples: # 2008.01 2008.02 2008.03 ... 2008.12 # 2001 2002 2003 ... 2008 # return an occurrence list like: # 22 19 45 ... 65 proc CreateAccessHistogram {repList patternList siteList} { foreach pattern $patternList { set numberOfAccessTable($pattern) 0 } foreach rep $repList { set siteContainingTheOriginal [FindSiteContainingTheOriginal2 $rep 1 $siteList] if [string equal {} $siteContainingTheOriginal] {continue} ;# site not found set histogram [Execute $siteContainingTheOriginal [list ExtractHistogram $rep $patternList]] set i 0 foreach pattern $patternList { incr numberOfAccessTable($pattern) [lindex $histogram $i] incr i } } set histogram {} foreach pattern $patternList { lappend histogram $numberOfAccessTable($pattern) } return $histogram } # CreateAccessHistogram - end # ---------------------------------------------------------------------- # DisplayEntryEvaluation # entryEvaluationFunctions is list of two unary operations (functions) and one binary operation # example: # set function1 {x {return [ConstantFunction $x]}} # set function2 {x {return [ConstantFunction $x]}} # set operation {{x y} {return [expr $x / $y]}} # set entryEvaluationFunctions [list $function1 $function1 $operation] # let i be an entry satisfying searchExpression # DisplayEntryEvaluation returns: # operation(sum(function1(i)), sum(function2(i))) # example of use: id NENDTJMTKW/37RKTD2 proc DisplayEntryEvaluation {searchExpression entryEvaluationFunctions {accent no} {case no} {useStoredValue 1}} { set searchExpression2 [list $searchExpression] return [DisplayNumber $searchExpression2 $accent $case {} 0 DisplayEntryEvaluation $entryEvaluationFunctions] } # DisplayEntryEvaluation - end # ---------------------------------------------------------------------- # ConstantFunction # example of use: id NENDTJMTKW/37RKTD2 proc ConstantFunction {x} { return 1 } # ConstantFunction - end # ---------------------------------------------------------------------- # ConstantFunction # example of use: id NENDTJMTKW/37RKTD2 proc ReturnStaticIPFlag {} { global staticIPFlag ;# set in InformURLibSystem return $staticIPFlag } # ConstantFunction - end # ----------------------------------------------------------------------