';
echo '';
}
/**
* Search for a media object.
*/
private static function mediaQuery() {
global $WT_TREE;
$iid2 = Filter::get('iid', WT_REGEX_XREF);
$controller = new SimpleController;
$controller
->setPageTitle(I18N::translate('Link to an existing media object'))
->pageHeader();
$record = GedcomRecord::getInstance($iid2, $WT_TREE);
if ($record) {
$headjs = '';
if ($record instanceof Family) {
if ($record->getHusband()) {
$headjs = $record->getHusband()->getXref();
} elseif ($record->getWife()) {
$headjs = $record->getWife()->getXref();
}
}
?>
getNote(), $match)) {
// This looks like a census-assistant shared note
$title = Html::escape($match[1]);
$preamble = Html::escape($match[2]);
$header = Html::escape($match[3]);
$data = Html::escape($match[4]);
$postamble = Html::escape($match[5]);
// Get the column headers for the census to which this note refers
// requires the fact place & date to match the specific census
// censusPlace() (Soundex match) and censusDate() functions
$fmt_headers = [];
/** @var GedcomRecord[] $linkedRecords */
$linkedRecords = array_merge($note->linkedIndividuals('NOTE'), $note->linkedFamilies('NOTE'));
$firstRecord = array_shift($linkedRecords);
if ($firstRecord) {
$countryCode = '';
$date = '';
foreach ($firstRecord->getFacts('CENS') as $fact) {
if (trim($fact->getAttribute('NOTE'), '@') === $note->getXref()) {
$date = $fact->getAttribute('DATE');
$place = explode(',', strip_tags($fact->getPlace()->getFullName()));
$countryCode = Soundex::daitchMokotoff(array_pop($place));
break;
}
}
foreach (Census::allCensusPlaces() as $censusPlace) {
if (Soundex::compare($countryCode, Soundex::daitchMokotoff($censusPlace->censusPlace()))) {
foreach ($censusPlace->allCensusDates() as $census) {
if ($census->censusDate() == $date) {
foreach ($census->columns() as $column) {
$abbrev = $column->abbreviation();
if ($abbrev) {
$description = $column->title() ? $column->title() : I18N::translate('Description unavailable');
$fmt_headers[$abbrev] = '' . $abbrev . '';
}
}
break 2;
}
}
}
}
}
// Substitute header labels and format as HTML
$thead = '
' . strtr(str_replace('|', '
', $header), $fmt_headers) . '
';
$thead = str_replace('.b.', '', $thead);
// Format data as HTML
$tbody = '';
foreach (explode("\n", $data) as $row) {
$tbody .= '
';
foreach (explode('|', $row) as $column) {
$tbody .= '
' . $column . '
';
}
$tbody .= '
';
}
return
$title . "\n" . // The newline allows the framework to expand the details and turn the first line into a link
'
' .
'
' . $preamble . '
' .
'
' .
'' . $thead . '' .
'' . $tbody . '' .
'
' .
'
' . $postamble . '
' .
'
';
} else {
// Not a census-assistant shared note - apply default formatting
return Filter::formatText($note->getNote(), $note->getTree());
}
}
/**
* Generate an HTML row of data for the census header
* Add prefix cell (store XREF and drag/drop)
* Add suffix cell (delete button)
*
* @param CensusInterface $census
*
* @return string
*/
public static function censusTableHeader(CensusInterface $census) {
$html = '';
foreach ($census->columns() as $column) {
$html .= '
' . $column->abbreviation() . '
';
}
return '
' . $html . '
';
}
/**
* Generate an HTML row of data for the census
* Add prefix cell (store XREF and drag/drop)
* Add suffix cell (delete button)
*
* @param CensusInterface $census
*
* @return string
*/
public static function censusTableEmptyRow(CensusInterface $census) {
return '
' . str_repeat('
', count($census->columns())) . '
';
}
/**
* Generate an HTML row of data for the census
* Add prefix cell (store XREF and drag/drop)
* Add suffix cell (delete button)
*
* @param CensusInterface $census
* @param Individual $individual
* @param Individual $head
*
* @return string
*/
public static function censusTableRow(CensusInterface $census, Individual $individual, Individual $head) {
$html = '';
foreach ($census->columns() as $column) {
$html .= '