MINOR Argument checks in AssetTableField->getCustomFieldsFor() (AIR-40)

This commit is contained in:
Ingo Schommer 2011-08-26 09:26:17 +02:00
parent 3809c1614f
commit de13f144fa

View File

@ -149,6 +149,10 @@ class AssetTableField extends ComplexTableField {
return null; return null;
} }
if(!$childData instanceof File) {
throw new InvalidArgumentException(sprintf('$childData is of class "%s", subclass of "File" expected', get_class($childData)));
}
if($childData->ParentID) { if($childData->ParentID) {
$folder = DataObject::get_by_id('File', $childData->ParentID ); $folder = DataObject::get_by_id('File', $childData->ParentID );
} else { } else {
@ -207,10 +211,15 @@ class AssetTableField extends ComplexTableField {
$links = $childData->BackLinkTracking(); $links = $childData->BackLinkTracking();
if(class_exists('Subsite')) Subsite::disable_subsite_filter(false); if(class_exists('Subsite')) Subsite::disable_subsite_filter(false);
$linkArray = array();
if($links && $links->exists()) { if($links && $links->exists()) {
$backlinks = array(); $backlinks = array();
foreach($links as $link) { foreach($links as $link) {
// Avoid duplicates
if (!in_array($link->ID, $linkArray)) {
$backlinks[] = "<li><a href=\"admin/show/$link->ID\">" . $link->Breadcrumbs(null,true). "</a></li>"; $backlinks[] = "<li><a href=\"admin/show/$link->ID\">" . $link->Breadcrumbs(null,true). "</a></li>";
$linkArray[] = $link->ID;
}
} }
$backlinks = "<div style=\"clear:left\">". _t('AssetTableField.PAGESLINKING','The following pages link to this file:') ."<ul>" . implode("",$backlinks) . "</ul></div>"; $backlinks = "<div style=\"clear:left\">". _t('AssetTableField.PAGESLINKING','The following pages link to this file:') ."<ul>" . implode("",$backlinks) . "</ul></div>";
} }