fan_style = WT_Filter::getInteger('fan_style', 2, 4, 3); $this->fan_width = WT_Filter::getInteger('fan_width', 50, 300, 100); $this->generations = WT_Filter::getInteger('generations', 2, 9, $default_generations); if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: http://en.wikipedia.org/wiki/Family_tree#Fan_chart - %s is an individual’s name */ WT_I18N::translate('Fan chart of %s', $this->root->getFullName()) ); } else { $this->setPageTitle(WT_I18N::translate('Fan chart')); } } public function getFanStyles() { return array( 2=>/* I18N: layout option for the fan chart */ WT_I18N::translate('half circle'), 3=>/* I18N: layout option for the fan chart */ WT_I18N::translate('three-quarter circle'), 4=>/* I18N: layout option for the fan chart */ WT_I18N::translate('full circle'), ); } /** * split and center text by lines * * @param string $data input string * @param int $maxlen max length of each line * @return string $text output string */ public function split_align_text($data, $maxlen) { $RTLOrd = array(215,216,217,218,219); $lines = explode("\n", $data); // more than 1 line : recursive calls if (count($lines)>1) { $text = ""; foreach ($lines as $indexval => $line) $text .= $this->split_align_text($line, $maxlen)."\n"; return $text; } // process current line word by word $split = explode(" ", $data); $text = ""; $line = ""; // do not split hebrew line $found = false; foreach ($RTLOrd as $indexval => $ord) { if (strpos($data, chr($ord)) !== false) $found=true; } if ($found) $line=$data; else foreach ($split as $indexval => $word) { $len = strlen($line); //if (!empty($line) and ord($line{0})==215) $len/=2; // hebrew text $wlen = strlen($word); // line too long ? if (($len+$wlen)<$maxlen) { if (!empty($line)) $line .= " "; $line .= "$word"; } else { $p = max(0,(int)(($maxlen-$len)/2)); if (!empty($line)) { $line = str_repeat(" ", $p) . "$line"; // center alignment using spaces $text .= "$line\n"; } $line = $word; } } // last line if (!empty($line)) { $len = strlen($line); if (in_array(ord($line{0}),$RTLOrd)) $len/=2; $p = max(0,(int)(($maxlen-$len)/2)); $line = str_repeat(" ", $p) . "$line"; // center alignment using spaces $text .= "$line"; } return $text; } // Generate either the HTML or PNG components of the chart - we send them separately public function generate_fan_chart($what) { global $fanChart; $treeid=ancestry_array($this->root->getXref(), $this->generations); $fanw =640*$this->fan_width/100; $fandeg=90*$this->fan_style; $html =''; // check for GD 2.x library if (!defined("IMG_ARC_PIE")) { return false; } if (!function_exists("ImageTtfBbox")) { return false; } // Validate if (!file_exists($fanChart['font'])) { $html.= '
'.WT_I18N::translate('The file “%s” does not exist.', $fanChart['font']).'
'; return false; } $fanChart['size'] = intval($fanChart['size']); if ($fanChart['size']<2) $fanChart['size'] = 7; if (empty($fanChart['color']) || $fanChart['color']{0}!='#') $fanChart['color'] = '#000000'; if (empty($fanChart['bgColor']) || $fanChart['bgColor']{0}!='#') $fanChart['bgColor'] = '#EEEEEE'; if (empty($fanChart['bgMColor']) || $fanChart['bgMColor']{0}!='#') $fanChart['bgMColor'] = '#D0D0AC'; if (empty($fanChart['bgFColor']) || $fanChart['bgFColor']{0}!='#') $fanChart['bgFColor'] = '#D0ACD0'; $treesize=count($treeid); if ($treesize<1) return; // generations count $gen=log($treesize)/log(2)-1; $sosa=$treesize-1; // fan size if ($fandeg==0) $fandeg=360; $fandeg=min($fandeg, 360); $fandeg=max($fandeg, 90); $cx=$fanw/2-1; // center x $cy=$cx; // center y $rx=$fanw-1; $rw=$fanw/($gen+1); $fanh=$fanw; // fan height if ($fandeg==180) $fanh=round($fanh*($gen+1)/($gen*2)); if ($fandeg==270) $fanh=round($fanh*.86); $scale=$fanw/640; // image init $image = ImageCreate($fanw, $fanh); $black = ImageColorAllocate($image, 0, 0, 0); $white = ImageColorAllocate($image, 0xFF, 0xFF, 0xFF); ImageFilledRectangle ($image, 0, 0, $fanw, $fanh, $white); ImageColorTransparent($image, $white); $color = ImageColorAllocate($image, hexdec(substr($fanChart['color'],1,2)), hexdec(substr($fanChart['color'],3,2)), hexdec(substr($fanChart['color'],5,2))); $bgcolor = ImageColorAllocate($image, hexdec(substr($fanChart['bgColor'],1,2)), hexdec(substr($fanChart['bgColor'],3,2)), hexdec(substr($fanChart['bgColor'],5,2))); $bgcolorM = ImageColorAllocate($image, hexdec(substr($fanChart['bgMColor'],1,2)), hexdec(substr($fanChart['bgMColor'],3,2)), hexdec(substr($fanChart['bgMColor'],5,2))); $bgcolorF = ImageColorAllocate($image, hexdec(substr($fanChart['bgFColor'],1,2)), hexdec(substr($fanChart['bgFColor'],3,2)), hexdec(substr($fanChart['bgFColor'],5,2))); // imagemap $imagemap="'; switch ($what) { case 'html': $image_title=WT_I18N::translate('Fan chart of %s', strip_tags($name)); return $html.$imagemap.'