mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-30 13:19:11 +02:00
Move the link-tracking into the cms to remove the SiteTree dependency.
Depends on 8996b67c13a773c3339f45d91bf2378a39e5178a in the cms module.
This commit is contained in:
parent
5cd85f6496
commit
efbc3b3a81
@ -64,36 +64,6 @@ class HtmlEditorField extends TextareaField {
|
|||||||
self::include_js();
|
self::include_js();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function Field($properties = array()) {
|
|
||||||
// mark up broken links
|
|
||||||
$value = Injector::inst()->create('HTMLValue', $this->value);
|
|
||||||
|
|
||||||
if($links = $value->getElementsByTagName('a')) foreach($links as $link) {
|
|
||||||
$matches = array();
|
|
||||||
|
|
||||||
if(preg_match('/\[sitetree_link(?:\s*|%20|,)?id=([0-9]+)\]/i', $link->getAttribute('href'), $matches)) {
|
|
||||||
if(!DataObject::get_by_id('SiteTree', $matches[1])) {
|
|
||||||
$class = $link->getAttribute('class');
|
|
||||||
$link->setAttribute('class', ($class ? "$class ss-broken" : 'ss-broken'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(preg_match('/\[file_link(?:\s*|%20|,)?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'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$properties['Value'] = htmlentities($value->getContent(), ENT_COMPAT, 'UTF-8');
|
|
||||||
|
|
||||||
return parent::Field($properties);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAttributes() {
|
public function getAttributes() {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
parent::getAttributes(),
|
parent::getAttributes(),
|
||||||
|
Loading…
Reference in New Issue
Block a user