' . check_plain($element['#title']) . '';
}
// Use #attributes to customize a wrapper
.
$attributes = '';
if (!empty($element['#attributes'])) {
$attributes = drupal_attributes($element['#attributes']);
}
// Render any child items.
if (!$element['#children']) {
$element['#children'] = drupal_render_children($element);
}
// Build simple output.
$output = "
{$title}{$element['#children']}
";
return $output;
}
/**
* Gets translation language status.
*
* @param 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 string
* Icon or a link icon that explains the translation status and possibly
* links to an active translation job.
*/
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('
', 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('
', implode(' ', $classes), $label);
$status .= l($job_status, $uri['path'], array(
'query' => array('destination' => current_path()),
'html' => TRUE,
'attributes' => array('title' => $label),
));
}
return $status;
}
/**
* Renders a data item status as an HTML/CSS icon.
*/
function theme_tmgmt_ui_translator_review_form_element_status($variables) {
$classes = array();
$classes[] = 'tmgmt-ui-icon';
$classes[] = 'tmgmt-ui-icon-32'; // Icon size 32px square.
switch ($variables['status']['#value']) {
case TMGMT_DATA_ITEM_STATE_ACCEPTED:
$title = t('Accepted');
// Unicode character U+2611 BALLOT BOX WITH CHECK.
$icon = '☑';
$classes[] = 'tmgmt-ui-icon-darkgreen';
$classes[] = 'tmgmt-ui-state-accepted';
break;
case TMGMT_DATA_ITEM_STATE_REVIEWED:
$title = t('Reviewed');
// Unicode character U+2611 BALLOT BOX WITH CHECK.
$icon = '☑';
$classes[] = 'tmgmt-ui-icon-green';
$classes[] = 'tmgmt-ui-state-reviewed';
break;
case TMGMT_DATA_ITEM_STATE_TRANSLATED:
$title = t('Translated');
// Unicode character U+2610 BALLOT BOX.
$icon = '☐';
$classes[] = 'tmgmt-ui-icon-yellow';
$classes[] = 'tmgmt-ui-state-translated';
break;
case TMGMT_DATA_ITEM_STATE_PENDING:
default:
$title = t('Pending');
// Just an empty icon without a sign.
$icon = '';
$classes[] = 'tmgmt-ui-icon-grey';
$classes[] = 'tmgmt-ui-state-pending';
break;
}
return sprintf('
%s
', implode(' ', $classes), $title, $icon);
}
/**
* Render one single data item as a table row.
*/
function theme_tmgmt_ui_translator_review_form_element($variables) {
$element = $variables['element'];
// Label of all element groups.
if (!isset($element['#top_label'])) {
$element['#top_label'] = array_shift($element['#parent_label']);
}
// Label of the current data item.
if (!isset($element['#leave_label'])) {
$element['#leave_label'] = array_pop($element['#parent_label']);
}
// Do not repeat labels inside the same hierarchy.
if ($element['#top_label'] == $element['#leave_label']) {
$element['#leave_label'] = '';
}
$result = '
';
}
return $result;
}
/**
* Renders a table containing a group of data items belonging to the same field.
*/
function theme_tmgmt_ui_translator_review_form($variables) {
$element = $variables['element'];
$result = '';
$labels = '';
$parent_label = '';
$element_groups = array();
$element_group = '';
foreach (element_children($element) as $key) {
// Label of all element groups.
$parent_label = array_shift($element[$key]['#parent_label']);
$element[$key]['#top_label'] = $parent_label;
$element[$key]['#leave_label'] = array_pop($element[$key]['#parent_label']);
// Start a new element group.
if ($labels != $element[$key]['#parent_label']) {
$labels = $element[$key]['#parent_label'];
if (!empty($labels)) {
// Append to previous group to the group collection.
if (!empty($element_group)) {
$element_groups[] = '' . $element_group . '';
}
// Header row for the current element group.
$cell = array(
// @todo: Deal with right to left languages.
'data' => check_plain(implode(t(' > '), $labels)),
'colspan' => 4,
);
$element_group = '
' . _theme_table_cell($cell, TRUE) . '
';
}
}
$element_group .= drupal_render($element[$key]);
}
// Append the last group to the group collection.
$element_groups[] = '' . $element_group . '';
// Display the label of all element groups inside a table header.
if (!empty($parent_label)) {
$cell = array(
'data' => $parent_label,
'colspan' => 5,
);
$result = '
' . _theme_table_cell($cell, TRUE) . '
' . implode('', $element_groups);
}
$table = '
' . $result . '
';
return '
' . $table . '
';
}
/**
* Adds a description to the translator entity on the entity overview form.
*
* @see theme_entity_ui_overview_item()
*/
function theme_tmgmt_ui_translator_overview_item($variables) {
$output = theme('entity_ui_overview_item', $variables);
if (!empty($variables['description'])) {
$output = '