function theme_tmgmt_ui_translation_language_status_single in Translation Management Tool 7
Gets translation language status.
Parameters
array $variables:
- 'translation_status': A flag that determines the status. Possible values: original, missing, outofdate.
- 'job_item': Current job item entity associated with translation.
Return value
string Icon or a link icon that explains the translation status and possibly links to an active translation job.
4 theme calls to theme_tmgmt_ui_translation_language_status_single()
- TMGMTEntitySourceUIController::overviewRow in sources/
entity/ ui/ tmgmt_entity_ui.ui.inc - Builds a table row for overview form.
- TMGMTI18nStringDefaultSourceUIController::overviewRow in sources/
i18n_string/ tmgmt_i18n_string.ui.inc - Builds a table row for overview form.
- TMGMTLocaleSourceUIController::overviewRow in sources/
locale/ tmgmt_locale.ui.inc - Builds a table row for overview form.
- tmgmt_node_handler_field_translation_language_status_single::render in sources/
node/ views/ handlers/ tmgmt_node_handler_field_translation_language_status_single.inc - Render the field.
File
- ui/
includes/ tmgmt_ui.theme.inc, line 50 - Theme file stub for tmgmt.
Code
function theme_tmgmt_ui_translation_language_status_single($variables) {
switch ($variables['translation_status']) {
case 'original':
$label = t('Source language');
$icon_color = 'tmgmt-ui-icon-white';
break;
case 'missing':
$label = t('Not translated');
$icon_color = 'tmgmt-ui-icon-grey';
break;
case 'outofdate':
$label = t('Translation Outdated');
$icon_color = 'tmgmt-ui-icon-orange';
break;
default:
$label = t('Translation up to date');
$icon_color = 'tmgmt-ui-icon-green';
}
// Add classes to show the correct html icon.
$classes = array();
$classes[] = 'tmgmt-ui-icon';
// Icon size 10px square.
$classes[] = 'tmgmt-ui-icon-10';
$classes[] = $icon_color;
// Add necessary css file.
drupal_add_css(drupal_get_path('module', 'tmgmt_ui') . '/css/tmgmt_ui.admin.css');
$status = sprintf('<div class="%s" title="%s"><span></span></div>', implode(' ', $classes), $label);
// If we have an active job item, wrap it in a link.
if (!empty($variables['job_item'])) {
$job_item_wrapper = entity_metadata_wrapper('tmgmt_job_item', $variables['job_item']);
$label = t('Active job item: @state', array(
'@state' => $job_item_wrapper->state
->label(),
));
$uri = $variables['job_item']
->uri();
/** @var TMGMTJob $job */
$job = $variables['job_item']
->getJob();
$job_wrapper = entity_metadata_wrapper('tmgmt_job', $job);
switch ($variables['job_item']->state) {
case TMGMT_JOB_ITEM_STATE_ACTIVE:
if ($job
->isUnprocessed()) {
$uri = $job
->uri();
$label = t('Active job item: @state', array(
'@state' => $job_wrapper->state
->label(),
));
}
$icon_color = 'tmgmt-ui-icon-blue';
break;
case TMGMT_JOB_ITEM_STATE_REVIEW:
$icon_color = 'tmgmt-ui-icon-yellow';
break;
}
// Add classes to show the correct html icon.
$classes = array();
$classes[] = 'tmgmt-ui-icon';
// Icon size 10px square.
$classes[] = 'tmgmt-ui-icon-10';
$classes[] = $icon_color;
$job_status = sprintf('<div class="%s" title="%s"><span></span></div>', implode(' ', $classes), $label);
$status .= l($job_status, $uri['path'], array(
'query' => array(
'destination' => current_path(),
),
'html' => TRUE,
'attributes' => array(
'title' => $label,
),
));
}
return $status;
}