Page MenuHomec4science

Create_Modify_Interface.py
No OneTemporary

File Metadata

Created
Sat, Nov 16, 20:16

Create_Modify_Interface.py

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
## Description: function Create_Modify_Interface
## This function creates the html form allowing the user to
## some bibliographic fields
## Author: T.Baron
## PARAMETERS: fieldnameMBI: name of the file containing the
## "+"-separated list of fields to modify
execfile("%s/cdsware/websubmit_functions/Retrieve_Data.py" % pylibdir)
def Create_Modify_Interface(parameters,curdir,form):
global sysno,rn
t=""
# variables declaration
fieldname = parameters['fieldnameMBI']
# Path of file containing fields to modify
if os.path.exists("%s/%s" % (curdir,fieldname)):
fp = open( "%s/%s" % (curdir,fieldname), "r" )
fieldstext = fp.read()
fp.close()
else:
raise functionError("cannot find fields to modify")
fieldstext = re.sub("\+","\n",fieldstext)
fields = fieldstext.split("\n")
#output some text
t=t+"<CENTER bgcolor=white>The document <B>%s</B> has been found in the database.</CENTER><BR>Please modify the following fields:<BR>Then press the 'END' button at the bottom of the page<BR>\n" % rn
for field in fields:
subfield = ""
value = ""
marccode = ""
text = ""
# retrieve and display the modification text
t=t+"<FONT color=darkblue>\n"
res = run_sql("SELECT modifytext FROM sbmFIELDDESC WHERE name=%s", (field,))
if len(res)>0:
t=t+"<small>%s</small> </FONT>\n" % res[0][0]
# retrieve the marc code associated with the field
res = run_sql("SELECT marccode FROM sbmFIELDDESC WHERE name=%s", (field,))
if len(res) > 0:
marccode = res[0][0]
# then retrieve the previous value of the field
if marccode != "":
value = Get_Field(marccode,sysno)
res = run_sql("SELECT * FROM sbmFIELDDESC WHERE name=%s", (field,))
if len(res) > 0:
type = res[0][3]
numcols = res[0][6]
numrows = res[0][5]
size = res[0][4]
maxlength = res[0][7]
val = res[0][8]
fidesc = res[0][9]
if type == "T":
text="<TEXTAREA name=\"%s\" rows=%s cols=%s wrap>%s</TEXTAREA>" % (field,numrows,numcols,value)
elif type == "F":
text="<INPUT TYPE=file name=\"%s\" size=%s maxlength=%s>" % (field,size,maxlength)
elif type == "I":
# JY correction, 15.6.01
value = re.sub("[\n\r\t]+","",value)
text="<INPUT name=\"%s\" size=%s value=\"%s\"> " % (field,size,val)
text= text + "<SCRIPT>document.forms[0].%s.value=\"%s\";</SCRIPT>" % (field,value)
elif type == "H":
text="<INPUT type=hidden name=\"%s\" value=\"%s\">" % (field,val)
text=text+"<SCRIPT>document.forms[0].%s.value=\"%s\";</SCRIPT>" % (field,value)
elif type == "S":
values = re.split("[\n\r]+",value)
text=fidesc
if re.search("%s\[\]" % field,fidesc):
multipletext = "[]"
else:
multipletext = ""
if len(values) > 0 and not(len(values) == 1 and values[0] == ""):
text += "<SCRIPT>\n"
text += "var i = 0;\n"
text += "el = document.forms[0].elements['%s%s'];\n" % (field,multipletext)
text += "max = el.length;\n"
for val in values:
text += "var found = 0;\n"
text += "var i=0;\n"
text += "while (i != max) {\n"
text += " if (el.options[i].value == \"%s\" || el.options[i].text == \"%s\") {\n" % (val,val)
text += " el.options[i].selected = true;\n"
text += " found = 1;\n"
text += " }\n"
text += " i=i+1;\n"
text += "}\n"
text += "if (found == 0) {\n"
text += " el[el.length] = new Option(\"%s\", \"%s\", 1,1);\n"
text += "}\n"
text += "</SCRIPT>\n"
elif type == "D":
text=fidesc
elif type == "R":
text=eval(fidesc)
else:
text="%s: unknown field type" % field
t = t+"<small>%s</small>" % text
# output some more text
t=t+"<BR><BR><CENTER><small><INPUT type=button width=400 height=50 name=End value=END onClick=\"document.forms[0].step.value = 2;document.forms[0].submit();\"></small></CENTER></H4>"
return t
</protect>

Event Timeline