function feedback_build_content in Feedback 7.2
Builds a structured array representing the feedback entry's content.
@todo This is an API function; move into feedback.module.
Parameters
$entry: A feedback entry object.
$view_mode: View mode, e.g. 'full', 'teaser'...
$langcode: (optional) A language code to use for rendering. Defaults to the global content language of the current request.
3 calls to feedback_build_content()
- feedback_admin_view_form in ./
feedback.admin.inc - Build a (sortable) form containing a checkbox for each feedback entry.
- feedback_form in ./
feedback.module - Form constructor for the feedback form.
- feedback_view in ./
feedback.admin.inc - Generate a render array for viewing a feedback entry.
File
- ./
feedback.admin.inc, line 367 - Administrative functionality for Feedback module.
Code
function feedback_build_content($entry, $view_mode = 'full', $langcode = NULL) {
if (!isset($langcode)) {
$langcode = $GLOBALS['language_content']->language;
}
// Remove previously built content, if exists.
$entry->content = array();
// Allow modules to change the view mode.
$context = array(
'entity_type' => 'feedback',
'entity' => $entry,
'langcode' => $langcode,
);
drupal_alter('entity_view_mode', $view_mode, $context);
$entry->content['message'] = array(
'#markup' => check_plain($entry->message),
);
if (!empty($entry->useragent)) {
$entry->content['browser'] = array(
'#theme' => 'container',
'#attributes' => array(
'class' => array(
'browserinfo',
'description',
),
),
);
if (module_exists('browscap')) {
$browserinfo = browscap_get_browser($entry->useragent);
// Browscap returns useragent but not always parent info.
$browser = isset($browserinfo['parent']) ? $browserinfo['parent'] . ' / ' . $browserinfo['platform'] : $browserinfo['useragent'];
$entry->content['browser']['#markup'] = check_plain($browser);
}
else {
$entry->content['browser']['#markup'] = check_plain($entry->useragent);
}
}
// Build fields content.
field_attach_prepare_view('feedback', array(
$entry->fid => $entry,
), $view_mode, $langcode);
entity_prepare_view('feedback', array(
$entry->fid => $entry,
), $langcode);
$entry->content += field_attach_view('feedback', $entry, $view_mode, $langcode);
$entry->content['links'] = array(
'#theme' => 'links__feedback',
'#pre_render' => array(
'drupal_pre_render_links',
),
'#attributes' => array(
'class' => array(
'links',
'inline',
),
),
);
$uri = entity_uri('feedback', $entry);
if ($uri['path'] != $_GET['q'] && arg(0) != 'admin') {
$entry->content['links']['#links']['view'] = array(
'title' => t('view'),
'href' => $uri['path'],
);
}
// Allow modules to make their own additions to the entry.
module_invoke_all('feedback_view', $entry, $view_mode, $langcode);
module_invoke_all('entity_view', $entry, 'feedback', $view_mode, $langcode);
}