mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX: Stopped HtmlEditorField->saveInto() from dying when encountering a link that cannot be made relative.
From: Andrew Short <andrewjshort@gmail.com> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88774 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
77dc826278
commit
26ece45bb0
@ -77,21 +77,23 @@ class HtmlEditorField extends TextareaField {
|
||||
if($links = $htmlValue->getElementsByTagName('a')) foreach($links as $link) {
|
||||
$href = Director::makeRelative($link->getAttribute('href'));
|
||||
|
||||
if(preg_match('/\[sitetree_link id=([0-9]+)\]/i', $href, $matches)) {
|
||||
$ID = $matches[1];
|
||||
|
||||
// clear out any broken link classes
|
||||
if($class = $link->getAttribute('class')) {
|
||||
$link->setAttribute('class', preg_replace('/(^ss-broken|ss-broken$| ss-broken )/', null, $class));
|
||||
if($href) {
|
||||
if(preg_match('/\[sitetree_link id=([0-9]+)\]/i', $href, $matches)) {
|
||||
$ID = $matches[1];
|
||||
|
||||
// clear out any broken link classes
|
||||
if($class = $link->getAttribute('class')) {
|
||||
$link->setAttribute('class', preg_replace('/(^ss-broken|ss-broken$| ss-broken )/', null, $class));
|
||||
}
|
||||
|
||||
if($page = DataObject::get_by_id('SiteTree', $ID)) {
|
||||
$linkedPages[] = $page->ID;
|
||||
} else {
|
||||
$record->HasBrokenLink = true;
|
||||
}
|
||||
} elseif($href[0] != '/' && $file = File::find($href)) {
|
||||
$linkedFiles[] = $file->ID;
|
||||
}
|
||||
|
||||
if($page = DataObject::get_by_id('SiteTree', $ID)) {
|
||||
$linkedPages[] = $page->ID;
|
||||
} else {
|
||||
$record->HasBrokenLink = true;
|
||||
}
|
||||
} elseif($href[0] != '/' && $file = File::find($href)) {
|
||||
$linkedFiles[] = $file->ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user