Commit d5e19999 authored by Kevin Atkinson's avatar Kevin Atkinson

Bug fixes for publication support.

Added #prep attribute in form_defs.which is a function used in
FormValidate to "normalize" a field.  For example if it is "trim" than
all leading and trailing whitespace will be removed.
parent 95733771
......@@ -10,8 +10,8 @@ $this_user = null;
$isadmin = null;
if (!$printable && LoginStatus()) {
if (!$HTTPS) {
# redirect to secure site, otherwise CheckLoginOrDie will die
if (!@$HTTPS) {
# redirect to secure site, otherwise CheckLoginOrDie will fail
$new_url = "https://$WWWHOST$REQUEST_URI";
header("Location: $new_url");
PAGEHEADER("Bibliography");
......@@ -77,4 +77,3 @@ else {
PAGEFOOTER();
}
?>
......@@ -29,6 +29,8 @@ $footnotes = null;
# '#size' => 30, # Optional
# '#maxlength' => 30, # Optional
# '#required' => TRUE, # Optional
# '#prep' => 'trim' # Optional used by FormValidate
# '#checkslot' => 'default:text'# Optional used by FormValidate
# '#mouseover' => 'Mouse Me', # Optional string over label
# '#footnote' => 'See ...', # Optional footnote section.
# '#javascript' => "..."); # Optional
......@@ -572,6 +574,10 @@ function FormRender($attributes, $errors, $fields, $submitted = null)
echo "$html\n";
}
#
# FormValidate and helper functions
#
function CombineLabels($parent, $attributes) {
$res = '';
$label = @$attributes['#label'];
......@@ -585,6 +591,10 @@ function FormValidateElement($name, &$errors, $attributes, &$submitted, $parent_
{
$error_label = CombineLabels($parent_label, $attributes);
# Check for required fields not filled out
if (isset($attributes['#prep']) &&
isset($submitted[$name]) && $submitted[$name] != "") {
$submitted[$name] = $attributes['#prep']($submitted[$name]);
}
if (isset($attributes['#required']) && $attributes['#required'] &&
!(isset($submitted[$name]) && $submitted[$name] != "")) {
$errors[$error_label] = "Missing required value";
......@@ -686,6 +696,10 @@ function FormValidate($form, &$errors, $fields, &$submitted, $parent_label = '')
}
}
#
# FormTextDump and helper functions
#
function FormTextDumpElement($name, $attributes, $values, $label_width, $parent_label)
{
$res = '';
......@@ -753,4 +767,4 @@ function FormTextDump($form, $fields, $values, $label_width = 20, $parent_label
}
return $res;
}
?>
?>
\ No newline at end of file
......@@ -18,7 +18,14 @@ function MayEditPub($user, $isadmin, $row) {
return TBMinTrust($proj->UserTrust($user), $TBDB_TRUST_LOCALROOT);
}
$thesis_map = array(
'thesis' => 'Thesis',
'phd thesis' => 'PhD Thesis',
'masters thesis' => "Master's Thesis",
'bachelors thesis' => "Bachelor's Thesis");
function MakeBib($user, $isadmin, $r) {
global $thesis_map;
$res = '';
if ($r['url'] != '')
$res .= "<a href=\"" . $r['url'] . "\">";
......@@ -48,12 +55,13 @@ function MakeBib($user, $isadmin, $r) {
} else if ($type == 'techreport') {
$res .= ' Technical Report '. $r['number'];
# Affiliation here, but can't for techreports because of our data
if (!preg_match('/,/', $r['affil']))
$res .= ', ' . $r['affil'];
# if Thesis
} else if ($type == 'thesis' || $type == 'ms thesis' ||
$type = 'phd thesis' || $type = 'bs thesis') {
$res .= ' Thesis';
if ($r['where'] != '')
$res .= ', ' . $r['where'];
} else if (preg_match('/^([a-z]+ |)thesis$/', $type)) {
$res .= ' '. $thesis_map[$type];
if ($r['affil'] != '')
$res .= ', ' . $r['affil'];
}
# Not an Article/Tech report/Thesis? Add nothing special (for now)
......
......@@ -6,8 +6,7 @@
#
include("defs.php3");
include_once("template_defs.php");
if ($PAPERSUPPORT)
include_once("paper_defs.php");
include_once("pub_defs.php");
#
# Note the difference with which this page gets it arguments!
......@@ -100,11 +99,11 @@ if ($isadmin) {
}
$papers_html = null;
if ($PAPERSUPPORT) {
if ($PUBSUPPORT) {
#
# List papers for this project if any
#
$query_result = GetPapers("`project` = \"$pid\"");
$query_result = GetPubs("`project` = \"$pid\"");
if (mysql_num_rows($query_result)) {
$papers_html = MakeBibList($this_user, $isadmin, $query_result);
}
......
......@@ -121,6 +121,7 @@ $fields['authors'] =
'#label' => 'Authors',
'#size' => $default_textfield_size,
'#required' => true,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8',
'#description' => 'comma seperated list');
$fields['affil'] =
......@@ -128,6 +129,7 @@ $fields['affil'] =
'#label' => 'Author Affiliations',
'#size' => $default_textfield_size,
'#required' => true,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8',
'#description' => 'comma separated list, only list each institution once');
$fields['title'] =
......@@ -135,18 +137,21 @@ $fields['title'] =
'#label' => 'Title',
'#size' => $default_textfield_size,
'#required' => true,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8');
$fields['conf'] =
array('#type' => 'textfield',
'#label' => 'Conference/Journal',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8');
$fields['where'] =
array('#type' => 'textfield',
'#label' => 'Conference Location',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8');
$fields['year'] =
array('#type' => 'textfield',
......@@ -154,6 +159,7 @@ $fields['year'] =
'#size' => 4,
'#maxlength' => 4,
'#required' => true,
'#prep' => 'trim',
'#checkslot' => '/^\d\d\d\d$/');
$fields['month'] =
array('#type' => 'select',
......@@ -167,30 +173,35 @@ $fields['volume'] =
'#label' => 'Volume',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
$fields['number'] =
array('#type' => 'textfield',
'#label' => 'Number',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
$fields['pages'] =
array('#type' => 'textfield',
'#label' => 'Pages',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
$fields['url'] =
array('#type' => 'textfield',
'#label' => 'Publication URL',
'#size' => $default_textfield_size,
'#required' => true,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
$fields['conf_url'] =
array('#type' => 'textfield',
'#label' => 'Conference URL',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
$fields['category'] =
array('#type' => 'vlist',
......@@ -206,6 +217,7 @@ $fields['category'] =
array('#type' => 'textfield',
'#label' => 'If other specify',
'#size' => 50,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext',
'#nodump' => true)));
if ($isadmin) {
......@@ -215,6 +227,7 @@ if ($isadmin) {
'#description' => '"Y" or "N"',
'#size' => $default_textfield_size,
'#required' => false,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext');
}
$fields['project'] =
......@@ -239,6 +252,7 @@ $fields['cite_osdi02'] =
array('#label' => 'If (no) why not',
'#type' => 'textfield',
'#size' => 50,
'#prep' => 'trim',
'#checkslot' => 'default:tinytext_utf8')));
if ($isadmin) {
$fields['visible'] =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment