You are here

function nodequeue_generate_form in Nodequeue 7.2

Same name and namespace in other branches
  1. 5.2 nodequeue_generate.module \nodequeue_generate_form()
  2. 6.2 nodequeue_generate.module \nodequeue_generate_form()
  3. 7.3 nodequeue_generate.module \nodequeue_generate_form()

Menu callback; Returns the nodequeue generate form.

1 string reference to 'nodequeue_generate_form'
nodequeue_generate_menu in ./nodequeue_generate.module
Implements hook_menu().

File

./nodequeue_generate.module, line 22

Code

function nodequeue_generate_form() {
  $form['help'] = array(
    '#markup' => '<p>' . t('Select which queues shall be <strong>emptied</strong> and re-populated with new nodes.') . '</p>',
  );
  $queues = nodequeue_load_queues(nodequeue_get_all_qids(25));

  // Tableselect header.
  $header = array(
    'name' => 'Queue name',
    'max_nodes' => 'Max nodes',
    'subqueues' => 'Subqueues',
  );

  // Tableselect data.
  $data = array();
  foreach ($queues as $queue) {
    $data[$queue->qid]['name'] = check_plain($queue->title);
    $data[$queue->qid]['max_nodes'] = $queue->size == 0 ? t('Infinite') : $queue->size;
    $data[$queue->qid]['subqueues'] = $queue->subqueues;
  }

  // Table select element.
  $form['nodequeues'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $data,
    '#empty' => t('There are no queues.'),
  );
  $form['nodequeue_generate_nodes_limit'] = array(
    '#type' => 'textfield',
    '#title' => t('Nodes limit'),
    '#description' => t('How many nodes to insert in a queue. This value is only taken into consideration for infinite queues.'),
    '#size' => 3,
    '#default_value' => 10,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Generate'),
  );
  return $form;
}