You are here

function forena_report_translations in Forena Reports 6.2

Same name and namespace in other branches
  1. 8 forena.report.inc \forena_report_translations()
  2. 7.5 forena.report.inc \forena_report_translations()
  3. 7.2 forena.admin.inc \forena_report_translations()
  4. 7.3 forena.admin.inc \forena_report_translations()
  5. 7.4 forena.report.inc \forena_report_translations()

Translations Dispaly.

Parameters

unknown_type $name_in:

1 string reference to 'forena_report_translations'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.admin.inc, line 2125

Code

function forena_report_translations($name_in = '') {
  $desc = forena_report_desc($name_in);
  global $language;
  $cur_lang = $language->language == 'en' ? '' : $language->language;
  $name = $desc['name'];
  $filename = $desc['filename'];
  $languages = language_list();
  @(list($lang, $base_name) = explode('/', $name, 2));
  if (array_key_exists($lang, $languages)) {
    $name = $base_name;
  }
  elseif ($cur_lang && file_exists(FrxReportGenerator::instance()
    ->report_path() . '/' . $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.
  $report_path = FrxReportGenerator::instance()
    ->report_path();
  foreach ($languages as $key => $lang) {
    $i_name = $key == 'en' ? $name : $key . '/' . $name;
    $i_link = $key . '.' . $name;
    if (file_exists($report_path . '/' . $i_name . '.frx')) {
      $modified = format_date(filemtime($report_path . '/' . $i_name . '.frx'));
      $r = forena_get_report_editor($i_name);
      $title = $r->title;
      $edit = l(t('Edit'), 'reports/' . str_replace('/', '.', $i_link) . '/edit', array(
        'query' => array(
          'language' => $key,
        ),
      ));
    }
    else {
      $modified = '';
      $title = '';

      //$language = $cur_lang;
      $edit = l(t('Add'), 'reports/' . $name_in . '/translate', array(
        'query' => array(
          'new_language' => $key,
        ),
      ));
    }
    $data[] = array(
      $lang->native,
      $title,
      $modified,
      $edit,
    );
  }
  return theme_table($headers, $data);
}