function profile_views_fetch_field

Same name in other branches
  1. 7.x-3.x modules/profile.views.inc \profile_views_fetch_field()

Add profile fields to view table

Related topics

1 call to profile_views_fetch_field()
profile_views_data in modules/profile.views.inc
Implementation of hook_views_data()

File

modules/profile.views.inc, line 97

Code

function profile_views_fetch_field($field) {
    $data = array(
        'title' => t('@category: @field-name', array(
            '@category' => $field->category,
            '@field-name' => $field->title,
        )),
    );
    // Add fields specific to the profile type.
    switch ($field->type) {
        case 'textfield':
            $data += array(
                'help' => t('Profile textfield'),
                'field' => array(
                    'handler' => 'views_handler_field_user',
                    'click sortable' => TRUE,
                ),
                'sort' => array(
                    'handler' => 'views_handler_sort',
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_string',
                ),
                'argument' => array(
                    'handler' => 'views_handler_argument_string',
                ),
            );
            break;
        case 'textarea':
            $data += array(
                'help' => t('Profile textarea'),
                'field' => array(
                    'handler' => 'views_handler_field_markup',
                    'format' => FILTER_FORMAT_DEFAULT,
                ),
                'sort' => array(
                    'handler' => 'views_handler_sort',
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_string',
                ),
            );
            break;
        case 'checkbox':
            $data += array(
                'help' => t('Profile checkbox'),
                'field' => array(
                    'handler' => 'views_handler_field_boolean',
                    'click sortable' => TRUE,
                ),
                'sort' => array(
                    'handler' => 'views_handler_sort',
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_boolean_operator',
                    'accept null' => TRUE,
                ),
            );
            break;
        case 'url':
            $data += array(
                'help' => t('Profile URL'),
                'field' => array(
                    'handler' => 'views_handler_field_url',
                    'click sortable' => TRUE,
                ),
                'sort' => array(
                    'handler' => 'views_handler_sort',
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_string',
                ),
            );
            break;
        case 'selection':
            $data += array(
                'help' => t('Profile selection'),
                'field' => array(
                    'handler' => 'views_handler_field',
                    'click sortable' => TRUE,
                ),
                'sort' => array(
                    'handler' => 'views_handler_sort',
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_profile_selection',
                    'fid' => $field->fid,
                ),
                'argument' => array(
                    'handler' => 'views_handler_argument_string',
                ),
            );
            break;
        case 'list':
            $data += array(
                'help' => t('Profile freeform list %field-name.', array(
                    '%field-name' => $field->title,
                )),
                'field' => array(
                    'handler' => 'views_handler_field_profile_list',
                    'no group by' => TRUE,
                ),
                'filter' => array(
                    'handler' => 'views_handler_filter_string',
                ),
            );
            break;
        case 'date':
            $data += array(
                'help' => t('Profile date %field-name.', array(
                    '%field-name' => $field->title,
                )),
                'field' => array(
                    'handler' => 'views_handler_field_profile_date',
                ),
            );
            break;
    }
    // @todo: add access control to hidden fields.
    return $data;
}