$c4x = $c3x + $w; $c1h = 170; $c2h = $c1h / 2; $c3h = $c2h / 2; $c4h = $c3h / 2; $bottom = $top + $c1h; $pdf = new PDF('L', 'mm', 'Letter'); $pdf->Open(); $pdf->SetTopMargin(13); $pdf->SetLeftMargin(13); $pdf->SetRightMargin(10); $pdf->SetAutoPageBreak(True, 13); $pdf->AddPage(); $pdf->SetCreator($_SERVER["PHP_SELF"]); $pdf->SetAuthor("Keith Morrison, keithm@infused.org"); $pdf->SetTitle(sprintf(gtc("Pedigree for %s"), $o->full_name())); $pdf->SetSubject(gtc("Genealogy")); # Person 1 $pdf->SetY($top); $pdf->SetX($c1x); $pdf->Cell($w, $c1h, '', 1, 0, 'L'); $pdf->SetY($top + $c1h / 2 - 6); $pdf->SetX($c1x); $pdf->SetFont($font, 'B', 10); $pdf->MultiCell($w, 4, isset($g_node_strings[1][0]) ? $g_node_strings[1][0] : '', 0, 'L'); $pdf->SetFont($font, '', 10); $pdf->Cell($w, 4, isset($g_node_strings[1][1]) ? $g_node_strings[1][1] : '', 0, 2, 'L'); $pdf->Cell($w, 4, isset($g_node_strings[1][2]) ? $g_node_strings[1][2] : '', 0, 0, 'L'); # Person 2 $pdf->SetY($top); $pdf->SetX($c2x);
function display_indiv($p_array) { global $g_content, $g_descendants, $g_generation, $g_max_gens, $g_count, $individuals; $string = ''; $p_node = $p_array[0]; $p_generation = $p_array[1]; $father = $p_node->father_indkey ? new Person($p_node->father_indkey, 3) : null; $mother = $p_node->mother_indkey ? new Person($p_node->mother_indkey, 3) : null; if ($p_generation > $g_generation) { $g_generation = $p_generation; } # children foreach ($p_node->marriages as $marriage) { $spouse = !empty($marriage->spouse) ? new Person($marriage->spouse, 3) : null; if ($marriage->child_count > 0) { $string .= '<br />' . "\n"; $string .= get_children_of_sentence($p_node, $spouse) . ':<br />'; foreach ($marriage->children as $child_indkey) { $child = new Person($child_indkey); if ($child->marriage_count > 0) { foreach ($child->marriages as $cmarriage) { if ($cmarriage->child_count > 0) { $child->ns_number = $g_count + 1; $child_gen = $p_generation + 1; if ($child_gen > $g_max_gens) { break; } array_push($g_descendants, array($child, $child_gen)); $g_count++; break; } } } $child_nk = '<a class="secondary" href="' . $_SERVER['PHP_SELF'] . '?m=family&id=' . $child->indkey . '">' . $child->full_name() . '</a>'; if ($child->ns_number) { $string .= '<ol><li value="' . $child->ns_number . '">' . $child_nk; if ($child->birth && $child->birth->date || $child->death && $child->death->date) { $string .= ' '; if ($child->birth && $child->birth->date) { $string .= gtc("b.") . ' ' . $child->birth->date . ' '; } if ($child->death && $child->death->date) { $string .= gtc("d.") . ' ' . $child->death->date; } } $string .= '</li></ol>'; } else { $string .= '<ul><li class="nobullet">' . $child_nk . '</li></ul>'; } } } } $string .= '</li></ol>'; $individual['generation'] = $p_generation; $individual['generation_title'] = sprintf(gtc("Generation %s"), $g_generation); $individual['ns_number'] = $p_node->ns_number; $individual['name_link'] = '<a href="' . $_SERVER['PHP_SELF'] . '?m=family&id=' . $p_node->indkey . '">' . $p_node->full_name() . '</a>'; $individual['parent_sentence'] = get_parents_sentence($p_node, $father, $mother); $individual['birth_sentence'] = get_birth_sentence($p_node); $individual['marriage_sentence'] = get_marriage_sentences($p_node); $individual['death_sentence'] = get_death_sentence($p_node); $individual['children_string'] = $string; $individuals[] = $individual; }
var $lastname; var $arm_count = 2; var $leg_count = 2; function say_hello() { echo "Hello World " . get_class($this); } function hello() { $this->say_hello(); } function full_name() { return $this->firstname . " " . $this->lastname; } } //To use instance of Person $person = new Person(); //There is no $ sign for arm_count = Dynamic variable echo $person->arm_count . "<br/>"; //To set value $person->firstname = "Raghu"; $person->lastname = "J"; //New Instance $person2 = new Person(); $person2->firstname = "Soundar"; echo $person->firstname . "<br/>"; echo $person2->firstname . "<br/>"; //To return function value echo $person->full_name() . "<br/>";
/** * Gets 'children of' sentence * @access public * @param Person $p Individual * @param Person $ps Spouse */ function get_children_of_sentence($p, $ps) { $s = ''; if ($p->full_name() and $ps->full_name()) { $s .= sprintf(gtc("Children of %s and %s"), $p->full_name(), $ps->full_name()); } else { $s .= sprintf(gtc("Children of %s"), $p->full_name()); } return $s; }
} else { $sql .= "OR " . TBL_NOTE . ".text LIKE \"%{$note_part}%\" "; } } } elseif ($parts == 'starts') { $sql = "SELECT DISTINCT " . TBL_INDIV . ".indkey FROM " . TBL_INDIV . ", " . TBL_NOTE . " "; $sql .= "WHERE " . TBL_INDIV . ".notekey = " . TBL_NOTE . ".notekey "; $sql .= "AND " . TBL_NOTE . ".text LIKE \"{$note}%\" "; } elseif ($parts == 'ends') { $sql = "SELECT DISTINCT " . TBL_INDIV . ".indkey FROM " . TBL_INDIV . ", " . TBL_NOTE . " "; $sql .= "WHERE " . TBL_INDIV . ".notekey = " . TBL_NOTE . ".notekey "; $sql .= "AND " . TBL_NOTE . ".text LIKE \"%{$note}\" "; } else { $note_arr = explode(' ', $note); $sql = "SELECT DISTINCT " . TBL_INDIV . ".indkey FROM " . TBL_INDIV . ", " . TBL_NOTE . " "; $sql .= "WHERE " . TBL_INDIV . ".notekey = " . TBL_NOTE . ".notekey "; foreach ($note_arr as $note_part) { $sql .= "AND " . TBL_NOTE . ".text LIKE \"%{$note_part}%\" "; } } } $rs = $db->Execute($sql); if ($rs->RecordCount() > 0) { $individuals = array(); while ($row = $rs->FetchRow()) { $o = new Person($row['indkey'], 1); keyword_push($o->full_name()); $individuals[] = $o; } $smarty->assign('individuals', $individuals); }
function display_indiv($p_array) { global $pdf, $g_descendants, $g_generation, $g_max_gens, $font; $gencol = 13; $factcol = 30; $childcol = 40; $birthcol = 100; $deathcol = 150; $p_node = $p_array[0]; $p_generation = $p_array[1]; if ($p_node->father_indkey) { $father = new Person($p_node->father_indkey, 3); } else { $father = null; } if ($p_node->mother_indkey) { $mother = new Person($p_node->mother_indkey, 3); } else { $mother = null; } if ($p_generation > $g_generation) { $g_generation = $p_generation; # display generation if it changed $pdf->SetLeftMargin(13); $pdf->SetX(0); $pdf->SetFont($font, 'BU', 10); $pdf->Ln(10); $pdf->Cell(0, 5, sprintf(gtc("Generation %s"), $g_generation), 0, 2, 'C'); //$pdf->Ln(5); } $pdf->LN(5); $pdf->SetX($gencol); $pdf->SetFont($font, '', 9); $pdf->Write(5, $p_node->ns_number . '.'); $pdf->SetLeftMargin($factcol); $pdf->SetFont($font, 'B', 9); $pdf->Write(5, $p_node->full_name()); $pdf->SetFont($font, '', 9); $pdf->Write(5, html_entity_decode(strip_tags(get_parents_sentence($p_node, $father, $mother)))); $pdf->LN(5); $pdf->Write(5, html_entity_decode(strip_tags(get_birth_sentence($p_node)))); $pdf->Write(5, html_entity_decode(strip_tags(get_marriage_sentences($p_node)))); $pdf->Write(5, html_entity_decode(strip_tags(get_death_sentence($p_node)))); $pdf->Ln(5); # children foreach ($p_node->marriages as $marriage) { $spouse = !empty($marriage->spouse) ? new Person($marriage->spouse) : null; if ($marriage->child_count > 0) { $pdf->Ln(5); $pdf->Write(5, html_entity_decode(strip_tags(get_children_of_sentence($p_node, $spouse))) . ':'); foreach ($marriage->children as $child_indkey) { $child = new Person($child_indkey); if ($child->marriage_count > 0) { foreach ($child->marriages as $cmarriage) { if ($cmarriage->child_count > 0) { $child->ns_number = count($g_descendants) + 1; $child_gen = $p_generation + 1; if ($child_gen > $g_max_gens) { break; } array_push($g_descendants, array($child, $child_gen)); break; } } } if ($child->ns_number) { $pdf->SetLeftMargin($factcol); $pdf->Ln(5); $pdf->Write(5, $child->ns_number); $pdf->SetX($childcol); $pdf->Write(5, $child->full_name()); if ($child->birth->date || $child->death->date) { if ($child->birth->date) { $pdf->SetX($birthcol); $pdf->Write(5, $child->birth->date); } if ($child->death->date) { $pdf->SetX($deathcol); $pdf->Write(5, $child->death->date); } } } else { $pdf->Ln(5); $pdf->SetX($childcol); $pdf->Write(5, $child->full_name()); if ($child->birth->date || $child->death->date) { if ($child->birth->date) { $pdf->SetX($birthcol); $pdf->Write(5, $child->birth->date); } if ($child->death->date) { $pdf->SetX($deathcol); $pdf->Write(5, $child->death->date); } } } } } } }
$this->SetFont($font, '', 8); $this->Cell(0, 4, '©2002-2003 Keith Morrison, Infused Solutions - www.infused.org', 0, 1, 'C', 0, 'http://www.infused.org'); $this->Cell(0, 4, sprintf(gtc("Send questions or comments to %s"), '*****@*****.**'), 0, 0, 'C', 0, 'mailto:keithm@infused.org'); } } # Begin PDF Output $pdf = new PDF('P', 'mm', 'Letter'); $pdf->Open(); $pdf->SetTopMargin(13); $pdf->SetLeftMargin(13); $pdf->SetRightMargin(10); $pdf->SetAutoPageBreak(True, 13); $pdf->AddPage(); $pdf->SetCreator($_SERVER['PHP_SELF']); $pdf->SetAuthor('Keith Morrison, keithm@infused.org'); $pdf->SetTitle(sprintf(gtc("Ahnentafel Report for %s"), $o->full_name())); $pdf->SetSubject(gtc("Genealogy")); $tree->level_order_traversal($root, 'display_indiv'); function display_indiv($p_node, $p_generation) { global $pdf, $g_generation, $font; $gencol = 13; $factcol = 30; $father = null; $mother = null; if ($p_node->father_indkey) { $father = new Person($p_node->father_indkey, 1); } if ($p_node->mother_indkey) { $mother = new Person($p_node->mother_indkey, 1); }
class Person { var $first_name; var $last_name; var $arm_count = 2; var $leg_count = 2; function say_hello() { echo "Hello from inside the class" . get_class($this) . ".<br>"; } function full_name() { return $this->first_name . " " . $this->last_name; } } $person = new Person(); echo $person->arm_count . "<br>"; $person->arm_count = 3; $person->first_name = 'Lucy'; $person->last_name = 'Ricardo'; $new_person = new Person(); $new_person->first_name = 'Ethel'; $new_person->last_name = 'Mertz'; echo $person->first_name . "<br>"; echo $new_person->first_name . "<br>"; echo $person->full_name() . "<br>"; echo $new_person->full_name() . "<br>"; $vars = get_class_vars('Person'); foreach ($vars as $var => $value) { echo "{$var} : {$value}<br>"; }
class Person { var $first_name; var $last_name; var $arm_count = 2; var $leg_count = 2; function say_hello() { echo "Hello from inside the class " . get_class($this) . "<br/>"; } function full_name() { return $this->first_name . " " . $this->last_name . "<br/>"; } } $person = new Person(); echo $person->arm_count . "<br/>"; $person->arm_count = 3; $person->first_name = 'Lucy'; $person->last_name = 'Ricardo'; $new_person = new Person(); $new_person->first_name = 'Ethel'; $new_person->last_name = 'Mertz'; echo $person->full_name(); echo $new_person->full_name(); $vars = get_class_vars('Person'); foreach ($vars as $var => $value) { echo "{$var} : {$value} <br/>"; } echo property_exists('Person', 'first_name') ? 'true' : 'false';
var $last_name; var $arm_count = 2; var $leg_count = 2; function say_hello() { echo "Hello from inside the class. " . get_class($this) . "<br>"; } function full_name() { return $this->first_name . " " . $this->last_name; } } $person = new Person(); echo $person->arm_count . '<br>'; $person->arm_count = 3; $person->first_name = 'Lucy'; $person->last_name = 'Ricardo'; $new_person = new Person(); $new_person->first_name = 'Ethel'; $new_person->last_name = 'Mertz'; echo $person->full_name() . '<br>'; echo $new_person->full_name() . '<br>'; /** Retrieves the list of vars */ $vars = get_class_vars('Person'); foreach ($vars as $var => $value) { echo "{$var}: {$value}<br>"; } echo property_exists('Person', 'first_name') ? 'true' : 'false'; ?> </div> </div>
/** * Display marriage function * @access public * @param string $p_marriage * @param integer $p_mnum */ function display_marriage($p_marriage, $p_mnum) { global $pdf, $font, $factcol, $placecol, $namecol, $birthcol, $deathcol, $sources; $spouse = !empty($p_marriage->spouse) ? new Person($p_marriage->spouse, 3) : null; $pdf->Ln(5); $pdf->SetFont($font, 'I', 10); $pdf->Cell(0, 5, sprintf(gtc("Family %s"), $p_mnum) . ' :', 0, 1); $pdf->Cell(0, 0, ' ', 'B', 1); $pdf->Ln(5); $pdf->SetFont($font, '', 10); $pdf->Cell(0, 5, gtc("Spouse/Partner") . ':'); $pdf->SetX($factcol); $spousestr = $spouse->full_name(); if ($spouse->birth) { $spousestr .= ' ' . gtc("b.") . ' ' . $spouse->birth->date; } if ($spouse->death) { $spousestr .= ' ' . gtc("d.") . ' ' . $spouse->death->date; } $pdf->Cell(0, 5, $spousestr, 0, 1); $pdf->Cell(0, 5, gtc($p_marriage->beginstatus) . ':'); $pdf->SetX($factcol); $pdf->Cell(0, 5, $p_marriage->date); $pdf->SetX($placecol); $marriageplace = $p_marriage->place; if ($p_marriage->sources) { $marriageplace .= ' (' . gtc("Sources") . ': '; foreach ($p_marriage->sources as $source) { array_push($sources, $source); $marriageplace .= ' ' . count($sources); } $marriageplace .= ')'; } $pdf->MultiCell(0, 5, $marriageplace, 0, 'L'); # print marriage end status if ($p_marriage->endstatus) { $pdf->SetFont($font, 'I', 10); $pdf->Cell(0, 5, gtc($p_marriage->endstatus) . ':'); $pdf->SetX($factcol); $pdf->Cell(0, 5, $p_marriage->enddate); $pdf->SetX($placecol); $endplace = $p_marriage->endplace; if ($p_marriage->end_sources) { $endplace .= ' (' . gtc("Sources") . ': '; foreach ($p_marriage->end_sources as $source) { array_push($sources, $source); $endplace .= ' ' . count($sources); } $endplace .= ')'; } $pdf->MultiCell(0, 5, $endplace, 0, 'L'); } # print misc events foreach ($p_marriage->events as $event) { $eventplace = ''; $pdf->SetFont($font, 'I', 10); $pdf->Cell(0, 5, gtc($event->type) . ':'); $pdf->SetX($factcol); $pdf->SetFont($font, '', 10); $pdf->Cell(0, 5, $event->date); $pdf->SetX($placecol); if (!empty($event->place) and !empty($event->comment)) { $eventstring = $event->comment . ' / ' . $event->place; } elseif (!empty($event->comment)) { $eventstring = $event->comment; } elseif (!empty($event->place)) { $eventstring = $event->place; } else { $eventstring = ''; } if ($event->sources) { $eventplace .= ' (' . gtc("Sources") . ': '; foreach ($event->sources as $source) { array_push($sources, $source); $eventplace .= ' ' . count($sources); } $eventplace .= ')'; } $pdf->MultiCell(0, 5, $eventstring, 0, 'L'); } # print marriage notes if ($p_marriage->notes) { $noteparagraphs = explode('<br>', $mnotes); $pdf->SetFont($font, 'I', 10); $pdf->Cell(0, 5, gtc("Notes") . ':'); $pdf->SetX($factcol); $pdf->SetFont($font, '', 10); foreach ($noteparagraphs as $noteparagraph) { $pdf->SetX($factcol); $pdf->MultiCell(0, 5, $noteparagraph, 0, 'L'); } } $pdf->Ln(5); # print children if ($p_marriage->child_count > 0) { $pdf->SetFont($font, 'I', 10); $pdf->Cell(0, 5, gtc("Children") . ':', 0, 1); $cnum = 0; foreach ($p_marriage->children as $child) { $cnum++; $c = new Person($child, 3); $pdf->Cell(0, 5, $cnum . '.'); $pdf->SetX($namecol); $pdf->Cell(0, 5, $c->full_name()); $pdf->SetX($birthcol); $pdf->Cell(0, 5, $c->birth->date); $pdf->SetX($deathcol); $pdf->Cell(0, 5, $c->death->date); $pdf->Ln(5); } } }