xref: /webtrees/app/Module/RecentChangesModule.php (revision 6d1c803999d2444620a1a560507f653ab973ff5f)
18c2e8227SGreg Roach<?php
28c2e8227SGreg Roach/**
38c2e8227SGreg Roach * webtrees: online genealogy
4369c0ce6SGreg Roach * Copyright (C) 2016 webtrees development team
58c2e8227SGreg Roach * This program is free software: you can redistribute it and/or modify
68c2e8227SGreg Roach * it under the terms of the GNU General Public License as published by
78c2e8227SGreg Roach * the Free Software Foundation, either version 3 of the License, or
88c2e8227SGreg Roach * (at your option) any later version.
98c2e8227SGreg Roach * This program is distributed in the hope that it will be useful,
108c2e8227SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118c2e8227SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128c2e8227SGreg Roach * GNU General Public License for more details.
138c2e8227SGreg Roach * You should have received a copy of the GNU General Public License
148c2e8227SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158c2e8227SGreg Roach */
1676692c8bSGreg Roachnamespace Fisharebest\Webtrees\Module;
1776692c8bSGreg Roach
180e62c4b8SGreg Roachuse Fisharebest\Webtrees\Auth;
196e45321fSGreg Roachuse Fisharebest\Webtrees\Database;
200e62c4b8SGreg Roachuse Fisharebest\Webtrees\Filter;
213d7a8a4cSGreg Roachuse Fisharebest\Webtrees\Functions\FunctionsEdit;
226e45321fSGreg Roachuse Fisharebest\Webtrees\GedcomRecord;
236e45321fSGreg Roachuse Fisharebest\Webtrees\GedcomTag;
240e62c4b8SGreg Roachuse Fisharebest\Webtrees\I18N;
256e45321fSGreg Roachuse Fisharebest\Webtrees\Individual;
260e62c4b8SGreg Roachuse Fisharebest\Webtrees\Theme;
276e45321fSGreg Roachuse Fisharebest\Webtrees\Tree;
286e45321fSGreg Roachuse Rhumsaa\Uuid\Uuid;
298c2e8227SGreg Roach
308c2e8227SGreg Roach/**
318c2e8227SGreg Roach * Class RecentChangesModule
328c2e8227SGreg Roach */
33e2a378d3SGreg Roachclass RecentChangesModule extends AbstractModule implements ModuleBlockInterface {
346e45321fSGreg Roach	const DEFAULT_BLOCK      = '1';
358c2e8227SGreg Roach	const DEFAULT_DAYS       = 7;
366e45321fSGreg Roach	const DEFAULT_HIDE_EMPTY = '0';
376e45321fSGreg Roach	const DEFAULT_SHOW_USER  = '1';
386e45321fSGreg Roach	const DEFAULT_SORT_STYLE = 'date_desc';
396e45321fSGreg Roach	const DEFAULT_INFO_STYLE = 'table';
408c2e8227SGreg Roach	const MAX_DAYS           = 90;
418c2e8227SGreg Roach
428c2e8227SGreg Roach	/** {@inheritdoc} */
438c2e8227SGreg Roach	public function getTitle() {
448c2e8227SGreg Roach		return /* I18N: Name of a module */ I18N::translate('Recent changes');
458c2e8227SGreg Roach	}
468c2e8227SGreg Roach
478c2e8227SGreg Roach	/** {@inheritdoc} */
488c2e8227SGreg Roach	public function getDescription() {
498c2e8227SGreg Roach		return /* I18N: Description of the “Recent changes” module */ I18N::translate('A list of records that have been updated recently.');
508c2e8227SGreg Roach	}
518c2e8227SGreg Roach
526e45321fSGreg Roach	/** {@inheritdoc} */
5376692c8bSGreg Roach	public function getBlock($block_id, $template = true, $cfg = array()) {
544b9ff166SGreg Roach		global $ctype, $WT_TREE;
558c2e8227SGreg Roach
56e2a378d3SGreg Roach		$days       = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
576e45321fSGreg Roach		$infoStyle  = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
586e45321fSGreg Roach		$sortStyle  = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
596e45321fSGreg Roach		$show_user  = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);
606e45321fSGreg Roach		$block      = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
616e45321fSGreg Roach		$hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY);
628c2e8227SGreg Roach
636e45321fSGreg Roach		foreach (array('days', 'infoStyle', 'sortStyle', 'hide_empty', 'show_user', 'block') as $name) {
648c2e8227SGreg Roach			if (array_key_exists($name, $cfg)) {
658c2e8227SGreg Roach				$$name = $cfg[$name];
668c2e8227SGreg Roach			}
678c2e8227SGreg Roach		}
688c2e8227SGreg Roach
696e45321fSGreg Roach		$records = $this->getRecentChanges($WT_TREE, WT_CLIENT_JD - $days);
708c2e8227SGreg Roach
716e45321fSGreg Roach		if (empty($records) && $hide_empty) {
728c2e8227SGreg Roach			return '';
738c2e8227SGreg Roach		}
746e45321fSGreg Roach
758c2e8227SGreg Roach		// Print block header
768c2e8227SGreg Roach		$id    = $this->getName() . $block_id;
778c2e8227SGreg Roach		$class = $this->getName() . '_block';
786e45321fSGreg Roach
794b9ff166SGreg Roach		if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
80*6d1c8039SGreg Roach			$title = '<a class="icon-admin" title="' . I18N::translate('Preferences') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
818c2e8227SGreg Roach		} else {
828c2e8227SGreg Roach			$title = '';
838c2e8227SGreg Roach		}
848c2e8227SGreg Roach		$title .= /* I18N: title for list of recent changes */ I18N::plural('Changes in the last %s day', 'Changes in the last %s days', $days, I18N::number($days));
858c2e8227SGreg Roach
868c2e8227SGreg Roach		$content = '';
878c2e8227SGreg Roach		// Print block content
886e45321fSGreg Roach		if (count($records) == 0) {
898c2e8227SGreg Roach			$content .= I18N::plural('There have been no changes within the last %s day.', 'There have been no changes within the last %s days.', $days, I18N::number($days));
908c2e8227SGreg Roach		} else {
918c2e8227SGreg Roach			switch ($infoStyle) {
928c2e8227SGreg Roach			case 'list':
936e45321fSGreg Roach				$content .= $this->changesList($records, $sortStyle, $show_user);
948c2e8227SGreg Roach				break;
958c2e8227SGreg Roach			case 'table':
966e45321fSGreg Roach				$content .= $this->changesTable($records, $sortStyle, $show_user);
978c2e8227SGreg Roach				break;
988c2e8227SGreg Roach			}
998c2e8227SGreg Roach		}
1008c2e8227SGreg Roach
1018c2e8227SGreg Roach		if ($template) {
1028c2e8227SGreg Roach			if ($block) {
1038c2e8227SGreg Roach				$class .= ' small_inner_block';
1048c2e8227SGreg Roach			}
105cbc1590aSGreg Roach
1068c2e8227SGreg Roach			return Theme::theme()->formatBlock($id, $title, $class, $content);
1078c2e8227SGreg Roach		} else {
1088c2e8227SGreg Roach			return $content;
1098c2e8227SGreg Roach		}
1108c2e8227SGreg Roach	}
1118c2e8227SGreg Roach
1128c2e8227SGreg Roach	/** {@inheritdoc} */
1138c2e8227SGreg Roach	public function loadAjax() {
1148c2e8227SGreg Roach		return true;
1158c2e8227SGreg Roach	}
1168c2e8227SGreg Roach
1178c2e8227SGreg Roach	/** {@inheritdoc} */
1188c2e8227SGreg Roach	public function isUserBlock() {
1198c2e8227SGreg Roach		return true;
1208c2e8227SGreg Roach	}
1218c2e8227SGreg Roach
1228c2e8227SGreg Roach	/** {@inheritdoc} */
1238c2e8227SGreg Roach	public function isGedcomBlock() {
1248c2e8227SGreg Roach		return true;
1258c2e8227SGreg Roach	}
1268c2e8227SGreg Roach
1276e45321fSGreg Roach	/** {@inheritdoc} */
1288c2e8227SGreg Roach	public function configureBlock($block_id) {
1298c2e8227SGreg Roach		if (Filter::postBool('save') && Filter::checkCsrf()) {
1306e45321fSGreg Roach			$this->setBlockSetting($block_id, 'days', Filter::postInteger('days', 1, self::MAX_DAYS));
1316e45321fSGreg Roach			$this->setBlockSetting($block_id, 'infoStyle', Filter::post('infoStyle', 'list|table'));
1326e45321fSGreg Roach			$this->setBlockSetting($block_id, 'sortStyle', Filter::post('sortStyle', 'name|date_asc|date_desc'));
133782f6af0SGreg Roach			$this->setBlockSetting($block_id, 'show_user', Filter::postBool('show_user'));
134e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'hide_empty', Filter::postBool('hide_empty'));
135e2a378d3SGreg Roach			$this->setBlockSetting($block_id, 'block', Filter::postBool('block'));
1368c2e8227SGreg Roach		}
1378c2e8227SGreg Roach
138e2a378d3SGreg Roach		$days       = $this->getBlockSetting($block_id, 'days', self::DEFAULT_DAYS);
1396e45321fSGreg Roach		$infoStyle  = $this->getBlockSetting($block_id, 'infoStyle', self::DEFAULT_INFO_STYLE);
1406e45321fSGreg Roach		$sortStyle  = $this->getBlockSetting($block_id, 'sortStyle', self::DEFAULT_SORT_STYLE);
1416e45321fSGreg Roach		$show_user  = $this->getBlockSetting($block_id, 'show_user', self::DEFAULT_SHOW_USER);
1426e45321fSGreg Roach		$block      = $this->getBlockSetting($block_id, 'block', self::DEFAULT_BLOCK);
1436e45321fSGreg Roach		$hide_empty = $this->getBlockSetting($block_id, 'hide_empty', self::DEFAULT_HIDE_EMPTY);
1448c2e8227SGreg Roach
1458c2e8227SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
1468c2e8227SGreg Roach		echo I18N::translate('Number of days to show');
1478c2e8227SGreg Roach		echo '</td><td class="optionbox">';
1488c2e8227SGreg Roach		echo '<input type="text" name="days" size="2" value="', $days, '">';
149def7396fSGreg Roach		echo ' <em>', I18N::plural('maximum %s day', 'maximum %s days', I18N::number(self::MAX_DAYS), I18N::number(self::MAX_DAYS)), '</em>';
1508c2e8227SGreg Roach		echo '</td></tr>';
1518c2e8227SGreg Roach
1528c2e8227SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
1538c2e8227SGreg Roach		echo I18N::translate('Presentation style');
1548c2e8227SGreg Roach		echo '</td><td class="optionbox">';
1553d7a8a4cSGreg Roach		echo FunctionsEdit::selectEditControl('infoStyle', array('list' => I18N::translate('list'), 'table' => I18N::translate('table')), null, $infoStyle, '');
1568c2e8227SGreg Roach		echo '</td></tr>';
1578c2e8227SGreg Roach
1588c2e8227SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
1598c2e8227SGreg Roach		echo I18N::translate('Sort order');
1608c2e8227SGreg Roach		echo '</td><td class="optionbox">';
1613d7a8a4cSGreg Roach		echo FunctionsEdit::selectEditControl('sortStyle', array(
1628c2e8227SGreg Roach			'name'      => /* I18N: An option in a list-box */ I18N::translate('sort by name'),
1638c2e8227SGreg Roach			'date_asc'  => /* I18N: An option in a list-box */ I18N::translate('sort by date, oldest first'),
164cbc1590aSGreg Roach			'date_desc' => /* I18N: An option in a list-box */ I18N::translate('sort by date, newest first'),
1658c2e8227SGreg Roach		), null, $sortStyle, '');
1668c2e8227SGreg Roach		echo '</td></tr>';
1678c2e8227SGreg Roach
1688c2e8227SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
169782f6af0SGreg Roach		echo /* I18N: label for a yes/no option */ I18N::translate('Show the user who made the change');
170782f6af0SGreg Roach		echo '</td><td class="optionbox">';
1716e45321fSGreg Roach		echo FunctionsEdit::editFieldYesNo('show_user', $show_user);
172782f6af0SGreg Roach		echo '</td></tr>';
173782f6af0SGreg Roach
174782f6af0SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
1758c2e8227SGreg Roach		echo /* I18N: label for a yes/no option */ I18N::translate('Add a scrollbar when block contents grow');
1768c2e8227SGreg Roach		echo '</td><td class="optionbox">';
1773d7a8a4cSGreg Roach		echo FunctionsEdit::editFieldYesNo('block', $block);
1788c2e8227SGreg Roach		echo '</td></tr>';
1798c2e8227SGreg Roach
1808c2e8227SGreg Roach		echo '<tr><td class="descriptionbox wrap width33">';
1816e45321fSGreg Roach		echo I18N::translate('Should this block be hidden when it is empty');
1828c2e8227SGreg Roach		echo '</td><td class="optionbox">';
1833d7a8a4cSGreg Roach		echo FunctionsEdit::editFieldYesNo('hide_empty', $hide_empty);
1848c2e8227SGreg Roach		echo '</td></tr>';
1858c2e8227SGreg Roach		echo '<tr><td colspan="2" class="optionbox wrap">';
1868c2e8227SGreg Roach		echo '<span class="error">', 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.'), '</span>';
1878c2e8227SGreg Roach		echo '</td></tr>';
1888c2e8227SGreg Roach	}
1898c2e8227SGreg Roach
1906e45321fSGreg Roach	/**
1916e45321fSGreg Roach	 * Find records that have changed since a given julian day
1926e45321fSGreg Roach	 *
1936e45321fSGreg Roach	 * @param Tree $tree Changes for which tree
1946e45321fSGreg Roach	 * @param int  $jd   Julian day
1956e45321fSGreg Roach	 *
1966e45321fSGreg Roach	 * @return GedcomRecord[] List of records with changes
1976e45321fSGreg Roach	 */
1986e45321fSGreg Roach	private function getRecentChanges(Tree $tree, $jd) {
1996e45321fSGreg Roach		$sql =
2006e45321fSGreg Roach			"SELECT d_gid FROM `##dates`" .
2016e45321fSGreg Roach			" WHERE d_fact='CHAN' AND d_julianday1 >= :jd AND d_file = :tree_id";
2026e45321fSGreg Roach
2036e45321fSGreg Roach		$vars = array(
2046e45321fSGreg Roach			'jd'      => $jd,
2056e45321fSGreg Roach			'tree_id' => $tree->getTreeId(),
2066e45321fSGreg Roach		);
2076e45321fSGreg Roach
2086e45321fSGreg Roach		$xrefs = Database::prepare($sql)->execute($vars)->fetchOneColumn();
2096e45321fSGreg Roach
2106e45321fSGreg Roach		$records = array();
2116e45321fSGreg Roach		foreach ($xrefs as $xref) {
2126e45321fSGreg Roach			$record = GedcomRecord::getInstance($xref, $tree);
2136e45321fSGreg Roach			if ($record->canShow()) {
2146e45321fSGreg Roach				$records[] = $record;
2156e45321fSGreg Roach			}
2166e45321fSGreg Roach		}
2176e45321fSGreg Roach
2186e45321fSGreg Roach		return $records;
2196e45321fSGreg Roach	}
2206e45321fSGreg Roach
2216e45321fSGreg Roach	/**
2226e45321fSGreg Roach	 * Format a table of events
2236e45321fSGreg Roach	 *
2246e45321fSGreg Roach	 * @param GedcomRecord[] $records
2256e45321fSGreg Roach	 * @param string         $sort
2266e45321fSGreg Roach	 * @param bool           $show_user
2276e45321fSGreg Roach	 *
2286e45321fSGreg Roach	 * @return string
2296e45321fSGreg Roach	 */
2306e45321fSGreg Roach	private function changesList(array $records, $sort, $show_user) {
2316e45321fSGreg Roach		switch ($sort) {
2326e45321fSGreg Roach		case 'name':
2336e45321fSGreg Roach			uasort($records, array('self', 'sortByNameAndChangeDate'));
2346e45321fSGreg Roach			break;
2356e45321fSGreg Roach		case 'date_asc':
2366e45321fSGreg Roach			uasort($records, array('self', 'sortByChangeDateAndName'));
2376e45321fSGreg Roach			$records = array_reverse($records);
2386e45321fSGreg Roach			break;
2396e45321fSGreg Roach		case 'date_desc':
2406e45321fSGreg Roach			uasort($records, array('self', 'sortByChangeDateAndName'));
2416e45321fSGreg Roach		}
2426e45321fSGreg Roach
2436e45321fSGreg Roach		$html = '';
2446e45321fSGreg Roach		foreach ($records as $record) {
2456e45321fSGreg Roach			$html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item name2">' . $record->getFullName() . '</a>';
2466e45321fSGreg Roach			$html .= '<div class="indent" style="margin-bottom: 5px;">';
2476e45321fSGreg Roach			if ($record instanceof Individual) {
2486e45321fSGreg Roach				if ($record->getAddName()) {
2496e45321fSGreg Roach					$html .= '<a href="' . $record->getHtmlUrl() . '" class="list_item">' . $record->getAddName() . '</a>';
2506e45321fSGreg Roach				}
2516e45321fSGreg Roach			}
2526e45321fSGreg Roach			if ($show_user) {
2536e45321fSGreg Roach				$html .= /* I18N: [a record was] Changed on <date/time> by <user> */
2546e45321fSGreg Roach					I18N::translate('Changed on %1$s by %2$s', $record->lastChangeTimestamp(), Filter::escapeHtml($record->lastChangeUser()));
2556e45321fSGreg Roach			} else {
2566e45321fSGreg Roach				$html .= /* I18N: [a record was] Changed on <date/time> */
2576e45321fSGreg Roach					I18N::translate('Changed on %1$s', $record->lastChangeTimestamp());
2586e45321fSGreg Roach			}
2596e45321fSGreg Roach			$html .= '</div>';
2606e45321fSGreg Roach		}
2616e45321fSGreg Roach
2626e45321fSGreg Roach		return $html;
2636e45321fSGreg Roach	}
2646e45321fSGreg Roach
2656e45321fSGreg Roach	/**
2666e45321fSGreg Roach	 * Format a table of events
2676e45321fSGreg Roach	 *
2686e45321fSGreg Roach	 * @param GedcomRecord[] $records
2696e45321fSGreg Roach	 * @param string         $sort
2706e45321fSGreg Roach	 * @param bool           $show_user
2716e45321fSGreg Roach	 *
2726e45321fSGreg Roach	 * @return string
2736e45321fSGreg Roach	 */
2746e45321fSGreg Roach	private function changesTable($records, $sort, $show_user) {
2756e45321fSGreg Roach		global $controller;
2766e45321fSGreg Roach
2776e45321fSGreg Roach		$table_id = 'table-chan-' . Uuid::uuid4(); // lists requires a unique ID in case there are multiple lists per page
2786e45321fSGreg Roach
2796e45321fSGreg Roach		switch ($sort) {
2806e45321fSGreg Roach		case 'name':
2816e45321fSGreg Roach		default:
2826e45321fSGreg Roach			$aaSorting = "[2,'asc'], [4,'desc']";
2836e45321fSGreg Roach			break;
2846e45321fSGreg Roach		case 'date_asc':
2856e45321fSGreg Roach			$aaSorting = "[4,'asc'], [2,'asc']";
2866e45321fSGreg Roach			break;
2876e45321fSGreg Roach		case 'date_desc':
2886e45321fSGreg Roach			$aaSorting = "[4,'desc'], [2,'asc']";
2896e45321fSGreg Roach			break;
2906e45321fSGreg Roach		}
2916e45321fSGreg Roach
2926e45321fSGreg Roach		$html = '';
2936e45321fSGreg Roach		$controller
2946e45321fSGreg Roach			->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)
2956e45321fSGreg Roach			->addInlineJavascript('
2966e45321fSGreg Roach				jQuery.fn.dataTableExt.oSort["unicode-asc" ]=function(a,b) {return a.replace(/<[^<]*>/, "").localeCompare(b.replace(/<[^<]*>/, ""))};
2976e45321fSGreg Roach				jQuery.fn.dataTableExt.oSort["unicode-desc"]=function(a,b) {return b.replace(/<[^<]*>/, "").localeCompare(a.replace(/<[^<]*>/, ""))};
2986e45321fSGreg Roach				jQuery("#' . $table_id . '").dataTable({
2996e45321fSGreg Roach					dom: \'t\',
3006e45321fSGreg Roach					paging: false,
3016e45321fSGreg Roach					autoWidth:false,
3026e45321fSGreg Roach					lengthChange: false,
3036e45321fSGreg Roach					filter: false,
3046e45321fSGreg Roach					' . I18N::datatablesI18N() . ',
3056e45321fSGreg Roach					jQueryUI: true,
3066e45321fSGreg Roach					sorting: [' . $aaSorting . '],
3076e45321fSGreg Roach					columns: [
3086e45321fSGreg Roach						/* 0-Type */     { sortable: false, class: "center" },
3096e45321fSGreg Roach						/* 1-Record */   { dataSort: 2 },
3106e45321fSGreg Roach						/* 2-SORTNAME */ { type: "unicode" },
3116e45321fSGreg Roach						/* 3-Change */   { dataSort: 4 },
3126e45321fSGreg Roach						/* 4-DATE */     null
3136e45321fSGreg Roach						' . ($show_user ? ',/* 5-By */      null' : '') . '
3146e45321fSGreg Roach					]
3156e45321fSGreg Roach				});
3166e45321fSGreg Roach			');
3176e45321fSGreg Roach
3186e45321fSGreg Roach		$html .= '<table id="' . $table_id . '" class="width100">';
3196e45321fSGreg Roach		$html .= '<thead><tr>';
3206e45321fSGreg Roach		$html .= '<th></th>';
3216e45321fSGreg Roach		$html .= '<th>' . I18N::translate('Record') . '</th>';
3226e45321fSGreg Roach		$html .= '<th hidden>SORTNAME</th>';
3236e45321fSGreg Roach		$html .= '<th>' . GedcomTag::getLabel('CHAN') . '</th>';
3246e45321fSGreg Roach		$html .= '<th hidden>DATE</th>';
3256e45321fSGreg Roach		if ($show_user) {
3266e45321fSGreg Roach			$html .= '<th>' . GedcomTag::getLabel('_WT_USER') . '</th>';
3276e45321fSGreg Roach		}
3286e45321fSGreg Roach		$html .= '</tr></thead><tbody>';
3296e45321fSGreg Roach
3306e45321fSGreg Roach		foreach ($records as $record) {
3316e45321fSGreg Roach			$html .= '<tr><td>';
3326e45321fSGreg Roach			switch ($record::RECORD_TYPE) {
3336e45321fSGreg Roach			case 'INDI':
3346e45321fSGreg Roach				$icon = $record->getSexImage('small');
3356e45321fSGreg Roach				break;
3366e45321fSGreg Roach			case 'FAM':
3376e45321fSGreg Roach				$icon = '<i class="icon-button_family"></i>';
3386e45321fSGreg Roach				break;
3396e45321fSGreg Roach			case 'OBJE':
3406e45321fSGreg Roach				$icon = '<i class="icon-button_media"></i>';
3416e45321fSGreg Roach				break;
3426e45321fSGreg Roach			case 'NOTE':
3436e45321fSGreg Roach				$icon = '<i class="icon-button_note"></i>';
3446e45321fSGreg Roach				break;
3456e45321fSGreg Roach			case 'SOUR':
3466e45321fSGreg Roach				$icon = '<i class="icon-button_source"></i>';
3476e45321fSGreg Roach				break;
3486e45321fSGreg Roach			case 'REPO':
3496e45321fSGreg Roach				$icon = '<i class="icon-button_repository"></i>';
3506e45321fSGreg Roach				break;
3516e45321fSGreg Roach			default:
3526e45321fSGreg Roach				$icon = '&nbsp;';
3536e45321fSGreg Roach				break;
3546e45321fSGreg Roach			}
3556e45321fSGreg Roach			$html .= '<a href="' . $record->getHtmlUrl() . '">' . $icon . '</a>';
3566e45321fSGreg Roach			$html .= '</td>';
3576e45321fSGreg Roach			$name = $record->getFullName();
3586e45321fSGreg Roach			$html .= '<td class="wrap">';
3596e45321fSGreg Roach			$html .= '<a href="' . $record->getHtmlUrl() . '">' . $name . '</a>';
3606e45321fSGreg Roach			if ($record instanceof Individual) {
3616e45321fSGreg Roach				$addname = $record->getAddName();
3626e45321fSGreg Roach				if ($addname) {
3636e45321fSGreg Roach					$html .= '<div class="indent"><a href="' . $record->getHtmlUrl() . '">' . $addname . '</a></div>';
3646e45321fSGreg Roach				}
3656e45321fSGreg Roach			}
3666e45321fSGreg Roach			$html .= '</td>';
3676e45321fSGreg Roach			$html .= '<td hidden>' . $record->getSortName() . '</td>';
3686e45321fSGreg Roach			$html .= '<td class="wrap">' . $record->lastChangeTimestamp() . '</td>';
3696e45321fSGreg Roach			$html .= '<td hidden>' . $record->lastChangeTimestamp(true) . '</td>';
3706e45321fSGreg Roach			if ($show_user) {
3716e45321fSGreg Roach				$html .= '<td class="wrap">' . Filter::escapeHtml($record->lastChangeUser()) . '</td>';
3726e45321fSGreg Roach			}
3736e45321fSGreg Roach			$html .= '</tr>';
3746e45321fSGreg Roach		}
3756e45321fSGreg Roach
3766e45321fSGreg Roach		$html .= '</tbody></table>';
3776e45321fSGreg Roach
3786e45321fSGreg Roach		return $html;
3796e45321fSGreg Roach	}
3806e45321fSGreg Roach
3816e45321fSGreg Roach	/**
3826e45321fSGreg Roach	 * Sort the records by (1) last change date and (2) name
3836e45321fSGreg Roach	 *
3846e45321fSGreg Roach	 * @param GedcomRecord $a
3856e45321fSGreg Roach	 * @param GedcomRecord $b
3866e45321fSGreg Roach	 *
3876e45321fSGreg Roach	 * @return int
3886e45321fSGreg Roach	 */
3896e45321fSGreg Roach	private static function sortByChangeDateAndName(GedcomRecord $a, GedcomRecord $b) {
3906e45321fSGreg Roach		return $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true) ?: GedcomRecord::compare($a, $b);
3916e45321fSGreg Roach	}
3926e45321fSGreg Roach
3936e45321fSGreg Roach	/**
3946e45321fSGreg Roach	 * Sort the records by (1) name and (2) last change date
3956e45321fSGreg Roach	 *
3966e45321fSGreg Roach	 * @param GedcomRecord $a
3976e45321fSGreg Roach	 * @param GedcomRecord $b
3986e45321fSGreg Roach	 *
3996e45321fSGreg Roach	 * @return int
4006e45321fSGreg Roach	 */
4016e45321fSGreg Roach	private static function sortByNameAndChangeDate(GedcomRecord $a, GedcomRecord $b) {
4026e45321fSGreg Roach		return GedcomRecord::compare($a, $b) ?: $b->lastChangeTimestamp(true) - $a->lastChangeTimestamp(true);
4036e45321fSGreg Roach	}
4048c2e8227SGreg Roach}
405