Skip to content

Commit 5969fe2

Browse files
author
Olivier Vanhoucke
committed
first commit
git-svn-id: http://svn.php.net/repository/pear/packages/Genealogy_Gedcom/trunk@109834 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 69d8929 commit 5969fe2

File tree

8 files changed

+1361
-0
lines changed

8 files changed

+1361
-0
lines changed

Genealogy_Family.php

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<?php
2+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3+
// +----------------------------------------------------------------------+
4+
// | PHP Version 4 |
5+
// +----------------------------------------------------------------------+
6+
// | Copyright (c) 1997-2002 The PHP Group |
7+
// +----------------------------------------------------------------------+
8+
// | This source file is subject to version 2.02 of the PHP license, |
9+
// | that is bundled with this package in the file LICENSE, and is |
10+
// | available at through the world-wide-web at |
11+
// | http://www.php.net/license/2_02.txt. |
12+
// | If you did not receive a copy of the PHP license and are unable to |
13+
// | obtain it through the world-wide-web, please send a note to |
14+
// | [email protected] so we can mail you a copy immediately. |
15+
// +----------------------------------------------------------------------+
16+
// | Authors: Olivier Vanhoucke <[email protected]> |
17+
// +----------------------------------------------------------------------+
18+
//
19+
// $Id$
20+
//
21+
22+
/*
23+
*/
24+
25+
/**
26+
* Genealogy_Family
27+
*
28+
* Purpose:
29+
*
30+
*
31+
*
32+
* Contributors:
33+
*
34+
* @author Olivier Vanhoucke <[email protected]>
35+
* @version $Revision$
36+
* @package Genealogy_Gedcom
37+
* @access public
38+
*/
39+
class Genealogy_Family {
40+
41+
/**
42+
* Contains the Gedcom family identifier
43+
*
44+
* @var string
45+
* @access public
46+
*/
47+
var $Identifier = '';
48+
49+
/**
50+
* Husband
51+
*
52+
* @var string
53+
* @access public
54+
*/
55+
var $Husband = '';
56+
57+
/**
58+
* Wife
59+
*
60+
* @var string
61+
* @access public
62+
*/
63+
var $Wife = '';
64+
65+
/**
66+
* Number of child
67+
*
68+
* @var string
69+
* @access public
70+
*/
71+
var $ChildNumber = '';
72+
73+
/**
74+
* Child
75+
*
76+
* @var array
77+
* @access public
78+
*/
79+
var $Child = array();
80+
81+
/**
82+
* Marriage
83+
*
84+
* @var array
85+
* @access public
86+
*/
87+
var $Marriage = array('Date' => '',
88+
'Time' => '',
89+
'Place' => '',
90+
'Witness' => array(),
91+
'Note' => '',
92+
'Source' => ''
93+
);
94+
95+
/**
96+
* Divorce
97+
*
98+
* @var array
99+
* @access public
100+
*/
101+
var $Divorce = array('Date' => '');
102+
103+
/**
104+
* Associates
105+
*
106+
* @var array
107+
* @access public
108+
*/
109+
var $Associates = array();
110+
111+
/**
112+
* Constructor
113+
*
114+
* Creates a new Genealogy_Family Object
115+
*
116+
* @access public
117+
* @param array
118+
* @return object Genealogy_Family
119+
*/
120+
function Genealogy_Family($arg) {
121+
$this->Identifier = $arg[0];
122+
$this->Husband = $arg[1];
123+
$this->Wife = $arg[2];
124+
$this->ChildNumber = $arg[3];
125+
$this->Child = $arg[4];
126+
$this->Marriage['Date'] = $arg[5];
127+
$this->Marriage['Time'] = $arg[6];
128+
$this->Marriage['Place'] = $arg[7];
129+
$this->Marriage['Witness'] = $arg[8];
130+
$this->Marriage['Note'] = $arg[9];
131+
$this->Marriage['Source'] = $arg[10];
132+
$this->Associates = $arg[11];
133+
$this->Divorce['Date'] = $arg[12];
134+
}
135+
}
136+
?>

