You are here

function views_rss_core_preprocess_item_dc_creator in Views RSS 8.2

Preprocess function for item <dc:creator> element. This strips stray "Author" text leaving just Author 1, Author 2

@todo make this more generalized, part of dc module, and a hook.

1 string reference to 'views_rss_core_preprocess_item_dc_creator'
views_rss_dc_views_rss_item_elements in modules/views_rss_dc/views_rss_dc.module
Implements hook_views_rss_item_elements().

File

modules/views_rss_core/views_rss_core.inc, line 414
Preprocess functions for Views RSS: Core Elements module.

Code

function views_rss_core_preprocess_item_dc_creator(&$variables) {
  if (empty($variables['elements'][0]['value'])) {
    return;
  }
  $authors = $variables['elements'][0]['value'];
  $authors = str_replace('   Author', '', $authors);
  $author_array = explode(',', $authors);
  $elements = array();
  foreach ($author_array as $dc_created) {

    // Strip Role and everything after.
    $dc_created = preg_replace('/Role(.*)$/s', '', $dc_created);
    $elements[] = array(
      'key' => 'dc:creator',
      'value' => trim($dc_created),
    );
  }
  $variables['elements'] = $elements;
}