You are here

function i18n_node_add_page in Internationalization 7

Replacement for node_add_page.

1 string reference to 'i18n_node_add_page'
i18n_node_menu_alter in i18n_node/i18n_node.module
Implements hook_menu_alter().

File

i18n_node/i18n_node.pages.inc, line 12
User page callbacks for the translation module.

Code

function i18n_node_add_page() {
  $item = menu_get_item();
  $content = system_admin_menu_block($item);

  // Bypass the node/add listing if only one content type is available.
  if (count($content) == 1) {
    $item = array_shift($content);
    drupal_goto($item['href']);
  }
  foreach ($content as &$item) {

    // Type machine name will be the first page argument
    $page_arguments = unserialize($item['page_arguments']);

    // Check whether this has a node type, other items may be here too, see #1264662
    $type = isset($page_arguments[0]) ? $page_arguments[0] : NULL;
    if ($type) {

      // We just need to translate the description, the title is translated by the menu system
      // The string will be filtered (xss_admin) on the theme layer
      $item['description'] = i18n_node_translate_type($type, 'description', $item['description'], array(
        'sanitize' => FALSE,
      ));
    }
  }
  return theme('node_add_list', array(
    'content' => $content,
  ));
}