You are here

public function ultimate_cron_job_ctools_export_ui::logs_page in Ultimate Cron 7.2

Page with logs.

File

plugins/ctools/export_ui/ultimate_cron_job_ctools_export_ui.class.php, line 213
Export-ui handler for the Ultimate Cron jobs.

Class

ultimate_cron_job_ctools_export_ui
Class for cTools Export UI.

Code

public function logs_page($js, $input, $item) {
  $log_entries = $item
    ->getLogEntries();
  $output = '';
  $header = array(
    t('Started'),
    t('Duration'),
    t('Launched by'),
    t('Initial message'),
    t('Message'),
    t('Status'),
  );
  $item->lock_id = isset($item->lock_id) ? $item->lock_id : $item
    ->isLocked();
  $rows = array();
  foreach ($log_entries as $log_entry) {
    $rows[$log_entry->lid]['data'] = array();
    $rows[$log_entry->lid]['data'][] = array(
      'data' => $log_entry
        ->formatStartTime(),
      'class' => array(
        'ctools-export-ui-start-time',
      ),
    );
    $progress = '';
    if ($log_entry->lid && $item->lock_id && $log_entry->lid === $item->lock_id) {
      $progress = ' ' . $item
        ->formatProgress();
    }
    $rows[$log_entry->lid]['data'][] = array(
      'data' => $log_entry
        ->formatDuration() . $progress,
      'class' => array(
        'ctools-export-ui-duration',
      ),
      'title' => strip_tags($log_entry
        ->formatEndTime()),
    );
    $rows[$log_entry->lid]['data'][] = array(
      'data' => $log_entry
        ->formatUser(),
      'class' => array(
        'ctools-export-ui-user',
      ),
    );
    $rows[$log_entry->lid]['data'][] = array(
      'data' => '<pre>' . $log_entry->init_message . '</pre>',
      'class' => array(
        'ctools-export-ui-init-message',
      ),
    );
    $rows[$log_entry->lid]['data'][] = array(
      'data' => '<pre>' . $log_entry->message . '</pre>',
      'class' => array(
        'ctools-export-ui-message',
      ),
    );

    // Status.
    if ($item->lock_id && $log_entry->lid == $item->lock_id) {
      list($status, $title) = $item
        ->getPlugin('launcher')
        ->formatRunning($item);
    }
    elseif ($log_entry->start_time && !$log_entry->end_time) {
      list($status, $title) = $item
        ->getPlugin('launcher')
        ->formatUnfinished($item);
    }
    else {
      list($status, $title) = $log_entry
        ->formatSeverity();
    }
    $rows[$log_entry->lid]['data'][] = array(
      'data' => $status,
      'class' => array(
        'ctools-export-ui-status',
      ),
      'title' => strip_tags($title),
    );
  }
  $output .= theme('table', array(
    'header' => $header,
    'rows' => $rows,
    'empty' => t('No log entries exists for this job yet.'),
  ));
  $output .= theme('pager');
  return $output;
}