You are here

function theme_queue_items in Examples for Developers 7

Themes the queue display.

Again, this is not part of the demonstration of the queue API, but is here just to make the user interface more understandable.

Parameters

array $variables: Our variables.

Related topics

1 theme call to theme_queue_items()
queue_example_add_remove_form in queue_example/queue_example.module
Form generator for managing the queue.

File

queue_example/queue_example.module, line 309
Examples demonstrating the Drupal Queue API.

Code

function theme_queue_items($variables) {
  $items = $variables['items'];
  $rows = array();
  foreach ($items as &$item) {
    if ($item['expire'] > 0) {
      $item['expire'] = t("Claimed: expires %expire", array(
        '%expire' => date('r', $item['expire']),
      ));
    }
    else {
      $item['expire'] = t('Unclaimed');
    }
    $item['created'] = date('r', $item['created']);
    $item['content'] = check_plain(unserialize($item['data']));
    unset($item['data']);
    $rows[] = $item;
  }
  if (!empty($rows)) {
    $header = array(
      t('Item ID'),
      t('Claimed/Expiration'),
      t('Created'),
      t('Content/Data'),
    );
    $output = theme('table', array(
      'header' => $header,
      'rows' => $rows,
    ));
    return $output;
  }
  else {
    return t('There are no items in the queue.');
  }
}