function translation_overview_language_page in Translation Overview 6
1 string reference to 'translation_overview_language_page'
- translation_overview_menu in ./
translation_overview.module - Implementation of hook_menu().
File
- ./
translation_overview.pages.inc, line 242
Code
function translation_overview_language_page($language) {
$rows_per_page = 30;
$types = array_keys(translation_overview_node_types());
// Bail if there are no translatable nodes
if (count($types) == 0) {
drupal_set_message(t('There are no translateable node types on this site.'), 'error');
return '';
}
$header = array(
array(
'field' => 'n.title',
'data' => t('Title'),
),
array(
'field' => 'n.type',
'data' => t('Type'),
),
array(
'field' => 'n.status',
'data' => t('Status'),
),
array(
'field' => 'n.language',
'data' => t('Language'),
),
array(
'field' => 'n.created',
'data' => t('Created'),
),
array(
'field' => 'translation_status',
'data' => t('Translated'),
'sort' => 'asc',
),
);
// We want to sort the nodes by the status so we have to resort to this SQL
// CASE statement.
// NOTE: the '0 AS i18n' is a little hack to prevent i18n from re-writing our
// query.
$rows = array();
$query = translation_overview_build_filter_query();
$sql = "SELECT n.nid, n.title, n.type, n.language, n.status, n.created, n.tnid, nt.nid AS t_nid, CASE\n WHEN n.language = '%s' THEN '4 LOCAL'\n WHEN nt.translate = 0 THEN '3 DONE'\n WHEN nt.tnid IS NULL THEN '2 MISS'\n WHEN n.nid = n.tnid THEN '1 OLD'\n ELSE 'unknown' END AS translation_status, 0 AS i18n\n FROM {node} n LEFT JOIN {node} nt ON n.nid = nt.tnid AND nt.language = '%s' " . implode(' ', $query['join']) . "\n WHERE (n.nid = n.tnid OR n.tnid = 0) AND n.language <> '' AND n.language IS NOT NULL\n AND " . implode(' AND ', $query['where']) . tablesort_sql($header);
// We need to put the language that we use as an argument early in the query
// at the beginning of the arguments list.
array_unshift($query['args'], $language);
array_unshift($query['args'], $language);
$rows = array();
$result = pager_query(db_rewrite_sql($sql), $rows_per_page, 0, NULL, $query['args']);
while ($node = db_fetch_object($result)) {
// Shorten down the title
$title = $node->title;
if (drupal_strlen($title) > 25) {
$title = drupal_substr($title, 0, 20) . '...';
}
$rows[] = array(
l($title, 'node/' . $node->nid, array(
'attributes' => array(
'title' => $node->title,
),
)),
check_plain($node->type),
empty($node->status) ? t('Unpublished') : t('Published'),
$node->language,
format_date($node->created, 'custom', 'j M Y'),
translation_overview_translation_link($node, $node->t_nid, $language, TRUE),
);
}
return drupal_get_form('translation_overview_filter_form') . theme('table', $header, $rows) . theme('pager', NULL, $rows_per_page);
}