You are here

function heartbeat_messages_overview in Heartbeat 6.3

Same name and namespace in other branches
  1. 6.4 heartbeat.admin.inc \heartbeat_messages_overview()
  2. 6.2 heartbeat.admin.inc \heartbeat_messages_overview()

Overview list of heartbeat messages This page must be viewed to make the messages appear in the database after a module is installed as well as make them translatable

1 string reference to 'heartbeat_messages_overview'
heartbeat_menu in ./heartbeat.module
Implementation of hook_menu().

File

./heartbeat.admin.inc, line 34

Code

function heartbeat_messages_overview() {
  global $base_url;
  if (module_exists('rules')) {
    $intro = t('Go to !link to add your conditional actions to one of the existing events.', array(
      '!link' => l('rules administration', 'admin/rules/trigger'),
    ));
  }

  // Try to import, synchronize and save  messages
  $info = heartbeat_gather_messages();
  if (!empty($info)) {
    drupal_set_message(t('New messages were added to heartbeat.'));
  }

  // Fetch the heartbeat_message objects
  $messages = heartbeat_messages('all', true, true);
  if (count($messages) <= 0) {
    return t('No messages yet');
  }
  $languages = module_exists('locale') ? locale_language_list() : array();
  foreach ($messages as $message) {

    // Additional tasks for translatable messages
    if ($languages != array()) {
      _heartbeat_messages_overview_language($languages, $message);
    }
    $rows[] = array(
      strlen($message->description) <= 0 ? str_replace('_', ' ', $message->message_id) : $message->description,
      $message->module,
      $message->message_type,
      l(t('edit'), $base_url . "/admin/build/heartbeat/edit/" . $message->hid, array(
        'query' => 'destination=admin/build/heartbeat/list',
      )) . ' - ' . l(t('delete'), $base_url . "/admin/build/heartbeat/delete/" . $message->hid, array(
        'query' => 'destination=admin/build/heartbeat/list',
      )),
    );
  }
  $headers = array(
    t('Description'),
    t('Module'),
    t('Message type'),
    t('Operations'),
  );

  // For locale which makes every string parsed to the t function translatable,
  // we check here if the reader needs to be informed about it.
  if (module_exists('locale')) {
    $intro .= t('<p>The messages are passed to the t-function when parsed to view.</p>
    <p>This means that once they are viewed, they are available for you to translate.
    Altering these messages will clear the rules cache and the altered message
    will need translation if you are dealing with a multilingual site.
    The links show only the untranslated messages.</p>');
  }
  return $intro . theme('table', $headers, $rows);
}