$module->order = $order; // Make the new order take effect immediately } uasort($modules, function ($x, $y) { return $x->order - $y->order; }); } ?> <div id="sidebars" align="center"> <form method="post" action="<?php echo WT_SCRIPT_NAME; ?> "> <input type="hidden" name="action" value="update_mods"> <?php echo WT_Filter::getCsrf(); ?> <table id="sidebars_table" class="modules_table"> <thead> <tr> <th><?php echo WT_I18N::translate('Sidebar'); ?> </th> <th><?php echo WT_I18N::translate('Description'); ?> </th> <th><?php echo WT_I18N::translate('Order'); ?>
var fieldIDx = jQuery(this).attr("id"); var idNum = fieldIDx.replace("RELATIONSHIP_PATH_LENGTH",""); var newIDx = "gedcomid"+idNum; if (jQuery("#"+newIDx).val()=="") { alert("' . WT_I18N::translate('You must specify an individual record before you can restrict the user to their immediate family.') . '"); jQuery(this).val(""); } }); function regex_quote(str) { return str.replace(/[\\\\.?+*()[\\](){}|]/g, "\\\\$&"); } '); echo ' <form name="newform" method="post" action="admin_users.php?action=createuser" onsubmit="return checkform(this);" autocomplete="off"> ', WT_Filter::getCsrf(), ' <table id="adduser"> <tr> <td>', WT_I18N::translate('Real name'), help_link('real_name'), '</td> <td><input type="text" name="realname" style="width:95%;" required maxlength="64" value="', WT_Filter::escapeHtml($realname), '" autofocus></td> <td>', WT_I18N::translate('Administrator'), help_link('role'), '</td> <td><input type="checkbox" name="canadmin" value="1"></td> </tr> <tr> <td>', WT_I18N::translate('Username'), help_link('username'), '</td> <td><input type="text" name="username" style="width:95%;" required maxlength="32" value="', WT_Filter::escapeHtml($username), '"></td> <td>', WT_I18N::translate('Approved by administrator'), help_link('useradmin_verification'), '</td> <td><input type="checkbox" name="verified_by_admin" value="1" checked="checked"></td> </tr> <tr> <td>', WT_I18N::translate('Email address'), help_link('email'), '</td>
private function edit() { require_once WT_ROOT . 'includes/functions/functions_edit.php'; if (WT_USER_CAN_EDIT) { if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) { $block_id = WT_Filter::postInteger('block_id'); if ($block_id) { WT_DB::prepare("UPDATE `##block` SET gedcom_id=?, xref=? WHERE block_id=?")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::post('xref', WT_REGEX_XREF), $block_id)); } else { WT_DB::prepare("INSERT INTO `##block` (gedcom_id, xref, module_name, block_order) VALUES (?, ?, ?, ?)")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::post('xref', WT_REGEX_XREF), $this->getName(), 0)); $block_id = WT_DB::getInstance()->lastInsertId(); } set_block_setting($block_id, 'title', WT_Filter::post('title')); set_block_setting($block_id, 'story_body', WT_Filter::post('story_body')); $languages = array(); foreach (WT_I18N::installed_languages() as $code => $name) { if (WT_Filter::postBool('lang_' . $code)) { $languages[] = $code; } } set_block_setting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = WT_Filter::getInteger('block_id'); $controller = new WT_Controller_Page(); if ($block_id) { $controller->setPageTitle(WT_I18N::translate('Edit story')); $title = get_block_setting($block_id, 'title'); $story_body = get_block_setting($block_id, 'story_body'); $gedcom_id = WT_DB::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); $xref = WT_DB::prepare("SELECT xref FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); } else { $controller->setPageTitle(WT_I18N::translate('Add a story')); $title = ''; $story_body = ''; $gedcom_id = WT_GED_ID; $xref = WT_Filter::get('xref', WT_REGEX_XREF); } $controller->pageHeader()->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();'); if (array_key_exists('ckeditor', WT_Module::getActiveModules())) { ckeditor_WT_Module::enableEditor($controller); } echo '<form name="story" method="post" action="module.php?mod=', $this->getName(), '&mod_action=admin_edit">'; echo WT_Filter::getCsrf(); echo '<input type="hidden" name="save" value="1">'; echo '<input type="hidden" name="block_id" value="', $block_id, '">'; echo '<input type="hidden" name="gedcom_id" value="', WT_GED_ID, '">'; echo '<table id="story_module">'; echo '<tr><th>'; echo WT_I18N::translate('Story title'); echo '</th></tr><tr><td><textarea name="title" rows="1" cols="90" tabindex="2">', WT_Filter::escapeHtml($title), '</textarea></td></tr>'; echo '<tr><th>'; echo WT_I18N::translate('Story'); echo '</th></tr><tr><td>'; echo '<textarea name="story_body" class="html-edit" rows="10" cols="90" tabindex="2">', WT_Filter::escapeHtml($story_body), '</textarea>'; echo '</td></tr>'; echo '</table><table id="story_module2">'; echo '<tr>'; echo '<th>', WT_I18N::translate('Individual'), '</th>'; echo '<th>', WT_I18N::translate('Show this block for which languages?'), '</th>'; echo '</tr>'; echo '<tr>'; echo '<td class="optionbox">'; echo '<input data-autocomplete-type="INDI" type="text" name="xref" id="pid" size="4" value="' . $xref . '">'; echo print_findindi_link('pid'); if ($xref) { $person = WT_Individual::getInstance($xref); if ($person) { echo ' ', $person->format_list('span'); } } echo '</td>'; $languages = get_block_setting($block_id, 'languages'); echo '<td class="optionbox">'; echo edit_language_checkboxes('lang_', $languages); echo '</td></tr></table>'; echo '<p><input type="submit" value="', WT_I18N::translate('save'), '" tabindex="5">'; echo '</p>'; echo '</form>'; exit; } } else { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH); exit; } }
$in_progress = WT_DB::prepare("SELECT 1 FROM `##gedcom_chunk` WHERE gedcom_id=? AND imported=1 LIMIT 1")->execute(array($tree->tree_id))->fetchOne(); if (!$in_progress) { echo '<div id="import', $tree->tree_id, '"><div id="progressbar', $tree->tree_id, '"><div style="position:absolute;">', WT_I18N::translate('Deleting old genealogy data…'), '</div></div></div>'; $controller->addInlineJavascript('jQuery("#progressbar' . $tree->tree_id . '").progressbar({value: 0});'); } else { echo '<div id="import', $tree->tree_id, '"></div>'; } $controller->addInlineJavascript('jQuery("#import' . $tree->tree_id . '").load("import.php?gedcom_id=' . $tree->tree_id . '&keep_media' . $tree->tree_id . '=' . WT_Filter::get('keep_media' . $tree->tree_id) . '");'); echo '<table border="0" width="100%" id="actions', $tree->tree_id, '" style="display:none">'; } else { echo '<table border="0" width="100%" id="actions', $tree->tree_id, '">'; } echo '<tr align="center">', '<td><a href="admin_trees_export.php?ged=', $tree->tree_name_url, '" onclick="return modalDialog(\'admin_trees_export.php?ged=', $tree->tree_name_url, '\', \'', WT_I18N::translate('Export'), '\');">', WT_I18N::translate('Export'), '</a>', help_link('export_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=importform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Import'), '</a>', help_link('import_gedcom'), '</td>', '<td><a href="admin_trees_download.php?ged=', $tree->tree_name_url, '">', WT_I18N::translate('Download'), '</a>', help_link('download_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=uploadform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Upload'), '</a>', help_link('upload_gedcom'), '</td>', '<td>', '<a href="#" onclick="if (confirm(\'' . WT_Filter::escapeJs(WT_I18N::translate('Are you sure you want to delete “%s”?', $tree->tree_name)), '\')) document.delete_form', $tree->tree_id, '.submit(); return false;">', WT_I18N::translate('Delete'), '</a>', '<form name="delete_form', $tree->tree_id, '" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="delete">', '<input type="hidden" name="gedcom_id" value="', $tree->tree_id, '">', WT_Filter::getCsrf(), '</form>', '</td></tr></table></td></tr></table><br>'; } } // Options for creating new gedcoms and setting defaults if (Auth::isAdmin()) { echo '<table class="gedcom_table2"><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<th>', WT_I18N::translate('Default family tree'), help_link('default_gedcom'), '</th>'; } echo '<th>', WT_I18N::translate('Create a new family tree'), help_link('add_new_gedcom'), '</th></tr><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<td><form name="defaultform" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="setdefault">', WT_Filter::getCsrf(), select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::preference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), '</form></td>'; } echo '<td class="button">', '<form name="createform" method="post" action="', WT_SCRIPT_NAME, '">', WT_Filter::getCsrf(), '<input type="hidden" name="action" value="new_tree">', '<input name="ged_name">', ' <input type="submit" value="', WT_I18N::translate('save'), '">', '</form>', '</td>', '</tr></table><br>'; // display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded if (count(WT_Tree::GetAll()) == 0 && count(User::all()) == 1) { echo '<div class="center">', '<a style="color:green; font-weight:bold;" href="admin_pgv_to_wt.php">', WT_I18N::translate('Click here for PhpGedView to <b>webtrees</b> transfer wizard'), '</a>', help_link('PGV_WIZARD'), '</div>'; } }
/** * If the Facebook username or email is associated with an account, login to it. Otherwise, register a new account. * * @param object $facebookUser Facebook user * @param string $url (optional) URL to redirect to afterwards. */ private function login_or_register(&$facebookUser, $url = '') { $REQUIRE_ADMIN_AUTH_REGISTRATION = WT_Site::getPreference('REQUIRE_ADMIN_AUTH_REGISTRATION'); if ($this->getSetting('require_verified', 1) && empty($facebookUser->verified)) { $this->error_page(WT_I18N::translate('Only verified Facebook accounts are authorized. Please verify your account on Facebook and then try again')); } if (empty($facebookUser->username)) { $facebookUser->username = $facebookUser->id; } $user_id = $this->get_user_id_from_facebook_username($facebookUser->username); if (!$user_id) { if (!isset($facebookUser->email)) { $this->error_page(WT_I18N::translate('You must grant access to your email address via Facebook in order to use this website. Please uninstall the application on Facebook and try again.')); } $user = User::findByIdentifier($facebookUser->email); if ($user) { $user_id = $user->getUserId(); } } if ($user_id) { // This is an existing user so log them in if they are approved $login_result = $this->login($user_id); $message = ''; switch ($login_result) { case -1: // not validated $message = WT_I18N::translate('This account has not been verified. Please check your email for a verification message.'); break; case -2: // not approved $message = WT_I18N::translate('This account has not been approved. Please wait for an administrator to approve it.'); break; default: $user = User::find($user_id); $user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username)); // redirect to the homepage/$url header('Location: ' . WT_SCRIPT_PATH . $url); return; } $this->error_page($message); } else { // This is a new Facebook user who may or may not already have a manual account if (!WT_Site::getPreference('USE_REGISTRATION_MODULE')) { $this->error_page('<p>' . WT_I18N::translate('The administrator has disabled registrations.') . '</p>'); } // check if the username is already in use $username = $this->cleanseFacebookUsername($facebookUser->username); $wt_username = substr($username, 0, 32); // Truncate the username to 32 characters to match the DB. if (User::findByIdentifier($wt_username)) { // fallback to email as username since we checked above that a user with the email didn't exist. $wt_username = $facebookUser->email; $wt_username = substr($wt_username, 0, 32); // Truncate the username to 32 characters to match the DB. } // Generate a random password since the user shouldn't need it and can always reset it. $password = md5(uniqid(rand(), TRUE)); $hashcode = md5(uniqid(rand(), true)); $preApproved = unserialize($this->getSetting('preapproved')); // From login.php: Log::addAuthenticationLog('User registration requested for: ' . $wt_username); if ($user = User::create($wt_username, $facebookUser->name, $facebookUser->email, $password)) { $verifiedByAdmin = !$REQUIRE_ADMIN_AUTH_REGISTRATION || isset($preApproved[$username]); $user->setPreference(self::user_setting_facebook_username, $this->cleanseFacebookUsername($facebookUser->username))->setPreference('language', WT_LOCALE)->setPreference('verified', '1')->setPreference('verified_by_admin', $verifiedByAdmin ? '1' : '0')->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', $hashcode)->setPreference('contactmethod', 'messaging2')->setPreference('visibleonline', '1')->setPreference('editaccount', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', $verifiedByAdmin ? WT_TIMESTAMP : '0')->setPreference('comment', @$facebookUser->birthday . "\n " . "https://www.facebook.com/" . $this->cleanseFacebookUsername($facebookUser->username)); // Apply pre-approval settings if (isset($preApproved[$username])) { $userSettings = $preApproved[$username]; foreach ($userSettings as $gedcom => $userGedcomSettings) { foreach (array('gedcomid', 'rootid', 'canedit') as $userPref) { if (empty($userGedcomSettings[$userPref])) { continue; } // Use a direct DB query instead of $tree->setUserPreference since we // can't get a reference to the WT_Tree since it checks permissions but // we are trying to give the permissions. WT_DB::prepare("REPLACE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, LEFT(?, 255))")->execute(array($user->getUserId(), $gedcom, $userPref, $userGedcomSettings[$userPref])); } } // Remove the pre-approval record unset($preApproved[$username]); $this->setSetting('preapproved', serialize($preApproved)); } // We need jQuery below global $controller; $controller = new WT_Controller_Page(); $controller->setPageTitle($this->getTitle())->pageHeader(); echo '<form id="verify-form" name="verify-form" method="post" action="', WT_LOGIN_URL, '" class="ui-autocomplete-loading" style="width:16px;height:16px;padding:0">'; echo $this->hidden_input("action", "verify_hash"); echo $this->hidden_input("user_name", $wt_username); echo $this->hidden_input("user_password", $password); echo $this->hidden_input("user_hashcode", $hashcode); echo WT_Filter::getCsrf(); echo '</form>'; if ($verifiedByAdmin) { $controller->addInlineJavaScript(' function verify_hash_success() { // now the account is approved but not logged in. Now actually login for the user. window.location = "' . $this->getConnectURL($url) . '"; } function verify_hash_failure() { alert("' . WT_I18N::translate("There was an error verifying your account. Contact the site administrator if you are unable to access the site.") . '"); window.location = "' . WT_SCRIPT_PATH . '"; } $(document).ready(function() { $.post("' . WT_LOGIN_URL . '", $("#verify-form").serialize(), verify_hash_success).fail(verify_hash_failure); }); '); } else { echo '<script>document.getElementById("verify-form").submit()</script>'; } } else { Log::addErrorLog("Facebook: Couldn't create the user account"); $this->error_page('<p>' . WT_I18N::translate('Unable to create your account. Please try again.') . '</p>' . '<div class="back"><a href="javascript:history.back()">' . WT_I18N::translate('Back') . '</a></div>'); } } }
function print_indi_form($nextaction, WT_Individual $person = null, WT_Family $family = null, WT_Fact $name_fact = null, $famtag = 'CHIL', $gender = 'U') { global $WORD_WRAPPED_NOTES, $NPFX_accept, $SHOW_GEDCOM_RECORD, $bdm, $STANDARD_NAME_FACTS, $ADVANCED_NAME_FACTS; global $QUICK_REQUIRED_FACTS, $QUICK_REQUIRED_FAMFACTS, $controller; $SURNAME_TRADITION = get_gedcom_setting(WT_GED_ID, 'SURNAME_TRADITION'); if ($person) { $xref = $person->getXref(); } elseif ($family) { $xref = $family->getXref(); } else { $xref = 'new'; } $name_fields = array(); if ($name_fact) { $name_fact_id = $name_fact->getFactId(); $name_type = $name_fact->getAttribute('TYPE'); $namerec = $name_fact->getGedcom(); // Populate the standard NAME field and subfields foreach ($STANDARD_NAME_FACTS as $tag) { if ($tag == 'NAME') { $name_fields[$tag] = $name_fact->getValue(); } else { $name_fields[$tag] = $name_fact->getAttribute($tag); } } } else { $name_fact_id = null; $name_type = null; $namerec = null; // Populate the standard NAME field and subfields foreach ($STANDARD_NAME_FACTS as $tag) { $name_fields[$tag] = ''; } } $bdm = ''; // used to copy '1 SOUR' to '2 SOUR' for BIRT DEAT MARR echo '<div id="edit_interface-page">'; echo '<h4>', $controller->getPageTitle(), '</h4>'; init_calendar_popup(); echo '<form method="post" name="addchildform" onsubmit="return checkform();">'; echo '<input type="hidden" name="ged" value="', WT_Filter::escapeHtml(WT_GEDCOM), '">'; echo '<input type="hidden" name="action" value="', $nextaction, '">'; echo '<input type="hidden" name="fact_id" value="', $name_fact_id, '">'; echo '<input type="hidden" name="xref" value="', $xref, '">'; echo '<input type="hidden" name="famtag" value="', $famtag, '">'; echo '<input type="hidden" name="gender" value="', $gender, '">'; echo '<input type="hidden" name="goto" value="">'; // set by javascript echo WT_Filter::getCsrf(); echo '<table class="facts_table">'; switch ($nextaction) { case 'add_child_to_family_action': case 'add_child_to_individual_action': // When adding a new child, specify the pedigree add_simple_tag('0 PEDI'); break; case 'update': // When adding/editing a name, specify the type add_simple_tag('0 TYPE ' . $name_type, '', '', null, $person); break; } $new_marnm = ''; // Inherit surname from parents, spouse or child if (!$namerec) { // We’ll need the parent’s name to set the child’s surname if ($family) { $father = $family->getHusband(); if ($father && $father->getFirstFact('NAME')) { $father_name = $father->getFirstFact('NAME')->getValue(); } else { $father_name = ''; } $mother = $family->getWife(); if ($mother && $mother->getFirstFact('NAME')) { $mother_name = $mother->getFirstFact('NAME')->getValue(); } else { $mother_name = ''; } } else { $father_name = ''; $mother_name = ''; } // We’ll need the spouse/child’s name to set the spouse/parent’s surname if ($person && $person->getFirstFact('NAME')) { $indi_name = $person->getFirstFact('NAME')->getValue(); } else { $indi_name = ''; } // Different cultures do surnames differently switch ($SURNAME_TRADITION) { case 'spanish': //Mother: Maria /AAAA BBBB/ //Father: Jose /CCCC DDDD/ //Child: Pablo /CCCC AAAA/ switch ($nextaction) { case 'add_child_to_family_action': if (preg_match('/\\/(\\S+) \\S+\\//', $mother_name, $matchm) && preg_match('/\\/(\\S+) \\S+\\//', $father_name, $matchf)) { $name_fields['SURN'] = $matchf[1] . ' ' . $matchm[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } break; case 'add_parent_to_individual_action': if ($famtag == 'HUSB' && preg_match('/\\/(\\S+) \\S+\\//', $indi_name, $match)) { $name_fields['SURN'] = $match[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } if ($famtag == 'WIFE' && preg_match('/\\/\\S+ (\\S+)\\//', $indi_name, $match)) { $name_fields['SURN'] = $match[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } break; case 'add_child_to_individual_action': case 'add_spouse_to_individual_action': case 'add_spouse_to_family_action': break; } break; case 'portuguese': //Mother: Maria /AAAA BBBB/ //Father: Jose /CCCC DDDD/ //Child: Pablo /BBBB DDDD/ switch ($nextaction) { case 'add_child_to_family_action': if (preg_match('/\\/\\S+\\s+(\\S+)\\//', $mother_name, $matchm) && preg_match('/\\/\\S+\\s+(\\S+)\\//', $father_name, $matchf)) { $name_fields['SURN'] = $matchf[1] . ' ' . $matchm[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } break; case 'add_parent_to_individual_action': if ($famtag == 'HUSB' && preg_match('/\\/\\S+\\s+(\\S+)\\//', $indi_name, $match)) { $name_fields['SURN'] = $match[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } if ($famtag == 'WIFE' && preg_match('/\\/(\\S+)\\s+\\S+\\//', $indi_name, $match)) { $name_fields['SURN'] = $match[1]; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } break; case 'add_child_to_individual_action': case 'add_spouse_to_individual_action': case 'add_spouse_to_family_action': break; } break; case 'icelandic': // Sons get their father’s given name plus “sson” // Daughters get their father’s given name plus “sdottir” switch ($nextaction) { case 'add_child_to_family_action': if ($gender == 'M' && preg_match('/(\\S+)\\s+\\/.*\\//', $father_name, $match)) { $name_fields['SURN'] = preg_replace('/s$/', '', $match[1]) . 'sson'; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } if ($gender == 'F' && preg_match('/(\\S+)\\s+\\/.*\\//', $father_name, $match)) { $name_fields['SURN'] = preg_replace('/s$/', '', $match[1]) . 'sdottir'; $name_fields['NAME'] = '/' . $name_fields['SURN'] . '/'; } break; case 'add_parent_to_individual_action': if ($famtag == 'HUSB' && preg_match('/(\\S+)sson\\s+\\/.*\\//i', $indi_name, $match)) { $name_fields['GIVN'] = $match[1]; $name_fields['NAME'] = $name_fields['GIVN'] . ' //'; } if ($famtag == 'WIFE' && preg_match('/(\\S+)sdottir\\s+\\/.*\\//i', $indi_name, $match)) { $name_fields['GIVN'] = $match[1]; $name_fields['NAME'] = $name_fields['GIVN'] . ' //'; } break; case 'add_child_to_individual_action': case 'add_spouse_to_individual_action': case 'add_spouse_to_family_action': break; } break; case 'patrilineal': // Father gives his surname to his children switch ($nextaction) { case 'add_child_to_family_action': if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $father_name, $match)) { $name_fields['SURN'] = $match[2]; $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_parent_to_individual_action': if ($famtag == 'HUSB' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) { $name_fields['SURN'] = $match[2]; $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_child_to_individual_action': case 'add_spouse_to_individual_action': case 'add_spouse_to_family_action': break; } break; case 'matrilineal': // Mother gives her surname to her children switch ($nextaction) { case 'add_child_to_family_action': if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $mother, $match)) { $name_fields['SURN'] = $match[2]; $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_parent_to_individual_action': if ($famtag == 'WIFE' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) { $name_fields['SURN'] = $match[2]; $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_child_to_individual_action': case 'add_spouse_to_individual_action': case 'add_spouse_to_family_action': break; } break; case 'paternal': case 'polish': case 'lithuanian': // Father gives his surname to his wife and children switch ($nextaction) { case 'add_spouse_to_individual_action': if ($famtag == 'WIFE' && preg_match('/\\/(.*)\\//', $indi_name, $match)) { if ($SURNAME_TRADITION == 'polish') { $match[1] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[1]); } elseif ($SURNAME_TRADITION == 'lithuanian') { $match[1] = preg_replace(array('/as$/', '/is$/', '/ys$/', '/us$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[1]); } $new_marnm = $match[1]; } break; case 'add_child_to_family_action': if (preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $father_name, $match)) { $name_fields['SURN'] = $match[2]; if ($SURNAME_TRADITION == 'polish' && $gender == 'F') { $match[2] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[2]); } elseif ($SURNAME_TRADITION == 'lithuanian' && $gender == 'F') { $match[2] = preg_replace(array('/as$/', '/a$/', '/is$/', '/ys$/', '/ius$/', '/us$/'), array('aitė', 'aitė', 'ytė', 'ytė', 'iūtė', 'utė'), $match[2]); } $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_child_to_individual_action': if ($person->getSex() == 'M' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) { $name_fields['SURN'] = $match[2]; if ($SURNAME_TRADITION == 'polish' && $gender == 'F') { $match[2] = preg_replace(array('/ski$/', '/cki$/', '/dzki$/', '/żki$/'), array('ska', 'cka', 'dzka', 'żka'), $match[2]); } elseif ($SURNAME_TRADITION == 'lithuanian' && $gender == 'F') { $match[2] = preg_replace(array('/as$/', '/a$/', '/is$/', '/ys$/', '/ius$/', '/us$/'), array('aitė', 'aitė', 'ytė', 'ytė', 'iūtė', 'utė'), $match[2]); } $name_fields['SPFX'] = trim($match[1]); $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } break; case 'add_parent_to_individual_action': if ($famtag == 'HUSB' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) { if ($SURNAME_TRADITION == 'polish' && $gender == 'M') { $match[2] = preg_replace(array('/ska$/', '/cka$/', '/dzka$/', '/żka$/'), array('ski', 'cki', 'dzki', 'żki'), $match[2]); } elseif ($SURNAME_TRADITION == 'lithuanian') { // not a complete list as the rules are somewhat complicated but will do 95% correctly $match[2] = preg_replace(array('/aitė$/', '/ytė$/', '/iūtė$/', '/utė$/'), array('as', 'is', 'ius', 'us'), $match[2]); } $name_fields['SPFX'] = trim($match[1]); $name_fields['SURN'] = $match[2]; $name_fields['NAME'] = "/{$match[1]}{$match[2]}/"; } if ($famtag == 'WIFE' && preg_match('/\\/((?:[a-z]{2,3} )*)(.*)\\//i', $indi_name, $match)) { if ($SURNAME_TRADITION == 'lithuanian') { $match[2] = preg_replace(array('/as$/', '/is$/', '/ys$/', '/us$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[2]); $match[2] = preg_replace(array('/aitė$/', '/ytė$/', '/iūtė$/', '/utė$/'), array('ienė', 'ienė', 'ienė', 'ienė'), $match[2]); } $new_marnm = $match[2]; } break; case 'add_spouse_to_family_action': break; } break; } } // Initialise an empty name field if (empty($name_fields['NAME'])) { $name_fields['NAME'] = '//'; } // Populate any missing 2 XXXX fields from the 1 NAME field $npfx_accept = implode('|', $NPFX_accept); if (preg_match("/((({$npfx_accept})\\.? +)*)([^\n\\/\"]*)(\"(.*)\")? *\\/(([a-z]{2,3} +)*)(.*)\\/ *(.*)/i", $name_fields['NAME'], $name_bits)) { if (empty($name_fields['NPFX'])) { $name_fields['NPFX'] = $name_bits[1]; } if (empty($name_fields['SPFX']) && empty($name_fields['SURN'])) { $name_fields['SPFX'] = trim($name_bits[7]); // For names with two surnames, there will be four slashes. // Turn them into a list $name_fields['SURN'] = preg_replace('~/[^/]*/~', ',', $name_bits[9]); } if (empty($name_fields['GIVN'])) { $name_fields['GIVN'] = $name_bits[4]; } // Don’t automatically create an empty NICK - it is an “advanced” field. if (empty($name_fields['NICK']) && !empty($name_bits[6]) && !preg_match('/^2 NICK/m', $namerec)) { $name_fields['NICK'] = $name_bits[6]; } } // Edit the standard name fields foreach ($name_fields as $tag => $value) { add_simple_tag("0 {$tag} {$value}"); } // Get the advanced name fields $adv_name_fields = array(); if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $ADVANCED_NAME_FACTS, $match)) { foreach ($match[1] as $tag) { $adv_name_fields[$tag] = ''; } } // This is a custom tag, but webtrees uses it extensively. if ($SURNAME_TRADITION == 'paternal' || $SURNAME_TRADITION == 'polish' || $SURNAME_TRADITION == 'lithuanian' || strpos($namerec, '2 _MARNM') !== false) { $adv_name_fields['_MARNM'] = ''; } if (isset($adv_name_fields['TYPE'])) { unset($adv_name_fields['TYPE']); } foreach ($adv_name_fields as $tag => $dummy) { // Edit existing tags if (preg_match_all("/2 {$tag} (.+)/", $namerec, $match)) { foreach ($match[1] as $value) { if ($tag == '_MARNM') { $mnsct = preg_match('/\\/(.+)\\//', $value, $match2); $marnm_surn = ''; if ($mnsct > 0) { $marnm_surn = $match2[1]; } add_simple_tag("2 _MARNM " . $value); add_simple_tag("2 _MARNM_SURN " . $marnm_surn); } else { add_simple_tag("2 {$tag} {$value}", '', WT_Gedcom_Tag::getLabel("NAME:{$tag}", $person)); } } } // Allow a new row to be entered if there was no row provided if (count($match[1]) == 0 && empty($name_fields[$tag]) || $tag != '_HEB' && $tag != 'NICK') { if ($tag == '_MARNM') { if (strstr($ADVANCED_NAME_FACTS, '_MARNM') == false) { add_simple_tag("0 _MARNM"); add_simple_tag("0 _MARNM_SURN {$new_marnm}"); } } else { add_simple_tag("0 {$tag}", '', WT_Gedcom_Tag::getLabel("NAME:{$tag}", $person)); } } } // Handle any other NAME subfields that aren’t included above (SOUR, NOTE, _CUSTOM, etc) if ($namerec) { $gedlines = explode("\n", $namerec); // -- find the number of lines in the record $fields = explode(' ', $gedlines[0]); $glevel = $fields[0]; $level = $glevel; $type = trim($fields[1]); $tags = array(); $i = 0; do { if ($type != 'TYPE' && !isset($name_fields[$type]) && !isset($adv_name_fields[$type])) { $text = ''; for ($j = 2; $j < count($fields); $j++) { if ($j > 2) { $text .= ' '; } $text .= $fields[$j]; } while ($i + 1 < count($gedlines) && preg_match("/" . ($level + 1) . " (CON[CT]) ?(.*)/", $gedlines[$i + 1], $cmatch) > 0) { if ($cmatch[1] == "CONT") { $text .= "\n"; } if ($WORD_WRAPPED_NOTES) { $text .= ' '; } $text .= $cmatch[2]; $i++; } add_simple_tag($level . ' ' . $type . ' ' . $text); } $tags[] = $type; $i++; if (isset($gedlines[$i])) { $fields = explode(' ', $gedlines[$i]); $level = $fields[0]; if (isset($fields[1])) { $type = $fields[1]; } } } while ($level > $glevel && $i < count($gedlines)); } // If we are adding a new individual, add the basic details if ($nextaction != 'update') { echo '</table><br><table class="facts_table">'; // 1 SEX if ($famtag == "HUSB" || $gender == "M") { add_simple_tag("0 SEX M"); } elseif ($famtag == "WIFE" || $gender == "F") { add_simple_tag("0 SEX F"); } else { add_simple_tag("0 SEX"); } $bdm = "BD"; if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (!in_array($match, explode('|', WT_EVENTS_DEAT))) { addSimpleTags($match); } } } //-- if adding a spouse add the option to add a marriage fact to the new family if ($nextaction == 'add_spouse_to_individual_action' || $nextaction == 'add_spouse_to_family_action') { $bdm .= "M"; if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FAMFACTS, $matches)) { foreach ($matches[1] as $match) { addSimpleTags($match); } } } if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $QUICK_REQUIRED_FACTS, $matches)) { foreach ($matches[1] as $match) { if (in_array($match, explode('|', WT_EVENTS_DEAT))) { addSimpleTags($match); } } } } echo keep_chan($person); echo "</table>"; if ($nextaction == 'update') { // GEDCOM 5.5.1 spec says NAME doesn’t get a OBJE print_add_layer('SOUR'); print_add_layer('NOTE'); print_add_layer('SHARED_NOTE'); } else { print_add_layer('SOUR', 1); print_add_layer('OBJE', 1); print_add_layer('NOTE', 1); print_add_layer('SHARED_NOTE', 1); } // If we are editing an existing name, allow raw GEDCOM editing if ($name_fact && (Auth::isAdmin() || $SHOW_GEDCOM_RECORD)) { echo '<br><br><a href="edit_interface.php?action=editrawfact&xref=', $xref, '&fact_id=', $name_fact->getFactId(), '&ged=', WT_GEDURL, '">', WT_I18N::translate('Edit raw GEDCOM'), '</a>'; } echo '<p id="save-cancel">'; echo '<input type="submit" class="save" value="', WT_I18N::translate('save'), '">'; if (preg_match('/^add_(child|spouse|parent|unlinked_indi)/', $nextaction)) { echo '<input type="submit" class="save" value="', WT_I18N::translate('go to new individual'), '" onclick="document.addchildform.goto.value=\'new\';">'; } echo '<input type="button" class="cancel" value="', WT_I18N::translate('close'), '" onclick="window.close();">'; echo '</p>'; echo '</form>'; $controller->addInlineJavascript(' SURNAME_TRADITION="' . $SURNAME_TRADITION . '"; gender="' . $gender . '"; famtag="' . $famtag . '"; function trim(str) { str=str.replace(/\\s\\s+/g, " "); return str.replace(/(^\\s+)|(\\s+$)/g, ""); } function lang_class(str) { if (str.match(/[\\u0370-\\u03FF]/)) return "greek"; if (str.match(/[\\u0400-\\u04FF]/)) return "cyrillic"; if (str.match(/[\\u0590-\\u05FF]/)) return "hebrew"; if (str.match(/[\\u0600-\\u06FF]/)) return "arabic"; return "latin"; // No matched text implies latin :-) } // Generate a full name from the name components function generate_name() { var frm =document.forms[0]; var npfx=frm.NPFX.value; var givn=frm.GIVN.value; var spfx=frm.SPFX.value; var surn=frm.SURN.value; var nsfx=frm.NSFX.value; if (SURNAME_TRADITION=="polish" && (gender=="F" || famtag=="WIFE")) { surn=surn.replace(/ski$/, "ska"); surn=surn.replace(/cki$/, "cka"); surn=surn.replace(/dzki$/, "dzka"); surn=surn.replace(/żki$/, "żka"); } // Commas are used in the GIVN and SURN field to separate lists of surnames. // For example, to differentiate the two Spanish surnames from an English // double-barred name. // Commas *may* be used in other fields, and will form part of the NAME. if (WT_LOCALE=="vi" || WT_LOCALE=="hu") { // Default format: /SURN/ GIVN return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+givn.replace(/ *, */g, " ")+" "+nsfx); } else if (WT_LOCALE=="zh") { // Default format: /SURN/GIVN return trim(npfx+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/"+givn.replace(/ *, */g, " ")+" "+nsfx); } else { // Default format: GIVN /SURN/ return trim(npfx+" "+givn.replace(/ *, */g, " ")+" /"+trim(spfx+" "+surn).replace(/ *, */g, " ")+"/ "+nsfx); } } // Update the NAME and _MARNM fields from the name components // and also display the value in read-only "gedcom" format. function updatewholename() { // don’t update the name if the user manually changed it if (manualChange) return; // Update NAME field from components and display it var frm =document.forms[0]; var npfx=frm.NPFX.value; var givn=frm.GIVN.value; var spfx=frm.SPFX.value; var surn=frm.SURN.value; var nsfx=frm.NSFX.value; document.getElementById("NAME").value=generate_name(); document.getElementById("NAME_display").innerText=frm.NAME.value; // Married names inherit some NSFX values, but not these nsfx=nsfx.replace(/^(I|II|III|IV|V|VI|Junior|Jr\\.?|Senior|Sr\\.?)$/i, ""); // Update _MARNM field from _MARNM_SURN field and display it // Be careful of mixing latin/hebrew/etc. character sets. var ip=document.getElementsByTagName("input"); var marnm_id=""; var romn=""; var heb=""; for (var i=0; i<ip.length; i++) { var val=ip[i].value; if (ip[i].id.indexOf("_HEB")==0) heb=val; if (ip[i].id.indexOf("ROMN")==0) romn=val; if (ip[i].id.indexOf("_MARNM")==0) { if (ip[i].id.indexOf("_MARNM_SURN")==0) { var msurn=""; if (val!="") { var lc=lang_class(document.getElementById(ip[i].id).value); if (lang_class(frm.NAME.value)==lc) msurn=trim(npfx+" "+givn+" /"+val+"/ "+nsfx); else if (lc=="hebrew") msurn=heb.replace(/\\/.*\\//, "/"+val+"/"); else if (lang_class(romn)==lc) msurn=romn.replace(/\\/.*\\//, "/"+val+"/"); } document.getElementById(marnm_id).value=msurn; document.getElementById(marnm_id+"_display").innerHTML=msurn; } else { marnm_id=ip[i].id; } } } } // Toggle the name editor fields between // <input type="hidden"> <span style="display:inline"> // <input type="text"> <span style="display:hidden"> var oldName = ""; var manualChange = false; function convertHidden(eid) { var input1 = jQuery("#" + eid); var input2 = jQuery("#" + eid + "_display"); // Note that IE does not allow us to change the type of an input, so we must create a new one. if (input1.attr("type")=="hidden") { input1.replaceWith(input1.clone().attr("type", "text")); input2.hide(); } else { input1.replaceWith(input1.clone().attr("type", "hidden")); input2.show(); } } /** * if the user manually changed the NAME field, then update the textual * HTML representation of it * If the value changed set manualChange to true so that changing * the other fields doesn’t change the NAME line */ function updateTextName(eid) { var element = document.getElementById(eid); if (element) { if (element.value!=oldName) manualChange = true; var delement = document.getElementById(eid+"_display"); if (delement) { delement.innerHTML = element.value; } } } function checkform() { var ip=document.getElementsByTagName("input"); for (var i=0; i<ip.length; i++) { // ADD slashes to _HEB and _AKA names if (ip[i].id.indexOf("_AKA")==0 || ip[i].id.indexOf("_HEB")==0 || ip[i].id.indexOf("ROMN")==0) if (ip[i].value.indexOf("/")<0 && ip[i].value!="") ip[i].value=ip[i].value.replace(/([^\\s]+)\\s*$/, "/$1/"); // Blank out temporary _MARNM_SURN if (ip[i].id.indexOf("_MARNM_SURN")==0) ip[i].value=""; // Convert "xxx yyy" and "xxx y yyy" surnames to "xxx,yyy" if ((SURNAME_TRADITION=="spanish" || "SURNAME_TRADITION"=="portuguese") && ip[i].id.indexOf("SURN")==0) { ip[i].value=document.forms[0].SURN.value.replace(/^\\s*([^\\s,]{2,})\\s+([iIyY] +)?([^\\s,]{2,})\\s*$/, "$1,$3"); } } return true; } // If the name isn’t initially formed from the components in a standard way, // then don’t automatically update it. if (document.getElementById("NAME").value!=generate_name() && document.getElementById("NAME").value!="//") { convertHidden("NAME"); } '); echo '</div>'; }
private function edit() { require_once WT_ROOT . 'includes/functions/functions_edit.php'; if (WT_Filter::postBool('save') && WT_Filter::checkCsrf()) { $block_id = WT_Filter::postInteger('block_id'); if ($block_id) { WT_DB::prepare("UPDATE `##block` SET gedcom_id=NULLIF(?, '0'), block_order=? WHERE block_id=?")->execute(array(WT_Filter::postInteger('gedcom_id'), WT_Filter::postInteger('block_order'), $block_id)); } else { WT_DB::prepare("INSERT INTO `##block` (gedcom_id, module_name, block_order) VALUES (NULLIF(?, '0'), ?, ?)")->execute(array(WT_Filter::postInteger('gedcom_id'), $this->getName(), WT_Filter::postInteger('block_order'))); $block_id = WT_DB::getInstance()->lastInsertId(); } set_block_setting($block_id, 'header', WT_Filter::post('header')); set_block_setting($block_id, 'faqbody', WT_Filter::post('faqbody')); $languages = array(); foreach (WT_I18N::installed_languages() as $code => $name) { if (WT_Filter::postBool('lang_' . $code)) { $languages[] = $code; } } set_block_setting($block_id, 'languages', implode(',', $languages)); $this->config(); } else { $block_id = WT_Filter::getInteger('block_id'); $controller = new WT_Controller_Page(); if ($block_id) { $controller->setPageTitle(WT_I18N::translate('Edit FAQ item')); $header = get_block_setting($block_id, 'header'); $faqbody = get_block_setting($block_id, 'faqbody'); $block_order = WT_DB::prepare("SELECT block_order FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); $gedcom_id = WT_DB::prepare("SELECT gedcom_id FROM `##block` WHERE block_id=?")->execute(array($block_id))->fetchOne(); } else { $controller->setPageTitle(WT_I18N::translate('Add an FAQ item')); $header = ''; $faqbody = ''; $block_order = WT_DB::prepare("SELECT IFNULL(MAX(block_order)+1, 0) FROM `##block` WHERE module_name=?")->execute(array($this->getName()))->fetchOne(); $gedcom_id = WT_GED_ID; } $controller->pageHeader(); if (array_key_exists('ckeditor', WT_Module::getActiveModules())) { ckeditor_WT_Module::enableEditor($controller); } // "Help for this page" link echo '<div id="page_help">', help_link('add_faq_item', $this->getName()), '</div>'; echo '<form name="faq" method="post" action="module.php?mod=', $this->getName(), '&mod_action=admin_edit">'; echo WT_Filter::getCsrf(); echo '<input type="hidden" name="save" value="1">'; echo '<input type="hidden" name="block_id" value="', $block_id, '">'; echo '<table id="faq_module">'; echo '<tr><th>'; echo WT_I18N::translate('Question'); echo '</th></tr><tr><td><input type="text" name="header" size="90" tabindex="1" value="' . WT_Filter::escapeHtml($header) . '"></td></tr>'; echo '<tr><th>'; echo WT_I18N::translate('Answer'); echo '</th></tr><tr><td>'; echo '<textarea name="faqbody" class="html-edit" rows="10" cols="90" tabindex="2">', WT_Filter::escapeHtml($faqbody), '</textarea>'; echo '</td></tr>'; echo '</table><table id="faq_module2">'; echo '<tr>'; echo '<th>', WT_I18N::translate('Show this block for which languages?'), '</th>'; echo '<th>', WT_I18N::translate('FAQ position'), help_link('add_faq_order', $this->getName()), '</th>'; echo '<th>', WT_I18N::translate('FAQ visibility'), help_link('add_faq_visibility', $this->getName()), '</th>'; echo '</tr><tr>'; echo '<td>'; $languages = get_block_setting($block_id, 'languages'); echo edit_language_checkboxes('lang_', $languages); echo '</td><td>'; echo '<input type="text" name="block_order" size="3" tabindex="3" value="', $block_order, '"></td>'; echo '</td><td>'; echo select_edit_control('gedcom_id', WT_Tree::getIdList(), WT_I18N::translate('All'), $gedcom_id, 'tabindex="4"'); echo '</td></tr>'; echo '</table>'; echo '<p><input type="submit" value="', WT_I18N::translate('save'), '" tabindex="5">'; echo '</form>'; exit; } }