You are here

function recipe_import_multi in Recipe 7.2

Same name and namespace in other branches
  1. 6 recipe.admin.inc \recipe_import_multi()
  2. 7 recipe.admin.inc \recipe_import_multi()

Page callback: Displays bulk recipe import forms.

See also

recipe_menu()

1 string reference to 'recipe_import_multi'
recipe_menu in ./recipe.module
Implements hook_menu().

File

./recipe.admin.inc, line 238
Contains admin page callbacks, form validation, and form submission handlers.

Code

function recipe_import_multi($type = NULL) {
  drupal_set_title(t('Recipe bulk import'));

  // load supported formats
  $formats = module_invoke_all('recipeio', 'import_multi');
  $o = t('Supported bulk input formats:');
  if ($type === NULL) {
    $format_count = 0;
    foreach ($formats as $key => $format) {
      if ($format) {
        $o .= '<br/>' . l($format['format_name'], "admin/structure/recipe/import_multi/{$key}");
        $format_count++;
      }
    }
    if ($format_count == 0) {
      $o .= '<br/><p>' . t('You have no import formats available with the bulk export feature.') . '</p>';
    }
    return $o;
  }

  // normalize typed urls
  $type = drupal_strtolower($type);

  // If callback exists, call it, otherwise error out.
  if (isset($formats[$type]) && function_exists($formats[$type]['callback'])) {
    $o = call_user_func($formats[$type]['callback']);
    return $o;
  }
  else {
    drupal_set_message(t('Unknown export format(%the_format).', array(
      '%the_format' => $type,
    )), 'error');
    drupal_not_found();
  }
}