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