Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91106739
addElement2PageEDS.php.wml
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Nov 7, 23:32
Size
33 KB
Mime Type
text/x-c
Expires
Sat, Nov 9, 23:32 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22196501
Attached To
R3600 invenio-infoscience
addElement2PageEDS.php.wml
View Options
## $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.
<?
require("commonPhpFunctions.php");
?>
#include "cdspage.wml" \
title="Add Element to Page <protect><?print "$pageNumber of $subname"?></protect>" \
navtrail_previous_links="<a class=navtrail href=<WEBURL>/admin/<lang:star: index.*.html>><MSG_ADMIN_AREA></a> > <a class=navtrail href=<WEBURL>/admin/websubmit/><MSG_ADMIN_SUBMIT></a>" \
navbar_name="admin" \
navbar_select="websubmit"
<?
<protect>
## $Id$
## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.
?>
<SCRIPT LANGUAGE="JavaScript">
<!-- hide
function checkRequired(param)
// This is a function to ensure that the user enters the required
// value for the level parameter of an EDS submission page element
// Author: Nicholas Robinson
// Email: Nicholas.Robinson@cern.ch
// ca8nro@yahoo.co.uk
// Created: Long ago!
// Last Modified: 14/12/2000
{
// If the field is left blank by the user...
if((param == "") || ((param.toUpperCase() != "M") &&
(param.toUpperCase() != "O")))
{ // Alert them, and return false.
alert("A value of M or O must be entered in the level field.");
return false;
} // End if
else // If level has been filled by the user...
{
return true;
} // End else
} // End function checkRequired(param)
// -->
</SCRIPT>
<?
/*********************Function Declarations***************************/
function TestFormField( $fidesc, $level )
{
$res = mysql_query("select type,fidesc from sbmFIELDDESC where name='$fidesc'");
$row = mysql_fetch_row($res);
$type = $row[0];
$body = $row[1];
if ($level == "M" && $type == "S" && !ereg(".*<option>[^<]*Select:.*",$body)) {
print "<SCRIPT TYPE='text/javascript'>alert('The mandatory $fidesc select box must begin with \"<option>Select:</option>\"');</SCRIPT>";
return 0;
}
return 1;
}
function procInsrtn($subname, $pageNumber, $fieldnb, $fidesc, $fitext,
$level, $sdesc, $checkn, $doctype, $nPgs)
{
/******************************************************************
This function has the task of actually processing the insertion
of an element into a submission page for a given doctype. It is
passed all of the various values that should be inserted into the
sbmFIELD table. It then constructs an insert query, and inserts
these values into the table. After the insertion has been
completed, it either informs the user that the new values have
successfully been inserted or not, depending upon whether the
query was successful or not.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 14/12/2000
Last Modified: 25/01/2001
******************************************************************/
if (!TestFormField($fidesc,$level)){
return 0;
}
# Now we can begin building the query string...
$insStr = "INSERT INTO sbmFIELD (subname, pagenb, fieldnb, fidesc, "
. "fitext, level, sdesc, checkn, cd, md, fiefi1, fiefi2) VALUES("
. "'$subname', '$pageNumber', '$fieldnb', '$fidesc', '$fitext', "
. "'$level', '$sdesc', '$checkn', NOW(), NOW(), NULL, NULL)";
# Now execute the above query string...
$insRes = mysql_query($insStr);
# Conduct a test to see if the instertion of these details was
# successful...
if($insRes)
{
# In this case, the details have been inserted correctly. This
# means we must update the modification date of the current
# submission, and the modification date of the current document
# type. We must also redirect the browser back to the
# "pageDetsEDS.php" page to show details of the current
# submission page.
# Update the md field for our submission.
$mdResult = mysql_query("UPDATE sbmIMPLEMENT SET md = "
. "'$md' WHERE subname = '$subname'");
if($mdResult)
{
# In this case, the update result for updating the
# modification date of a submission worked, so we can free
# it's result pointer
mysql_free_result($mdResult);
} // END if
else
{
# Update the submission md query error...output a quick alert
print("<SCRIPT TYPE='text/javascript'>alert('ERROR: Unable"
. " to update the Modification Date field for this "
. "submission<BR>in the sbmIMPLEMENT table.');</SCRIPT>\n");
} // END else
# Update the md field for our doctype
updateEDSDOCTYPEmd($doctype, $md);
# Now output a message on screen informing the user that the
# update has been completed
print("<P STYLE=\"color: green; font-weight: bold; font-size: "
. "large; text-align: center\">The New Element Has Been Added"
. "</P>\n");
# Now output a javascript alert saying more or less the same, in
# a little more detail
print("<SCRIPT TYPE='text/javascript'>alert('The $fidesc element"
. " has been added to page $pageNumber of the\\n$subname "
. "submission of the $doctype document type.\\nIt was added "
. "into element position $fieldnb.\\n\\nYour browser has been re"
. "directed to the page where you can view the details of this"
. " submission page.');</SCRIPT>\n");
# Now make a message and send it to the system administrator to
# inform them that this element addition has taken place.
$msgTxt = "A new element has been added to page $pageNumber of "
. "the $subname submission of the $doctype document type. "
. "This new element is an instance of the $fidesc element "
. "description, and was inserted into position $fieldnb."
. "\n\nWebSubmit Administrator (";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "$fidesc Element added to $subname page "
. "$pageNumber", $msgTxt, "From: WebSubmit_Administrator");
# Now redirect the browser to "pageDetsEDS.php"
sendToPageDets($subname, $pageNumber, $nPgs, $doctype);
} // END if
else
{
# In this case, the query to insert the new details has failed.
# This means that we must warn the user of this problem, warn the
# administrator by email, and then redirect the page back to the
# "pageDetsEDS.php" page.
# Now output a message on screen informing the user that the
# update has been completed
print("<P CLASS=\"errorMsg\"><SPAN STYLE=\"color: red\">ERROR:"
. "</SPAN> Unable To Add This Element To The <EM>$subname</EM>"
. " Submission</P>\n");
# Now output a javascript alert saying more or less the same, in
# a little more detail
print("<SCRIPT TYPE='text/javascript'>alert('Error: It was not "
. " possible to add the $fidesc element\\n to page $pageNumber "
. "of the $subname submission of the $doctype document type.\\n"
. "This is because it was not possible to commit values to the "
. "sbmFIELD table.');</SCRIPT>\n");
# Now make a message and send it to the system administrator to
# inform them that this element addition has taken place.
$msgTxt = "An error ocurred when attempting to add the "
. "$fidesc element to page $pageNumber of "
. "the $subname submission of the $doctype document type. "
. "This error meant that it was not possible to commit the "
. "details for this new element to the sbmFIELD table, and "
. "therefore the element has not been added.\n\nThere may be"
. " a problem with the sbmFIELD table, and this situation should"
. " be looked into as soon as possible.\n\nWebSubmit Administrator "
. "(";
$msgTxt .= makeDate();
$msgTxt .= ")";
# Now send the mail..
mail(ADMIN_EMAIL, "ERROR: Unable To Add $fidesc Element To "
. "$subname Page $pageNumber",
$msgTxt, "From: WebSubmit_Administrator");
# Now redirect the browser to "pageDetsEDS.php"
sendToPageDets($subname, $pageNumber, $nPgs, $doctype);
} // END else
} // END function procInsrtn()
//************
function charSmaller($chr, $datum)
{
/**************************************************************
This function simply compares 2 values to see if a character
($chr) is smaller than a given other character ($datum). It was
written because I wanted to split a <SELECT> box which was
massive up into several select boxes alphabetically. The
original select query on the DB returned the results sorted
alphabetically ascending, and it returned any numeric values as
coming before alphabetic values, so I made this function claim
that anything that is not a letter is smaller than the datum if
it is alphabetic. If the datum is not alphabetic, I just let the
computer decide whether or not the $chr is less than the datum,
as I don't really care, as I never intend to call the function
with non-alphabetic datums.
Not brilliant practice I know! :o
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 17/01/2001
Last Modified: 17/01/2001
**************************************************************/
if(($datum >= "A" && $datum <= "Z") ||
($datum >= "a" && $datum <= "z"))
{
# $datum is an alphabetic char, and all is easy...
if(($chr >= "A" && $chr <= "Z") ||
($chr >= "a" && $chr <= "z"))
{
# Here, the character to compare is an alphabetic char.
if(strtolower($chr) < strtolower($datum))
{
# In this case, our letter is less than the allowed limit
return true;
} // END if
else
{
# In this case, the letter has exceeded it's boundary
return false;
} // END else
} // END if
else
{
# Char to compare is not alphabetic. Therefore, we just let
# Mr computer decide!
return ($chr < strtoupper($datum)) ? true : false;
} // END else
} // END if
else
{
# Datum is non-alphabetic...Grrr!
if(($chr >= "A" && $chr <= "Z") ||
($chr >= "a" && $chr <= "z"))
{
# The character is alphabetic
return (strtoupper($chr) < $datum) ? true : false;
} // END if
else
{
# Character is ! alphabetic, so just let Mr Computer decide
return ($chr < $datum) ? true : false;
} // END else
} // END else
} // END function charSmaller()
//*************
function makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$noElements, $fitext = "", $level = "", $sdesc = "",
$checkn = "", $whichBox = "", $fidesc = "")
{
/*******************************************************************
This function has the job of creating the form that is used to
enter the details of a new element for a page. The function
executes a select query to retrieve the codes for each of the
element descriptions from the sbmFIELDDESC table. If this query was
successful, it then proceeds to create the input form.
Otherwise, it creates the relevant error messages.
Author: Nicholas Robinson
Email: Nicholas.Robinson@cern.ch
ca8nro@yahoo.co.uk
Created: 15/12/2000
Last Modified: 30/01/2001
*******************************************************************/
# The first thing we need to do is get a list of all element
# descriptions from the sbmFIELDDESC table...
$qRes = mysql_query("SELECT distinct(name) FROM sbmFIELDDESC ORDER BY "
. "name");
if($qRes)
{
# In this case, the query to get a list of all of the elements
# has been successful, so we can continue making the form
if(mysql_num_rows($qRes) <= 0)
{
# In this case, there are no element descriptions stored in
# the sbmFIELDDESC table. This means we can't add an element to
# a page, so we'd better let the user know this!
print("<P CLASS='errorMsg'>There are currently no element "
. "descriptions stored in EDS.<BR>Unable to add a new "
. "element</P>\n");
print("<SCRIPT TYPE=\"text/javascript\">alert('Because there "
. " are no element configuration descriptions stored in the"
. "\\nsbmFIELDDESC table of EDS, it is not possible to add a new"
. " element instance to a submission.\\n\\nIf you wish to add"
. " elements to a submission page, you must first add meta "
. "data about\\nthese elements to the sbmFIELDDESC table.');"
. "</SCRIPT>\n");
# Now redirect the browser
sendToPageDets($subname, $pageNumber, $nPgs, $doctype);
} // END if
else
{
# Now, display a quick set of page instructions for the user..
print("<TABLE WIDTH='90%' BGCOLOR='#D3DCE3' ALIGN='center' "
. "CELLSPACING=0 CELLPADDING=0 BORDER=1>\n<TR><TD ALIGN='"
. "center'>\n<P STYLE=\"color: blue; text-align: center; "
. "font-size: small; font-weight: bold\">The following form "
. "can be used to add a new element to <EM>page $pageNumber"
. "</EM> of the <EM>$subname</EM> submission.<BR>The first "
. "step is to select an element from a list box. The "
. "element selected will determine the configuration "
. "information template<BR>used to create the element for the"
. " submission page.<BR><BR>When the element description has "
. "been selected, enter all of the other details using the "
. "form and submit it by clicking on \"SAVE CHANGES\".<BR><BR"
. "><SPAN STYLE=\"color: green\">There are many EDS element "
. "descriptions. For ease of selection, they have been split"
. " alphabetically into 3 list boxes.<BR>When selecting an "
. "element, please only select from 1 list box. If se"
. "veral are selected, the value will be taken from the<BR>"
. "left-most listbox.</SPAN>\n</P>\n"
. "</TD>\n</TR>\n</TABLE>\n");
# Make a horizontal rule to divide the page sections...
drawSeparator();
# Now, begin making the form for the new elements details.
print("<FORM ACTION='addElement2PageEDS.php' METHOD='post'>"
. "\n<INPUT TYPE='hidden' NAME='insertElement' VALUE='true'>"
. "\n<INPUT TYPE='hidden' NAME='doctype' VALUE='$doctype'>\n"
. "<INPUT TYPE='hidden' NAME='nPgs' VALUE='$nPgs'>\n"
. "<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 ALIGN='center'"
. " BGCOLOR='#CECEFF' WIDTH='100%'>\n<TR>\n<TH ALIGN='right' "
. "WIDTH='25%'>\n<SPAN STYLE=\"color: green;\""
. ">Element Description Code: </SPAN></TH>\n<TD "
. "ALIGN='left' WIDTH='75%'>\n");
# We are going to have 3 select boxes (1 for a-h, 1 for i-p
# and 1 for p-z), because there are so many elements.
# Get the number of elements returned by query
$numEles = mysql_num_rows($qRes);
# Put all elements as returned by the query into a 2d array
$eles = resToArray($qRes);
# ****************Make the 1st select list*****************
print("<SELECT NAME='fidesc_A'>\n<OPTION"
. " VALUE='--X--'>-----A..H-----"
. "</OPTION>\n");
for($idx = 0; (($idx < $numEles) &&
(charSmaller($eles[$idx][0][0], "H"))); $idx++)
{
if($eles[$idx][0])
{
print("<OPTION");
if($whichBox == "fidesc_A" && $fidesc == $eles[$idx][0])
{
# The current element descr should be selected
print(" SELECTED");
} // END if
print(" VALUE='"
. ereg_replace("'", "'",
htmlspecialchars($eles[$idx][0]))
. "'>" . ereg_replace("'", "'",
htmlspecialchars($eles[$idx][0]))
. "</OPTION>\n");
} // END if
} // END for
# Close the current select list
print("</SELECT>");
print(" ");
# ****************Make the 2nd select list*****************
print("<SELECT NAME='fidesc_B'>\n<OPTION"
. " VALUE='--X--'>-----I..P-----"
. "</OPTION>\n");
for($idx2 = $idx; (($idx2 < $numEles) &&
(charSmaller($eles[$idx2][0][0], "Q"))); $idx2++)
{
if($eles[$idx2][0])
{
print("<OPTION VALUE='"
. ereg_replace("'", "'",
htmlspecialchars($eles[$idx2][0]))
. "'");
if($whichBox == "fidesc_B" &&
$fidesc == $eles[$idx2][0])
{
# The current element descr should be selected
print(" SELECTED");
} // END if
print(">" . ereg_replace("'", "'",
htmlspecialchars($eles[$idx2][0]))
. "</OPTION>\n");
} // END if
} // END for
# Close the current select list
print("</SELECT>");
print(" ");
# ****************Make the 3rd select list*****************
print("<SELECT NAME='fidesc_C'>\n<OPTION"
. " VALUE='--X--'>-----Q..Z-----"
. "</OPTION>\n");
for($idx3 = $idx2; $idx3 < $numEles; $idx3++)
{
if($eles[$idx3][0])
{
print("<OPTION VALUE='"
. ereg_replace("'", "'",
htmlspecialchars($eles[$idx3][0]))
. "'");
if($whichBox == "fidesc_C" &&
$fidesc == $eles[$idx3][0])
{
# The current element descr should be selected
print(" SELECTED");
} // END if
print(">" . ereg_replace("'", "'",
htmlspecialchars($eles[$idx3][0]))
. "</OPTION>\n");
} // END if
} // END for
# Close the current select list
print("</SELECT>");
# Now close up the newly created listbox
print("\n</TD>\n</TR>\n</TABLE>\n");
# Now, we can present the user with the form in which they can
# fill in the details that will be committed to the sbmFIELD
# table...
# Get the date for the created date & modification date
$theDate = makeEDSmdDate();
# Get information about all of the fields in the fitext table
$cols = mysql_list_fields(DOCS_DATABASE, "sbmFIELD");
print("<BR><TABLE CELLSPACING=0 CELLPADDING=0 ALIGN='center' "
. "WIDTH='100%' BORDER=0>\n<TR><TH ALIGN='right' WIDTH='25%'"
. " BGCOLOR='"
. "#D3DCE3'>Submission Code: </TH>\n<TD WIDTH='75%' ALIG"
. "N='left' BGCOLOR='#FFFFCC'><INPUT TYPE='readonly' NAME='"
. "subname' VALUE='$subname'></TD>\n</TR>\n<TR>\n<TH ALIGN='"
. "right' WIDTH='25%' BGCOLOR='#D3DCE3'>Page Number: </"
. "TH>\n<TD WIDTH='75%' ALIGN='left' BGCOLOR='#FFFFCC'><INPUT"
. " TYPE='readonly' NAME='pageNumber' VALUE='$pageNumber'></T"
. "D>\n</TR>\n<TR>\n<TH ALIGN='right' WIDTH='25%' BGCOLOR='"
. "#D3DCE3'>Field Number: </TH>\n<TD WIDTH='75%' ALIGN='"
. "left' BGCOLOR='#FFFFCC'><INPUT TYPE='readonly' NAME='field"
. "nb' VALUE='" . ($noElements + 1) . "'></TD>\n</TR>\n<TR><"
. "TH ALIGN='right' WIDTH='25%' BGCOLOR='#D3DCE3'>Creation D"
. "ate: </TH><TD WIDTH='75%' ALIGN='left' BGCOLOR='#FFF"
. "FCC'><INPUT TYPE='readonly' NAME='cd' VALUE='$theDate'>"
. "</TD>\n</TR>\n<TR><TH ALIGN='right' WIDTH='25%' BGCOLOR='"
. "#D3DCE3'>Modification Date: </TH>\n<TD WIDTH='75%' "
. "ALIGN='left' BGCOLOR='#FFFFCC'><INPUT TYPE='readonly' "
. "NAME='md' VALUE='$theDate'></TD>\n</TR>\n<TR><TH ALIGN='"
. "right' WIDTH='25%' BGCOLOR='#87CEFA'>Element Label: "
. "</TH><TD WIDTH='75%' ALIGN='left' BGCOLOR='#FFFFCC'><"
. "INPUT TYPE='text' NAME='fitext' SIZE=40 VALUE='"
. ereg_replace("'", "'", htmlspecialchars($fitext))
. "'></TD>\n</TR>\n<TR><TH ALIGN="
. "'right' WIDTH='25%' BGCOLOR='#87CEFA'>Level: </TH><T"
. "D WIDTH='75%' ALIGN='left' BGCOLOR='#FFFFCC'><SELECT NAME="
. "'level'>\n<OPTION VALUE='M'>Mandatory</OPTION>\n<OPTION ");
if($level == "O" || $level == "o")
{
print("SELECTED ");
} // END if
print("VALUE='O'>Optional</OPTION>\n</SELECT>\n"
. "</TD>\n</TR>\n<TR><TH ALIGN='right' WIDTH='25%' BGCOLOR="
. "'#87CEFA'>Short Desc: </TH><TD WIDTH='75%' ALIGN='"
. "left' BGCOLOR='#FFFFCC'><INPUT TYPE='text' NAME='sdesc' "
. "SIZE=40 VALUE='" . ereg_replace("'", "'",
htmlspecialchars($sdesc))
. "'></TD>\n</TR>\n<TR><TH ALIGN='right' WIDTH='25%' BGCOLOR="
. "'#87CEFA'>Check: </TH><TD WIDTH='75%' ALIGN='left' "
. "BGCOLOR='#FFFFCC'>");
# Now, we wish to use a select list of checks to ensure that
# the user can only select checks that are already stored in
# the EDS DB. Therefore, we need to query sbmCHECKS.
if($chksRes = mysql_query("SELECT chname FROM sbmCHECKS ORDER "
. "BY chname"))
{
# Query fine.
if(mysql_num_rows($chksRes) > 0)
{
# Checks to be put into a select box...good!
print("<SELECT NAME='checkn'>\n<OPTION VALUE=''>"
. "NO CHECK</OPTION>\n");
while($stuff = mysql_fetch_row($chksRes))
{
print("<OPTION VALUE='" . ereg_replace("'", "'",
htmlspecialchars($stuff[0]))
. "'");
if($checkn == $stuff[0])
{
# This check was already selected, so note that
print(" SELECTED");
} // END if
print(">" . ereg_replace("'", "'",
htmlspecialchars($stuff[0]))
. "</OPTION>\n");
} // END while
# Close up the select list
print("</SELECT>\n");
} // END if
else
{
# No checks stored in DB! Offer link to add a check page
print("<SPAN STYLE=\"font-size: small; font-weight: "
. "bold; text-align: left; color: red\">There are "
. "currently no " . DOCS_DATABASE . " checks. "
. "<A HREF='addCheckEDS.php'>Add.</A></SPAN><INPUT "
. "TYPE='hidden' NAME='checkn' VALUE=''>\n");
} // END else
} // END if
else
{
# Can't query for checks, therefore can't add any!
print("<SPAN STYLE=\"font-size: small; font-weight: bold;"
. " text-align: left; color: red\">Unable to retrieve "
. "details of checks from " . DOCS_DATABASE . ". "
. "Try adding check later.</SPAN><INPUT TYPE='hidden' "
. "NAME='checkn' VALUE=''>\n");
} // END else
# Close the current table cell
print("</TD>\n</TR>\n</TABLE>");
# Now that we have finished displaying the input fields of the
# form, we can produce some buttons....1 for submitting the
# form, 1 for resetting the form, and 1 for cancelling the
# action (i.e. not adding a new element at all) - this button
# will return you to the "pageDetsEDS.php" page.
print("<TABLE CELLSPACING=1 CELLPADDING=1 ALIGN="
. "'center' BORDER=0>\n<TR>\n<TD ALIGN='right'>\n<INPUT TYPE="
. "'button' VALUE='SAVE DETAILS' onClick=\"submit();\">\n"
. "</TD>\n<TD ALIGN='center'>\n<INPUT TYPE='button'"
. " VALUE='RESET' onClick=\"reset();\">\n</TD>\n</FORM>\n<FO"
. "RM ACTION='pageDetsEDS.php' METHOD='post'>\n<INPUT TYPE='h"
. "idden' NAME='subname' VALUE='$subname'>\n<INPUT TYPE='hidd"
. "en' NAME='pageNumber' VALUE='$pageNumber'>\n<INPUT TYPE='"
. "hidden' NAME='nPgs' VALUE='$nPgs'>\n<INPUT TYPE='hidden' "
. "NAME='doctype' VALUE='$doctype'>\n<TD ALIGN='left'>"
. "<INPUT TYPE='button' VALUE='CANCEL' onClick=\"submit();\">"
. "\n</TD>\n</FORM>\n</TR>\n</TABLE>\n");
} // END else
} // END if
else
{
# In this case, the query to retrieve the descriptions of all
# elements has failed, so we can display an error message
# indicating this and redirect the browser to the
# "pageDetsEDS.php" page
# Display an error message about this...
print("<P CLASS='errorMsg'><SPAN STYLE=\"color: red\">"
. "ERROR:</SPAN> It was not possible to retrieve the details of "
. "the element descriptions from the <EM>sbmFIELDDESC</EM> "
. "table.<BR>Unable to add element.</P>\n");
# Now display a JavaScript alert saying more or less the same as
# the above message...
print("<SCRIPT TYPE=\"text/javascript\">alert('ERROR: It was not"
. " possible to retrieve the details for the descriptions of the"
. " EDS elements\\nfrom the sbmFIELDDESC table.\\nThis meant that "
. "it was not possible to add a new element to the requested "
. "submission page.\\n\\nPlease inform the system administrator "
. "of this problem.');</SCRIPT>\n");
# Now redirect the browser
sendToPageDets($subname, $pageNumber, $nPgs, $doctype);
} // END else
} // END function makeEleForm()
function displayPage()
{
global $insertElement,$fidesc_A,$fidesc_B,$fidesc_C,$subname,$pageNumber,$nPgs,$doctype,$fieldnb,$fitext,$level,$sdesc,$checkn,$noElements;
# The first thing to do is to work out what sort of call to the script
# this is. It can either be a first call whereby the form to fill in
# must be displayed, or a self-referential call, whereby the new
# element must actually be inserted into the sbmFIELD table.
if(isset($insertElement))
{
# In this case, this call to the page is a call to insert the new
# element details. We must however perform certain tests to ensure
# values have been filled/selected, just incase our JavaScript
# failed (Likely!).
# Free the $insertElement value...
unset($insertElement);
# Now ensure that the value of "level" is in upper case...
$level = strtoupper($level);
if($fidesc_A == "--X--" && $fidesc_B == "--X--" &&
$fidesc_C == "--X--")
{
# No element descr code selected
print("<P STYLE=\"color: red; text-align: center; font-size:"
. " medium; font-weight: bold\">\nNo Element Description "
. "Code Was Selected\n</P>\n");
# Redisplay the form for re-entry.
makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$fieldnb - 1, $fitext, $level, $sdesc, $checkn);
} // END if
elseif($fidesc_A != "--X--")
{
# Perfect...we take the left-most, which in this case is
# $fidesc_A, so it does not matter if $fidesc_B or $fidesc_C
# are selected or not - we don't care.
if($level == "M" || $level == "O")
{
# $level checks out.
if (!procInsrtn($subname, $pageNumber, $fieldnb, $fidesc_A, $fitext, $level, $sdesc, $checkn, $doctype, $nPgs)) {
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,$fieldnb - 1, $fitext, "", $sdesc, $checkn, "fidesc_A", $fidesc_A);
}
} // END if
else
{
# Level doesn't check out
print("<P STYLE=\"color: red; text-align: center; font-size:"
. " medium; font-weight: bold\">\nThe Value of the Level "
. "Field Must be \"M\" or \"O\"\n</P>\n");
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$fieldnb - 1, $fitext, "", $sdesc, $checkn,
"fidesc_A", $fidesc_A);
} // END else
} // END elseif
elseif($fidesc_A == "--X--" && $fidesc_B != "--X--")
{
# Here, $fidesc_A has not been selected, but $fidesc_B has
# been, meaning that $fidesc_B is the leftmost, and we don't
# care whether or not $fidesc_C has been selected - we take B
if($level == "M" || $level == "O")
{
# $level checks out.
if (!procInsrtn($subname, $pageNumber, $fieldnb, $fidesc_B,$fitext, $level, $sdesc, $checkn, $doctype,$nPgs)) {
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,$fieldnb - 1, $fitext, "", $sdesc, $checkn, "fidesc_B", $fidesc_B);
}
} // END if
else
{
# $level doesn't check out
print("<P STYLE=\"color: red; text-align: center; font-size:"
. " medium; font-weight: bold\">\nThe Value of the Level "
. "Field Must be \"M\" or \"O\"\n</P>\n");
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$fieldnb - 1, $fitext, "", $sdesc, $checkn,
"fidesc_B", $fidesc_B);
} // END else
} // END elseif
else
{
# $fidesc_C must be the only one selected
if($level == "M" || $level == "O")
{
# $level checks out.
if (!procInsrtn($subname, $pageNumber, $fieldnb, $fidesc_C,$fitext, $level, $sdesc, $checkn, $doctype,$nPgs)) {
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,$fieldnb - 1, $fitext, "", $sdesc, $checkn, "fidesc_C", $fidesc_C);
}
} // END if
else
{
# Level doesn't check out
print("<P STYLE=\"color: red; text-align: center; font-size:"
. " medium; font-weight: bold\">\nThe Value of the Level "
. "Field Must be \"M\" or \"O\"\n</P>\n");
# Redisplay input form
makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$fieldnb - 1, $fitext, "", $sdesc, $checkn,
"fidesc_C", $fidesc_C);
} // END else
} // END else
} // END if
else
{
# In this case, this is the first call to the page, and it is
# necessary to display the form in which the user can enter the
# details of the new element for the given page of the given
# submission of the given doctype.
makeEleForm($subname, $pageNumber, $nPgs, $doctype,
$noElements);
} // END else
}
/**********************Start of main script***************************/
# Connect to the MySQL server
serverConnect(MYSQLDOCMACHINE, MYSQLDOCUSERID, MYSQLDOCPASSWORD);
# Select the CDS Search database...
dbSelect(DOCS_DATABASE);
if (!canUseWebSubmitAdmin($uid,$doctype))
outWarning("You are not allowed to access WebSubmit Admin for this "
. "type of documents");
else
displayPage();
/************************End of main script***************************/
</protect>
?>
Event Timeline
Log In to Comment