# Copyright for the Uniform Repository Service (c) 1995 - 2022, # by Gerald Banon. All rights reserved. # Version 2.1 # cgi/displaydoccontent.tcl # ---------------------------------------------------------------------- # DisplayDocContent # Examples: # http://banon-pc2/displaydoccontent.cgi/iconet.com.br/banon/2007/04.29.22.55 # http://banon-pc2/displaydoccontent.cgi/iconet.com.br/banon/2007/04.29.22.55?closebutton=yes # http://gerald/rep/urlib.net/www/2012/12.27.16.41?metadatarepository=urlib.net/www/2012/12.27.16.41.55&ibiurl.backgroundlanguage=pt-BR&requiredsite=gerald&requiredmetadatatimestamp=2014:01.25.14.10.55&requiredmirror=dpi.inpe.br/banon/1999/06.19.17.00&searchsite=gerald:80&searchmirror=dpi.inpe.br/banon/1999/06.19.17.00&choice=brief&displaytype=Gallery # displaytype field value range is: Gallery FileList Resume {Archival Unit|ArchivalUnit} proc DisplayDocContent {} { if [catch { set currentProcedureName DisplayDocContent global env global cgi ;# used in MountHTMLPage global homePath ;# needed in FindLanguage, MultipleSubmit, UpdateContentDescriptionFile and MountHTMLPage global serverAddress ;# used in SetFieldValue global localSite ;# used MountHTMLPage and CreateDirectoryContentList (called in xxDocContent.html) global mirrorHomePageRep ;# defined in FindLanguage (utilities1.tcl) global currentRep ;# set in this procedure - thisRepository global language languageRep1 languageRep2 ;# needed by CreateOutput and MountHTMLPage global translationTable ;# set in this procedure and used in MountHTMLPage global URLibServiceRepository ;# used in MultipleSubmit (called in MultipleExecute2 called in CreateOutput) global queueLengthFlag ;# used in MultipleSubmit (called in MultipleExecute2 called in CreateOutput) global contentDescriptionArray ;# set in CreateInputList set col ../../../../.. set URLibServiceRepository $env(URLIB_SERVICE_REP) source ../$col/$URLibServiceRepository/doc/utilities1.tcl source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl source ../$col/$URLibServiceRepository/doc/utilitiesStart.tcl ;# ListIntersection and ListNegatedImplication # set queueLengthFlag 1 ;# could be anything - added by GJFB in 2013-04-17 in order to detect not writable site (site that doesn't reply) if 0 { # required when using puts puts {Content-Type: text/html} puts {} } # serverAddress set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)] # thisRepository (repository whose content is being displayed) ## relativePathPrefix if {[llength [file split $env(PATH_INFO)]] == 3} { # ibip form regsub -all { } [lrange [file split $env(PATH_INFO)] 1 2] {/} ibi set thisRepository [Execute $serverAddress [list FindRepositoryNameFromIBI $ibi]] set folder {} # set relativePathPrefix ../../../col } else { # repository form regsub -all { } [lrange [file split $env(PATH_INFO)] 1 4] {/} thisRepository # folder regsub -all { } [lrange [file split $env(PATH_INFO)] 5 end] {/} folder # set relativePathPrefix ../../../../../col } # puts --$folder-- # homePath (used in FindLanguage) set homePath $env(DOCUMENT_ROOT) # mirrorRep set mirrorRep $env(LOBIMIREP) # localSite set localSite $env(SERVER_NAME):$env(SERVER_PORT) # dir if [string equal {} $folder] { set dir $homePath/col/$thisRepository/doc } else { set dir $homePath/col/$thisRepository/doc/$folder } # puts --$dir-- if 0 { # commented by GJFB in 2020-01-02 - see REDIRECT below # Security issue # otherwise the archive directory could be created at a wrong place in system file if ![file isdirectory $dir] { puts "DisplayDocContent: $thisRepository is not a repository in the current local collection." return } # Security issue - end } if [info exists env(QUERY_STRING)] { foreach {name value} [split $env(QUERY_STRING) &=] { set cgi([DecodeURL $name]) [DecodeURL $value] } } # puts --[array get cgi]-- if 0 { # commented by GJFB in 2013-09-21 - now one click is counted when opening the body frame (see Get) # Count one click set URParts [file split $thisRepository] set localURLibClientSocketId [StartCommunication $env(SERVER_NAME) $env(URLIB_PORT)] Submit $localURLibClientSocketId [list PostponeOneClickCount $URParts] close $localURLibClientSocketId # Count one click - end } # SET FIELD VALUES # targetfile # ConditionalSet metadataRep cgi(metadatarepository) [Execute $serverAddress [list FindMetadataRep $thisRepository]] ;# commented by GJFB in 2014-05-22 after a change in CreateAbsolutePath # set metadataRep [Execute $serverAddress [list FindMetadataRep $thisRepository]] ;# commented by GJFB in 2014-08-23 - doesn't display the correct mtadata language of id J8LNKB5R7W/3C8MGFP ConditionalSet metadataRep cgi(metadatarepository) [Execute $serverAddress [list FindMetadataRep $thisRepository]] ;# added by GJFB in 2014-08-23 # puts $metadataRep # SetFieldValue $serverAddress $metadataRep-0 {referencetype title targetfile creatorname fullname identifier contents language textlanguage descriptionlevel secondarytype} # SetFieldValue $serverAddress $metadataRep-0 {referencetype title targetfile creatorname fullname identifier contents language textlanguage descriptionlevel secondarytype parameterlist creatorhistory} # SetFieldValue $serverAddress $metadataRep-0 {referencetype title targetfile creatorname fullname identifier contents language textlanguage descriptionlevel secondarytype parameterlist creatorhistory volume} ;# commented by GJFB in 2022-04-14 SetFieldValue $serverAddress $metadataRep-0 {referencetype title targetfile creatorname fullname date identifier contents language textlanguage descriptionlevel secondarytype parameterlist creatorhistory volume} ;# added by GJFB in 2022-04-14 # textlanguage is the language of the metadata ($metadataRep-0) set docPath $homePath/col/$thisRepository/doc # set targetFileExtension [file extension $targetfile] # if [regexp {^(Resume|Archival Unit)$} $referencetype] # ;# commented by GJFB in 2023-03-14 if {[regexp {^(Resume|Archival Unit)$} $referencetype] && [info exists cgi(nonemptyquerystring)]} { ;# added by GJFB in 2023-03-14 - see 2023-03-14 companion update by GJFB in CreateAbsolutePath # display Resume or Archival Unit if [regexp {^Archival Unit$} $referencetype] { ConditionalSet displayType cgi(displaytype) {Archival Unit} ;# added by GJFB in 2022-04-26 - some Archival Unit might contain a file (@archivistWarning.html); to see it the access button appears with the pair displaytype=FileList in the query string SetFieldValue $serverAddress $metadataRep-0 {readpermission} ;# added by GJFB in 2022-11-18 - required when the Archival Unit contains more than one file (see argument readpermission of ComputeAccessRestrictionFlag in xxDocContent.html) } else { set displayType $referencetype } # # elseif {[string equal {Image} $referencetype]} # ;# commented by GJFB in 2020-08-24 } elseif {[string equal {Image} $referencetype] && ![string equal {} $targetfile]} { ;# added by GJFB in 2020-08-24 # display Gallery # SetFieldValue $serverAddress $metadataRep-0 {readpermission} ;# added by GJFB in 2021-03-03 - required to display the zip download option SetFieldValue $serverAddress $metadataRep-0 {readpermission lastupdate} ;# added by GJFB in 2021-03-03 - required to display the zip download option - added by GJFB in 2021-07-16 - required to preserve any comma (,) in file name ConditionalSet displayType cgi(displaytype) Gallery } else { # display FileList SetFieldValue $serverAddress $metadataRep-0 {readpermission} set displayType FileList } # puts $displayType # if [info exists cgi(displaytype)] # # set displayType $cgi(displaytype) if [string equal {FileList} $displayType] { # Find the language and the language repository foreach {language3 languageRep1 languageRep2} [FindLanguage $mirrorRep] {break} # Find the language and the language repository - end # puts $mirrorRep # puts $language3 # without languagebutton, language3 == env(LANGUAGE_PREFERENCE) # languageRep if ![file isdirectory $homePath/col/$thisRepository] { ;# added by GJFB in 2020-01-02 # thisRepository doesn't exist # REDIRECT - a warning message will be displayed puts "Location: http://$localSite/$thisRepository?ibiurl.backgroundlanguage=$language3" puts "" return } if [file exists $homePath/col/$languageRep1/doc/${language3}DocContent.html] { set languageRep $languageRep1 } else { set languageRep $languageRep2 ;# default } } else { # not FileList # set mirrorHomePageRep dpi.inpe.br/banon/2000/01.23.20.24 set textLanguage $textlanguage ;# textLanguage is used to display "Automatically generated by URLibService" in the text language (language of the metadata) # puts --$textLanguage-- # puts --$language-- if [regexp {fr} $textLanguage] { ;# metadata language # fr set language2 fr ;# needed by CreateOutput } elseif {[regexp {pt} $textLanguage]} { ;# metadata language # pt set language2 pt-BR ;# needed by CreateOutput } elseif {[regexp {en} $textLanguage]} { ;# metadata language # en set language2 en ;# needed by CreateOutput } elseif {[regexp {fr} $language]} { ;# data language # fr set language2 fr ;# needed by CreateOutput } elseif {[regexp {pt} $language]} { ;# data language # pt set language2 pt-BR ;# needed by CreateOutput } elseif {[regexp {en} $language]} { ;# data language # en set language2 en ;# needed by CreateOutput } else { # no data language and no metadata language # Find the language and the language repository foreach {language2 languageRep1 languageRep2} [FindLanguage $mirrorRep] {break} # Find the language and the language repository - end # puts --$language2-- # puts --$languageRep1-- # puts --$languageRep2-- # languageRep if [file exists $homePath/col/$languageRep1/doc/${language2}DocContent.html] { set languageRep $languageRep1 } else { set languageRep $languageRep2 ;# default } } # puts $language2 if [regexp {fr|pt-BR} $language2] { # fr or pt-BR set language3 pt-BR set languageRep dpi.inpe.br/banon/1999/06.19.22.43 ;# needed by xxDocContent.html set languageRep1 dpi.inpe.br/banon/1999/06.19.22.43 ;# needed by CreateOutput set languageRep2 dpi.inpe.br/banon/1999/06.19.22.43 ;# needed by CreateOutput } else { # en set language3 en set languageRep dpi.inpe.br/banon/1999/05.03.22.11 ;# needed by xxDocContent.html set languageRep1 dpi.inpe.br/banon/1999/05.03.22.11 ;# needed by CreateOutput set languageRep2 dpi.inpe.br/banon/1999/05.03.22.11 ;# needed by CreateOutput } set mirrorHomePageRep dpi.inpe.br/banon/2000/01.23.20.24 } puts {Content-Type: text/html} puts {} # puts --$language3-- # puts --$languageRep-- set language $language3 ;# language is a global variable ConditionalSet updateBodyFlag cgi(updatebodyflag) 0 ;# default is don't update - up to now, this flag is not used # ConditionalSet displayType cgi(displaytype) {FileList} # puts $displayType # puts [array get cgi] switch -regexp -- $displayType { Gallery { # gallery components (.png, .gif, .js and .css) were copied from: # http://www.php4script.com/demo/php-photo-album-script/skins/ad_gallery/azcms/skins/ad_gallery # currentRep set currentRep $thisRepository # contentDescriptionArray set targetDirName [file dirname $targetfile] ;# added by GJFB in 2020-03-25 to work with images in directories # if [file exists $docPath/contentDescription.tcl] # if [file exists $docPath/$targetDirName/contentDescription.tcl] { ;# added by GJFB in 2020-03-25 to work with images in directories set inputList [CreateInputList $docPath $targetDirName $lastupdate] # puts $inputList # set startIndex [lsearch $inputList *,$targetfile] # set startIndex [lsearch $inputList *,[file tail $targetfile]] ;# added by GJFB in 2020-03-25 to work with images in directories set startIndex [lsearch $inputList [file tail $targetfile]] ;# added by GJFB in 2020-07-29 - new image ranking facility } else { if 0 { # commented by GJFB in 2020-07-09 set inputList {} set startIndex 0 } elseif 0 { # commented by GJFB in 2020-07-10 # Create inputList # added by GJFB in 2020-07-09 - required after submission and before any update set pwd [pwd] cd $docPath/$targetDirName set inputList {} set inputList [concat $inputList [glob -nocomplain {*.[bB][mM][pP]}]] set inputList [concat $inputList [glob -nocomplain {*.[jJ][pP][gG]}]] cd $pwd # Create inputList - end set startIndex [lsearch $inputList [file tail $targetfile]] ;# added by GJFB in 2020-03-25 to work with images in directories } else { # added by GJFB in 2020-07-10 - useful after submission and before any update # Update contentDescription.tcl UpdateContentDescriptionFile $currentRep $targetfile # Update contentDescription.tcl - end set inputList [CreateInputList $docPath $targetDirName $lastupdate] # set startIndex [lsearch $inputList *,[file tail $targetfile]] set startIndex [lsearch $inputList [file tail $targetfile]] ;# added by GJFB in 2020-07-29 - new image ranking facility } } if [regexp {fr} $language2] { # fr set {translationTable(Gallery deposited in:)} {Galerie déposée en:} set {translationTable(Start)} {Marche} set {translationTable(Stop)} {Arret} } elseif {[regexp {pt} $language2]} { # pt set {translationTable(Gallery deposited in:)} {Galeria depositada em:} set {translationTable(Start)} {Ligar} set {translationTable(Stop)} {Desligar} } else { # en set {translationTable(Gallery deposited in:)} {Gallery deposited in:} set {translationTable(Start)} {Start} set {translationTable(Stop)} {Stop} } puts "
[EscapeUntrustedData $title]
$translationTable(Gallery deposited in:) $currentRep |
puts $m if 0 {global errorInfo; puts $errorInfo} puts} } } # DisplayDocContent - end # ---------------------------------------------------------------------- # CreateInputList proc CreateInputList {docPath targetDirName lastupdate} { global contentDescriptionArray interp create -safe slave interp expose slave source # set contentDescriptionList [interp eval slave [list source $docPath/contentDescription.tcl]] ;# set contentDescriptionList set contentDescriptionList [interp eval slave [list source $docPath/$targetDirName/contentDescription.tcl]] ;# set contentDescriptionList - added by GJFB in 2020-03-25 to work with images in directories array set contentDescriptionArray $contentDescriptionList ;# commented by GJFB in 2020-07-29 # return [encoding convertfrom utf-8 [lsort -dictionary [array names contentDescriptionArray]]] ;# solves the accent problem in md-m09 - added by GJFB in 2013-08-31 - commented by GJFB in 2020-07-29 set imageList2 {} foreach {imageName2 imageLegend} $contentDescriptionList { # lastup 2020:0[89]* or lastup 2020:1* or lastup 2021:* if ![regexp {2020:0[89]|2020:1|202[^0]:} $lastupdate] { ;# if added by GJFB in 2021-07-16 - required to preserve any comma (,) in file name after 2020-08-01 (approximation of 2020-07-29) # imageName2 old format (ex: zzz,2.jpg) regsub {.*?,} $imageName2 {} imageName2 ;# remove initial string - migration to the new image ranking facility } lappend imageList2 $imageName2 } return [encoding convertfrom utf-8 $imageList2] ;# solves the accent problem in md-m09 - added by GJFB in 2020-07-29 - new image ranking facility } # CreateInputList - end # ---------------------------------------------------------------------- # MountHTMLPage # updateNextHigherUnitFlag value is 0 or 1 # 1 means to update nexthigherunit # parameterlist value example: sort shorttitle (used in id 8JMKD3MGPCW/3EQCC85) # called by DisplayDocContent only proc MountHTMLPage { thisRepository htmlTitle translatedTitle descriptionlevel creator date identifier mirrorRep contentsListForArray updateNextHigherUnitFlag secondaryType parameterlist updateBodyFlag {creatorhistory {}} {volume {}} } { global env global cgi ;# set in DisplayDocContent global homePath ;# set in DisplayDocContent global localSite ;# set in DisplayDocContent global mirrorHomePageRep ;# defined in FindLanguage (utilities1.tcl) global language languageRep1 languageRep2 ;# set in DisplayDocContent global translationTable ;# set in DisplayDocContent global currentRep ;# set in this procedure - mirrorRep; needed in DisplaySearch global multipleLineReferFieldNamePattern ;# used by GetReferField (called by CreateVersionStamp) # ConditionalSet run cgi(run) 0 ;# slow loading (the page is displayed only after completion of all searches) set run 1 ;# faster - uses progressive loading if !$run { # slow loading - not used # code found in: http://www.electrictoolbox.com/load-content-jquery-ajax-loading-image/ puts "
[expr [string equal {} $volume]?{}:{Volume $volume $descriptionlevel " } ]
$creator
[
if [regexp {\.} $env(SERVER_NAME)] {
set x "
$translationTable(Original document URL:)
|
||||
$fileContent | ||||
|