diff options
| author | fisharebest <fisharebest@gmail.com> | 2013-05-13 18:30:36 +0000 |
|---|---|---|
| committer | fisharebest <fisharebest@gmail.com> | 2013-05-13 18:30:36 +0000 |
| commit | 0a0aa5179f6b2f82ea17b900bfeaa297a5955022 (patch) | |
| tree | ec2ef68ced2f91cb1cc5fcb3b9ba63521d63385b | |
| parent | c7e77016259011bfd9ee8787e45996045f0f93a0 (diff) | |
| download | webtrees-0a0aa5179f6b2f82ea17b900bfeaa297a5955022.tar.gz webtrees-0a0aa5179f6b2f82ea17b900bfeaa297a5955022.tar.bz2 webtrees-0a0aa5179f6b2f82ea17b900bfeaa297a5955022.zip | |
#1161600 - Tags "1 _WT_OBJE_SORT" not deleted
| -rw-r--r-- | edit_interface.php | 2 | ||||
| -rw-r--r-- | includes/functions/functions_edit.php | 29 | ||||
| -rw-r--r-- | modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php | 2 |
3 files changed, 11 insertions, 22 deletions
diff --git a/edit_interface.php b/edit_interface.php index ef04cf8952..3cc891c448 100644 --- a/edit_interface.php +++ b/edit_interface.php @@ -157,7 +157,7 @@ case 'delete': // When deleting a media link, $linenum comes is an OBJE and the $mediaid to delete should be set if ($linenum=='OBJE') { - $newged = remove_subrecord($gedrec, $linenum, $_REQUEST['mediaid']); + $newged = remove_media_subrecord($gedrec, $_REQUEST['mediaid']); } else { $newged = remove_subline($gedrec, $linenum); } diff --git a/includes/functions/functions_edit.php b/includes/functions/functions_edit.php index 4f30315750..39292f0d0d 100644 --- a/includes/functions/functions_edit.php +++ b/includes/functions/functions_edit.php @@ -487,33 +487,22 @@ function check_gedcom($gedrec, $chan=true) { return $newrec; } -/** -* remove a subrecord from a parent record by gedcom tag -* -* @param string $oldrecord the parent record to remove the subrecord from -* @param string $tag the GEDCOM subtag to start deleting at -* @param string $gid [optional] gid can be used to limit to @gid@ -* @param int $num [optional] num specifies which multiple of the tag to remove, set to -1 to remove all -* @return string returns the oldrecord minus the subrecord(s) -*/ -function remove_subrecord($oldrecord, $tag, $gid='', $num=0) { +// Remove a link to a media object from a GEDCOM record +function remove_media_subrecord($oldrecord, $gid) { $newrec = ''; $gedlines = explode("\n", $oldrecord); - $n = 0; - $matchstr = $tag; - if (!empty($gid)) $matchstr .= " @".$gid."@"; for ($i=0; $i<count($gedlines); $i++) { - if (preg_match("/".$matchstr."/", $gedlines[$i])>0) { - if ($num==-1 || $n==$num) { - $glevel = $gedlines[$i]{0}; + if (preg_match('/^\d (?:OBJE|_WT_OBJE_SORT) @' . $gid . '@$/', $gedlines[$i])) { + $glevel = $gedlines[$i]{0}; + $i++; + while ((isset($gedlines[$i]))&&(strlen($gedlines[$i])<4 || $gedlines[$i]{0}>$glevel)) { $i++; - while ((isset($gedlines[$i]))&&(strlen($gedlines[$i])<4 || $gedlines[$i]{0}>$glevel)) $i++; - $i--; } - else $n++; + $i--; + } else { + $newrec .= $gedlines[$i]."\n"; } - else $newrec .= $gedlines[$i]."\n"; } return trim($newrec); diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php index 9fe50053e4..34973c7fe6 100644 --- a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php +++ b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php @@ -637,7 +637,7 @@ function unlinkMedia($linktoid, $linenum, $mediaid, $level=1, $chan=true) { //-- when deleting/unlinking a media link //-- $linenum comes as an OBJE and the $mediaid to delete should be set if (!is_numeric($linenum)) { - $newged = remove_subrecord($gedrec, $linenum, $mediaid); + $newged = remove_media_subrecord($gedrec, $mediaid); } else { $newged = remove_subline($gedrec, $linenum); } |
