You are here

function _theme_heartbeat_widgets in Heartbeat 6.4

Theme function for the widgets of a message

2 calls to _theme_heartbeat_widgets()
theme_heartbeat_messages in ./heartbeat.module
Theme function for messages
_heartbeat_render_view in views/heartbeat_views.module
Helper function to (re-)render the messages from views.

File

./heartbeat.module, line 892

Code

function _theme_heartbeat_widgets(&$message) {
  $widgets = array();
  $message_attachments = $message->template->attachments;
  if ($message_attachments && is_array($message_attachments)) {
    foreach ($message_attachments as $field => $attachment) {

      // If the data is cached, return it.
      if (isset($message->additions->{$field}, $message->additions->{$field}['_cached'])) {
        $widgets[] = $message->additions->{$field}['_cached'];
      }
      elseif (!empty($attachment)) {
        if (isset($attachment['_rendered'])) {
          $widgets[] = $attachment['_rendered'];
        }
        elseif (function_exists($func = $field . '_widget')) {
          $widgets[] = $func($message_attachments, $message);
        }
      }
    }
  }
  return implode('', $widgets);
}