function forena_report_translations in Forena Reports 8
Same name and namespace in other branches
- 6.2 forena.admin.inc \forena_report_translations()
- 7.5 forena.report.inc \forena_report_translations()
- 7.2 forena.admin.inc \forena_report_translations()
- 7.3 forena.admin.inc \forena_report_translations()
- 7.4 forena.report.inc \forena_report_translations()
File
- ./
forena.report.inc, line 779
Code
function forena_report_translations($name_in = '') {
$desc = Frx::Menu()
->parseURL($name_in);
$language = \Drupal::languageManager()
->getCurrentLanguage();
$cur_lang = $language->language == 'en' ? '' : $language->language;
$name = $desc['name'];
$filename = $desc['filename'];
$languages = locale_translatable_language_list();
@(list($lang, $base_name) = explode('/', $name, 2));
if (array_key_exists($lang, $languages)) {
$name = $base_name;
}
elseif ($cur_lang && Frx::File()
->exists($cur_lang . '/' . str_replace('.', '/', $name_in) . '.frx')) {
$name_in = $cur_lang . '.' . $name_in;
}
$data = array();
$headers = array(
t('Language'),
t('Title'),
t('Last Modified'),
t('Operation'),
);
// Generate list of all existing tranlsations and their status.
foreach ($languages as $key => $language) {
$i_name = $key == 'en' ? $name : $key . '/' . $name;
$i_link = $key . '.' . $name;
if (Frx::File()
->exists($i_name . '.frx')) {
$modified = format_date(filemtime(Frx::File()
->path($i_name . '.frx')));
$r = Frx::Editor($i_name);
$title = $r->title;
$edit = '';
// l(t('Edit'), 'reports/' . str_replace('/', '.', $i_link) . '/edit', array('query' => array('target_language' => $key)));
}
else {
$modified = '';
$title = '';
// @FIXME Provide a valid URL, generated from a route name, as the second argument to l(). See https://www.drupal.org/node/2346779 for more information.
// $edit = l(t('Add'), 'reports/' . $name_in . '/translate', array('query' => array('target_language' => $key)));
}
$data[] = array(
$language->native,
$title,
$modified,
$edit,
);
}
return theme_table(array(
'header' => $headers,
'rows' => $data,
'attributes' => array(),
'caption' => '',
'sticky' => TRUE,
'colgroups' => array(),
'empty' => '',
));
}