You are here

function _taxonomy_menu_insert_link_items_batch in Taxonomy menu 6.2

Same name and namespace in other branches
  1. 7 taxonomy_menu.batch.inc \_taxonomy_menu_insert_link_items_batch()

@file The $batch can include the following values. Only 'operations' and 'finished' are required, all others will be set to default values.

Parameters

operations: An array of callbacks and arguments for the callbacks. There can be one callback called one time, one callback called repeatedly with different arguments, different callbacks with the same arguments, one callback with no arguments, etc.

finished: A callback to be used when the batch finishes.

title: A title to be displayed to the end user when the batch starts.

init_message: An initial message to be displayed to the end user when the batch starts.

progress_message: A progress message for the end user. Placeholders are available. Placeholders note the progression by operation, i.e. if there are 2 operations, the message will look like: 'Processed 1 out of 2.' 'Processed 2 out of 2.' Placeholders include: @current, @remaining, @total and @percentage

error_message: The error message that will be displayed to the end user if the batch fails.

1 call to _taxonomy_menu_insert_link_items_batch()
_taxonomy_menu_insert_link_items in ./taxonomy_menu.module
Creates new link items for the vocabulary

File

./taxonomy_menu.batch.inc, line 37
The $batch can include the following values. Only 'operations' and 'finished' are required, all others will be set to default values.

Code

function _taxonomy_menu_insert_link_items_batch($vid) {
  $depth_limit = (int) variable_get('taxonomy_menu_depth_limit_' . $vid, 0);

  // Make sure we have a valid value for $depth_limit.
  if ($depth_limit < 1) {
    $depth_limit = NULL;
  }
  $terms = taxonomy_get_tree($vid, 0, -1, $depth_limit);
  $menu_name = variable_get('taxonomy_menu_vocab_menu_' . $vid, FALSE);
  $batch = array(
    'operations' => array(
      array(
        '_taxonomy_menu_insert_link_items_process',
        array(
          $terms,
          $menu_name,
        ),
      ),
    ),
    'finished' => '_taxonomy_menu_insert_link_items_success',
    'title' => t('Rebuilding Taxonomy Menu'),
    'init_message' => t('The menu items have been deleted, and are about to be regenerated.'),
    'progress_message' => t('Import progress: Completed @current of @total stages.'),
    'redirect' => 'admin/content/taxonomy/edit/vocabulary/' . $vid,
    'error_message' => t('The Taxonomy Menu rebuild process encountered an error.'),
  );
  batch_set($batch);
  batch_process();
}