/includes/functions_import.php

Description

Import specific functions

phpGedView: Genealogy Viewer Copyright (C) 2002 to 2007 PGV Development Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

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

  • version: $Id: functions_import.php 981 2007-03-21 13:24:38Z fisharebest $
Includes
include_once ('includes/functions_lang.php') (line 34)
require_once ('includes/mutex_class.php') (line 35)
require_once ('includes/index_cache.php') (line 36)
require_once ('includes/media_class.php') (line 33)

Import specific functions

phpGedView: Genealogy Viewer Copyright (C) 2002 to 2007 PGV Development Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

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

  • version: $Id: functions_import.php 981 2007-03-21 13:24:38Z fisharebest $
Functions
accept_changes (line 1526)

Accpet changed gedcom record into database

This function gets an updated record from the gedcom file and replaces it in the database

  • author: John Finlay
void accept_changes (string $cid)
  • string $cid: The change id of the record to accept
add_new_name (line 360)

Add a new calculated name to the individual names table

this function will add a new name record for the given individual, this function is called from the importgedcom.php script stage 5

void add_new_name (string $gid, string $newname, string $letter, string $surname,  $indirec)
  • string $gid: gedcom xref id of individual to update
  • string $newname: the new calculated name to add
  • string $surname: the surname for this name
  • string $letter: the letter for this name
  • $indirec
cleanup_database (line 1425)

perform any database cleanup

during the import process it might be necessary to cleanup some database values. In index mode the file handles need to be closed. For database mode we probably don't need to do anything in this funciton.

void cleanup_database ()
cleanup_tags_y (line 1717)
void cleanup_tags_y ( &$irec)
  • &$irec
create_dates_table (line 1278)

Create the dates table

void create_dates_table ()
create_families_table (line 1071)

Create the families table

void create_families_table ()
create_individuals_table (line 1043)

Create the individuals table

void create_individuals_table ()
create_media_mapping_table (line 1315)

Create the media_mapping table

void create_media_mapping_table ()
create_media_table (line 1257)

Create the media table

void create_media_table ()
create_names_table (line 1189)

Create the names table

void create_names_table ()
create_nextid_table (line 1338)

Create the nextid table

void create_nextid_table ()
create_other_table (line 1120)

Create the other table

void create_other_table ()
create_placelinks_table (line 1141)

Create the placelinks table

void create_placelinks_table ()
create_places_table (line 1164)

Create the places table

void create_places_table ()
create_remotelinks_table (line 1216)

Create the remotelinks table

void create_remotelinks_table ()
create_soundex_table (line 1238)

Create the soundex table

void create_soundex_table ()
create_sources_table (line 1097)

Create the sources table

void create_sources_table ()
empty_database (line 1358)

delete a gedcom from the database

deletes all of the imported data about a gedcom from the database

void empty_database (string $FILE, [boolean $keepmedia = false])
  • string $FILE: the gedcom to remove from the database
  • boolean $keepmedia: Whether or not to keep media and media links in the tables
import_record (line 45)

import record into database

this function will parse the given gedcom record and add it to the database

void import_record (string $indirec, [boolean $update = false])
  • string $indirec: the raw gedcom record to parse
  • boolean $update: whether or not this is an updated record that has been accepted
insert_media (line 524)

Insert media items into the database

This method is used in conjuction with the gedcom import/update routines

void insert_media (string $objrec, int $objlevel, boolean $update, string $gid, int $count)
  • string $objrec: The OBJE subrecord
  • int $objlevel: The original level of this OBJE
  • boolean $update: Whether or not this is an update or an import
  • string $gid: The XREF ID of the record this OBJE is related to
  • int $count: The count of OBJE records in the parent record
read_gedcom_file (line 1454)

read the contents of a gedcom file

opens a gedcom file and reads the contents into the $fcontents global string

void read_gedcom_file ()
setup_database (line 772)

Create database schema

function that checks if the database exists and creates tables automatically handles version updates

  • postgres does not support fields of type int(11) and
with a similar construct
  • postgres does not like strings to be inserted into
the db surrounded by double quotes - it tries to treat it as if it was the name of another column; the proper way is to surround it by single quotes.

void setup_database ()
subrecord_createobjectref (line 1796)

parse out specific subrecords (NOTE, _PRIM, _THUM) from a given OBJE record

  • return: containing NOTE, _PRIM, and _THUM subrecords parsed from the passed object record
  • author: Joseph King
string subrecord_createobjectref (string $objrec, int $objlevel, string $m_media)
  • string $objrec: the OBJE record to retrieve the subrecords from
  • int $objlevel: the level of the OBJE record
  • string $m_media: that media id of the OBJE record
update_dates (line 458)

extract all date info from the given record and insert them

into the dates table

void update_dates ( $gid, string $indirec)
  • string $indirec
  • $gid
update_media (line 606)

import media items from record

  • return: an updated record
  • todo: Decide whether or not to update the original gedcom file
string update_media ( $gid,  $indirec, [ $update = false])
  • $gid
  • $indirec
  • $update
update_places (line 383)

extract all places from the given record and insert them

into the places table

void update_places ( $gid, string $indirec, [ $update = false])
  • string $indirec
  • $gid
  • $update
update_record (line 1635)

update a record in the database

void update_record (string $indirec, [ $delete = false])
  • string $indirec
  • $delete
uuid (line 1772)

Generates a Universally Unique IDentifier, version 4.

RFC 4122 (http://www.ietf.org/rfc/rfc4122.txt) defines a special type of Globally Unique IDentifiers (GUID), as well as several methods for producing them. One such method, described in section 4.4, is based on truly random or pseudo-random number generators, and is therefore implementable in a language like PHP.

We choose to produce pseudo-random numbers with the Mersenne Twister, and to always limit single generated numbers to 16 bits (ie. the decimal value 65535). That is because, even on 32-bit systems, PHP's RAND_MAX will often be the maximum *signed* value, with only the equivalent of 31 significant bits. Producing two 16-bit random numbers to make up a 32-bit one is less efficient, but guarantees that all 32 bits are random.

The algorithm for version 4 UUIDs (ie. those based on random number generators) states that all 128 bits separated into the various fields (32 bits, 16 bits, 16 bits, 8 bits and 8 bits, 48 bits) should be random, except : (a) the version number should be the last 4 bits in the 3rd field, and (b) bits 6 and 7 of the 4th field should be 01. We try to conform to that definition as efficiently as possible, generating smaller values where possible, and minimizing the number of base conversions.

  • return: A UUID, made up of 36 hex digits
  • author: David Holmes <dholmes@cfdsoftware.net>
  • copyright: Copyright (c) CFD Labs, 2006. This function may be used freely for any purpose ; it is distributed without any form of warranty whatsoever.
string uuid ()
write_file (line 1473)
void write_file ()

Documentation generated on Wed, 28 Mar 2007 09:54:18 -0600 by phpDocumentor 1.3.1