function theme_dblog_message

Returns HTML for a log message.

Parameters

array $variables: An associative array containing:

  • event: An object with at least the message and variables properties.
  • link: (optional) Format message as link, event->wid is required.

Related topics

3 theme calls to theme_dblog_message()
dblog_event in modules/dblog/dblog.admin.inc
Page callback: Displays details about a specific database log message.
dblog_overview in modules/dblog/dblog.admin.inc
Page callback: Displays a listing of database log messages.
dblog_top in modules/dblog/dblog.admin.inc
Page callback: Shows the most frequent log messages of a given event type.

File

modules/dblog/dblog.admin.inc, line 284

Code

function theme_dblog_message($variables) {
    $output = '';
    $event = $variables['event'];
    // Check for required properties.
    if (isset($event->message) && isset($event->variables)) {
        $event_variables = @unserialize($event->variables);
        // Messages without variables or user specified text.
        if ($event_variables === NULL) {
            $output = $event->message;
        }
        elseif (!is_array($event_variables)) {
            $output = t('Log data is corrupted and cannot be unserialized: @message', array(
                '@message' => $event->message,
            ));
        }
        else {
            $output = t($event->message, $event_variables);
        }
        // If the output is expected to be a link, strip all the tags and
        // special characters by using filter_xss() without any allowed tags.
        // If not, use filter_xss_admin() to allow some tags.
        if ($variables['link'] && isset($event->wid)) {
            // Truncate message to 56 chars after stripping all the tags.
            $output = truncate_utf8(filter_xss($output, array()), 56, TRUE, TRUE);
            $output = l($output, 'admin/reports/event/' . $event->wid, array(
                'html' => TRUE,
            ));
        }
        else {
            // Prevent XSS in log detail pages.
            $output = filter_xss_admin($output);
        }
    }
    return $output;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.