$MEDIA_DIRECTORY_LEVELS)) {
$directory = $MEDIA_DIRECTORY;
$level = 0;
} elseif (preg_match("'^$MEDIA_DIRECTORY'", $directory)==0) {
$directory = $MEDIA_DIRECTORY;
$level = 0;
}
// End variables for find media
switch ($type) {
case "indi":
$controller->setPageTitle(WT_I18N::translate('Find individual ID'));
break;
case "fam":
$controller->setPageTitle(WT_I18N::translate('Find Family List'));
break;
case "media":
$controller->setPageTitle(WT_I18N::translate('Find media'));
$action="filter";
break;
case "place":
$controller->setPageTitle(WT_I18N::translate('Find Place'));
$action="filter";
break;
case "repo":
$controller->setPageTitle(WT_I18N::translate('Repositories'));
$action="filter";
break;
case "note":
$controller->setPageTitle(WT_I18N::translate('Find Shared Note'));
$action="filter";
break;
case "source":
$controller->setPageTitle(WT_I18N::translate('Find Source'));
$action="filter";
break;
case "specialchar":
// Users will probably always want the same language, so remember their setting
$language_filter=safe_GET('language_filter');
if (!$language_filter) {
$language_filter=get_user_setting(WT_USER_ID, 'default_language_filter');
} else {
set_user_setting(WT_USER_ID, 'default_language_filter', $language_filter);
}
require WT_ROOT.'includes/specialchars.php';
$controller->setPageTitle(WT_I18N::translate('Find Special Characters'));
$action="filter";
break;
case "facts":
$controller
->setPageTitle(WT_I18N::translate('Find fact tags'))
->addInlineJavaScript('initPickFact();');
break;
}
$controller->pageHeader();
echo WT_JS_START;
?>
function pasteid(id, name, thumb) {
if (thumb) {
window.opener.(id, name, thumb);
} else {
// GEDFact_assistant ========================
if (window.opener.document.getElementById('addlinkQueue')) {
window.opener.insertRowToTable(id, name);
// Check if Indi, Fam or source ===================
/*
if (id.match("I")=="I") {
var win01 = window.opener.window.open('edit_interface.php?action=addmedia_links¬eid=newnote&pid='+id, 'win01', 'top=50, left=600, width=420, height=650, resizable=1, scrollbars=1');
if (window.focus) {win01.focus();}
} else if (id.match("F")=="F") {
// TODO --- alert('Opening Navigator with family id entered will come later');
}
*/
}
window.opener.(id);
if (window.opener.pastename) window.opener.pastename(name);
}
}
function checknames(frm) {
if (document.forms[0].subclick) button = document.forms[0].subclick.value;
else button = "";
if (frm.filter.value.length<2&button!="all") {
alert("");
frm.filter.focus();
return false;
}
if (button=="all") {
frm.filter.value = "";
}
return true;
}
'; // header title
switch ($type) {
case "indi":
echo WT_I18N::translate('Find individual ID');
break;
case "fam":
echo WT_I18N::translate('Find Family List');
break;
case "media":
echo WT_I18N::translate('Find media');
break;
case "place":
echo WT_I18N::translate('Find Place');
break;
case "repo":
echo WT_I18N::translate('Repositories');
break;
case "note":
echo WT_I18N::translate('Find Shared Note');
break;
case "source":
echo WT_I18N::translate('Find Source');
break;
case "specialchar":
echo WT_I18N::translate('Find Special Characters');
break;
case "facts":
echo WT_I18N::translate('Find fact tags');
break;
}
echo "
"; // close header title
// Show indi and hide the rest
if ($type == "indi") {
echo '';
}
// Show fam and hide the rest
if ($type == "fam") {
echo '';
}
// Show media and hide the rest
if ($type == 'media') {
echo '';
}
// Show place and hide the rest
if ($type == "place") {
echo '';
}
// Show repo and hide the rest
if ($type == "repo") {
echo '';
}
// Show Shared Notes and hide the rest
if ($type == "note") {
echo '';
}
// Show source and hide the rest
if ($type == "source") {
echo '';
}
// Show specialchar and hide the rest
if ($type == 'specialchar') {
echo '';
}
// Show facts
if ($type == "facts") {
echo '';
}
if ($action=="filter") {
$filter = trim($filter);
$filter_array=explode(' ', preg_replace('/ {2,}/', ' ', $filter));
// Output Individual
if ($type == "indi") {
echo '';
$myindilist=search_indis_names($filter_array, array(WT_GED_ID), 'AND');
if ($myindilist) {
echo '
';
usort($myindilist, array('WT_GedcomRecord', 'Compare'));
foreach ($myindilist as $indi) {
echo $indi->format_list('li', true);
}
echo '
', WT_I18N::translate('Total individuals: %s', count($myindilist)), '
';
} else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
echo '
';
}
// Output Family
if ($type == "fam") {
echo '';
// Get the famrecs with hits on names from the family table
// Get the famrecs with hits in the gedcom record from the family table
$myfamlist = array_unique(array_merge(
search_fams_names($filter_array, array(WT_GED_ID), 'AND'),
search_fams($filter_array, array(WT_GED_ID), 'AND', true)
));
if ($myfamlist) {
$curged = $GEDCOM;
echo '
';
usort($myfamlist, array('WT_GedcomRecord', 'Compare'));
foreach ($myfamlist as $family) {
echo $family->format_list('li', true);
}
echo '
', WT_I18N::translate('Total families: %s', count($myfamlist)), '
';
} else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
echo '
';
}
// Output Media
if ($type == "media") {
global $dirs;
$medialist = get_medialist(true, $directory);
echo '';
// Show link to previous folder
if ($level>0) {
$levels = explode("/", $directory);
$pdir = "";
for ($i=0; $i
<-- ".$pdir." ";
}
// Start of media directory table
// Tell the user where he is
echo '', WT_I18N::translate('Current directory'), ' = ', substr($directory, 0, -1), '
';
// display the directory list
if (count($dirs) || $level) {
sort($dirs);
if ($level) {
echo '', $uplink, '
';
}
echo '';
foreach ($dirs as $indexval => $dir) {
echo '';
}
}
/**
* This action generates a thumbnail for the file
*
* @name $create->thumbnail
*/
if ($create=="thumbnail") {
$filename = $_REQUEST["file"];
generate_thumbnail($directory.$filename, $thumbdir.$filename);
}
// display the images TODO x across if lots of files??
if (count($medialist) > 0) {
foreach ($medialist as $indexval => $media) {
// Check if the media belongs to the current folder
preg_match_all("/\//", $media["FILE"], $hits);
$ct = count($hits[0]);
if (($ct <= $level+1 && $external_links != "http" && !isFileExternal($media["FILE"])) || (isFileExternal($media["FILE"]) && $external_links == "http")) {
// simple filter to reduce the number of items to view
$isvalid = filterMedia($media, $filter, 'http');
if ($isvalid && $chooseType!="all") {
if ($chooseType=="0file" && !empty($media["XREF"])) $isvalid = false; // skip linked media files
if ($chooseType=="media" && empty($media["XREF"])) $isvalid = false; // skip unlinked media files
}
if ($isvalid) {
if ($media["EXISTS"] && media_filesize($media["FILE"]) != 0) {
$imgsize = findImageSize($media["FILE"]);
$imgwidth = $imgsize[0]+40;
$imgheight = $imgsize[1]+150;
}
else {
$imgwidth = 0;
$imgheight = 0;
}
echo ''; // close div="find-media-media"
}
}
}
}
else {
echo '', WT_I18N::translate('No results found.'), '
';
}
echo '
';
echo ' ';
}
// Output Places
if ($type == "place") {
echo '';
$placelist = array();
if ($all || $filter) {
$placelist=find_place_list($filter);
$ctplace = count($placelist);
if ($ctplace>0) {
$revplacelist = array();
foreach ($placelist as $indexval => $place) {
$levels = explode(',', $place); // -- split the place into comma seperated values
$levels = array_reverse($levels); // -- reverse the array so that we get the top level first
$placetext = "";
$j=0;
foreach ($levels as $indexval => $level) {
if ($j>0) $placetext .= ", ";
$placetext .= trim($level);
$j++;
}
$revplacelist[] = $placetext;
}
uasort($revplacelist, "utf8_strcasecmp");
echo '
', WT_I18N::translate('Places found'), ' ', $ctplace, '
';
}
else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
}
echo '
';
}
// Output Repositories
if ($type == "repo") {
echo '';
if ($filter) {
$repo_list = search_repos($filter_array, array(WT_GED_ID), 'AND', true);
} else {
$repo_list = get_repo_list(WT_GED_ID);
}
if ($repo_list) {
usort($repo_list, array('WT_GedcomRecord', 'Compare'));
echo '
', WT_I18N::translate('Repositories found'), " ", count($repo_list), '
';
}
else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
echo '
';
}
// Output Shared Notes
if ($type=="note") {
echo '';
if ($filter) {
$mynotelist = search_notes($filter_array, array(WT_GED_ID), 'AND', true);
} else {
$mynotelist = get_note_list(WT_GED_ID);
}
if ($mynotelist) {
usort($mynotelist, array('WT_GedcomRecord', 'Compare'));
echo '
', WT_I18N::translate('Shared Notes found'), ' ', count($mynotelist), '
';
}
else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
echo '
';
}
// Output Sources
if ($type=="source") {
echo '';
if ($filter) {
$mysourcelist = search_sources($filter_array, array(WT_GED_ID), 'AND', true);
} else {
$mysourcelist = get_source_list(WT_GED_ID);
}
if ($mysourcelist) {
usort($mysourcelist, array('WT_GedcomRecord', 'Compare'));
echo '
', WT_I18N::translate('Total sources: %s', count($mysourcelist)), '
';
}
else {
echo '
', WT_I18N::translate('No results found.'), '
';
}
echo '
';
}
// Output Special Characters
if ($type == "specialchar") {
echo '';
// lower case special characters
foreach ($lcspecialchars as $key=>$value) {
echo '', $key, ' ';
}
echo '
';
//upper case special characters
foreach ($ucspecialchars as $key=>$value) {
echo '', $key, ' ';
}
echo '
';
// other special characters (not letters)
foreach ($otherspecialchars as $key=>$value) {
echo '', $key, ' ';
}
echo '
';
}
}
echo '';
echo ""; // Close div="find-page"
// Set focus to the input field
if ($type!='facts') echo WT_JS_START, 'document.filter', $type, '.filter.focus();', WT_JS_END;