i18n::translate('Charts Block'),
'type'=>'both',
'descr'=>i18n::translate('The Charts block allows you to place a chart on the Home or My Page. You can configure the block to show an ancestors, descendants, or hourglass view. You can also choose the root person for the chart.'),
'canconfig'=>true,
'config'=>array(
'cache'=>1,
'pid'=>'',
'type'=>'pedigree',
'details'=>'no'
)
);
function print_charts_block($block = true, $config="", $side, $index) {
global $WT_BLOCKS, $ctype, $WT_IMAGE_DIR, $WT_IMAGES, $PEDIGREE_ROOT_ID, $PEDIGREE_FULL_DETAILS;
global $show_full, $bwidth, $bheight;
if (empty($config)) $config = $WT_BLOCKS["print_charts_block"]["config"];
if (empty($config['details'])) $config['details'] = 'no';
if (empty($config["pid"])) {
if (!WT_USER_ID) {
$config["pid"] = $PEDIGREE_ROOT_ID;
} else {
if (WT_USER_GEDCOM_ID) {
$config["pid"] = WT_USER_GEDCOM_ID;
} else {
$config["pid"] = $PEDIGREE_ROOT_ID;
}
}
}
// Override GEDCOM configuration temporarily
if (isset($show_full)) $saveShowFull = $show_full;
$savePedigreeFullDetails = $PEDIGREE_FULL_DETAILS;
if ($config["details"]=="no") {
$show_full = 0;
// Here we could adjust the block width & height to accommodate larger displays
} else {
$show_full = 1;
// Here we could adjust the block width & height to accommodate larger displays
}
$PEDIGREE_FULL_DETAILS = $show_full;
if ($config['type']!='treenav') {
$controller = new HourglassController();
$controller->init($config["pid"],0,3);
$controller->setupJavascript();
}
else {
$nav = new TreeNav($config['pid'],'blocknav',-1);
$nav->generations = 2;
}
$person = Person::getInstance($config["pid"]);
if ($person==null) {
$config["pid"] = $PEDIGREE_ROOT_ID;
$person = Person::getInstance($PEDIGREE_ROOT_ID);
}
$id = "charts_block";
$title='';
if ($WT_BLOCKS["print_charts_block"]["canconfig"]) {
if ($ctype=="gedcom" && WT_USER_GEDCOM_ADMIN || $ctype=="user" && WT_USER_ID) {
if ($ctype=="gedcom") {
$name = WT_GEDCOM;
} else {
$name = WT_USER_NAME;
}
$title .= "";
$title .= "";
}
}
if ($person) {
$name=PrintReady($person->getFullName());
switch($config['type']) {
case 'pedigree':
$title .= $name." ".i18n::translate('Pedigree Tree');
break;
case 'descendants':
$title .= $name." ".i18n::translate('Descendancy Chart');
break;
case 'hourglass':
$title .= $name." ".i18n::translate('Hourglass Chart');
break;
case 'treenav':
$title .= $name." ".i18n::translate('Tree');
break;
}
$title .= help_link('index_charts');
$content = "";
$content .= "";
if ($show_full==0) {
$content .= '
| "; ob_start(); $controller->print_descendency($person->getXref(), 1, false); $content .= ob_get_clean(); $content .= " | "; } if ($config['type']=='pedigree' || $config['type']=='hourglass') { //-- print out the root person if ($config['type']!='hourglass') { $content .= ""; ob_start(); print_pedigree_person($person->getXref()); $content .= ob_get_clean(); $content .= " | "; } $content .= ""; ob_start(); $controller->print_person_pedigree($person->getXref(), 1); $content .= ob_get_clean(); $content .= " | "; } if ($config['type']=='treenav') { $content .= ""; ob_start(); $nav->drawViewport('blocknav', "", "240px"); $content .= ob_get_clean(); $content .= " | "; } $content .= "