Commit 425c4b89 authored by Kevin Atkinson's avatar Kevin Atkinson
Browse files

Set the charset for all emulab pages to utf-8 which is needed to
display foreign names correctly.  Also added three rows to table_regex:
tinytext_utf8, text_utf8, fulltext_utf8

Enhanced form_defs.php:

  - Add Support for Textarea

  - Add Support for a vertical list, for example see Category in
    submitpub.php

  - Add support for dumping the form values in plain text, used in the
    email I send to testbed-ops.

  - Change Error Reporting text for subfields such as in a list so
    they also include the text from the outer field, for example in
    newosid "ping" will become "OS Features, ping".  I needed this
    since some of my subfields didn't have labels and it seamed like
    the right thing to do.

  - Set #return_value to 1 in FormRenderCheckBox if it not already
    specified

  - In FormRenderSelect, if the #value is not in the list add it to
    the end.

  - Add support for "display" type, to just display some text in the
    table

  - Possibly some other little things I forgot about.

...
parent 357df448
......@@ -1448,6 +1448,8 @@ done
......@@ -1502,13 +1504,14 @@ OUTERBOSS_NODENAME=""
OUTERBOSS_XMLRPCPORT=3069
OUTERBOSS_SSLCERTNAME="/etc/outer_emulab.pem"
PLABSUPPORT=0
PUBSUPPORT=0
WIKISUPPORT=0
TRACSUPPORT=0
BUGDBSUPPORT=0
OPSDBSUPPORT=0
MAILMANSUPPORT=0
WINSUPPORT=0
CVSSUPPORT=0
TRACSUPPORT=0
CHATSUPPORT=0
STAMPS=0
ARCHIVESUPPORT=0
......@@ -1740,7 +1743,6 @@ if test $ISOLATEADMINS -eq 1; then
EOF
fi
if test $DYNAMICROOTPASSWORDS -eq 1; then
cat >> confdefs.h <<EOF
#define DYNAMICROOTPASSWORDS 1
......@@ -1866,6 +1868,8 @@ fi
cat >> confdefs.h <<EOF
#define TBBASE "$TBBASE"
EOF
if test -z "$THISHOMEBASE"; then
THISHOMEBASE="Emulab.Net"
fi
......@@ -2122,17 +2126,17 @@ for ac_hdr in ulxmlrpcpp/ulxr_config.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2114: checking for $ac_hdr" >&5
echo "configure:2130: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2119 "configure"
#line 2135 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2140: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2171,17 +2175,17 @@ for ac_hdr in linux/videodev.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:2163: checking for $ac_hdr" >&5
echo "configure:2179: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2168 "configure"
#line 2184 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:2173: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:2189: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
......@@ -2214,7 +2218,7 @@ done
# Extract the first word of "gtk-config", so it can be a program name with args.
set dummy gtk-config; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2206: checking for $ac_word" >&5
echo "configure:2222: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_GTK_CONFIG'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2293,7 +2297,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:2285: checking for a BSD compatible install" >&5
echo "configure:2301: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......@@ -2354,7 +2358,7 @@ esac
# Extract the first word of "rsync", so it can be a program name with args.
set dummy rsync; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:2346: checking for $ac_word" >&5
echo "configure:2362: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_path_RSYNC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
......@@ -2811,8 +2815,8 @@ s%@OUTERBOSS_NODENAME@%$OUTERBOSS_NODENAME%g
s%@OUTERBOSS_XMLRPCPORT@%$OUTERBOSS_XMLRPCPORT%g
s%@OUTERBOSS_SSLCERTNAME@%$OUTERBOSS_SSLCERTNAME%g
s%@PLABSUPPORT@%$PLABSUPPORT%g
s%@PUBSUPPORT@%$PUBSUPPORT%g
s%@WIKISUPPORT@%$WIKISUPPORT%g
s%@TRACSUPPORT@%$TRACSUPPORT%g
s%@MAILMANSUPPORT@%$MAILMANSUPPORT%g
s%@BUGDBSUPPORT@%$BUGDBSUPPORT%g
s%@OPSDBSUPPORT@%$OPSDBSUPPORT%g
......@@ -2850,9 +2854,8 @@ s%@FRISEBEEMCASTADDR@%$FRISEBEEMCASTADDR%g
s%@FRISEBEEMCASTPORT@%$FRISEBEEMCASTPORT%g
s%@WINSUPPORT@%$WINSUPPORT%g
s%@CVSSUPPORT@%$CVSSUPPORT%g
s%@TRACSUPPORT@%$TRACSUPPORT%g
s%@CHATSUPPORT@%$CHATSUPPORT%g
s%@ISOLATEADMINS@%$ISOLATEADMINS%g
s%@DYNAMICROOTPASSWORDS@%$DYNAMICROOTPASSWORDS%g
s%@STAMPS@%$STAMPS%g
s%@ARCHIVESUPPORT@%$ARCHIVESUPPORT%g
s%@MIN_UNIX_UID@%$MIN_UNIX_UID%g
......@@ -2860,6 +2863,8 @@ s%@MIN_UNIX_GID@%$MIN_UNIX_GID%g
s%@DELAYTHRESH@%$DELAYTHRESH%g
s%@PELABSUPPORT@%$PELABSUPPORT%g
s%@ELVIN_COMPAT@%$ELVIN_COMPAT%g
s%@ISOLATEADMINS@%$ISOLATEADMINS%g
s%@DYNAMICROOTPASSWORDS@%$DYNAMICROOTPASSWORDS%g
s%@TBOPSEMAIL@%$TBOPSEMAIL%g
s%@TBOPSEMAIL_NOSLASH@%$TBOPSEMAIL_NOSLASH%g
s%@TBROBOCOPSEMAIL@%$TBROBOCOPSEMAIL%g
......
......@@ -155,6 +155,7 @@ AC_SUBST(OUTERBOSS_NODENAME)
AC_SUBST(OUTERBOSS_XMLRPCPORT)
AC_SUBST(OUTERBOSS_SSLCERTNAME)
AC_SUBST(PLABSUPPORT)
AC_SUBST(PUBSUPPORT)
AC_SUBST(WIKISUPPORT)
AC_SUBST(MAILMANSUPPORT)
AC_SUBST(BUGDBSUPPORT)
......@@ -256,6 +257,7 @@ OUTERBOSS_NODENAME=""
OUTERBOSS_XMLRPCPORT=3069
OUTERBOSS_SSLCERTNAME="/etc/outer_emulab.pem"
PLABSUPPORT=0
PUBSUPPORT=0
WIKISUPPORT=0
BUGDBSUPPORT=0
OPSDBSUPPORT=0
......
......@@ -43,6 +43,7 @@ ELVIN_COMPAT=1
#
# This next group will not work outside of Utah (yet).
#
PUBSUPPORT=1
WIKISUPPORT=1
TRACSUPPORT=1
BUGDBSUPPORT=1
......
......@@ -147,6 +147,8 @@ REPLACE INTO exported_tables VALUES ('state_triggers');
REPLACE INTO exported_tables VALUES ('table_regex');
REPLACE INTO exported_tables VALUES ('testsuite_preentables');
REPLACE INTO exported_tables VALUES ('webdb_table_permissions');
REPLACE INTO exported_tables VALUES ('emulab_pubs_month_map');
--
-- Dumping data for table `foreign_keys`
......@@ -944,6 +946,10 @@ REPLACE INTO table_regex VALUES ('user_pubkeys','verify','text','redirect','defa
REPLACE INTO table_regex VALUES ('user_pubkeys','user','text','redirect','users:uid',0,0,NULL);
REPLACE INTO table_regex VALUES ('user_pubkeys','keyfile','text','regex','^[-_\\w\\.\\/:+]*$',1,256,NULL);
REPLACE INTO table_regex VALUES ('default','tinytext_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,256,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','text_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','fulltext_utf8','text','regex','^(?:[\\x09\\x0A\\x0D\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
--
-- Dumping data for table `testsuite_preentables`
--
......@@ -1002,3 +1008,34 @@ REPLACE INTO webdb_table_permissions VALUES ('projects',1,1,0);
REPLACE INTO webdb_table_permissions VALUES ('osidtoimageid',1,0,1);
REPLACE INTO webdb_table_permissions VALUES ('table_regex',1,1,1);
--
-- Dumping data for table `emulab_pubs_month_map`
--
REPLACE INTO `emulab_pubs_month_map` VALUES (1,0.0,'');
REPLACE INTO `emulab_pubs_month_map` VALUES (2,1.0,'Jan');
REPLACE INTO `emulab_pubs_month_map` VALUES (3,2.0,'Feb');
REPLACE INTO `emulab_pubs_month_map` VALUES (4,3.0,'Mar');
REPLACE INTO `emulab_pubs_month_map` VALUES (5,4.0,'Apr');
REPLACE INTO `emulab_pubs_month_map` VALUES (6,5.0,'May');
REPLACE INTO `emulab_pubs_month_map` VALUES (7,6.0,'Jun');
REPLACE INTO `emulab_pubs_month_map` VALUES (8,7.0,'Jul');
REPLACE INTO `emulab_pubs_month_map` VALUES (9,8.0,'Aug');
REPLACE INTO `emulab_pubs_month_map` VALUES (10,9.0,'Sep');
REPLACE INTO `emulab_pubs_month_map` VALUES (11,10.0,'Oct');
REPLACE INTO `emulab_pubs_month_map` VALUES (12,11.0,'Nov');
REPLACE INTO `emulab_pubs_month_map` VALUES (13,12.0,'Dec');
REPLACE INTO `emulab_pubs_month_map` VALUES (14,1.5,'Jan-Feb');
REPLACE INTO `emulab_pubs_month_map` VALUES (15,2.5,'Feb-Mar');
REPLACE INTO `emulab_pubs_month_map` VALUES (16,3.5,'Mar-Apr');
REPLACE INTO `emulab_pubs_month_map` VALUES (17,4.5,'Apr-May');
REPLACE INTO `emulab_pubs_month_map` VALUES (18,5.5,'May-Jun');
REPLACE INTO `emulab_pubs_month_map` VALUES (19,6.5,'Jun-Jul');
REPLACE INTO `emulab_pubs_month_map` VALUES (20,7.5,'Jul-Aug');
REPLACE INTO `emulab_pubs_month_map` VALUES (21,8.5,'Aug-Sep');
REPLACE INTO `emulab_pubs_month_map` VALUES (22,9.5,'Sep-Oct');
REPLACE INTO `emulab_pubs_month_map` VALUES (23,10.5,'Oct-Nov');
REPLACE INTO `emulab_pubs_month_map` VALUES (24,11.5,'Nov-Dec');
REPLACE INTO `emulab_pubs_month_map` VALUES (25,12.5,'Dec-Jan');
......@@ -4545,3 +4545,8 @@ last_net_act,last_cpu_act,last_ext_act);
alter table interfaces add `uuid` varchar(40) NOT NULL default '';
alter table interfaces add KEY `uuid` (`uuid`);
update interfaces set uuid=UUID();
4.156: Create emulab_pubs and related tables.
Add support for UTF-8 fields in table_regex.
mysql tbdb < emulab_pubs.sql
drop table if exists emulab_pubs;
create table `emulab_pubs` (
`idx` int unsigned not null primary key auto_increment,
`uuid` varchar(40) not null unique,
`created` datetime not null,
`owner` mediumint(8) unsigned not null,
`submitted_by` mediumint(8) unsigned not null,
`last_edit` datetime not null,
`last_edit_by` mediumint(8) unsigned not null,
`type` tinytext not null,
`authors` tinytext not null,
`affil` tinytext not null,
`title` tinytext not null,
`conf` tinytext not null,
`conf_url` tinytext not null,
`where` tinytext not null,
`year` tinytext not null,
`month` float(3,1) not null,
`volume` tinytext not null,
`number` tinytext not null,
`pages` tinytext not null,
`url` tinytext not null,
`evaluated_on_emulab` tinytext not null,
`category` tinytext not null,
`project` tinytext not null,
`cite_osdi02` tinyint(1),
`no_cite_why` tinytext not null,
`notes` text not null,
`visible` tinyint(1) default 1 not null,
`deleted` tinyint(1) default 0 not null,
`editable_owner` tinyint(1) default 1 not null,
`editable_proj` tinyint(1) default 1 not null
);
drop table if exists emulab_pubs_month_map;
create table `emulab_pubs_month_map` (
`display_order` int unsigned not null unique auto_increment,
`month` float(3,1) not null primary key,
`month_name` char(8) not null
);
insert into emulab_pubs_month_map (`month`, `month_name`) values
(0, ''),
(1, 'Jan'),
(2, 'Feb'),
(3, 'Mar'),
(4, 'Apr'),
(5, 'May'),
(6, 'Jun'),
(7, 'Jul'),
(8, 'Aug'),
(9, 'Sep'),
(10, 'Oct'),
(11, 'Nov'),
(12, 'Dec'),
(1.5, 'Jan-Feb'),
(2.5, 'Feb-Mar'),
(3.5, 'Mar-Apr'),
(4.5, 'Apr-May'),
(5.5, 'May-Jun'),
(6.5, 'Jun-Jul'),
(7.5, 'Jul-Aug'),
(8.5, 'Aug-Sep'),
(9.5, 'Sep-Oct'),
(10.5, 'Oct-Nov'),
(11.5, 'Nov-Dec'),
(12.5, 'Dec-Jan');
REPLACE INTO table_regex VALUES ('default','tinytext_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,256,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','text_utf8','text','regex','^(?:[\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
REPLACE INTO table_regex VALUES ('default','fulltext_utf8','text','regex','^(?:[\\x09\\x0A\\x0D\\x20-\\x7E]|[\\xC2-\\xDF][\\x80-\\xBF]|\\xE0[\\xA0-\\xBF][\\x80-\\xBF]|[\\xE1-\\xEC\\xEE\\xEF][\\x80-\\xBF]{2}|\\xED[\\x80-\\x9F][\\x80-\\xBF])*$',0,65535,'adopted from http://www.w3.org/International/questions/qa-forms-utf-8.en.php');
......@@ -25,6 +25,7 @@ $TBWWW = "@TBWWW@";
$THISHOMEBASE = "@THISHOMEBASE@";
$ELABINELAB = @ELABINELAB@;
$PLABSUPPORT = @PLABSUPPORT@;
$PUBSUPPORT = @PUBSUPPORT@;
$WIKISUPPORT = @WIKISUPPORT@;
$TRACSUPPORT = @TRACSUPPORT@;
$BUGDBSUPPORT = @BUGDBSUPPORT@;
......
......@@ -88,3 +88,8 @@ else {
}
?>
This diff is collapsed.
......@@ -19,7 +19,7 @@
<br>
<li>
<font size="+1">
<a href="docwrapper.php3?docname=expubs.html"
<a href="../expubs.php"
>Published papers that have used Emulab</a>
</font>
</li>
......@@ -30,4 +30,5 @@
>Classes that have used Emulab</a>
</font>
</li>
</ul>
\ No newline at end of file
</ul>
<?php
include("pub_defs.php");
$optargs = OptionalPageArguments("printable", PAGEARG_BOOLEAN);
if (!isset($printable))
$printable = 0;
$this_user = null;
$isadmin = null;
if (!$printable && LoginStatus()) {
if (!$HTTPS) {
# redirect to secure site, otherwise CheckLoginOrDie will die
$new_url = "https://$WWWHOST$REQUEST_URI";
header("Location: $new_url");
PAGEHEADER("Bibliography");
echo "<p>Please use $new_url when logged in.</p>";
PAGEFOOTER();
return;
} else {
$this_user = CheckLoginOrDie();
$isadmin = ISADMIN();
}
}
#
# Standard Testbed Header
#
if ($printable) {
#
# Need to spit out some header stuff.
#
echo "<html>
<head>
<link rel='stylesheet' href='../tbstyle-plain.css' type='text/css'>
</head>
<body>\n";
} else {
PAGEHEADER("Bibliography");
echo "<b><a href=$REQUEST_URI?printable=1>
Printable version of this document</a></b><br>\n";
}
?>
<p>
This page summarizes publications about Emulab as well as publications
that used Emulab to validate research they present. For additional publications
see <a href="http://www.isi.edu/deter/publications.php"
>Publications Made Possible By DETERlab</a>.
<p>
If you have a publications that used Utah's Emulab to validate your
research please use <a href="submitpub.php">this form</a> to add it.
For other updates or corrections please email
<a href="mailto:papers@emulab.net">papers@emulab.net</a>.
</p>
<?php
$query_result = GetPubs("`visible`");
echo MakeBibList($this_user, $isadmin, $query_result);
if ($isadmin) {
echo '<p><a href="deleted_pubs.php">Show Deleted Publications</a></p>';
}
#
# Standard Testbed Footer
#
if ($printable) {
echo "</body>
</html>\n";
}
else {
PAGEFOOTER();
}
?>
......@@ -98,12 +98,11 @@ function FormRenderTextField($name, $attrs)
function FormRenderCheckBox($name, $attrs)
{
$html = "<input type=checkbox name=\"formfields[$name]\" ";
if (isset($attrs['#return_value'])) {
$html .= "value=\"" . $attrs['#return_value'] . "\" ";
if (isset($attrs['#value']) &&
$attrs['#value'] == $attrs['#return_value']) {
$html .= "checked ";
}
$return_value = isset($attrs['#return_value']) ? $attrs['#return_value'] : 1;
$html .= "value=\"" . $return_value . "\" ";
if (isset($attrs['#value']) &&
$attrs['#value'] == $return_value) {
$html .= "checked ";
}
if (isset($attrs['#class'])) {
$html .= "class=\"" . $attrs['#class'] . "\" ";
......@@ -174,14 +173,20 @@ function FormRenderSelect($name, $attrs)
}
$html .= ">\n";
if (isset($attrs['#default']))
$default = $attrs['#default'];
else
$default = "Please Select";
$html .= "<option value=''>$default &nbsp</option>\n";
if (!@$attrs['#no_default']) {
if (isset($attrs['#default']))
$default = $attrs['#default'];
else
$default = "Please Select";
$html .= "<option value=''>$default &nbsp</option>\n";
}
if (isset($attrs['#options'])) {
while (list ($selectvalue, $selectlabel) = each ($attrs['#options'])) {
$options = $attrs['#options'];
if (isset($attrs['#value']) && $attrs['#value'] != ''
&& !isset($options[$attrs['#value']]))
$options[$attrs['#value']] = $attrs['#value'];
foreach ($options as $selectvalue => $selectlabel) {
$selected = "";
if (isset($attrs['#value']) && $attrs['#value'] == $selectvalue) {
$selected = "selected";
......@@ -217,6 +222,32 @@ function FormRenderFile($name, $attrs)
return $html;
}
function FormRenderTextArea($name, $attrs)
{
$html = "<textarea name=\"formfields[$name]\" ";
if (isset($attrs['#javascript'])) {
$html .= $attrs['#javascript'] . " ";
}
if (isset($attrs['#class'])) {
$html .= "class=\"" . $attrs['#class'] . "\" ";
}
else {
$html .= "class=\"form-text\" ";
}
if (isset($attrs['#cols'])) {
$html .= "cols=" . $attrs['#cols'] . " ";
}
if (isset($attrs['#rows'])) {
$html .= "rows=" . $attrs['#rows'] . " ";
}
$html .= ">";
if (isset($attrs['#value'])) {
$html .= htmlspecialchars($attrs['#value']);
}
$html .= "</textarea>\n";
return $html;
}
function FormRenderSubmit($name, $attrs)
{
$html = "";
......@@ -295,6 +326,23 @@ function FormRenderList($name, $attributes, $submitted)
return $html;
}
# Render a list of elements together, vertically
function FormRenderVList($name, $attributes, $submitted)
{
$html = "";
while (list ($subname, $subattrs) = each ($attributes['#elements'])) {
if ($submitted && array_key_exists($subname, $submitted)) {
$subattrs['#value'] = $submitted[$subname];
}
if (isset($subattrs['#label']))
$html .= $subattrs['#label'] . ": ";
$html .= FormRenderElement($subname, $subattrs, $submitted);
$html .= "<br>";
}
return $html;
}
function FormRenderElement($name, $attributes, $submitted)
{
$field_html = null;
......@@ -352,6 +400,15 @@ function FormRenderElement($name, $attributes, $submitted)
case "list":
$field_html = FormRenderList($name, $attributes, $submitted);
break;
case "vlist":
$field_html = FormRenderVList($name, $attributes, $submitted);
break;
case "textarea":
$field_html = FormRenderTextArea($name, $attributes, $submitted);
break;
case "display":
$field_html = isset($submitted[$name]) ? $submitted[$name] : $attributes['#value'];
break;
}
return $field_html;
}
......@@ -370,7 +427,7 @@ function FormRenderElements($fields, $submitted)
continue;
}
$cols = "";
if ($attributes['#type'] == "table")
if ($attributes['#type'] == "table" || $attributes['#type'] == "textarea")
$cols = "colspan=2";
$mouseover = "";
......@@ -402,6 +459,7 @@ function FormRenderElements($fields, $submitted)
$html .= "<tr>";
if ($attributes['#type'] != "submit" &&
isset($attributes['#label']) &&
!isset($attributes['#colspan'])) {
$html .= "<td align=left $mouseover $cols>";
......@@ -420,8 +478,9 @@ function FormRenderElements($fields, $submitted)
$attributes['#description'] . ")";
if ($attributes['#type'] == "table") {
$html .= "$field_html</td>";
}
else {
} else if ($attributes['#type'] == "textarea") {
$html .= "<br>$field_html</td>";
} else {
$html .= "</td>";
$html .= "<td align=left>$field_html</td>";
}
......@@ -513,12 +572,22 @@ function FormRender($attributes, $errors, $fields, $submitted = null)
echo "$html\n";
}
function FormValidateElement($name, &$errors, $attributes, &$submitted)
function CombineLabels($parent, $attributes) {
$res = '';
$label = @$attributes['#label'];
$res .= $parent;
if ($parent != '' && $label != '') $res .= ', ';
$res .= $label;
return $res;
}
function FormValidateElement($name, &$errors, $attributes, &$submitted, $parent_label)
{
$error_label = CombineLabels($parent_label, $attributes);
# Check for required fields not filled out
if (isset($attributes['#required']) && $attributes['#required'] &&
!(isset($submitted[$name]) && $submitted[$name] != "")) {
$errors[$attributes['#label']] = "Missing required value";
$errors[$error_label] = "Missing required value";
}
elseif (isset($attributes['#checkslot']) &&
isset($submitted[$name]) && $submitted[$name] != "") {
......@@ -538,13 +607,13 @@ function FormValidateElement($name, &$errors, $attributes, &$submitted)
$matches[1], $matches[2],
TBDB_CHECKDBSLOT_WARN|
TBDB_CHECKDBSLOT_ERROR)) {
$errors[$attributes['#label']] = TBFieldErrorString();
$errors[$error_label] = TBFieldErrorString();
}
}
elseif (substr($check, 0, 1) == "/") {
# Regular expression.
if (!preg_match($check, $submitted[$name])) {
$errors[$attributes['#label']] = "Illegal characters";
$errors[$error_label] = "Illegal characters";
}
}
else {
......@@ -555,10 +624,11 @@ function FormValidateElement($name, &$errors, $attributes, &$submitted)
function FormValidateFileUpload($name, &$errors, $attributes)
{
$error_label = CombineLabels($parent_label, $attributes);
# Check for required fields not filled out
if (isset($attributes['#required']) && $attributes['#required'] &&
!(isset($_FILES[$name]['name']) && $_FILES[$name]['size'] != 0)) {
$errors[$attributes['#label']] = "Missing required value";
$errors[$error_label] = "Missing required value";
}
elseif (isset($attributes['#checkslot'])) {
$check = $attributes['#checkslot'];
......@@ -572,7 +642,7 @@ function FormValidateFileUpload($name, &$errors, $attributes)
}