You are here

function nodequeue_node_tab in Nodequeue 5.2

Same name and namespace in other branches
  1. 6.2 includes/nodequeue.admin.inc \nodequeue_node_tab()
  2. 7.3 includes/nodequeue.admin.inc \nodequeue_node_tab()
  3. 7.2 includes/nodequeue.admin.inc \nodequeue_node_tab()

Display the queue controls for a node.

Parameters

$node: The loaded $node; will be loaded by the hook_menu.

$queues: The list of queues. Loaded by the menu in order to test access control.

1 string reference to 'nodequeue_node_tab'
nodequeue_menu in ./nodequeue.module
Implementation of hook_menu

File

./nodequeue.module, line 395

Code

function nodequeue_node_tab($node, $queues) {
  $header = array();
  $header[] = array(
    'data' => t('Title'),
    'class' => 'nodequeue-title',
  );
  if (variable_get('nodequeue_tab_display_max', 1)) {
    $header[] = array(
      'data' => t('Max nodes'),
      'class' => 'nodequeue-max-nodes',
    );
  }
  $header[] = array(
    'data' => t('In queue'),
    'class' => 'nodequeue-in-queue',
  );
  $header[] = array(
    'data' => t('Operation'),
    'class' => 'nodequeue-operation',
  );
  $subqueues = nodequeue_get_subqueues_by_node($queues, $node);
  nodequeue_set_subqueue_positions($subqueues, $node->nid);
  $rows = array();
  foreach ($subqueues as $subqueue) {
    $queue = $queues[$subqueue->qid];
    if (!$subqueue->position) {
      $op = l(t('Add to queue'), "admin/content/nodequeue/{$queue->qid}/add/{$subqueue->sqid}/{$node->nid}", array(
        'class' => 'nodequeue-ajax-toggle',
      ), drupal_get_destination() . '&tab&' . nodequeue_get_token($node->nid));
    }
    else {
      $op = l(t('Remove from queue'), "admin/content/nodequeue/{$queue->qid}/remove-node/{$subqueue->sqid}/{$node->nid}", array(
        'class' => 'nodequeue-ajax-toggle',
      ), drupal_get_destination() . '&tab&' . nodequeue_get_token($node->nid));
    }
    $row = array();
    $row[] = array(
      'class' => 'nodequeue-title',
      'data' => l(nodequeue_title_substitute($queue->subqueue_title, $queue, $subqueue), "admin/content/nodequeue/{$queue->qid}/view/{$subqueue->sqid}"),
    );
    if (variable_get('nodequeue_tab_display_max', 1)) {
      $row[] = array(
        'class' => 'nodequeue-max-nodes',
        'data' => $queue->size ? $queue->size : t('Infinite'),
      );
    }
    $row[] = array(
      'id' => 'nodequeue-count-' . $subqueue->sqid,
      'class' => 'nodequeue-in-queue',
      'data' => nodequeue_subqueue_size_text($queue->size, $subqueue->count, FALSE),
    );
    $row[] = array(
      'class' => 'nodequeue-operation',
      'data' => $op,
    );
    $rows[] = $row;
  }
  $output .= theme('table', $header, $rows, array(
    'class' => 'nodequeue-table',
  ));
  drupal_add_js(drupal_get_path('module', 'nodequeue') . '/nodequeue.js');
  drupal_add_css(drupal_get_path('module', 'nodequeue') . '/nodequeue.css');
  return $output;
}