Genealogy_Gedcom.php

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
<?php
2+
/* vim: set expandtab tabstop=4 shiftwidth=4: */
3+
// +----------------------------------------------------------------------+
4+
// | PHP Version 4 |
5+
// +----------------------------------------------------------------------+
6+
// | Copyright (c) 1997-2002 The PHP Group |
7+
// +----------------------------------------------------------------------+
8+
// | This source file is subject to version 2.02 of the PHP license, |
9+
// | that is bundled with this package in the file LICENSE, and is |
10+
// | available at through the world-wide-web at |
11+
// | http://www.php.net/license/2_02.txt. |
12+
// | If you did not receive a copy of the PHP license and are unable to |
13+
// | obtain it through the world-wide-web, please send a note to |
14+
// | [email protected] so we can mail you a copy immediately. |
15+
// +----------------------------------------------------------------------+
16+
// | Authors: Olivier Vanhoucke <[email protected]> |
17+
// +----------------------------------------------------------------------+
18+
//
19+
// $Id$
20+
//
21+
22+
require_once 'Gedcom/Parser.php';
23+
24+
/**
25+
* Genealogy_Gedcom
26+
*
27+
* Example:
28+
*
29+
* require_once 'Genealogy/Gedcom.php';
30+
* $ged =& new Genealogy_Gedcom('test.ged');
31+
*
32+
* echo 'Number of individuals : '. $ged->getNumberOfIndividuals().'<br>';
33+
* echo 'Number of families : '. $ged->getNumberOfFamilies(). '<br>';
34+
* echo 'Number of objects :' . $ged->getNumberOfObjects(). '<br>';
35+
* echo 'Last Update :'. $ged->getLastUpdate(). '<br>';
36+
* echo '<br>';
37+
*
38+
* echo '<pre>';
39+
* print_r($ged->GedcomIndividualsTreeObjects);
40+
* print_r($ged->GedcomFamiliesTreeObjects);
41+
* print_r($ged->GedcomObjectsTreeObjects);
42+
* print_r($ged->GedcomHeaderTreeObject);
43+
* print_r($ged->getIndividual('I1'));
44+
* print_r($ged->getFamily('F1'));
45+
* print_r($ged->getObject('O1'));
46+
* echo '</pre>';
47+
*
48+
* display all firstname and lastname of individuals
49+
*
50+
* foreach ($ged->GedcomIndividualsTreeObjects as $obj) {
51+
* echo $obj->Firstname.' '.$obj->Lastname.'<br>';
52+
* }
53+
*
54+
* Contributors:
55+
*
56+
* @author Olivier Vanhoucke <[email protected]>
57+
* @version $Revision$
58+
* @package Genealogy_Gedcom
59+
* @access public
60+
*/
61+
class Genealogy_Gedcom extends Genealogy_Parser {
62+
63+
/**
64+
* Constructor
65+
*
66+
* Creates a new Genealogy_Gedcom Object
67+
*
68+
* @access public
69+
* @param string Gedcom filename
70+
* @return object Genealogy_Gedcom the new Genealogy_Gedcom object
71+
*/
72+
function Genealogy_Gedcom($filename) {
73+
$this->_GedcomFile = $filename;
74+
parent::parse();
75+
}
76+
77+
/**
78+
* return the number of individual
79+
*
80+
* @access public
81+
* @return integer
82+
*/
83+
function getNumberOfIndividuals() {
84+
return count($this->_GedcomIndividualsTree);
85+
}
86+
87+
/**
88+
* return the number of family
89+
*
90+
* @access public
91+
* @return integer
92+
*/
93+
function getNumberOfFamilies() {
94+
return count($this->_GedcomFamiliesTree);
95+
}
96+
97+
/**
98+
* return the number of object
99+
*
100+
* @access public
101+
* @return integer
102+
*/
103+
function getNumberOfObjects() {
104+
return count($this->_GedcomObjectsTree);
105+
}
106+
107+
/**
108+
* return the last update
109+
*
110+
* @access public
111+
* @return string
112+
*/
113+
function getLastUpdate() {
114+
return $this->GedcomHeaderTreeObject->Date;
115+
}
116+
117+
/**
118+
* Get an Individual (object) from an identifier
119+
*
120+
* @param string Indentifier
121+
* @access public
122+
* @return mixed object or boolean (error)
123+
*/
124+
function getIndividual($identifier) {
125+
foreach ($this->GedcomIndividualsTreeObjects as $obj) {
126+
if ($obj->Identifier == $identifier) {
127+
return $obj;
128+
}
129+
}
130+
return false;
131+
}
132+
133+
/**
134+
* Get a family (object) from an identifier
135+
*
136+
* @param string Indentifier
137+
* @access public
138+
* @return mixed object or boolean (error)
139+
*/
140+
function getFamily($identifier) {
141+
foreach ($this->GedcomFamiliesTreeObjects as $obj) {
142+
if ($obj->Identifier == $identifier) {
143+
return $obj;
144+
}
145+
}
146+
return false;
147+
}
148+
149+
/**
150+
* Get an object (object) from an identifier
151+
*
152+
* @param string Indentifier
153+
* @access public
154+
* @return mixed object or boolean (error)
155+
*/
156+
function getObject($identifier) {
157+
foreach ($this->GedcomObjectsTreeObjects as $obj) {
158+
if ($obj->Identifier == $identifier) {
159+
return $obj;
160+
}
161+
}
162+
return false;
163+
}
164+
165+
/**
166+
* test if an individual exists
167+
*
168+
* @param string Indentifier
169+
* @access public
170+
* @return boolean
171+
*/
172+
function isIndividual($identifier) {
173+
foreach ($this->GedcomIndividualsTreeObjects as $obj) {
174+
if ($obj->Identifier == $identifier) {
175+
return true;
176+
}
177+
}
178+
return false;
179+
}
180+
181+
/**
182+
* test if a family exists
183+
*
184+
* @param string Indentifier
185+
* @access public
186+
* @return boolean
187+
*/
188+
function isFamily($identifier) {
189+
foreach ($this->GedcomFamiliesTreeObjects as $obj) {
190+
if ($obj->Identifier == $identifier) {
191+
return true;
192+
}
193+
}
194+
return false;
195+
}
196+
197+
/**
198+
* test if an object exists
199+
*
200+
* @param string Indentifier
201+
* @access public
202+
* @return boolean
203+
*/
204+
function isObject($identifier) {
205+
foreach ($this->GedcomObjectsTreeObjects as $obj) {
206+
if ($obj->Identifier == $identifier) {
207+
return true;
208+
}
209+
}
210+
return false;
211+
}
212+
}
213+
?>

0 commit comments

Comments
 (0)