';
echo FunctionsEdit::selectEditControl('sortStyle', array(
'name' => /* I18N: An option in a list-box */ I18N::translate('sort by name'),
'date_asc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, oldest first'),
'date_desc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, newest first'),
), null, $sortStyle, '');
echo '
';
echo '
';
echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change');
echo '
';
echo '', I18N::translate('If you hide an empty block, you will not be able to change its configuration until it becomes visible by no longer being empty.'), '';
echo '
';
}
/**
* Find records that have changed since a given julian day
*
* @param Tree $tree Changes for which tree
* @param int $jd Julian day
*
* @return GedcomRecord[] List of records with changes
*/
private function getRecentChanges(Tree $tree, $jd) {
$sql =
"SELECT d_gid FROM `##dates`" .
" WHERE d_fact='CHAN' AND d_julianday1 >= :jd AND d_file = :tree_id";
$vars = array(
'jd' => $jd,
'tree_id' => $tree->getTreeId(),
);
$xrefs = Database::prepare($sql)->execute($vars)->fetchOneColumn();
$records = array();
foreach ($xrefs as $xref) {
$record = GedcomRecord::getInstance($xref, $tree);
if ($record->canShow()) {
$records[] = $record;
}
}
return $records;
}
/**
* Format a table of events
*
* @param GedcomRecord[] $records
* @param string $sort
* @param bool $show_user
*
* @return string
*/
private function changesList(array $records, $sort, $show_user) {
switch ($sort) {
case 'name':
uasort($records, array('self', 'sortByNameAndChangeDate'));
break;
case 'date_asc':
uasort($records, array('self', 'sortByChangeDateAndName'));
$records = array_reverse($records);
break;
case 'date_desc':
uasort($records, array('self', 'sortByChangeDateAndName'));
}
$html = '';
foreach ($records as $record) {
$html .= '' . $record->getFullName() . '';
$html .= '
';
if ($record instanceof Individual) {
if ($record->getAddName()) {
$html .= '' . $record->getAddName() . '';
}
}
// The timestamp may be missing or private.
$timestamp = $record->lastChangeTimestamp();
if ($timestamp !== '') {
if ($show_user) {
$html .= /* I18N: [a record was] Changed on by */
I18N::translate('Changed on %1$s by %2$s', $timestamp, Filter::escapeHtml($record->lastChangeUser()));
} else {
$html .= /* I18N: [a record was] Changed on */
I18N::translate('Changed on %1$s', $timestamp);
}
}
$html .= '
';
}
return $html;
}
/**
* Format a table of events
*
* @param GedcomRecord[] $records
* @param string $sort
* @param bool $show_user
*
* @return string
*/
private function changesTable($records, $sort, $show_user) {
global $controller;
$table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
switch ($sort) {
case 'name':
default:
$aaSorting = "[1,'asc'], [2,'desc']";
break;
case 'date_asc':
$aaSorting = "[2,'asc'], [1,'asc']";
break;
case 'date_desc':
$aaSorting = "[2,'desc'], [1,'asc']";
break;
}
$html = '';
$controller
->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
->addInlineJavascript('
jQuery("#' . $table_id . '").dataTable({
dom: \'t\',
paging: false,
autoWidth:false,
lengthChange: false,
filter: false,
' . I18N::datatablesI18N() . ',
jQueryUI: true,
sorting: [' . $aaSorting . '],
columns: [
{ sortable: false, class: "center" },
null,
null,
{ visible: ' . ($show_user ? 'true' : 'false') . ' }
]
});
');
$html .= '
';
$html .= '
';
$html .= '
';
$html .= '
' . I18N::translate('Record') . '
';
$html .= '
' . GedcomTag::getLabel('CHAN') . '
';
$html .= '
' . GedcomTag::getLabel('_WT_USER') . '
';
$html .= '
';
foreach ($records as $record) {
$html .= '
';
switch ($record::RECORD_TYPE) {
case 'INDI':
$html .= $record->getSexImage('small');
break;
case 'FAM':
$html .= '';
break;
case 'OBJE':
$html .= '';
break;
case 'NOTE':
$html .= '';
break;
case 'SOUR':
$html .= '';
break;
case 'REPO':
$html .= '';
break;
}
$html .= '