本文整理匯總了PHP中Fisharebest\Webtrees\Functions\FunctionsEdit::removeLinks方法的典型用法代碼示例。如果您正苦於以下問題:PHP FunctionsEdit::removeLinks方法的具體用法?PHP FunctionsEdit::removeLinks怎麽用?PHP FunctionsEdit::removeLinks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Fisharebest\Webtrees\Functions\FunctionsEdit
的用法示例。
在下文中一共展示了FunctionsEdit::removeLinks方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1:
$old_gedcom = $linker->getGedcom();
$new_gedcom = FunctionsEdit::removeLinks($old_gedcom, $record->getXref());
// FunctionsDb::fetch_all_links() does not take account of pending changes. The links (or even the
// record itself) may have already been deleted.
if ($old_gedcom !== $new_gedcom) {
// If we have removed a link from a family to an individual, and it has only one member
if (preg_match('/^0 @' . WT_REGEX_XREF . '@ FAM/', $new_gedcom) && preg_match_all('/\\n1 (HUSB|WIFE|CHIL) @(' . WT_REGEX_XREF . ')@/', $new_gedcom, $match) == 1) {
// Delete the family
$family = GedcomRecord::getInstance($xref, $WT_TREE);
FlashMessages::addMessage(I18N::translate('The family “%s” has been deleted because it only has one member.', $family->getFullName()));
$family->deleteRecord();
// Delete any remaining link to this family
if ($match) {
$relict = GedcomRecord::getInstance($match[2][0], $WT_TREE);
$new_gedcom = $relict->getGedcom();
$new_gedcom = FunctionsEdit::removeLinks($new_gedcom, $linker->getXref());
$relict->updateRecord($new_gedcom, false);
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $relict->getFullName(), $family->getFullName()));
}
} else {
// Remove links from $linker to $record
FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $linker->getFullName(), $record->getFullName()));
$linker->updateRecord($new_gedcom, false);
}
}
}
// Delete the record itself
$record->deleteRecord();
} else {
http_response_code(406);
}