You are here

function nodequeue_generate_form in Nodequeue 5.2

Same name and namespace in other branches
  1. 6.2 nodequeue_generate.module \nodequeue_generate_form()
  2. 7.3 nodequeue_generate.module \nodequeue_generate_form()
  3. 7.2 nodequeue_generate.module \nodequeue_generate_form()
1 string reference to 'nodequeue_generate_form'
nodequeue_generate_menu in ./nodequeue_generate.module

File

./nodequeue_generate.module, line 17

Code

function nodequeue_generate_form() {
  $form['help'] = array(
    '#value' => '<p>' . t('Select which node queues shall be <strong>emptied</strong> and re-populated with new nodes.') . '</p>',
  );
  $queues = nodequeue_load_queues(nodequeue_get_all_qids(25));
  if (empty($queues)) {
    form_set_error('', t('No node queues exist.'));
    return array();
  }
  $qids = array();

  // For every queue that has exactly 1 subqueue,
  foreach ($queues as $queue) {
    if ($queue->subqueues == 1) {
      $qids[] = $queue->qid;
    }
  }
  $subqueues = nodequeue_load_subqueues_by_queue($qids);

  // Relate all the subqueues we loaded back to our queues.
  foreach ($subqueues as $subqueue) {
    $queues[$subqueue->qid]->subqueue = $subqueue;
  }
  foreach ($queues as $queue) {
    $sub_text = $queue->subqueues;
    if ($sub_text == 1) {
      $sub_text .= " (" . nodequeue_subqueue_size_text($queue->size, $queue->subqueue->count) . ")";
    }
    $form['rows']['cb'][$queue->qid] = array(
      '#type' => 'checkbox',
      '#default_value' => 0,
    );
    $form['rows'][$queue->qid]['nodequeue-title'] = array(
      '#value' => check_plain($queue->title),
    );
    $form['rows'][$queue->qid]['nodequeue-max-nodes'] = array(
      '#value' => $queue->size == 0 ? t('Infinite') : $queue->size,
    );
    $form['rows'][$queue->qid]['nodequeue-subqueues'] = array(
      '#value' => $sub_text,
    );
    $form['rows'][$queue->qid]['limit'] = array(
      '#type' => 'value',
      '#value' => $queue->size == 0 || $queue->size > 20 ? 10 : $queue->size,
    );
  }
  $form['qids'] = array(
    '#type' => 'value',
    '#value' => array_keys($queues),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Generate'),
  );
  $form['#tree'] = TRUE;
  return $form;
}