예제 #1
0
require_once CORE_PATH . 'core.php';
require_once CORE_PATH . 'atree.class.php';
require_once LIB_PATH . 'fpdf/fpdf.php';
# process expected get/post variables
$g_indiv = isset($_GET['id']) ? $_GET['id'] : exit;
# get first person information
$o = new Person($g_indiv);
# initialize other variables
$sources = array();
$font = 'helvetica';
$g_node_indkey = array();
$g_node_strings = array();
$g_node_parents = array();
$g_content_height = 625;
# instantiate new tree
$tree = new ATree($g_indiv);
# fill tree with ancestors
$tree->fill_tree(4);
# get root node and traverse tree
# each node of the tree is passed to the display_indiv function
$root = $tree->get_node_at_index(0);
$tree->level_order_traversal($root, 'process_indiv');
/**
 * Extend FPDF class to add header and footer
 * @package theme_default
 * @access public
 */
class PDF extends FPDF
{
    # Page header
    function Header()
예제 #2
0
require_once CORE_PATH . 'f_report.php';
# process expected get/post variables
$g_indiv = isset($_GET['id']) ? $_GET['id'] : exit;
$g_max_gens = isset($_GET['g']) ? $_GET['g'] : 250;
# populate keyword array
keyword_push(gtc("Ahnentafel"));
keyword_push(gtc("Ancestors"));
# initialize other variables
$g_generation = 0;
# current generation
$individuals = array();
# get first person information
$o = new Person($g_indiv);
$smarty->assign('indiv', $o);
# instantiate new tree and populate with ancestors
$tree = new ATree($g_indiv);
$tree->fill_tree($g_max_gens);
# assign other smarty variables
$smarty->assign_by_ref('page_title', sprintf(gtc("Ahnentafel Report for %s"), $o->full_name()));
$smarty->assign_by_ref('surname_title', sprintf(gtc("%s Surname"), $o->sname));
$content_title = $o->prefix . ' ' . $o->full_name();
if ($o->suffix) {
    $content_title .= ', ' . $o->suffix;
}
$smarty->assign_by_ref('content_title', $content_title);
# get root node and traverse tree
# each node of the tree is passed to the process_indiv function
$root = $tree->get_node_at_index(0);
$tree->level_order_traversal($root, 'process_indiv');
$smarty->assign_by_ref('individuals', $individuals);
unset($root, $tree, $o);
 function calculate($other_indkey, $common_indiv = false)
 {
     $treeOtherIndiv = new ATree($other_indkey);
     $treeOtherIndiv->fill_tree($this->_max_gens);
     $skip_i = array();
     $skip_o = array();
     $common_ancestors = array();
     foreach ($this->_treeIndiv->nodes as $i) {
         foreach ($treeOtherIndiv->nodes as $o) {
             if (strcmp($i->data, $o->data) == 0) {
                 $branch_found = false;
                 foreach ($common_ancestors as $common) {
                     $ci = $common['indiv'];
                     if (in_array($i->node_index, $skip_i)) {
                         if ($i->father_index && !in_array($i->father_index, $skip_i)) {
                             $skip_i[] = $i->father_index;
                         }
                         if ($i->mother_index && !in_array($i->mother_index, $skip_i)) {
                             $skip_i[] = $i->mother_index;
                         }
                         $branch_found = true;
                     }
                     if (in_array($o->node_index, $skip_o)) {
                         if ($o->father_index && !in_array($o->father_index, $skip_o)) {
                             $skip_o[] = $o->father_index;
                         }
                         if ($o->mother_index && !in_array($o->mother_index, $skip_o)) {
                             $skip_o[] = $o->mother_index;
                         }
                         $branch_found = true;
                     }
                 }
                 if (!$branch_found) {
                     $common_ancestor = array();
                     $common_ancestor["indiv"] = $i;
                     $common_ancestor["other_indiv"] = $o;
                     $skip_i[] = $i->node_index;
                     if ($i->father_index && !in_array($i->father_index, $skip_i)) {
                         $skip_i[] = $i->father_index;
                     }
                     if ($i->mother_index && !in_array($i->mother_index, $skip_i)) {
                         $skip_i[] = $i->mother_index;
                     }
                     $skip_o[] = $o->node_index;
                     if ($o->father_index && !in_array($o->father_index, $skip_o)) {
                         $skip_o[] = $o->father_index;
                     }
                     if ($o->mother_index && !in_array($o->mother_index, $skip_o)) {
                         $skip_o[] = $o->mother_index;
                     }
                     $common_ancestors[] = $common_ancestor;
                 }
             }
         }
     }
     $common_indivs = array();
     foreach ($common_ancestors as $common) {
         $common_indiv = new Person($common['indiv']->data);
         $common_indivs[] = $common_indiv;
     }
     # get other person information
     $other_indiv = new Person($other_indkey);
     $relationship = "";
     $number_suffixes = array(1 => "st", 2 => "nd", 3 => "rd");
     $removed_names = array(1 => 'once', 2 => 'twice');
     if (count($common_ancestors) < 1) {
         $relationship = "";
     } else {
         $common = $common_ancestors[0];
         $level = min($common['indiv']->generation, $common['other_indiv']->generation);
         $removed = abs($common['indiv']->generation - $common['other_indiv']->generation);
         switch ($level) {
             case 1:
                 if ($level == $common['indiv']->generation) {
                     $grand_type = $other_indiv->sex == 'F' ? 'daughter' : 'son';
                 } else {
                     $grand_type = $other_indiv->sex == 'F' ? 'mother' : 'father';
                 }
                 switch ($removed) {
                     case 0:
                         $relationship = "";
                         break;
                         // same person
                     // same person
                     case 1:
                         $relationship = $grand_type;
                         break;
                     case 2:
                         $relationship = "grand" . $grand_type;
                         break;
                     case 3:
                         $relationship = "great grand" . $grand_type;
                         break;
                     default:
                         $great_level = $removed - 2;
                         $suffix = $number_suffixes[$great_level] ? $number_suffixes[$great_level] : "th";
                         $relationship = "" . $great_level . $suffix . " great grand" . $grand_type;
                         break;
                         break;
                 }
                 break;
             case 2:
                 if ($level == $common['indiv']->generation) {
                     $nephew_type = $other_indiv->sex == 'F' ? 'niece' : 'nephew';
                 } else {
                     $nephew_type = $other_indiv->sex == 'F' ? 'aunt' : 'uncle';
                 }
                 switch ($removed) {
                     case 0:
                         $relationship = $other_indiv->sex == 'F' ? 'sister' : 'brother';
                         break;
                     case 1:
                         $relationship = $nephew_type;
                         break;
                     case 2:
                         $relationship = "grand" . $nephew_type;
                         break;
                     case 3:
                         $relationship = "great grand" . $nephew_type;
                         break;
                     default:
                         $great_level = $removed - 2;
                         $suffix = $number_suffixes[$great_level] ? $number_suffixes[$great_level] : "th";
                         $relationship = "" . $great_level . $suffix . " great grand" . $nephew_type;
                         break;
                         break;
                 }
                 break;
             default:
                 $cousin_type = $level - 2;
                 $suffix = $number_suffixes[$cousin_type] ? $number_suffixes[$cousin_type] : "th";
                 $relationship = "" . $cousin_type . $suffix . " cousin";
                 if ($removed > 0) {
                     $removed_name = $removed_names[$removed] ? $removed_names[$removed] : "" . $removed . " times";
                     $relationship .= " " . $removed_name . " removed";
                 }
                 break;
         }
     }
     $results = array();
     $results['relationship'] = $relationship;
     $results['common_ancestors'] = $common_indivs;
     return $results;
 }
예제 #4
0
# Ensure this file is being included by a parent file
defined('_RGDS_VALID') or die('Direct access to this file is not allowed.');
require_once LIB_PATH . 'fpdf/fpdf.php';
require_once CORE_PATH . 'atree.class.php';
require_once CORE_PATH . 'f_report.php';
$font = 'Helvetica';
# process expected get/post variables
$g_indiv = isset($_GET['id']) ? $_GET['id'] : exit;
$g_max_gens = isset($_GET['max_gens']) ? $_GET['max_gens'] : 250;
# init other vars
$g_generation = 0;
# current generation
# get first person information
$o = new Person($g_indiv);
# instantiate new tree
$tree = new ATree($g_indiv);
# fill tree with ancestors
$tree->fill_tree($g_max_gens);
# get root node and traverse tree
# each node of the tree is passed to the display_indiv function
$root = $tree->get_node_at_index(0);
/**
 * Extend FPDF class to add header and footer
 * @package theme_default
 * @access public
 */
class PDF extends FPDF
{
    /**
     * Page header
     * @access public