fields.php File Reference

Access an applicant's record in the database. More...

Go to the source code of this file.

Functions

 fields_init ($link, $lang)
 initialize the $fields[] array
 input_control ($field, $name, $value)
 delivers HTML code of an input control for $field

Variables

 $fields
 describes how to access record fields in the database


Detailed Description

Access an applicant's record in the database.

Definition in file fields.php.


Function Documentation

fields_init ( link,
lang 
)

initialize the $fields[] array

This function must be called before $fields[] can be accessed.

Parameters:
$link an open handle to the MySQL database
Returns:
nothing

Definition at line 392 of file fields.php.

References $field_labels, $fields, $lang, $link, $q, $text_multi, $v, and db_query_mysql().

00392                                    {
00393         global $field_labels, $fields, $text_multi;
00394 
00395         $q  = "select usertype_names.usertype_id, usertype_names.name " 
00396             . "from usertype_names where "
00397             . "usertype_names.type = 'u' and usertype_names.lang='@lang@'";
00398 
00399         $result = db_query_mysql($link, $q, array("@lang@" => $lang));
00400 
00401         foreach ($result as $row) 
00402                 $fields["usertype"]["choices"][$row["usertype_id"]] = 
00403                         $row["name"];
00404 
00405         foreach ($fields as $k => $v) {
00406                 if (!isset($v['pica_query']))
00407                         $fields[$k]['pica_query'] = $v['query'];
00408 
00409                 if (!isset($v['view_query']))
00410                         $fields[$k]['view_query'] = $v['query'];
00411         }
00412 
00413         ## assign field labels
00414 
00415         foreach ($field_labels[$lang] as $k => $v) {
00416                 $fields[$k]['label'] = $v;
00417         }
00418 
00419         $fields['sex']['choices'] = array();
00420 
00421         $fields['sex']['choices']['m'] = $text_multi[$lang]['sex_m'];
00422         $fields['sex']['choices']['w'] = $text_multi[$lang]['sex_w'];
00423 }

Here is the call graph for this function:

input_control ( field,
name,
value 
)

delivers HTML code of an input control for $field

This function delivers HTML code suitable for embedding into HTML forms for editing database records.

Parameters:
$link an open handle to the MySQL database
$field an index into the $fields[] array
$name name of the input control
$value initial value of the input control
Returns:
HTML code

Definition at line 437 of file fields.php.

References $f, $fields, $months, $v, nbsp, and print.

Referenced by print_table().

00437                                               {
00438         global $fields;
00439         
00440         if (isset($fields[$field])) {
00441                 $f = $fields[$field];
00442 
00443         if ($f["type"] == "text") {
00444 
00445                 print '<input type="text" name="' . $name . '" ';
00446                 print 'value="' . htmlentities($value) . '" ';
00447                 print 'size="' . $f["size"] . '" ';
00448                 print 'maxlength="' . $f["size"] . '" >';
00449 
00450         } else if ($f["type"] == "choice") {
00451                 
00452                 print '<select name="' . $name . '">';
00453                 foreach ($f["choices"] as $k => $v) {
00454                         print '<option value="' . htmlentities($k) . '"';
00455                         if ($k == $value) 
00456                                 print ' selected="yes" ';
00457                         print '>';
00458                         print htmlentities($v);
00459                         print '</option>';
00460                 }
00461                 print '</select>';
00462         } else if ($f["type"] == "date") {
00463                 global $months;
00464 
00465                 list($year, $month, $day) = split('-', $value,3); 
00466 
00467                 print '<input type="text" name="' . $name . '_day" ';
00468                 print 'size="2" maxlength="2" value="' . $day . '"> &nbsp;';
00469 
00470                 print '<select name="' . $name . '_month">';
00471                 foreach ($months as $k => $v) {
00472                         print '<option value="' . htmlentities($k) . '"';
00473                         if ($k == $month) 
00474                                 print ' selected="yes" ';
00475                         print '>';
00476                         print htmlentities($v);
00477                         print '</option>';
00478                 }
00479                 print '</select>';
00480 
00481                 print '&nbsp; <input type="text" name="' . $name . '_year" ';
00482                 print 'size="4" maxlength="4" value="' . $year . '">';
00483                 
00484         }
00485 
00486         }
00487         
00488 }

Here is the caller graph for this function:


Variable Documentation

$fields

describes how to access record fields in the database

The $fields[] array contains information about how to query and change the value of record fields in the database.

Each element is an array representing a field in a database record. The sub-array consists of the following fields:

label
a human-readable description of the field's meaning
type
'text', 'choice', or 'date'
size
maximum length of input field (for "text" only)
choices
an array that contains the valid choices for the select list
valid
user's input is considered valid if it matches this regexp
query
sql query for retrieving the value of the field
update
sql query for modifying the value of the field
pica_query
sql query for retrieving the value of the field in the context of creating a PICA export record
view_query
sql query for displaying the value of the field
pica_field
corresponding field number in the PICA export record

Definition at line 47 of file fields.php.

Referenced by check_for_doubles(), export_to_pica(), fields_init(), input_control(), and print_table().


Generated on Mon Aug 28 09:46:10 2006 for anmeldung by  doxygen 1.4.7