You are here

function total_control_nodequeue_content_type_render in Total Control Admin Dashboard 7.2

Run-time rendering of the body of the block.

File

plugins/content_types/nodequeue.inc, line 41

Code

function total_control_nodequeue_content_type_render($subtype, $conf, $args, &$context) {

  // Check for nodequeue module.
  if (module_exists('nodequeue')) {

    // Get nodequeues.
    module_load_include('module', 'nodequeue', 'nodequeue');
    $queues = nodequeue_load_queues(nodequeue_get_all_qids(25));
    foreach ($queues as $queue) {
      if (!nodequeue_queue_access($queue)) {
        unset($queues[$queue->qid]);
      }
    }
    $options = array(
      'query' => array(
        'destination' => 'admin/dashboard',
      ),
    );
    $header = array(
      array(
        'data' => t('Title'),
      ),
      array(
        'data' => t('Size'),
      ),
      array(
        'data' => t('Operations'),
        'colspan' => 2,
      ),
    );
    $rows = array();
    foreach ($queues as $queue) {
      $rows[] = array(
        array(
          'class' => 'nodequeue-title',
          'data' => check_plain($queue->title),
        ),
        array(
          'class' => 'nodequeue-max-nodes',
          'data' => $queue->size == 0 ? t('Infinite') : $queue->size,
        ),
        array(
          'data' => l(t('Configure'), 'admin/structure/nodequeue/' . $queue->qid . '/edit', $options),
        ),
        array(
          'data' => l(t('Manage items'), 'admin/structure/nodequeue/' . $queue->qid . '/view', $options),
        ),
      );
    }
    $empty_text = t('There are no nodequeues to display.');
    $link = '';
    if (user_access('administer nodequeue')) {
      $link = l(t('NodeQueue administration'), 'admin/structure/nodequeue');
    }
  }
  else {
    $header = array();
    $empty_text = t('Dashboard administration for the <a href="!href">nodequeue</a> module.', array(
      '!href' => 'http://drupal.org/project/nodequeue',
    ));
    $link = '';
  }
  if (empty($rows)) {
    $rows[] = array(
      array(
        'data' => $empty_text,
        'colspan' => 5,
      ),
    );
  }
  $block = new stdClass();
  $block->module = t('total_control');
  $block->title = t('Manage NodeQueues');
  $block->content = $block->content = theme('total_control_admin_table', array(
    'header' => $header,
    'rows' => $rows,
    'link' => $link,
  ));
  return $block;
}