function print_recent_changes($block = true, $config = "", $side, $index) { global $pgv_lang, $ctype; global $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS; $block = true; // Always restrict this block's height if (empty($config)) { $config = $PGV_BLOCKS["print_recent_changes"]["config"]; } if ($config["days"] < 1) { $config["days"] = 30; } if (isset($config["hide_empty"])) { $HideEmpty = $config["hide_empty"]; } else { $HideEmpty = "no"; } $found_facts = get_recent_changes(client_jd() - $config['days']); // Start output if (count($found_facts) == 0 and $HideEmpty == "yes") { return false; } // Print block header $id = "recent_changes"; $title = print_help_link("recent_changes_help", "qm", "", false, true); if ($PGV_BLOCKS["print_recent_changes"]["canconfig"]) { if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) { if ($ctype == "gedcom") { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>"; } } $title .= $pgv_lang["recent_changes"]; $content = ""; // Print block content $pgv_lang["global_num1"] = $config["days"]; // Make this visible if (count($found_facts) == 0) { $content .= print_text("recent_changes_none", 0, 1); } else { $content .= print_text("recent_changes_some", 0, 1); // sortable table require_once PGV_ROOT . 'includes/functions/functions_print_lists.php'; ob_start(); print_changes_table($found_facts); $content .= ob_get_clean(); } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
function print_todays_events($block = true, $config = "", $side, $index) { global $pgv_lang, $SHOW_ID_NUMBERS, $ctype, $TEXT_DIRECTION; global $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS; $block = true; // Always restrict this block's height $todayjd = client_jd(); if (empty($config)) { $config = $PGV_BLOCKS["print_todays_events"]["config"]; } if (isset($config["filter"])) { $filter = $config["filter"]; } else { $filter = "all"; } if (isset($config["onlyBDM"])) { $onlyBDM = $config["onlyBDM"]; } else { $onlyBDM = "no"; } if (isset($config["infoStyle"])) { $infoStyle = $config["infoStyle"]; } else { $infoStyle = "style2"; } if (isset($config["sortStyle"])) { $sortStyle = $config["sortStyle"]; } else { $sortStyle = "alpha"; } if (isset($config["allowDownload"])) { $allowDownload = $config["allowDownload"]; } else { $allowDownload = "yes"; } // Don't permit calendar download if not logged in if (!PGV_USER_ID) { $allowDownload = "no"; } //-- Start output $id = "on_this_day_events"; $title = print_help_link("index_onthisday_help", "qm", "", false, true); if ($PGV_BLOCKS["print_todays_events"]["canconfig"]) { if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) { if ($ctype == "gedcom") { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>"; } } $title .= $pgv_lang["on_this_day"]; $content = ""; switch ($infoStyle) { case "style1": // Output style 1: Old format, no visible tables, much smaller text. Better suited to right side of page. $content .= print_events_list($todayjd, $todayjd, $onlyBDM == 'yes' ? 'BIRT MARR DEAT' : '', $filter == 'living', $sortStyle); break; case "style2": // Style 2: New format, tables, big text, etc. Not too good on right side of page ob_start(); $content .= print_events_table($todayjd, $todayjd, $onlyBDM == 'yes' ? 'BIRT MARR DEAT' : '', $filter == 'living', $allowDownload == 'yes', $sortStyle); $content .= ob_get_clean(); break; } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
function print_todo($block = true, $config = '', $side, $index) { global $pgv_lang, $factarray, $ctype, $PGV_IMAGE_DIR, $PGV_IMAGES, $PGV_BLOCKS; $block = true; // Always restrict this block's height if (empty($config)) { $config = $PGV_BLOCKS['print_todo']['config']; } $id = 'todo'; $title = print_help_link('todo_help', 'qm', '', false, true); if ($PGV_BLOCKS['print_todo']['canconfig']) { if ($ctype == 'gedcom' && PGV_USER_GEDCOM_ADMIN || $ctype == 'user' && PGV_USER_ID) { if ($ctype == 'gedcom') { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/{$PGV_IMAGES['admin']['small']}\" width=\"15\" height=\"15\" border=\"0\" alt=\"{$pgv_lang['config_block']}\" /></a>"; } } $title .= $pgv_lang['todo_block']; $content = ""; require_once PGV_ROOT . 'js/sorttable.js.htm'; require_once PGV_ROOT . 'includes/classes/class_gedcomrecord.php'; $table_id = 'ID' . floor(microtime() * 1000000); // sorttable requires a unique ID $content .= '<table id="' . $table_id . '" class="sortable list_table center">'; $content .= '<tr>'; $content .= '<th class="list_label">' . $factarray['DATE'] . '</th>'; $content .= '<th class="list_label">' . $pgv_lang['record'] . '</th>'; if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') { $content .= '<th class="list_label">' . $pgv_lang['username'] . '</th>'; } $content .= '<th class="list_label">' . $factarray['TEXT'] . '</th>'; $content .= '</tr>'; $found = false; $end_jd = $config['show_future'] == 'yes' ? 99999999 : client_jd(); foreach (get_calendar_events(0, $end_jd, '_TODO', PGV_GED_ID) as $todo) { $record = GedcomRecord::getInstance($todo['id']); if ($record && $record->canDisplayDetails()) { $pgvu = get_gedcom_value('_PGVU', 2, $todo['factrec']); if ($pgvu == PGV_USER_NAME || !$pgvu && $config['show_unassigned'] == 'yes' || $pgvu && $config['show_other'] == 'yes') { $content .= '<tr valign="top">'; $content .= '<td class="list_value_wrap">' . str_replace('<a', '<a name="' . $todo['date']->MinJD() . '"', $todo['date']->Display(false)) . '</td>'; $name = $record->getListName(); $content .= '<td class="list_value_wrap" align="' . get_align(PGV_GEDCOM) . '"><a href="' . encode_url($record->getLinkUrl()) . '">' . PrintReady($name) . '</a></td>'; if ($config['show_unassigned'] == 'yes' || $config['show_other'] == 'yes') { $content .= '<td class="list_value_wrap">' . $pgvu . '</td>'; } $text = get_gedcom_value('_TODO', 1, $todo['factrec']); $content .= '<td class="list_value_wrap" align="' . get_align($text) . '">' . PrintReady($text) . '</td>'; $content .= '</tr>'; $found = true; } } } $content .= '</table>'; if (!$found) { $content .= '<p>' . $pgv_lang['todo_nothing'] . '</p>'; } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
static function GetAgeGedcom($d1, $d2 = null) { if (is_null($d2)) { return $d1->date1->GetAge(true, client_jd()); } else { // If dates overlap, then can't calculate age. if (GedcomDate::Compare($d1, $d2)) { return $d1->date1->GetAge(true, $d2->MinJD()); } if (GedcomDate::Compare($d1, $d2) == 0 && $d1->date1->minJD == $d2->MinJD()) { return '0d'; } else { return ''; } } }
function _topTenOldestAlive($type = 'list', $sex = 'BOTH', $params = null) { global $TBLPREFIX, $TEXT_DIRECTION, $pgv_lang, $lang_short_cut, $LANGUAGE; if (!PGV_USER_CAN_ACCESS) { return $pgv_lang["privacy_error"]; } if ($sex == 'F') { $sex_search = " AND i_sex='F'"; } elseif ($sex == 'M') { $sex_search = " AND i_sex='M'"; } else { $sex_search = ''; } if ($params !== null && isset($params[0])) { $total = $params[0]; } else { $total = 10; } $rows = self::_runSQL('' . ' SELECT' . ' birth.d_gid AS id,' . ' birth.d_julianday1 AS age' . ' FROM' . " {$TBLPREFIX}dates AS birth," . " {$TBLPREFIX}individuals AS indi" . ' WHERE' . ' indi.i_id=birth.d_gid AND' . ' indi.i_isdead=0 AND' . " birth.d_file={$this->_ged_id} AND" . ' birth.d_file=indi.i_file AND' . " birth.d_fact IN ('BIRT', 'CHR', 'BAPM', '_BRTM') AND" . ' birth.d_julianday1!=0' . $sex_search . ' GROUP BY' . ' id' . ' ORDER BY' . ' age ASC', $total); if (!isset($rows)) { return 0; } $top10 = array(); $func = "age_localisation_{$lang_short_cut[$LANGUAGE]}"; if (!function_exists($func)) { $func = "DefaultAgeLocalisation"; } $show_years = true; foreach ($rows as $row) { $person = Person::getInstance($row['id']); $age = client_jd() - $row['age']; if (floor($age / 365.25) > 0) { $age = floor($age / 365.25) . 'y'; } else { if (floor($age / 12) > 0) { $age = floor($age / 12) . 'm'; } else { $age = $age . 'd'; } } $func($age, $show_years); if ($type == 'list') { $top10[] = "\t<li><a href=\"" . $person->getLinkUrl() . "\">" . PrintReady($person->getFullName()) . "</a> [" . $age . "]</li>\n"; } else { $top10[] = "<a href=\"" . $person->getLinkUrl() . "\">" . PrintReady($person->getFullName()) . "</a> [" . $age . "]"; } } if ($type == 'list') { $top10 = join("\n", $top10); } else { $top10 = join('; ', $top10); } if ($TEXT_DIRECTION == 'rtl') { $top10 = str_replace(array("[", "]", "(", ")", "+"), array("‏[", "‏]", "‏(", "‏)", "‏+"), $top10); } if ($type == 'list') { return "<ul>\n{$top10}</ul>\n"; } return $top10; }