You are here

function _date_ical_get_summary_fields in Date iCal 7.2

Same name and namespace in other branches
  1. 7.3 date_ical.module \_date_ical_get_summary_fields()

Identify all potential SUMMARY fields. This is a cut down version of _date_views_fields() from date_views_fields.inc in date_views module.

Return value

array with fieldname, type, and table. @see date_views_date_views_fields(), which implements hook_date_views_fields() for the core date fields.

1 call to _date_ical_get_summary_fields()
date_ical_get_summary_fields in ./date_ical.module
Identify all potential fields that could populate the custom SUMMARY field

File

./date_ical.module, line 451
Adds ical functionality to Views, and an iCal parser to Feeds.

Code

function _date_ical_get_summary_fields($base = 'node') {

  // Make sure $base is never empty.
  if (empty($base)) {
    $base = 'node';
  }
  $cid = 'date_ical_summary_fields_' . $base;
  cache_clear_all($cid, 'cache_views');

  // Iterate over all the fields that Views knows about.
  $all_fields = date_views_views_fetch_fields($base, 'field');
  $fields = array();
  foreach ($all_fields as $alias => $val) {
    $name = $alias;
    $tmp = explode('.', $name);
    $field_name = $tmp[1];
    $table_name = $tmp[0];

    // Skip unsupported field types and fields that weren't defined through
    // the Field module.
    $info = field_info_field($field_name);
    if (!$info || !in_array($info['type'], array(
      'text',
      'text_long',
      'text_with_summary',
      'node_reference',
      'taxonomy_term_reference',
    ))) {
      continue;
    }

    // Build an array of the field info that we'll need.
    $alias = str_replace('.', '_', $alias);
    $fields['name'][$name] = array(
      'label' => "{$val['group']}: {$val['title']} ({$field_name})",
      'table_name' => $table_name,
      'field_name' => $field_name,
      'type' => $info['type'],
    );

    // These are here only to make this $field array conform to the same format
    // as the one returned by _date_views_fields(). They're probably not needed,
    // but I thought that consistency would be a good idea.
    $fields['name'][$name]['real_field_name'] = $field_name;
    $fields['alias'][$alias] = $fields['name'][$name];
  }
  cache_set($cid, $fields, 'cache_views');
  return $fields;
}