function _linkchecker_replace_fields in Link checker 7
Replace the old url by a new url on 301 status codes.
Parameters
string $entity_type: The type of entity; e.g., 'node', 'comment'.
string $bundle_name: The name of the bundle aka node type, e.g., 'article', 'page'.
object $entity: The entity to parse, a $node or a $comment object.
string $old_url: The previous url.
string $new_url: The new url to replace the old.
Return value
object
1 call to _linkchecker_replace_fields()
- _linkchecker_status_handling in ./
linkchecker.module - Status code handling.
File
- ./
linkchecker.module, line 1799 - This module periodically check links in given node types, blocks etc.
Code
function _linkchecker_replace_fields($entity_type, $bundle_name, $entity, $old_url, $new_url) {
// Collect the fields from this entity_type and bundle.
foreach (field_info_instances($entity_type, $bundle_name) as $field_name => $instance) {
$field = field_info_field($field_name);
$entity_field =& $entity->{$field['field_name']};
switch ($field['type']) {
// Core fields.
case 'text_with_summary':
foreach ($entity_field as $language_name => $language_value) {
foreach ($language_value as $item_name => $item_value) {
_linkchecker_link_replace($entity_field[$language_name][$item_name]['value'], $old_url, $new_url);
_linkchecker_link_replace($entity_field[$language_name][$item_name]['summary'], $old_url, $new_url);
}
}
break;
// Core fields.
case 'text_long':
case 'text':
foreach ($entity_field as $language_name => $language_value) {
foreach ($language_value as $item_name => $item_value) {
_linkchecker_link_replace($entity_field[$language_name][$item_name]['value'], $old_url, $new_url);
}
}
break;
// Link module field, https://drupal.org/project/link.
case 'link_field':
foreach ($entity_field as $language_name => $language_value) {
foreach ($language_value as $item_name => $item_value) {
_linkchecker_link_replace($entity_field[$language_name][$item_name]['url'], $old_url, $new_url);
_linkchecker_link_replace($entity_field[$language_name][$item_name]['title'], $old_url, $new_url);
}
}
break;
}
}
return $entity;
}