You are here

function _taxonomy_menu_insert_link_items_batch in Taxonomy menu 7

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

Starts a batch operation.

Parameters

int $vid: Vocabulary ID.

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 14
Batch API Code

Code

function _taxonomy_menu_insert_link_items_batch($vid) {
  $depth = variable_get(_taxonomy_menu_build_variable('max_depth', $vid), 0);
  if ($depth == 0) {
    $depth = NULL;
  }
  $terms = taxonomy_get_tree($vid, 0, $depth, TRUE);
  $menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $vid), FALSE);
  $batch = array(
    // An array of callbacks and arguments for the callbacks.
    'operations' => array(
      array(
        '_taxonomy_menu_insert_link_items_process',
        array(
          $terms,
          $menu_name,
        ),
      ),
    ),
    // A callback to be used when the batch finishes.
    'finished' => '_taxonomy_menu_insert_link_items_success',
    // A title to be displayed to the end user when the batch starts.
    'title' => t('Rebuilding Taxonomy Menu'),
    // An initial message to be displayed to the end user when the batch starts.
    'init_message' => t('The menu items have been deleted, and are about to be regenerated.'),
    // A progress message for the end user. Placeholders are available.
    // Placeholders include: @current, @remaining, @total and @percentage
    'progress_message' => t('Import progress: Completed @current of @total stages.'),
    // The message that will be displayed to the end user if the batch fails.
    'error_message' => t('The Taxonomy Menu rebuild process encountered an error.'),
    'redirect' => 'admin/structure/taxonomy',
  );
  batch_set($batch);
  batch_process();
}