function getFallBackName() { if ($this->canDisplayDetails()) { return UTF8_strtoupper(basename($this->file)); } else { return $this->getXref(); } }
function UTF8_strncasecmp($text1, $text2, $maxLen = 0) { $UTF8_text1 = UTF8_str_split($text1); $UTF8_text2 = UTF8_str_split($text2); if ($maxLen > 0) { $UTF8_text1 = array_slice($UTF8_text1, 0, $maxLen); $UTF8_text2 = array_slice($UTF8_text2, 0, $maxLen); } return UTF8_strcmp(UTF8_strtoupper($UTF8_text1), UTF8_strtoupper($UTF8_text2)); }
/** * Load language variables * Set language-dependent global variables * * This function loads the variables for the language, as specified by the first * input parameter. It also loads any existing language-specific functions such * special date handling for Finnish and Turkish. * * If the forceLoad parameter is true, English will be loaded first, followed by * the desired language file. * */ function loadLanguage($desiredLanguage = "english", $forceLoad = false) { global $LANGUAGE, $lang_short_cut; global $pgv_lang, $countries, $altCountryNames, $factarray, $factAbbrev, $faqlist; global $pgv_language, $factsfile, $adminfile, $editorfile, $extrafile, $pgv_lang_self; global $TEXT_DIRECTION, $TEXT_DIRECTION_array; global $DATE_FORMAT, $DATE_FORMAT_array, $CONFIGURED; global $TIME_FORMAT, $TIME_FORMAT_array; global $WEEK_START, $WEEK_START_array; global $NAME_REVERSE, $NAME_REVERSE_array; global $MULTI_LETTER_ALPHABET, $digraph, $trigraph, $quadgraph, $digraphAll, $trigraphAll, $quadgraphAll; global $DICTIONARY_SORT, $UCDiacritWhole, $UCDiacritStrip, $UCDiacritOrder, $LCDiacritWhole, $LCDiacritStrip, $LCDiacritOrder; global $unknownNN, $unknownPN; global $JEWISH_ASHKENAZ_PRONUNCIATION, $CALENDAR_FORMAT; global $DBTYPE, $DB_UTF8_COLLATION, $COLLATION, $DBCOLLATE; global $gBitDb; // Need to change the collation sequence each time we change language if ($DB_UTF8_COLLATION) { switch ($DBTYPE) { case 'mysql': case 'mysqli': $DBCOLLATE = "COLLATE {$COLLATION[$LANGUAGE]}"; break; default: $DBCOLLATE = ''; break; } } else { $DBCOLLATE = ''; } if (!isset($pgv_language[$desiredLanguage])) { $desiredLanguage = "english"; } // Make sure we start with a clean slate $pgv_lang = $pgv_lang_self; $countries = array(); $altCountryNames = array(); $factarray = array(); $factAbbrev = array(); $faqlist = array(); if ($forceLoad) { $LANGUAGE = "english"; require PHPGEDVIEW_PKG_PATH . $pgv_language[$LANGUAGE]; // Load English require PHPGEDVIEW_PKG_PATH . $factsfile[$LANGUAGE]; $TEXT_DIRECTION = $TEXT_DIRECTION_array[$LANGUAGE]; $DATE_FORMAT = $DATE_FORMAT_array[$LANGUAGE]; $TIME_FORMAT = $TIME_FORMAT_array[$LANGUAGE]; $WEEK_START = $WEEK_START_array[$LANGUAGE]; $NAME_REVERSE = $NAME_REVERSE_array[$LANGUAGE]; // Load functions that are specific to the active language $file = PHPGEDVIEW_PKG_PATH . "includes/extras/functions." . $lang_short_cut[$LANGUAGE] . ".php"; if (file_exists($file)) { include_once $file; } // load admin lang keys $file = $adminfile[$LANGUAGE]; if (file_exists($file)) { if (!$CONFIGURED || !empty($gBitDb->mDb) || !adminUserExists() || PGV_USER_GEDCOM_ADMIN) { include $file; } } // load the edit lang keys $file = $editorfile[$LANGUAGE]; if (file_exists($file)) { if (!empty($gBitDb->mDb) || !adminUserExists() || PGV_USER_GEDCOM_ADMIN || PGV_USER_CAN_EDIT) { include $file; } } } if ($desiredLanguage != $LANGUAGE) { $LANGUAGE = $desiredLanguage; $file = $pgv_language[$LANGUAGE]; if (file_exists($file)) { include $file; // Load the requested language } $file = $factsfile[$LANGUAGE]; if (file_exists($file)) { include $file; } $TEXT_DIRECTION = $TEXT_DIRECTION_array[$LANGUAGE]; $DATE_FORMAT = $DATE_FORMAT_array[$LANGUAGE]; $TIME_FORMAT = $TIME_FORMAT_array[$LANGUAGE]; $WEEK_START = $WEEK_START_array[$LANGUAGE]; $NAME_REVERSE = $NAME_REVERSE_array[$LANGUAGE]; // Load functions that are specific to the active language $file = "./includes/extras/functions." . $lang_short_cut[$LANGUAGE] . ".php"; if (file_exists($file)) { include_once $file; } // load admin lang keys $file = $adminfile[$LANGUAGE]; if (file_exists($file)) { if (!$CONFIGURED || empty($gBitDb->mDb) || !adminUserExists() || PGV_USER_GEDCOM_ADMIN) { include $file; } } // load the edit lang keys $file = $editorfile[$LANGUAGE]; if (file_exists($file)) { if (empty($gBitDb->mDb) || !adminUserExists() || PGV_USER_CAN_EDIT) { include $file; } } } // load the extra language file $file = "./languages/lang." . $lang_short_cut[$LANGUAGE] . ".extra.php"; if (file_exists($file)) { include $file; } $file = $extrafile[$LANGUAGE]; if (file_exists($file)) { include $file; } // Modify certain spellings if Ashkenazi pronounciations are in use. if ($JEWISH_ASHKENAZ_PRONUNCIATION) { switch ($lang_short_cut[$LANGUAGE]) { case 'en': $pgv_lang['csh'] = 'Cheshvan'; $pgv_lang['tvt'] = 'Teves'; break; } } // Special formatting options; R selects conversion to a language-dependent calendar. // i.e. a French user will see conversion to the french calendar, a Hebrew user will // see conversion to the hebrew calendar, etc. if (strpos($DATE_FORMAT, 'R') !== false) { switch ($LANGUAGE) { case 'french': case 'hebrew': case 'arabic': // Two ways of doing this: $CALENDAR_FORMAT = $LANGUAGE; // override gedcom calendar choice // if (strpos($CALENDAR_FORMAT, $LANGUAGE)===false) $CALENDAR_FORMAT.="_and_{$language}"; // add to gedcom calendar choice break; } $DATE_FORMAT = trim(str_replace('R', '', $DATE_FORMAT)); } /** * Build the tables of multi-character sequences that must be considered as a * single character when sorting lists of names and titles. * Reference http://en.wikipedia.org/wiki/Hungarian_alphabet * Reference http://en.wikipedia.org/wiki/Alphabets_derived_from_the_Latin */ $digraph = array(); $trigraph = array(); $quadgraph = array(); if (!isset($MULTI_LETTER_ALPHABET[$LANGUAGE])) { $MULTI_LETTER_ALPHABET[$LANGUAGE] = ""; } if ($MULTI_LETTER_ALPHABET[$LANGUAGE] != "") { $myList = UTF8_strtoupper($MULTI_LETTER_ALPHABET[$LANGUAGE]); $myList = str_replace(array(";", ","), " ", $myList); $myList = preg_replace("/\\s\\s+/", " ", $myList); $myList = trim($myList); $wholeList = explode(" ", $myList); $sortValue = array(); foreach ($wholeList as $letter) { $first = substr($letter, 0, 1); if ($letter == "CH") { $first = "H"; } // This one doesn't follow the rule if (!isset($sortValue[$first])) { $sortValue[$first] = 0; } $sortValue[$first]++; if (strlen($letter) == 2) { $digraph[$letter] = $sortValue[$first]; } if (strlen($letter) == 3) { $trigraph[$letter] = $sortValue[$first]; } if (strlen($letter) == 4) { $quadgraph[$letter] = $sortValue[$first]; } } $MULTI_LETTER_ALPHABET[$LANGUAGE] = " " . $myList . " "; } $digraphAll = array(); $trigraphAll = array(); $quadgraphAll = array(); $MULTI_LETTER_ALPHABET["all"] = ""; foreach ($MULTI_LETTER_ALPHABET as $lang => $letters) { if ($lang != "all") { $MULTI_LETTER_ALPHABET["all"] .= $letters . " "; } } $MULTI_LETTER_ALPHABET["all"] = UTF8_strtoupper($MULTI_LETTER_ALPHABET["all"]); $MULTI_LETTER_ALPHABET["all"] = str_replace(array(";", ","), " ", $MULTI_LETTER_ALPHABET["all"]); $MULTI_LETTER_ALPHABET["all"] = preg_replace("/\\s\\s+/", " ", $MULTI_LETTER_ALPHABET["all"]); $wholeList = explode(" ", $MULTI_LETTER_ALPHABET["all"]); $sortValue = array(); foreach ($wholeList as $letter) { $first = substr($letter, 0, 1); if ($letter == "CH") { $first = "H"; } // This one doesn't follow the rule if (!isset($sortValue[$first])) { $sortValue[$first] = 0; } $sortValue[$first]++; if (strlen($letter) == 2) { $digraphAll[$letter] = $sortValue[$first]; } if (strlen($letter) == 3) { $trigraphAll[$letter] = $sortValue[$first]; } if (strlen($letter) == 4) { $quadgraphAll[$letter] = $sortValue[$first]; } } $MULTI_LETTER_ALPHABET["all"] = " " . trim($MULTI_LETTER_ALPHABET["all"]) . " "; /** * Build the tables required for the Dictionary sort * * A Dictionary sort is one where all letters with diacritics are considered to be * identical to the base letter (without the mark). Diacritics become important * only when the two strings (without marks) are identical. * * There are two sets of tables, one for the Upper Case version of a UTF8 character * and the other for the lower-case version. The two tables are not necessarily * identical. For example, the Turkish dotless i doesn't exist in the Upper case * table. * * Within each set, there are three lists which MUST have a one-to-one relationship. * The "DiacritStrip" list gives the base letter of the corresponding "DiacritWhole" * character. * The "DiacritOrder" list assigns a sort value to the diacritic mark of the * "DiacritWhole" character. All letters that don't appear in these lists, including * the base letter from which the one bearing diacritic marks is formed, are assigned * a sort value of " ". By using a single letter from the ASCII code chart, we can * have 52 different UTF8 characters all mapping to the same base character. This will * handle Vietnamese, which is by far the richest language in terms of diacritic marks. */ require_once PHPGEDVIEW_PKG_PATH . "/includes/sort_tables_utf8.php"; }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @package PhpGedView * @subpackage Lists * @version $Id: branches.php 6879 2010-01-30 11:35:46Z fisharebest $ */ define('PGV_SCRIPT_NAME', 'branches.php'); require './config.php'; //-- const define('PGV_ICON_RINGS', "<img src=\"images/small/rings.gif\" alt=\"{$factarray["MARR"]}\" title=\"{$factarray["MARR"]}\" />"); define('PGV_ICON_BRANCHES', "<img src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["patriarch"]["small"] . "\" alt=\"\" align=\"middle\" />"); //-- args $surn = safe_GET('surn', '[^<>&%{};]*'); $surn = UTF8_strtoupper($surn); $soundex_std = safe_GET_bool('soundex_std'); $soundex_dm = safe_GET_bool('soundex_dm'); $ged = safe_GET('ged'); if (empty($ged)) { $ged = $GEDCOM; } //-- rootid $rootid = ""; if (PGV_USER_ID) { $rootid = PGV_USER_ROOT_ID; if (empty($_SESSION['user_ancestors']) || $_SESSION['user_ancestors'][1] !== $rootid) { unset($_SESSION['user_ancestors']); load_ancestors_array($rootid); } }
if ($action == "select") { print "<h2>" . $pgv_lang["merge_step2"] . "</h2>\n"; print "<form method=\"post\" action=\"edit_merge.php\">\n"; print $pgv_lang["merge_facts_same"] . "<br />\n"; print "<input type=\"hidden\" name=\"gid1\" value=\"{$gid1}\">\n"; print "<input type=\"hidden\" name=\"gid2\" value=\"{$gid2}\">\n"; print "<input type=\"hidden\" name=\"ged\" value=\"{$GEDCOM}\">\n"; print "<input type=\"hidden\" name=\"ged2\" value=\"{$ged2}\">\n"; print "<input type=\"hidden\" name=\"action\" value=\"merge\">\n"; $equal_count = 0; $skip1 = array(); $skip2 = array(); print "<table border=\"1\">\n"; foreach ($facts1 as $i => $fact1) { foreach ($facts2 as $j => $fact2) { if (UTF8_strtoupper($fact1["subrec"]) == UTF8_strtoupper($fact2["subrec"])) { $skip1[] = $i; $skip2[] = $j; $equal_count++; print "<tr><td>"; if (isset($factarray[$fact1["fact"]])) { print $factarray[$fact1["fact"]]; } else { print $fact1["fact"]; } print "<input type=\"hidden\" name=\"keep1[]\" value=\"{$i}\" /></td>\n<td>" . nl2br($fact1["subrec"]) . "</td></tr>\n"; } } } if ($equal_count == 0) { print "<tr><td>" . $pgv_lang["no_matches_found"] . "</td></tr>\n";
/** * builds and returns sosa relationship name in the active language * * @param string $sosa sosa number */ function get_sosa_name($sosa) { global $LANGUAGE, $pgv_lang; if ($sosa < 2) { return ""; } $sosaname = ""; $sosanr = floor($sosa / 2); $gen = floor(log($sosanr) / log(2)); // first try a generic algorithm, this is later overridden // by language specific algorithms. if (!empty($pgv_lang["sosa_{$sosa}"])) { $sosaname = $pgv_lang["sosa_{$sosa}"]; } else { if ($gen > 2) { switch ($LANGUAGE) { case "danish": case "norwegian": case "swedish": $sosaname = ""; $addname = ""; $father = UTF8_strtolower($pgv_lang["father"]); $mother = UTF8_strtolower($pgv_lang["mother"]); $grand = "be" . ($LANGUAGE == "danish" ? "dste" : "ste"); $great = "olde"; $tip = "tip" . ($LANGUAGE == "danish" ? "-" : "p-"); for ($i = $gen; $i > 2; $i--) { $sosaname .= $tip; } if ($gen >= 2) { $sosaname .= $great; } if ($gen == 1) { $sosaname .= $grand; } for ($i = $gen; $i > 0; $i--) { if (!(floor($sosa / pow(2, $i)) % 2)) { $addname .= $father; } else { $addname .= $mother; } if ($gen % 2 && !($i % 2) || !($gen % 2) && $i % 2) { $addname .= "s "; } } if ($LANGUAGE == "swedish") { $sosaname = $addname; } if ($sosa % 2 == 0) { $sosaname .= $father; if ($gen > 0) { $addname .= $father; } } else { $sosaname .= $mother; if ($gen > 0) { $addname .= $mother; } } $sosaname = UTF8_str_split($sosaname); $sosaname[0] = UTF8_strtoupper($sosaname[0]); $sosaname = implode('', $sosaname); if ($LANGUAGE != "swedish") { if (!empty($addname)) { $sosaname .= ($gen > 5 ? "<br /> " : "") . " <small>(" . $addname . ")</small>"; } } break; case "dutch": // reference: http://nl.wikipedia.org/wiki/Voorouder // Our numbers are 2 less than those shown in the article. We number parents // as generation zero where the article numbers them as generation 2. $sosaname = ""; // Please leave the following strings untranslated if ($gen & 512) { break; } // 512 or higher if ($gen & 256) { $sosaname .= "hoog"; } // 256 to 511 if ($gen & 128) { $sosaname .= "opper"; } // 128 to 511 if ($gen & 64) { $sosaname .= "aarts"; } // 64 to 511 if ($gen & 32) { $sosaname .= "voor"; } // 32 to 511 if ($gen & 16) { $sosaname .= "edel"; } // 16 to 511 if ($gen & 8) { $sosaname .= "stam"; } // 8 to 511 if ($gen & 4) { $sosaname .= "oud"; } // 4 to 511 $gen = $gen & 3; if ($gen == 3) { $sosaname .= "betovergroot"; } if ($gen == 2) { $sosaname .= "overgroot"; } if ($gen == 1) { $sosaname .= "groot"; } if ($sosa % 2 == 0) { $sosaname .= $pgv_lang["father"]; } else { $sosaname .= $pgv_lang["mother"]; } $sosaname = strtolower($sosaname); break; case "finnish": $sosaname = ""; $father = UTF8_strtolower($pgv_lang["father"]); $mother = UTF8_strtolower($pgv_lang["mother"]); // $father = "isä"; // $mother = "äiti"; // $pgv_lang["sosa_2"]= "äidin"; //Grand (mother) for ($i = $gen; $i > 0; $i--) { if (!(floor($sosa / pow(2, $i)) % 2)) { $sosaname .= $father . "n"; } else { $sosaname .= UTF8_substr($mother, 0, 2) . "din"; } } if ($sosa % 2 == 0) { $sosaname .= $father; } else { $sosaname .= $mother; } $sosaname = UTF8_str_split($sosaname); $sosaname[0] = UTF8_strtoupper($sosaname[0]); $sosaname = implode('', $sosaname); break; case "hebrew": $sosaname = ""; $addname = ""; $father = $pgv_lang["father"]; $mother = $pgv_lang["mother"]; $greatf = $pgv_lang["sosa_22"]; $greatm = $pgv_lang["sosa_21"]; $of = $pgv_lang["sosa_23"]; $grandfather = $pgv_lang["sosa_4"]; $grandmother = $pgv_lang["sosa_5"]; // $father = "Aba"; // $mother = "Ima"; // $grandfather = "Saba"; // $grandmother = "Savta"; // $greatf = " raba"; // $greatm = " rabta"; // $of = " shel "; for ($i = $gen; $i >= 0; $i--) { if ($i == 0) { if (!($sosa % 2)) { $addname .= "f"; } else { $addname .= "m"; } } else { if (!(floor($sosa / pow(2, $i)) % 2)) { $addname .= "f"; } else { $addname .= "m"; } } if ($i == 0 || strlen($addname) == 3) { if (strlen($addname) == 3) { if (substr($addname, 2, 1) == "f") { $addname = $grandfather . $greatf; } else { $addname = $grandmother . $greatm; } } else { if (strlen($addname) == 2) { if (substr($addname, 1, 1) == "f") { $addname = $grandfather; } else { $addname = $grandmother; } } else { if ($addname == "f") { $addname = $father; } else { $addname = $mother; } } } $sosaname = $addname . ($i < $gen - 2 ? $of : "") . $sosaname; $addname = ""; } } break; default: $paternal = floor($sosa / pow(2, $gen)) == 2 ? "paternal" : "maternal"; $male = $sosa % 2 == 0 ? "male" : "female"; if (!empty($pgv_lang["sosa_{$paternal}_{$male}_n_generations"])) { $sosaname = sprintf($pgv_lang["sosa_{$paternal}_{$male}_n_generations"], $gen + 1, $gen, $gen - 1); } } } } if (!empty($sosaname)) { return "{$sosaname}<!-- sosa={$sosa} nr={$sosanr} gen={$gen} -->"; } else { return "<!-- sosa={$sosa} nr={$sosanr} gen={$gen} -->"; } }
function print_block_name_top10($block = true, $config = "", $side, $index) { global $pgv_lang, $COMMON_NAMES_ADD, $COMMON_NAMES_REMOVE, $COMMON_NAMES_THRESHOLD, $PGV_BLOCKS, $ctype, $PGV_IMAGES, $PGV_IMAGE_DIR, $SURNAME_LIST_STYLE; if (empty($config)) { $config = $PGV_BLOCKS["print_block_name_top10"]["config"]; } // This next function is a bit out of date, and doesn't cope well with surname variants $top_surnames = get_top_surnames(PGV_GED_ID, 1, $config["num"]); $all_surnames = array(); foreach (array_keys($top_surnames) as $top_surname) { $all_surnames = array_merge($all_surnames, get_indilist_surns($top_surname, '', false, false, PGV_GED_ID)); } // Insert from the "Add Names" list if not already in there if ($COMMON_NAMES_ADD) { foreach (preg_split('/[,; ]+/', $COMMON_NAMES_ADD) as $addname) { $ADDNAME = UTF8_strtoupper($addname); if (isset($all_surnames[$ADDNAME])) { $SURNAME = $ADDNAME; foreach (array_keys($all_surnames[$ADDNAME]) as $surname) { if ($SURNAME != $surname && $SURNAME == UTF8_strtoupper($surname)) { $all_surnames[$ADDNAME][$SURNAME] = $all_surnames[$ADDNAME][$surname]; unset($all_surnames[$ADDNAME][$surname]); } } if (isset($all_surnames[$ADDNAME][$SURNAME])) { $n = count($all_surnames[$ADDNAME][$SURNAME]); $all_surnames[$ADDNAME][$SURNAME] = array_fill(0, max($n, $COMMON_NAMES_THRESHOLD), true); } else { $all_surnames[$ADDNAME][$SURNAME] = array_fill(0, $COMMON_NAMES_THRESHOLD, true); } } else { $all_surnames[$ADDNAME][$ADDNAME] = array_fill(0, $COMMON_NAMES_THRESHOLD, true); } } } // Remove names found in the "Remove Names" list if ($COMMON_NAMES_REMOVE) { foreach (preg_split("/[,; ]+/", $COMMON_NAMES_REMOVE) as $delname) { unset($all_surnames[UTF8_strtoupper($delname)]); } } $id = "top10surnames"; $title = print_help_link("index_common_names_help", "qm", "", false, true); if ($PGV_BLOCKS["print_block_name_top10"]["canconfig"]) { if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) { if ($ctype == "gedcom") { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>"; } } $title .= str_replace("10", $config["num"], $pgv_lang["block_top10_title"]); switch ($SURNAME_LIST_STYLE) { case 'style3': uksort($all_surnames, 'stringsort'); $content = format_surname_tagcloud($all_surnames, 'indilist', true); break; case 'style2': default: uasort($all_surnames, "top_surname_sort"); $content = format_surname_table($all_surnames, 'indilist'); break; } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
* along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * @package PhpGedView * @subpackage Edit * @version $Id: autocomplete.php 6996 2010-12-01 11:29:54Z canajun2eh $ */ define('PGV_SCRIPT_NAME', 'autocomplete.php'); require './config.php'; header("Content-Type: text/plain; charset={$CHARACTER_SET}"); // We have finished writing to $_SESSION, so release the lock session_write_close(); //-- args $FILTER = safe_GET('q', PGV_REGEX_UNSAFE); // we can search on '"><& etc. $FILTER = UTF8_strtoupper($FILTER); $OPTION = safe_GET('option'); $FORMAT = safe_GET('fmt'); $FIELD = safe_GET('field'); switch ($FIELD) { case 'INDI': $data = autocomplete_INDI($FILTER, $OPTION); break; case 'FAM': $data = autocomplete_FAM($FILTER, $OPTION); break; case 'NOTE': $data = autocomplete_NOTE($FILTER); break; case 'SOUR': $data = autocomplete_SOUR($FILTER);
function chartCommonSurnames($params = null) { global $pgv_lang, $COMMON_NAMES_THRESHOLD, $PGV_STATS_CHART_COLOR1, $PGV_STATS_CHART_COLOR2, $PGV_STATS_S_CHART_X, $PGV_STATS_S_CHART_Y; if ($params === null) { $params = array(); } if (isset($params[0]) && $params[0] != '') { $size = strtolower($params[0]); } else { $size = $PGV_STATS_S_CHART_X . "x" . $PGV_STATS_S_CHART_Y; } if (isset($params[1]) && $params[1] != '') { $color_from = strtolower($params[1]); } else { $color_from = $PGV_STATS_CHART_COLOR1; } if (isset($params[2]) && $params[2] != '') { $color_to = strtolower($params[2]); } else { $color_to = $PGV_STATS_CHART_COLOR2; } if (isset($params[3]) && $params[3] != '') { $threshold = strtolower($params[3]); } else { $threshold = $COMMON_NAMES_THRESHOLD; } if (isset($params[4]) && $params[4] != '') { $maxtoshow = strtolower($params[4]); } else { $maxtoshow = 7; } $sizes = explode('x', $size); $tot_indi = $this->totalIndividuals(); $surnames = get_common_surnames($threshold); uasort($surnames, array('stats', '_name_total_rsort')); $surnames = array_slice($surnames, 0, $maxtoshow); $all_surnames = array(); foreach (array_keys($surnames) as $n => $surname) { if ($n >= $maxtoshow) { break; } $all_surnames = array_merge($all_surnames, get_indilist_surns(UTF8_strtoupper($surname), '', false, false, PGV_GED_ID)); } if (count($surnames) <= 0) { return ''; } $tot = 0; foreach ($surnames as $indexval => $surname) { $tot += $surname['match']; } $chart_title = ""; $chd = ''; $chl = array(); foreach ($all_surnames as $surn => $surns) { foreach ($surns as $spfxsurn => $indis) { if ($tot == 0) { $per = 0; } else { $per = round(100 * count($indis) / $tot_indi, 0); } $chd .= self::_array_to_extended_encoding($per); $chl[] = $spfxsurn . ' - ' . count($indis); $chart_title .= $spfxsurn . ' [' . count($indis) . '], '; } } $per = round(100 * ($tot_indi - $tot) / $tot_indi, 0); $chd .= self::_array_to_extended_encoding($per); $chl[] = $pgv_lang["other"] . ' - ' . ($tot_indi - $tot); $chart_title .= $pgv_lang["other"] . ' [' . ($tot_indi - $tot) . ']'; $chl = join('|', $chl); return "<img src=\"" . encode_url("http://chart.apis.google.com/chart?cht=p3&chd=e:{$chd}&chs={$size}&chco={$color_from},{$color_to}&chf=bg,s,ffffff00&chl={$chl}") . "\" width=\"{$sizes[0]}\" height=\"{$sizes[1]}\" alt=\"" . $chart_title . "\" title=\"" . $chart_title . "\" />"; }
if (!$initials) { $initials[] = '@'; } // Make sure selections are consistent. // i.e. can't specify show_all and surname at the same time. if ($show_all == 'yes') { $alpha = ''; $surname = ''; $legend = $pgv_lang['all']; $url = 'famlist.php?show_all=yes'; } elseif ($surname) { $surname = UTF8_strtoupper($surname); $alpha = UTF8_substr($surname, 0, 1); foreach (db_collation_digraphs() as $from => $to) { if (strpos($surname, UTF8_strtoupper($to)) === 0) { $alpha = UTF8_strtoupper($from); } } $show_all = 'no'; $legend = $surname; switch ($falpha) { case '': break; case '@': $legend .= ', ' . $pgv_lang['NN']; break; default: $legend .= ', ' . $falpha; break; } $surname_sublist = 'no';
function find_place_list($place) { global $TBLPREFIX, $gBitDb; $rows = $gBitDb->getAll("SELECT p_id, p_place, p_parent_id FROM {$TBLPREFIX}places WHERE p_file=? ORDER BY p_parent_id, p_id", array(PGV_GED_ID)); $placelist = array(); foreach ($rows as $row) { if ($row->p_parent_id == 0) { $placelist[$row->p_id] = $row->p_place; } else { $placelist[$row->p_id] = $placelist[$row->p_parent_id] . ", " . $row->p_place; } } if (!empty($place)) { $found = array(); foreach ($placelist as $indexval => $pplace) { if (preg_match("/{$place}/i", $pplace) > 0) { $upperplace = UTF8_strtoupper($pplace); if (!isset($found[$upperplace])) { $found[$upperplace] = $pplace; } } } $placelist = array_values($found); } return $placelist; }
/** * @todo add info * @see PGVRListEHandler() * @param array $attrs an array of key value pairs for the attributes */ function PGVRListSHandler($attrs) { global $pgvreport, $gedrec, $repeats, $repeatBytes, $list, $repeatsStack, $processRepeats, $parser, $vars, $sortby; global $pgv_changes, $GEDCOM, $TBLPREFIX; $processRepeats++; if ($processRepeats > 1) { return; } if (isset($attrs["sortby"])) { $sortby = $attrs["sortby"]; $vmatch = array(); if (preg_match("/\\\$(\\w+)/", $sortby, $vmatch) > 0) { $sortby = $vars[$vmatch[1]]["id"]; $sortby = trim($sortby); } } else { $sortby = "NAME"; } if (isset($attrs["list"])) { $listname = $attrs["list"]; } else { $listname = "individual"; } // Some filters/sorts can be applied using SQL, while others require PHP switch ($listname) { case 'pending': $list = array(); foreach ($pgv_changes as $changes) { $change = end($changes); if ($change['gedcom'] == $GEDCOM) { $list[] = new GedcomRecord($change['undo']); } } break; case 'individual': case 'family': $sql_col_prefix = substr($listname, 0, 1) . '_'; // i_ for individual, f_ for family, etc. $sql_join = array(); $sql_where = array($sql_col_prefix . "file=" . PGV_GED_ID); $sql_order_by = array(); foreach ($attrs as $attr => $value) { if (strpos($attr, 'filter') === 0 && $value) { // Substitute global vars $value = preg_replace('/\\$(\\w+)/e', '$vars["\\1"]["id"]', $value); // Convert the various filters into SQL $match = array(); if (preg_match('/^(\\w+):DATE (LTE|GTE) (.+)$/', $value, $match)) { $sql_join[] = "JOIN {$TBLPREFIX}dates AS {$attr} ON ({$attr}.d_file={$sql_col_prefix}file AND {$attr}.d_gid={$sql_col_prefix}id)"; $sql_where[] = "{$attr}.d_fact='{$match[1]}'"; $date = new GedcomDate($match[3]); if ($match[2] == 'LTE') { $sql_where[] = "{$attr}.d_julianday2<=" . $date->minJD(); } else { $sql_where[] = "{$attr}.d_julianday1>=" . $date->minJD(); } if ($sortby == $match[1]) { $sortby = ''; $sql_order_by[] = "{$attr}.d_julianday1"; } unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == 'individual' && preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) { $sql_join[] = "JOIN {$TBLPREFIX}name AS {$attr} ON (n_file={$sql_col_prefix}file AND n_id={$sql_col_prefix}id)"; $sql_where[] = "{$attr}.n_sort LIKE '" . UTF8_strtoupper($match[1]) . "%'"; if ($sortby == 'NAME') { $sortby = ''; $sql_order_by[] = "{$attr}.n_sort"; } unset($attrs[$attr]); // This filter has been fully processed } elseif ($listname == 'family' && preg_match('/^NAME CONTAINS (.+)$/', $value, $match)) { // Eventually, family "names" will be stored in pgv_name. Until then, an extra is needed.... $sql_join[] = "JOIN {$TBLPREFIX}link AS {$attr}a ON ({$attr}a.l_file={$sql_col_prefix}file AND {$attr}a.l_from={$sql_col_prefix}id)"; $sql_join[] = "JOIN {$TBLPREFIX}name AS {$attr}b ON ({$attr}b.n_file={$sql_col_prefix}file AND n_id={$sql_col_prefix}id)"; $sql_where[] = "{$attr}a.l_type=IN ('HUSB, 'WIFE')"; $sql_where[] = "{$attr}.n_sort LIKE '" . UTF8_strtoupper($match[1]) . "%'"; if ($sortby == 'NAME') { $sortby = ''; $sql_order_by[] = "{$attr}.n_sort"; } unset($attrs[$attr]); // This filter has been fully processed //returns all the record with the filter place - does not verify that we speak of a BIRT record for the birth report value=BIRT:PLAC etc. /* } elseif (preg_match('/^(?:\w+):PLAC CONTAINS (.+)$/', $value, $match)) { $sql_join[]="JOIN {$TBLPREFIX}places AS {$attr}a ON ({$attr}a.p_file={$sql_col_prefix}file)"; $sql_join[]="JOIN {$TBLPREFIX}placelinks AS {$attr}b ON ({$attr}a.p_file={$attr}b.pl_file AND {$attr}b.pl_p_id={$attr}a.p_id AND {$attr}b.pl_gid={$sql_col_prefix}id)"; $sql_where[]="{$attr}a.p_place LIKE '".UTF8_strtoupper($match[1])."%'"; unset($attrs[$attr]); // This filter has been fully processed */ } else { // TODO: what other filters can we apply in SQL? //var_dump($value); } } } if ($listname == 'family') { $list = search_fams_custom($sql_join, $sql_where, $sql_order_by); } else { $list = search_indis_custom($sql_join, $sql_where, $sql_order_by); } break; default: die("Invalid list name: {$listname}"); } $filters = array(); $filters2 = array(); if (isset($attrs["filter1"])) { $j = 0; foreach ($attrs as $key => $value) { $ct = preg_match("/filter(\\d)/", $key, $match); if ($ct > 0) { $condition = $value; $ct = preg_match("/@(\\w+)/", $condition, $match); if ($ct > 0) { $id = $match[1]; $value = "''"; if ($id == "ID") { $ct = preg_match("/0 @(.+)@/", $gedrec, $match); if ($ct > 0) { $value = "'" . $match[1] . "'"; } } else { if ($id == "fact") { $value = "'{$fact}'"; } else { if ($id == "desc") { $value = "'{$desc}'"; } else { $ct = preg_match("/\\d {$id} (.+)/", $gedrec, $match); if ($ct > 0) { $value = "'" . preg_replace("/@/", "", trim($match[1])) . "'"; } } } } $condition = preg_replace("/@{$id}/", $value, $condition); } //-- handle regular expressions $ct = preg_match("/([A-Z:]+)\\s*([^\\s]+)\\s*(.+)/", $condition, $match); if ($ct > 0) { $tag = trim($match[1]); $expr = trim($match[2]); $val = trim($match[3]); if (preg_match("/\\\$(\\w+)/", $val, $vmatch) > 0) { $val = $vars[$vmatch[1]]["id"]; $val = trim($val); } $searchstr = ""; $tags = explode(':', $tag); //-- only limit to a level number if we are specifically looking at a level if (count($tags) > 1) { $level = 1; foreach ($tags as $t) { if (!empty($searchstr)) { $searchstr .= "[^\n]*(\n[2-9][^\n]*)*\n"; } //-- search for both EMAIL and _EMAIL... silly double gedcom standard if ($t == "EMAIL" || $t == "_EMAIL") { $t = "_?EMAIL"; } $searchstr .= $level . " " . $t; $level++; } } else { if ($tag == "EMAIL" || $tag == "_EMAIL") { $tag = "_?EMAIL"; } $t = $tag; $searchstr = "1 " . $tag; } switch ($expr) { case "CONTAINS": if ($t == "PLAC") { $searchstr .= "[^\n]*[, ]" . $val; } else { $searchstr .= "[^\n]*" . $val; } $filters[] = $searchstr; break; default: if (!empty($val)) { $filters2[] = array("tag" => $tag, "expr" => $expr, "val" => $val); } break; } } } $j++; } } //-- apply other filters to the list that could not be added to the search string if ($filters) { foreach ($list as $key => $record) { foreach ($filters as $filter) { if (!preg_match('/' . $filter . '/i', $record->getGedcomRecord())) { unset($list[$key]); break; } } } } if ($filters2) { $mylist = array(); foreach ($list as $indi) { $key = $indi->getXref(); $value = $indi->getGedcomRecord(); $keep = true; foreach ($filters2 as $filter) { if ($keep) { $tag = $filter["tag"]; $expr = $filter["expr"]; $val = $filter["val"]; if ($val == "''") { $val = ""; } $tags = explode(':', $tag); $t = end($tags); $v = get_gedcom_value($tag, 1, $value["gedcom"], '', false); //-- check for EMAIL and _EMAIL (silly double gedcom standard :P) if ($t == "EMAIL" && empty($v)) { $tag = preg_replace("/EMAIL/", "_EMAIL", $tag); $tags = explode(':', $tag); $t = end($tags); $v = get_sub_record(1, $tag, $value["gedcom"]); } $level = count($tags); switch ($expr) { case "GTE": if ($t == "DATE") { $date1 = new GedcomDate($v); $date2 = new GedcomDate($val); $keep = GedcomDate::Compare($date1, $date2) >= 0; } else { if ($val >= $v) { $keep = true; } } break; case "LTE": if ($t == "DATE") { $date1 = new GedcomDate($v); $date2 = new GedcomDate($val); $keep = GedcomDate::Compare($date1, $date2) <= 0; } else { if ($val >= $v) { $keep = true; } } break; case "SUBCONTAINS": $v = get_sub_record($level, $level . " " . $tag, $value["gedcom"]); if (empty($v) && $tag == "ADDR") { $v = get_sub_record($level + 1, $level + 1 . " " . $tag, $value["gedcom"]); } $ct = preg_match("/{$val}\\b/i", $v); if ($ct > 0) { $keep = true; } else { $keep = false; } break; default: if ($v == $val) { $keep = true; } else { $keep = false; } break; } } } if ($keep) { $mylist[$key] = $indi; } } $list = $mylist; } switch ($sortby) { case 'NAME': uasort($list, array('GedcomRecord', 'Compare')); break; case 'ID': uasort($list, array('GedcomRecord', 'CompareId')); break; case 'CHAN': uasort($list, array('GedcomRecord', 'CompareChanDate')); break; case 'BIRT:DATE': uasort($list, array('Person', 'CompareBirtDate')); break; case 'DEAT:DATE': uasort($list, array('Person', 'CompareDeatDate')); break; case 'MARR:DATE': uasort($list, array('Family', 'CompareMarrDate')); break; default: // unsorted or already sorted by SQL break; } array_push($repeatsStack, array($repeats, $repeatBytes)); $repeatBytes = xml_get_current_line_number($parser) + 1; }
function _addName($type, $full, $gedrec) { global $UNDERLINE_NAME_QUOTES, $NAME_REVERSE, $unknownNN, $unknownPN, $pgv_lang; // Look for GIVN/SURN at level n+1 $sublevel = 1 + (int) $gedrec[0]; // Fix bad slashes. e.g. "John/Smith" => "John/Smith/" if (substr_count($full, '/') % 2 == 1) { $full .= '/'; } // Need the GIVN and SURN to generate the sortable name. $givn = preg_match("/\n{$sublevel} GIVN (.+)/", $gedrec, $match) ? $match[1] : ''; $surn = preg_match("/\n{$sublevel} SURN (.+)/", $gedrec, $match) ? $match[1] : ''; $spfx = preg_match("/\n{$sublevel} SPFX (.+)/", $gedrec, $match) ? $match[1] : ''; if ($givn || $surn) { // An empty surname won't have a SURN field if (strpos($full, '//')) { $surn = '@N.N.'; } // GIVN and SURN can be comma-separated lists. $surns = preg_split('/ *, */', $surn); $givn = str_replace(array(', ', ','), ' ', $givn); // SPFX+SURN for lists $surn = ($spfx ? $spfx . ' ' : '') . $surn; } else { $name = $full; // We do not have a structured name - extract the GIVN and SURN(s) ourselves // Strip the NPFX if (preg_match('/^(?:(?:(?:ADM|AMB|BRIG|CAN|CAPT|CHAN|CHAPLN|CMDR|COL|CPL|CPT|DR|GEN|GOV|HON|LADY|LORD|LT|MR|MRS|MS|MSGR|PFC|PRES|PROF|PVT|RABBI|REP|REV|SEN|SGT|SIR|SR|SRA|SRTA|VEN)\\.? +)+)(.+)/i', $name, $match)) { $name = $match[1]; } // Strip the NSFX if (preg_match('/(.+)(?:(?: +(?:ESQ|ESQUIRE|JR|JUNIOR|SR|SENIOR|[IVX]+)\\.?)+)$/i', $name, $match)) { $name = $match[1]; } // Extract GIVN/SURN. if (strpos($full, '/') === false) { $givn = trim($name); $spfx = ''; $surns = array(''); } else { // Extract SURN. Split at "/". Odd numbered parts are SURNs. $spfx = ''; $surns = array(); foreach (preg_split(': */ *:', $name) as $key => $value) { if ($key % 2 == 1) { if ($value) { // Strip SPFX if (preg_match('/^((?:(?:A|AAN|AB|AF|AL|AP|AS|AUF|AV|BAT|BIJ|BIN|BINT|DA|DE|DEL|DELLA|DEM|DEN|DER|DI|DU|EL|FITZ|HET|IBN|LA|LAS|LE|LES|LOS|ONDER|OP|OVER|\'S|ST|\'T|TE|TEN|TER|TILL|TOT|UIT|UIJT|VAN|VANDEN|VON|VOOR|VOR) )+(?:[DL]\')?)(.+)$/i', $value, $match)) { $spfx = trim($match[1]); $value = $match[2]; } $surns[] = $value ? $value : '@N.N.'; } else { $surns[] = '@N.N.'; } } } // SPFX+SURN for lists $surn = ($spfx ? $spfx . ' ' : '') . implode(' ', $surns); // Extract the GIVN. Before first "/" and after last. $pos1 = strpos($name, '/'); if ($pos1 === false) { $givn = $name; } else { $pos2 = strrpos($name, '/'); $givn = trim(substr($name, 0, $pos1) . ' ' . substr($name, $pos2 + 1)); } } } // Tidy up whitespace $full = preg_replace('/ +/', ' ', trim($full)); // Add placeholder for unknown surname if (preg_match(':/ */:', $full)) { $full = preg_replace(':/ */:', '/@N.N./', $full); } // Add placeholder for unknown given name if (!$givn) { $givn = '@P.N.'; $pos = strpos($full, '/'); $full = substr($full, 0, $pos) . '@P.N. ' . substr($full, $pos); } // Some systems don't include the NPFX in the NAME record. $npfx = preg_match('/^' . $sublevel . ' NPFX (.+)/m', $gedrec, $match) ? $match[1] : ''; if ($npfx && stristr($full, $npfx) === false) { $full = $npfx . ' ' . $full; } // Make sure the NICK is included in the NAME record. if (preg_match('/^' . $sublevel . ' NICK (.+)/m', $gedrec, $match)) { $pos = strpos($full, '/'); if ($pos === false) { $full .= ' "' . $match[1] . '"'; } else { $full = substr($full, 0, $pos) . '"' . $match[1] . '" ' . substr($full, $pos); } } // Convert "user-defined" unknowns into PGV unknowns $full = preg_replace('/\\/(_+|\\?+|-+)\\//', '/@N.N./', $full); $full = preg_replace('/(?<= |^)(_+|\\?+|-+)(?= |$)/', '@P.N.', $full); $surn = preg_replace('/^(_+|\\?+|-+)$/', '@N.N.', $surn); $givn = preg_replace('/(?<= |^)(_+|\\?+|-+)(?= |$)/', '@P.N.', $givn); foreach ($surns as $key => $value) { $surns[$key] = preg_replace('/^(_+|\\?+|-+)$/', '@N.N.', $value); } // Create the list (surname first) version of the name. Note that zero // slashes are valid; they indicate NO surname as opposed to missing surname. $pos1 = strpos($full, '/'); if ($pos1 === false) { $list = $full; } else { $pos2 = strrpos($full, '/'); $list = trim(substr($full, $pos1 + 1, $pos2 - $pos1 - 1)) . ', ' . substr($full, 0, $pos1) . substr($full, $pos2 + 1); $list = trim(str_replace(array('/', ' '), array('', ' '), $list)); $full = trim(str_replace(array('/', ' '), array('', ' '), $full)); } // Need the "not known" place holders for the database $fullNN = $full; $listNN = $list; $surname = $surn; // Hungarians want the "full" name to be the surname first (i.e. "list") variant if ($NAME_REVERSE) { $full = $list; } // Some people put preferred names in quotes if ($UNDERLINE_NAME_QUOTES) { $full = preg_replace('/"([^"]*)"/', '<span class="starredname">\\1</span>', $full); $list = preg_replace('/"([^"]*)"/', '<span class="starredname">\\1</span>', $list); } // The standards say you should use a suffix of "*" $full = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $full); $list = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $list); // If the name is written in greek/cyrillic/hebrew/etc., use the "unknown" name // from that character set. Otherwise use the one in the language file. if (strpos($givn, '@P.N.') !== false || $surn == '@N.N.' || $surns[0] == '@N.N.') { if (strpos($givn, '@P.N.') !== false && ($surn == '@N.N.' || $surns[0] == '@N.N.')) { $PN = $pgv_lang['PN']; $NN = $pgv_lang['NN']; } else { if ($surn !== '') { $PN = $unknownPN[whatLanguage($surn)]; } else { $PN = $unknownPN[whatLanguage($surns[0])]; } $NN = $unknownNN[whatLanguage($givn)]; } $list = str_replace(array('@N.N.', '@P.N.'), array($NN, $PN), $list); $full = str_replace(array('@N.N.', '@P.N.'), array($NN, $PN), $full); } // A comma separated list of surnames (from the SURN, not from the NAME) indicates // multiple surnames (e.g. Spanish). Each one is a separate sortable name. // Where nicknames are entered in the given name field, these will break // sorting, so strip them out. $GIVN = preg_replace('/["\'()]/', '', UTF8_strtoupper($givn)); foreach ($surns as $n => $surn) { $SURN = UTF8_strtoupper($surn); // Scottish "Mc and Mac" prefixes sort under "Mac" if (substr($SURN, 0, 2) == 'MC') { $SURN = 'MAC' . substr($SURN, 2); } if (substr($SURN, 0, 4) == 'MAC ') { $SURN = 'MAC' . substr($SURN, 4); } $this->_getAllNames[] = array('type' => $type, 'full' => $full, 'list' => $list, 'sort' => $SURN . ',' . $GIVN, 'fullNN' => $fullNN, 'listNN' => $listNN, 'surname' => $surname, 'givn' => $givn, 'spfx' => $n ? '' : $spfx, 'surn' => $SURN); } }