You are here

function translation_table_menu in Translation table 7

Same name and namespace in other branches
  1. 6 translation_table.module \translation_table_menu()

Implements hook_menu().

File

./translation_table.module, line 19
Translation table module

Code

function translation_table_menu() {
  $items = array();

  // Get the different translation tables.
  foreach (module_list() as $module) {
    translation_table_module_include("{$module}.translation_table.inc");
  }
  $module_items = module_invoke_all('translation_table_data');
  foreach ($module_items as $key => $module_item) {
    if (isset($module_item['form']) && isset($module_item['file'])) {
      $items['admin/config/regional/translate/table/' . $key] = array(
        'title' => isset($module_item['title']) ? $module_item['title'] : t('Unknown'),
        'description' => isset($module_item['description']) ? $module_item['description'] : '*',
        'page callback' => 'translation_table_get_form',
        'page arguments' => array(
          $module_item['form'],
        ),
        'access callback' => 'user_access',
        'access arguments' => array(
          'translate interface',
        ),
        'type' => MENU_LOCAL_TASK,
        'file' => $module_item['file'],
        'file path' => isset($module_item['file path']) ? $module_item['file path'] : NULL,
      );
    }
  }
  if (!empty($items)) {

    // Modify the fist item to local task.
    $first_key = key($items);
    $items[$first_key]['weight'] = -10;
    $items[$first_key]['type'] = MENU_DEFAULT_LOCAL_TASK;
    $items['admin/config/regional/translate/table'] = array(
      'title' => 'Translation table',
      'description' => 'Edit translations',
      'page callback' => 'translation_table_get_form',
      'page arguments' => $items[$first_key]['page arguments'],
      'access callback' => 'user_access',
      'access arguments' => array(
        'translate interface',
      ),
      'type' => MENU_LOCAL_TASK,
      'file' => $items[$first_key]['file'],
    );
  }
  return $items;
}