function heartbeat_messages_overview in Heartbeat 6.2
Same name and namespace in other branches
- 6.4 heartbeat.admin.inc \heartbeat_messages_overview()
- 6.3 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 26
Code
function heartbeat_messages_overview() {
global $base_url;
// Clear the rules cache to avoid problems
rules_clear_cache();
$intro = '';
// Invoke a hook function of contributed modules
// so that their messages are known in the database
$info = heartbeat_gather_messages();
// Fetch the heartbeat_message objects
$messages = heartbeat_messages('all', true, true);
if (!empty($info)) {
drupal_set_message(t('New messages were added to heartbeat.'));
}
if (count($messages) <= 0) {
return t('Sorry, no heartbeat messages yet');
}
foreach ($messages as $message) {
// Additional things to do if messages need to be translatable
if (module_exists('locale')) {
$languages = locale_language_list();
// Pretend we are showing the strings to translate (display none)
$message->description .= '<div style="display: none;">';
foreach ($languages as $lang => $human_language) {
$message->description .= $human_language . ': ' . t($message->message, array(), $lang) . '<br />';
$message->description .= $human_language . ': ' . t($message->message_concat, array(), $lang) . '<br />';
}
$message->description .= '</div>';
// Show the admin user that there are things that need translation
$report = array();
foreach ($languages as $lang => $human_language) {
if ($lang != 'en') {
// Look into the messages
if (t($message->message, array(), $lang) == t($message->message, array(), 'en')) {
$label = t('translate message in @human_language', array(
'@human_language' => strip_tags($human_language),
));
$options = array(
'query' => 'op=Search&string=' . str_replace(" ", "+", $message->message),
);
$report[] = l($label, 'admin/build/translate/search', $options);
}
// Look into the message_concat groupings
if (t($message->message_concat, array(), $lang) == t($message->message_concat, array(), 'en')) {
$label = t('translate grouping message in @human_language', array(
'@human_language' => strip_tags($human_language),
));
$options = array(
'query' => 'op=Search&string=' . str_replace(" ", "+", $message->message_concat),
);
$report[] = l($label, 'admin/build/translate/search', $options);
}
// Look into the variables to detect message parts that need translation
if (eregi("#", $message->variables_string)) {
$report[] = '<small>' . t('In at least one of the messages a part must be translated separately') . '</small>';
}
}
}
// Add a report of todo translations to the list
if ($report != array()) {
$message->description .= '<br />' . implode(', ', $report);
}
}
$rows[] = array(
$message->event,
$message->description,
$message->karma_index,
l(t('edit'), $base_url . "/admin/settings/heartbeat/messages/" . $message->event),
);
}
$headers = array(
t('Event'),
t('Description'),
t('Karma index'),
t('Operations'),
);
$intro .= '<h2>Modules that describe heartbeat messages.</h2>';
$intro .= '<p>The messages that go with this event are passed to the t-function when parsed to view.';
$intro .= '</p>';
if (module_exists('locale')) {
$intro .= '<p>';
$intro .= 'This means that once they are viewed, they are available for you to translate.';
$intro .= 'Altering these messages will clear the rules cache and the altered message ';
$intro .= 'will need translation if you are dealing with a multilingual site. The links show only the untranslated messages.';
$intro .= '</p>';
}
return t($intro) . theme('table', $headers, $rows);
}