ENHANCEMENT Ensure that broken File links receive an "ss-broken" class, just like broken SiteTree links

This commit is contained in:
Sean Harvey 2012-03-01 23:24:58 +13:00
parent 898c8f5497
commit f5c4bc0802

View File

@ -69,8 +69,15 @@ class HtmlEditorField extends TextareaField {
$link->setAttribute('class', ($class ? "$class ss-broken" : 'ss-broken'));
}
}
if(preg_match('/\[file_link id=([0-9]+)\]/i', $link->getAttribute('href'), $matches)) {
if(!DataObject::get_by_id('File', $matches[1])) {
$class = $link->getAttribute('class');
$link->setAttribute('class', ($class ? "$class ss-broken" : 'ss-broken'));
}
}
}
return $this->createTag (
'textarea',
$this->getAttributes(),