You are here

function _hosting_task_list in Hosting 7.3

Same name and namespace in other branches
  1. 5 task/hosting_task.module \_hosting_task_list()
  2. 6.2 task/hosting_task.module \_hosting_task_list()
  3. 7.4 task/hosting_task.module \_hosting_task_list()

Theme a task list

1 call to _hosting_task_list()
hosting_task_list in task/hosting_task.module
Display list of tasks.

File

task/hosting_task.module, line 1699
Web server node type is defined here.

Code

function _hosting_task_list($filter_by, $filter_value, $count = 5, $element = 0, $field = 'title', $skip = array(), $pager = TRUE) {
  $nodes = hosting_get_tasks($filter_by, $filter_value, $count, $element);
  if (!$nodes) {
    return t('No tasks available');
  }
  else {
    $headers[t('Task')] = '';
    foreach ($nodes as $node) {
      $row = array();
      if ($field == 'title') {
        $data = drupal_ucfirst($node->task_type) . ' ' . _hosting_node_link($node->rid);
      }
      else {
        $data = $node->{$field};
      }
      $row['type'] = array(
        'data' => $data,
        'class' => array(
          'hosting-status',
        ),
      );
      if (!in_array('created', $skip)) {
        $row['created'] = t("@interval ago", array(
          '@interval' => format_interval(REQUEST_TIME - $node->created, 1),
        ));
        $headers[t('Created')] = '';
      }
      if ($node->task_status == 0) {
        $row['executed'] = '';
      }
      else {
        $row['executed'] = t("@interval ago", array(
          '@interval' => format_interval(REQUEST_TIME - $node->changed, 1),
        ));
      }
      $headers[t('Executed')] = '';
      $headers[t('Actions')] = '';
      $actions['log'] = l(t('View'), 'node/' . $node->nid, array(
        'attributes' => array(
          'class' => array(
            'hosting-button-dialog',
            'hosting-button-enabled',
            'hosting-button-log',
          ),
        ),
      ));
      $row['actions'] = array(
        'data' => $actions['log'],
        'class' => array(
          'hosting-actions',
        ),
      );
      $class = hosting_task_status_class($node->task_status);
      $rows[] = array(
        'data' => $row,
        'class' => array(
          $class,
        ),
      );
    }
    $output = theme('table', array(
      'header' => array_keys($headers),
      'rows' => $rows,
      'attributes' => array(
        'class' => array(
          'hosting-table',
        ),
      ),
    ));
    if ($pager === TRUE) {
      $output .= theme('pager', array(
        'tags' => NULL,
        'element' => $element,
      ));
    }
    elseif (is_string($pager)) {
      $output .= $pager;
    }
    return $output;
  }
}