function ctools_profile_fields_content_type_render

'Render' callback for the 'profile fields' content type.

File

plugins/content_types/user_context/profile_fields.inc, line 27

Code

function ctools_profile_fields_content_type_render($subtype, $conf, $panel_args, $context) {
    $account = isset($context->data) ? clone $context->data : NULL;
    $block = new stdClass();
    $block->module = 'profile fields';
    if ($account) {
        // Get the category from the options.
        $category = str_replace("_", " ", $conf['category']);
        // Set the subject to the name of the category.
        $block->subject = $category;
        // Put all the fields in the category into an array.
        profile_view_profile($account);
        if (is_array($account->content[$category])) {
            foreach ($account->content[$category] as $field) {
                if (is_array($field['#attributes'])) {
                    // @todo 'class' is *always* an array now. 04/10/2009 sun
                    $vars[$field['#attributes']['class']]['title'] = $field['#title'];
                    $vars[$field['#attributes']['class']]['value'] = $field['#value'];
                }
            }
        }
        if (count($vars) == 0) {
            // Output the given empty text.
            $output = $conf['empty'];
        }
        else {
            // Call the theme function with the field vars.
            $output = theme('profile_fields_pane', $category, $vars);
        }
        $block->content = $output;
        $block->delta = $account->uid;
    }
    else {
        $block->subject = $conf['category'];
        $block->content = t('Profile content goes here.');
        $block->delta = 'unknown';
    }
    return $block;
}