# Copyright for the Uniform Repository Service (c) 1995 - 2012,
# by Gerald Banon. All rights reserved.
# Version 2.1
# createindex.tcl
# creates index pages for Google
# to create the index enter:
# http://gjfb:1905/createindex.cgi
proc CreateIndex {} {
if [catch {
global env
global currentRep
global language languageRep1 languageRep2
global cgi
global homePath ;# used in mirror/enSearchResult.tcl
set col ../../../../..
set URLibServiceRepository $env(URLIB_SERVICE_REP)
source ../$col/$URLibServiceRepository/doc/utilities1.tcl
source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl
set currentRep $env(LOBIMIREP)
# loCoInRep
set loCoInRep $env(LOCOINREP)
# localSite
set localSite $env(SERVER_NAME):$env(SERVER_PORT)
# homePath
set homePath $env(DOCUMENT_ROOT)
# Find the language and the language repository
foreach {language languageRep1 languageRep2} {en dpi.inpe.br/banon/1999/05.03.22.11 dpi.inpe.br/banon/1999/05.03.22.11} {break}
# Find the language and the language repository - end
# bgColor, background, bgProperties, fontTag and fontTag2
foreach {bgColor background bgProperties fontTag fontTag2} [GetBg $languageRep1 $language] {break}
if 0 {
if [info exists env(QUERY_STRING)] {
foreach {name value} [split $env(QUERY_STRING) &=] {
set cgi([DecodeURL $name]) [DecodeURL $value]
}
}
}
puts {Content-Type: text/html}
puts {}
Load $homePath/col/$URLibServiceRepository/doc/localIndex.html fileContent
set pageList [glob -nocomplain $homePath/col/$loCoInRep/doc/index?*.html]
foreach page $pageList {
file delete $page
}
set searchExpression {size *}
set accent no
set case no
set choice briefTitleAuthor
set sort key
set excludedFields {^accessdate$|^area$|^course$|^hostcollection$|^keywords$|^lastupdate$|^metadatalastupdate$|^metadatarepository$|^numberoffiles$|^secondarykey$|^secondarytype$|^size$|^targetfile$}
set localSearch 1
set numbering {}
set outputFormat 1
set cellBackgroungColors {}
set siteList {}
set page no
# set linkType 0
set linkType 1
# set targetValue _blank
set targetValue _top
set dateFieldName metadatalastupdate
set siteFieldName site
set option Search
set maximuNumberOfEntries 0
set nameFormat short
set nameSeparator {; }
set multipleSearch 0
set imageFlag 0
set displayHiddenRecord 0
set searchInputValue {}
set childIdentifier {}
set forceRecentFlag 0
# set searchInputValue $cgi(searchinputvalue)
# set childIdentifier $cgi(childidentifier)
# set forceRecentFlag $cgi(forcerecentflag)
set entryList [GetSearchResult $searchExpression $accent $case \
$choice $sort $excludedFields \
$localSearch $numbering $outputFormat \
$cellBackgroungColors $siteList \
$page $linkType $targetValue \
$dateFieldName $siteFieldName $option $maximuNumberOfEntries \
$nameFormat $nameSeparator $multipleSearch \
$imageFlag $displayHiddenRecord $searchInputValue \
$childIdentifier $forceRecentFlag]
set lastEntryNumber [llength $entryList]
# numberOfEntriesPerPage
# set numberOfEntriesPerPage 200
set numberOfEntriesPerPage 100
set list {} ;# a1 a2
set list2 {} ;# {$a1} {$a2}
for {set i 1} {$i <= $numberOfEntriesPerPage} {incr i} {
lappend list a$i
lappend list2 \$a$i
}
set entryList2 {}
foreach entry $entryList {lappend entryList2 [list $entry]}
set pageList {}
foreach $list $entryList2 {
lappend pageList [join [eval concat [join $list2]]
\n]
}
set lastPageNumber [llength $pageList]
set pageNumber 1
foreach page $pageList {
if {$pageNumber == 1} {
# first page
if {$lastPageNumber == 1} {
set navegationBar {}
} else {
set navegationBar "Next Page"
}
} elseif {$pageNumber == $lastPageNumber} {
# last page
if {$lastPageNumber == 1} {
set navegationBar {}
} else {
set previousPage [expr $lastPageNumber - 1]
set navegationBar "Previous Page"
}
} else {
# the other pages
set previousPage [expr $pageNumber - 1]
set nextPage [expr $pageNumber + 1]
set navegationBar "Previous Page | Next Page"
}
set fileContent2 [subst $fileContent]
Store fileContent2 $homePath/col/$loCoInRep/doc/index$pageNumber.html
incr pageNumber
}
puts "