updated to 7.x-2.x-dev (2013-Mar-04)
This commit is contained in:
Regular → Executable
+60
-14
@@ -9,6 +9,8 @@
|
||||
* Build a (sortable) form containing a checkbox for each feedback entry.
|
||||
*/
|
||||
function feedback_admin_view_form($form, &$form_state) {
|
||||
$form['#attached']['js'][] = drupal_get_path('module', 'feedback') . '/feedback.admin.js';
|
||||
|
||||
$status_headings = array(
|
||||
FEEDBACK_OPEN => t('Open feedback messages'),
|
||||
FEEDBACK_PROCESSED => t('Processed feedback messages'),
|
||||
@@ -57,7 +59,7 @@ function feedback_admin_view_form($form, &$form_state) {
|
||||
$form['feedback-messages'][$status][$fid]['location'] = array('#markup' => l(truncate_utf8($entry->location, 32, FALSE, TRUE), $entry->url));
|
||||
$form['feedback-messages'][$status][$fid]['date'] = array('#markup' => format_date($entry->timestamp, 'small'));
|
||||
$form['feedback-messages'][$status][$fid]['user'] = array('#markup' => check_plain(format_username($entry)));
|
||||
$form['feedback-messages'][$status][$fid]['message'] = feedback_format_message($entry);
|
||||
$form['feedback-messages'][$status][$fid]['message'] = feedback_build_content($entry, 'teaser');
|
||||
$form['feedback-messages'][$status][$fid]['operations'] = array(
|
||||
'#theme' => 'links',
|
||||
'#links' => array(
|
||||
@@ -206,6 +208,9 @@ function feedback_entry_form($form, &$form_state, $entry) {
|
||||
|
||||
/**
|
||||
* Form submit callback for entry edit form.
|
||||
*
|
||||
* @todo Duplicates feedback_form_submit(). Add all default entity properties
|
||||
* as #type 'value' to feedback_form() and merge the two submit handlers.
|
||||
*/
|
||||
function feedback_entry_form_submit(&$form, &$form_state) {
|
||||
$entry = feedback_load($form['#fid']);
|
||||
@@ -248,34 +253,35 @@ function feedback_admin_settings_form($form, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an array for rendering the given entry.
|
||||
* Generate a render array for viewing a feedback entry.
|
||||
*
|
||||
* @param $entry
|
||||
* A feedback entry object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full'.
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @return
|
||||
* An array as expected by drupal_render().
|
||||
*
|
||||
* @todo This is an API function; move into feedback.module.
|
||||
*/
|
||||
function feedback_view($entry, $view_mode = 'full', $langcode = NULL) {
|
||||
if (!isset($langcode)) {
|
||||
$langcode = $GLOBALS['language_content']->language;
|
||||
}
|
||||
|
||||
// Retrieve all entry fields and attach to $entry->content.
|
||||
// Populate $entry->content with a render() array.
|
||||
feedback_build_content($entry, $view_mode, $langcode);
|
||||
|
||||
$build = $entry->content;
|
||||
// We don't need duplicate rendering info in entry->content.
|
||||
unset($entry->content);
|
||||
|
||||
$build += array(
|
||||
'#theme' => 'feedback_entry',
|
||||
'#entry' => $entry,
|
||||
'#feedback' => $entry,
|
||||
'#view_mode' => $view_mode,
|
||||
'#language' => $langcode,
|
||||
);
|
||||
@@ -288,26 +294,68 @@ function feedback_view($entry, $view_mode = 'full', $langcode = NULL) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a structured array representing the feedback message content.
|
||||
* Builds a structured array representing the feedback entry's content.
|
||||
*
|
||||
* @param $entry
|
||||
* A feedback entry object.
|
||||
* @param $view_mode
|
||||
* View mode, e.g. 'full'.
|
||||
* View mode, e.g. 'full', 'teaser'...
|
||||
* @param $langcode
|
||||
* (optional) A language code to use for rendering. Defaults to the global
|
||||
* content language of the current request.
|
||||
*
|
||||
* @todo This is an API function; move into feedback.module.
|
||||
*/
|
||||
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);
|
||||
entity_prepare_view('feedback', array($entry->fid => $entry));
|
||||
$entry->content = field_attach_view('feedback', $entry, $view_mode, $langcode);
|
||||
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);
|
||||
}
|
||||
@@ -324,8 +372,7 @@ function template_preprocess_feedback_entry(&$variables) {
|
||||
foreach (element_children($variables['elements']) as $key) {
|
||||
$variables['content'][$key] = $variables['elements'][$key];
|
||||
}
|
||||
|
||||
$entry = $variables['elements']['#entry'];
|
||||
$entry = $variables['elements']['#feedback'];
|
||||
|
||||
// Preprocess fields.
|
||||
field_attach_preprocess('feedback', $entry, $variables['elements'], $variables);
|
||||
@@ -333,7 +380,6 @@ function template_preprocess_feedback_entry(&$variables) {
|
||||
$variables['location'] = l($entry->location, $entry->url);
|
||||
$variables['date'] = format_date($entry->timestamp, 'small');
|
||||
$variables['account'] = check_plain(format_username($entry));
|
||||
$variables['message'] = feedback_format_message($entry);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user