You are here

function forena_report_translations in Forena Reports 7.4

Same name and namespace in other branches
  1. 8 forena.report.inc \forena_report_translations()
  2. 6.2 forena.admin.inc \forena_report_translations()
  3. 7.5 forena.report.inc \forena_report_translations()
  4. 7.2 forena.admin.inc \forena_report_translations()
  5. 7.3 forena.admin.inc \forena_report_translations()
1 string reference to 'forena_report_translations'
forena_menu in ./forena.module
Implementation of hook_menu.

File

./forena.report.inc, line 774

Code

function forena_report_translations($name_in = '') {
  $desc = Frx::Menu()
    ->parseURL($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 && 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 = '';
      $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' => '',
  ));
}