示例#1
0
 /**
  * Startup activity
  */
 public function __construct()
 {
     parent::__construct();
     // Extract the request parameters
     $this->show_thumbs = Filter::getBool('show_thumbs');
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Compact tree of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Compact tree'));
     }
     $this->treeid = $this->sosaAncestors(5);
 }
 /**
  * Create the descendancy controller
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     // Extract parameters from form
     $this->chart_style = Filter::getInteger('chart_style', 0, 3, 0);
     $this->generations = Filter::getInteger('generations', 2, $WT_TREE->getPreference('MAX_DESCENDANCY_GENERATIONS'), $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Descendants of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Descendants'));
     }
 }
 /**
  * Startup activity
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     // Extract form parameters
     $this->show_cousins = Filter::getInteger('show_cousins', 0, 1);
     $this->chart_style = Filter::getInteger('chart_style', 0, 3);
     $this->generations = Filter::getInteger('PEDIGREE_GENERATIONS', 2, $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'), $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Ancestors of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Ancestors'));
     }
 }
 /**
  * Create the controller
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     $default_generations = $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS');
     // Extract the request parameters
     $this->fan_style = Filter::getInteger('fan_style', 2, 4, 3);
     $this->fan_width = Filter::getInteger('fan_width', 50, 500, 100);
     $this->generations = Filter::getInteger('generations', 2, 9, $default_generations);
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Fan chart of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Fan chart'));
     }
 }
 /**
  * Create a family-book controller
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     // Extract the request parameters
     $this->show_spouse = Filter::getInteger('show_spouse', 0, 1);
     $this->descent = Filter::getInteger('descent', 0, 9, 5);
     $this->generations = Filter::getInteger('generations', 2, $WT_TREE->getPreference('MAX_DESCENDANCY_GENERATIONS'), 2);
     $this->bhalfheight = $this->getBoxDimensions()->height / 2;
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Family book of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Family book'));
     }
     //Checks how many generations of descendency is for the person for formatting purposes
     $this->dgenerations = $this->maxDescendencyGenerations($this->root->getXref(), 0);
     if ($this->dgenerations < 1) {
         $this->dgenerations = 1;
     }
 }
 /**
  * Create the hourglass controller.
  *
  * @param string $rootid
  * @param int    $show_full
  * @param bool   $loadJS
  */
 public function __construct($rootid = '', $show_full = 1, $loadJS = true)
 {
     global $WT_TREE;
     parent::__construct($show_full);
     // Extract parameters from
     $this->show_spouse = Filter::getInteger('show_spouse', 0, 1, 0);
     $this->generations = Filter::getInteger('generations', 2, $WT_TREE->getPreference('MAX_DESCENDANCY_GENERATIONS'), 3);
     $this->canLoadJS = $loadJS;
     //-- flip the arrows for RTL languages
     if (I18N::direction() === 'ltr') {
         $this->left_arrow = 'icon-larrow';
         $this->right_arrow = 'icon-rarrow';
     } else {
         $this->left_arrow = 'icon-rarrow';
         $this->right_arrow = 'icon-larrow';
     }
     $this->bhalfheight = (int) ($this->getBoxDimensions()->height / 2);
     //Checks how many generations of descendency is for the person for formatting purposes
     $this->dgenerations = $this->maxDescendencyGenerations($this->root, 0);
     if ($this->dgenerations < 1) {
         $this->dgenerations = 1;
     }
     $this->setPageTitle(I18N::translate('Hourglass chart of %s', $this->root->getFullName()));
 }
 /**
  * Create a pedigree controller
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     $this->orientation = Filter::getInteger('orientation', 0, 3, $WT_TREE->getPreference('PEDIGREE_LAYOUT'));
     $this->generations = Filter::getInteger('PEDIGREE_GENERATIONS', 2, $WT_TREE->getPreference('MAX_PEDIGREE_GENERATIONS'), $WT_TREE->getPreference('DEFAULT_PEDIGREE_GENERATIONS'));
     $bxspacing = Theme::theme()->parameter('chart-spacing-x');
     $byspacing = Theme::theme()->parameter('chart-spacing-y');
     $curgen = 1;
     // -- track which generation the algorithm is currently working on
     $addoffset = array();
     // With more than 8 generations, we run out of pixels on the <canvas>
     if ($this->generations > 8) {
         $this->generations = 8;
     }
     if ($this->root && $this->root->canShowName()) {
         $this->setPageTitle(I18N::translate('Pedigree tree of %s', $this->root->getFullName()));
     } else {
         $this->setPageTitle(I18N::translate('Pedigree'));
     }
     $this->treesize = pow(2, $this->generations) - 1;
     // sosaAncestors() starts array at index 1 we need to start at 0
     $this->nodes = array_map(function ($item) {
         return array('indi' => $item, 'x' => 0, 'y' => 0);
     }, array_values($this->sosaAncestors($this->generations)));
     //check earliest generation for any ancestors
     for ($i = (int) ceil($this->treesize / 2); $i < $this->treesize; $i++) {
         $this->chartHasAncestors = $this->chartHasAncestors || $this->nodes[$i]['indi'] && $this->nodes[$i]['indi']->getChildFamilies();
     }
     $this->arrows = new \stdClass();
     switch ($this->orientation) {
         case self::PORTRAIT:
             //drop through
         //drop through
         case self::LANDSCAPE:
             $this->arrows->prevGen = I18N::direction() === 'rtl' ? 'icon-larrow' : 'icon-rarrow';
             $this->arrows->menu = I18N::direction() === 'rtl' ? 'icon-rarrow' : 'icon-larrow';
             $addoffset['x'] = $this->chartHasAncestors ? self::ARROW_SIZE : 0;
             $addoffset['y'] = 0;
             break;
         case self::OLDEST_AT_TOP:
             $this->arrows->prevGen = 'icon-uarrow';
             $this->arrows->menu = 'icon-darrow';
             $addoffset['x'] = 0;
             $addoffset['y'] = $this->root->getSpouseFamilies() ? self::ARROW_SIZE : 0;
             break;
         case self::OLDEST_AT_BOTTOM:
             $this->arrows->prevGen = 'icon-darrow';
             $this->arrows->menu = 'icon-uarrow';
             $addoffset['x'] = 0;
             $addoffset['y'] = $this->chartHasAncestors ? self::ARROW_SIZE : 0;
             break;
     }
     // -- this next section will create and position the DIV layers for the pedigree tree
     // -- loop through all of IDs in the array from last to first
     // -- calculating the box positions
     for ($i = $this->treesize - 1; $i >= 0; $i--) {
         // -- check to see if we have moved to the next generation
         if ($i < (int) ($this->treesize / pow(2, $curgen))) {
             $curgen++;
         }
         // -- box position in current generation
         $boxpos = $i - pow(2, $this->generations - $curgen);
         // -- offset multiple for current generation
         if ($this->orientation < self::OLDEST_AT_TOP) {
             $genoffset = pow(2, $curgen - $this->orientation);
             $boxspacing = $this->getBoxDimensions()->height + $byspacing;
         } else {
             $genoffset = pow(2, $curgen - 1);
             $boxspacing = $this->getBoxDimensions()->width + $byspacing;
         }
         // -- calculate the yoffset position in the generation put child between parents
         $yoffset = $boxpos * ($boxspacing * $genoffset) + $boxspacing / 2 * $genoffset + $boxspacing * $genoffset;
         // -- calculate the xoffset
         switch ($this->orientation) {
             case self::PORTRAIT:
                 $xoffset = ($this->generations - $curgen) * (($this->getBoxDimensions()->width + $bxspacing) / 1.8);
                 if (!$i && $this->root->getSpouseFamilies()) {
                     $xoffset -= self::ARROW_SIZE;
                 }
                 // -- compact the tree
                 if ($curgen < $this->generations) {
                     if ($i % 2 == 0) {
                         $yoffset = $yoffset - $boxspacing / 2 * ($curgen - 1);
                     } else {
                         $yoffset = $yoffset + $boxspacing / 2 * ($curgen - 1);
                     }
                     $parent = (int) (($i - 1) / 2);
                     $pgen = $curgen;
                     while ($parent > 0) {
                         if ($parent % 2 == 0) {
                             $yoffset = $yoffset - $boxspacing / 2 * $pgen;
                         } else {
                             $yoffset = $yoffset + $boxspacing / 2 * $pgen;
                         }
                         $pgen++;
                         if ($pgen > 3) {
                             $temp = 0;
                             for ($j = 1; $j < $pgen - 2; $j++) {
                                 $temp += pow(2, $j) - 1;
                             }
                             if ($parent % 2 == 0) {
                                 $yoffset = $yoffset - $boxspacing / 2 * $temp;
                             } else {
                                 $yoffset = $yoffset + $boxspacing / 2 * $temp;
                             }
                         }
                         $parent = (int) (($parent - 1) / 2);
                     }
                     if ($curgen > 3) {
                         $temp = 0;
                         for ($j = 1; $j < $curgen - 2; $j++) {
                             $temp += pow(2, $j) - 1;
                         }
                         if ($i % 2 == 0) {
                             $yoffset = $yoffset - $boxspacing / 2 * $temp;
                         } else {
                             $yoffset = $yoffset + $boxspacing / 2 * $temp;
                         }
                     }
                 }
                 $yoffset -= $boxspacing / 2 * pow(2, $this->generations - 2) - $boxspacing / 2;
                 break;
             case self::LANDSCAPE:
                 $xoffset = ($this->generations - $curgen) * ($this->getBoxDimensions()->width + $bxspacing);
                 if ($curgen == 1) {
                     $xoffset += 10;
                 }
                 break;
             case self::OLDEST_AT_TOP:
                 //swap x & y offsets as chart is rotated
                 $xoffset = $yoffset;
                 $yoffset = $curgen * ($this->getBoxDimensions()->height + $byspacing * 4);
                 break;
             case self::OLDEST_AT_BOTTOM:
                 //swap x & y offsets as chart is rotated
                 $xoffset = $yoffset;
                 $yoffset = ($this->generations - $curgen) * ($this->getBoxDimensions()->height + $byspacing * 2);
                 if ($i && $this->root->getSpouseFamilies()) {
                     $yoffset += self::ARROW_SIZE;
                 }
                 break;
         }
         $this->nodes[$i]["x"] = (int) $xoffset;
         $this->nodes[$i]["y"] = (int) $yoffset;
     }
     // find the minimum x & y offsets and deduct that number from
     // each value in the array so that offsets start from zero
     $min_xoffset = min(array_map(function ($item) {
         return $item['x'];
     }, $this->nodes));
     $min_yoffset = min(array_map(function ($item) {
         return $item['y'];
     }, $this->nodes));
     array_walk($this->nodes, function (&$item) use($min_xoffset, $min_yoffset) {
         $item['x'] -= $min_xoffset;
         $item['y'] -= $min_yoffset;
     });
     // calculate chart & canvas dimensions
     $max_xoffset = max(array_map(function ($item) {
         return $item['x'];
     }, $this->nodes));
     $max_yoffset = max(array_map(function ($item) {
         return $item['y'];
     }, $this->nodes));
     $this->chartsize['x'] = $max_xoffset + $bxspacing + $this->getBoxDimensions()->width + $addoffset['x'];
     $this->chartsize['y'] = $max_yoffset + $byspacing + $this->getBoxDimensions()->height + $addoffset['y'];
 }