summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/functions/functions_import.php69
-rw-r--r--includes/functions/functions_print_facts.php18
2 files changed, 36 insertions, 51 deletions
diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php
index c6fc1c6984..a8cf6d2b9f 100644
--- a/includes/functions/functions_import.php
+++ b/includes/functions/functions_import.php
@@ -991,7 +991,7 @@ function insert_media($objrec, $objlevel, $update, $gid, $ged_id, $count) {
if (isset($m_media)) {
//-- add the entry to the media_mapping table
$sql_insert_media_mapping->execute(array($m_media, $gid, $count, $ged_id, $objref));
- return $objref;
+ return "{$objlevel} OBJE @{$m_media}@\n";
} else {
print "Media reference error ".$objrec;
return "";
@@ -1075,18 +1075,16 @@ function update_media($gid, $ged_id, $gedrec, $update = false) {
//-- if there aren't any media records then don't look for them just return
$pt = preg_match("/\d OBJE/", $gedrec, $match);
if ($pt > 0) {
- //-- go through all of the lines and replace any local
- //--- OBJE to referenced OBJEs
- $newrec = "";
- $lines = explode("\n", $gedrec);
- $ct_lines = count($lines);
- $inobj = false;
- $processed = false;
- $objlevel = 0;
- $objrec = "";
- $count = 1;
- foreach ($lines as $key => $line) {
- if (!empty ($line)) {
+ //-- go through all of the lines and replace any local
+ //--- OBJE to referenced OBJEs
+ $newrec = "";
+ $lines = explode("\n", $gedrec);
+ $inobj = false;
+ $processed = false;
+ $objlevel = 0;
+ $objrec = "";
+ $count = 1;
+ foreach ($lines as $key => $line) {
// NOTE: Match lines that resemble n OBJE @0000@
// NOTE: Renumber the old ID to a new ID and save the old ID
// NOTE: in case there are more references to it
@@ -1103,42 +1101,37 @@ function update_media($gid, $ged_id, $gedrec, $update = false) {
$objlevel = 0;
$inobj = false;
}
- if (preg_match("/[1-9] OBJE @(.*)@/", $line, $match) != 0) {
- // NOTE: Set object level
- $objlevel = $level;
- $inobj = true;
- $objrec = $line . "\n";
- } elseif (preg_match("/[1-9] OBJE/", $line, $match)) {
+ if (preg_match("/^[1-9] OBJE @(.*)@/", $line, $match) != 0) {
+ // NOTE: Set object level
+ $objlevel = $level;
+ $inobj = true;
+ $objrec = $line . "\n";
+ } elseif (preg_match("/^[1-9] OBJE/", $line, $match)) {
// NOTE: Set the details for the next media record
$objlevel = $level;
$inobj = true;
- $objrec = $line . "\n";
+ $objrec = $line . "\n";
} else {
- $ct = preg_match("/(\d+) (\w+)(.*)/", $line, $match);
- if ($ct > 0) {
- if ($inobj) {
- $objrec .= $line . "\n";
- } else {
- $newrec .= $line . "\n";
- }
+ if ($inobj) {
+ $objrec .= $line . "\n";
} else {
$newrec .= $line . "\n";
}
}
}
- }
- //-- make sure the last line gets handled
- if ($inobj) {
- $objref = insert_media($objrec, $objlevel, $update, $gid, $ged_id, $count);
- $count++;
- $newrec .= $objref;
+ //-- make sure the last line gets handled
+ if ($inobj) {
+ $objref = insert_media($objrec, $objlevel, $update, $gid, $ged_id, $count);
+ $count++;
+ $newrec .= $objref;
- // NOTE: Set the details for the next media record
- $objlevel = 0;
- $inobj = false;
- }
+ // NOTE: Set the details for the next media record
+ $objlevel = 0;
+ $inobj = false;
+ }
+ } else {
+ $newrec = $gedrec;
}
- else $newrec = $gedrec;
if ($keepmedia) {
$newrec = trim($newrec)."\n";
diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php
index 68f74f8d6b..1ba12e4a20 100644
--- a/includes/functions/functions_print_facts.php
+++ b/includes/functions/functions_print_facts.php
@@ -1407,7 +1407,7 @@ function print_main_media($pid, $level=1, $related=false, $noedit=false) {
function print_main_media_row($rtype, $rowm, $pid) {
global $WT_IMAGES, $TEXT_DIRECTION, $GEDCOM, $THUMBNAIL_WIDTH, $USE_MEDIA_VIEWER, $SEARCH_SPIDER, $MEDIA_TYPES;
- if (!canDisplayRecord($rowm['m_gedfile'], $rowm['m_gedrec']) || !canDisplayFact($rowm['m_media'], $rowm['m_gedfile'], $rowm['mm_gedrec'])) {
+ if (!canDisplayRecord($rowm['m_gedfile'], $rowm['m_gedrec'])) {
return false;
}
@@ -1448,8 +1448,6 @@ function print_main_media_row($rtype, $rowm, $pid) {
// NOTE Print the title of the media
echo "</td><td class=\"optionbox wrap $styleadd\"><span class=\"field\">";
$mediaTitle = $rowm["m_titl"];
- $subtitle = get_gedcom_value("TITL", 2, $rowm["mm_gedrec"]);
- if (!empty($subtitle)) $mediaTitle = $subtitle;
$mainMedia = check_media_depth($rowm["m_file"], "NOTRUNC");
if ($mediaTitle=="") $mediaTitle = basename($rowm["m_file"]);
@@ -1506,12 +1504,10 @@ function print_main_media_row($rtype, $rowm, $pid) {
} else {
echo "<i>", PrintReady(htmlspecialchars($mediaTitle, ENT_COMPAT, 'UTF-8')."&nbsp;&nbsp;({$rowm['m_media']})");
}
- $addtitle = get_gedcom_value("TITL:_HEB", 2, $rowm["mm_gedrec"]);
- if (empty($addtitle)) $addtitle = get_gedcom_value("TITL:_HEB", 2, $rowm["m_gedrec"]);
+ $addtitle = get_gedcom_value("TITL:_HEB", 2, $rowm["m_gedrec"]);
if (empty($addtitle)) $addtitle = get_gedcom_value("TITL:_HEB", 1, $rowm["m_gedrec"]);
if (!empty($addtitle)) echo "<br />\n", PrintReady(htmlspecialchars($addtitle, ENT_COMPAT, 'UTF-8'));
- $addtitle = get_gedcom_value("TITL:ROMN", 2, $rowm["mm_gedrec"]);
- if (empty($addtitle)) $addtitle = get_gedcom_value("TITL:ROMN", 2, $rowm["m_gedrec"]);
+ $addtitle = get_gedcom_value("TITL:ROMN", 2, $rowm["m_gedrec"]);
if (empty($addtitle)) $addtitle = get_gedcom_value("TITL:ROMN", 1, $rowm["m_gedrec"]);
if (!empty($addtitle)) echo "<br />\n", PrintReady(htmlspecialchars($addtitle, ENT_COMPAT, 'UTF-8'));
echo "</i>";
@@ -1575,8 +1571,7 @@ function print_main_media_row($rtype, $rowm, $pid) {
}
//-- don't show _PRIM option to regular users
if (WT_USER_GEDCOM_ADMIN) {
- $prim = get_gedcom_value("_PRIM", 2, $rowm["mm_gedrec"]);
- if (empty($prim)) $prim = get_gedcom_value("_PRIM", 1, $rowm["m_gedrec"]);
+ $prim = get_gedcom_value("_PRIM", 1, $rowm["m_gedrec"]);
if (!empty($prim)) {
echo "<span class=\"label\">", translate_fact('_PRIM'), ":</span> ";
if ($prim=="Y") echo i18n::translate('Yes'); else echo i18n::translate('No');
@@ -1585,8 +1580,7 @@ function print_main_media_row($rtype, $rowm, $pid) {
}
//-- don't show _THUM option to regular users
if (WT_USER_GEDCOM_ADMIN) {
- $thum = get_gedcom_value("_THUM", 2, $rowm["mm_gedrec"]);
- if (empty($thum)) $thum = get_gedcom_value("_THUM", 1, $rowm["m_gedrec"]);
+ $thum = get_gedcom_value("_THUM", 1, $rowm["m_gedrec"]);
if (!empty($thum)) {
echo "<span class=\"label\">", translate_fact('_THUM'), ":</span> ";
if ($thum=="Y") echo i18n::translate('Yes'); else echo i18n::translate('No');
@@ -1594,9 +1588,7 @@ function print_main_media_row($rtype, $rowm, $pid) {
}
}
print_fact_notes($rowm["m_gedrec"], 1);
- print_fact_notes($rowm["mm_gedrec"], 2);
print_fact_sources($rowm["m_gedrec"], 1);
- print_fact_sources($rowm["mm_gedrec"], 2);
echo "</td></tr>";
return true;
}