function update_marc_record_from_post(&$marc_record)
 {
     //Update the Name of Work
     if (!empty($_POST['nameofwork'])) {
         $marc_record->title = $_POST['nameofwork'];
     }
     //Update the Authors Name
     if (!empty($_POST['authorsname'])) {
         $marc_record->author = $_POST['authorsname'];
     }
     //Update the Primary Language
     $curr_lang = langcode3_for_langname($_POST['pri_language']);
     $marc_record->language = $curr_lang;
     //Update the Genre
     $marc_record->literary_form = $_POST['genre'];
 }
function _handle_action($action, $list_type, $language, $word_string)
{
    // look up the langcode3 for the language passed-in
    $langcode3 = langcode3_for_langname($language);
    $display_list = FALSE;
    switch ($action) {
        case "delete":
            // they want to delete a list, prompt for confirmation first
            echo "<p>" . sprintf(_("Are you sure you want to delete the <b>%s</b> site word list for language <b>%s</b>?"), $list_type, $language) . "<p>";
            echo "<form action='manage_site_word_lists.php' method='post'>";
            echo "<input type='hidden' name='action' value='deleteconfirmed'>";
            echo "<input type='hidden' name='list_type' value='{$list_type}'>";
            echo "<input type='hidden' name='language' value='{$language}'>";
            echo "<input type='submit' value='" . _("Yes") . "'>";
            echo "</form>";
            echo "<form action='manage_site_word_lists.php' method='post'>";
            echo "<input type='hidden' name='action' value='list'>";
            echo "<input type='submit' value='" . _("No") . "'>";
            echo "</form>";
            break;
        case "deleteconfirmed":
            // they've confirmed a deletion, delete the file
            $fileObject = get_site_word_file($langcode3, $list_type);
            unlink($fileObject->abs_path);
            echo "<p>" . sprintf(_("File <b>%s</b> has been deleted."), $fileObject->abs_path) . "</p>";
            $display_list = TRUE;
            break;
        case "create":
            // they want to create a word list
            // see if the word list has words already
            $fileObject = get_site_word_file($langcode3, $list_type);
            $list_words = load_word_list($fileObject->abs_path);
            if (count($list_words)) {
                echo "<p class='error'>" . sprintf(_("Can't create a <b>%s</b> list for <b>%s</b> (<b>%s</b>) as it already exists! Edit the list below instead."), $list_type, $language, $langcode3) . "</p>";
                $display_list = TRUE;
            } else {
                echo "<p>" . sprintf(_("Creating a <b>%s</b> list for language <b>%s</b>."), $list_type, $language) . "</p>";
                _echo_input_form($list_type, $langcode3, $language);
            }
            break;
        case "edit":
            // we're editing the list
            echo "<p>" . sprintf(_("Editing a <b>%s</b> list for language <b>%s</b>."), $list_type, $language) . "</p>";
            _echo_input_form($list_type, $langcode3, $language);
            break;
        case "save":
            // they want to save a list, prompt for validation first
            // calculate the changes
            // load existing word list
            $fileObject = get_site_word_file($langcode3, $list_type);
            $old_words = load_word_list($fileObject->abs_path);
            // clean up the new words
            $new_words = explode("\n", $word_string);
            $new_words = array_map('rtrim', $new_words);
            $new_words = array_unique($new_words);
            // the above set mirrors the clean-up code in save_word_list
            // TODO: other good checks might be ensuring that the words are
            // recognized by WordCheck, that they don't have spaces within
            // them, that they are all in $charset, etc
            // calculate the differences
            $unchanged = count(array_intersect($old_words, $new_words));
            $additions = count(array_diff($new_words, $old_words));
            $deletions = count(array_diff($old_words, $new_words));
            echo "<p>" . sprintf(_("Are you sure you want to save the <b>%s</b> site word list for language <b>%s</b>?"), $list_type, $language) . "<p>";
            echo "<p>" . sprintf(_("You made %d additions and %d deletions from the list (with %d words unchanged)."), $additions, $deletions, $unchanged) . "</p>";
            echo "<form action='manage_site_word_lists.php' method='post'>";
            echo "<input type='hidden' name='action' value='saveconfirmed'>";
            echo "<input type='hidden' name='list_type' value='{$list_type}'>";
            echo "<input type='hidden' name='language' value='{$language}'>";
            echo "<input type='hidden' name='word_string' value='" . attr_safe($word_string) . "'>";
            echo "<input type='submit' value='" . _("Yes") . "'>";
            echo "</form>";
            echo "<form action='manage_site_word_lists.php' method='post'>";
            echo "<input type='hidden' name='action' value='list'>";
            echo "<input type='submit' value='" . _("No") . "'>";
            echo "</form>";
            break;
        case "saveconfirmed":
            // save the list if requested
            $fileObject = get_site_word_file($langcode3, $list_type);
            $words = explode("\n", $word_string);
            save_word_list($fileObject->abs_path, $words, "\n");
            echo "<p>" . sprintf(_("The <b>%s</b> list for language <b>%s</b> has been saved."), $list_type, $language) . "</p>";
            $display_list = TRUE;
            break;
        case "list":
            $display_list = TRUE;
            break;
        default:
            die("Invalid action encountered.");
    }
    return $display_list;
}