You are here

public function ultimate_cron_job_ctools_export_ui::list_build_row in Ultimate Cron 7.2

Build a row based on the item.

By default all of the rows are placed into a table by the render method, so this is building up a row suitable for theme('table'). This doesn't have to be true if you override both.

Overrides ctools_export_ui::list_build_row

1 call to ultimate_cron_job_ctools_export_ui::list_build_row()
ultimate_cron_job_ctools_export_ui::list_form_submit in plugins/ctools/export_ui/ultimate_cron_job_ctools_export_ui.class.php
Submit the filter/sort form.

File

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

Class

ultimate_cron_job_ctools_export_ui
Class for cTools Export UI.

Code

public function list_build_row($item, &$form_state, $operations) {

  // Set up sorting.
  $name = $item->{$this->plugin['export']['key']};
  $schema = ctools_export_get_schema($this->plugin['schema']);

  // Started and duration.
  $item->lock_id = isset($item->lock_id) ? $item->lock_id : $item
    ->isLocked();
  $item->log_entry = isset($item->log_entry) ? $item->log_entry : $item
    ->loadLatestLogEntry();
  $item->progress = isset($item->progress) ? $item->progress : $item
    ->getProgress();
  if ($item->log_entry->lid && $item->lock_id && $item->log_entry->lid !== $item->lock_id) {
    $item->log_entry = $item
      ->loadLogEntry($item->lock_id);
  }

  // Note: $item->{$schema['export']['export type string']} should have
  // already been set up by export.inc so we can use it safely.
  switch ($form_state['values']['order']) {
    case 'disabled':
      $this->rows[$name]['sort'] = array(
        (int) (!empty($item->disabled)),
        $item
          ->getModuleName(),
        empty($this->plugin['export']['admin_title']) ? $name : $item->{$this->plugin['export']['admin_title']},
      );
      break;
    case 'title':
      $this->rows[$name]['sort'] = array(
        $item->{$this->plugin['export']['admin_title']},
      );
      break;
    case 'start_time':
      $this->rows[$name]['sort'] = array(
        $item->log_entry->start_time,
      );
      break;
    case 'duration':
      $this->rows[$name]['sort'] = array(
        $item->log_entry
          ->getDuration(),
      );
      break;
    case 'storage':
      $this->rows[$name]['sort'] = array(
        $item->{$schema['export']['export type string']} . $name,
      );
      break;
  }

  // Setup row.
  $this->rows[$name]['id'] = $name;
  $this->rows[$name]['data'] = array();

  // Enabled/disabled.
  $this->rows[$name]['class'] = !empty($item->disabled) ? array(
    'ctools-export-ui-disabled',
  ) : array(
    'ctools-export-ui-enabled',
  );

  // Module.
  $this->rows[$name]['data'][] = array(
    'data' => check_plain($item
      ->getModuleName()),
    'class' => array(
      'ctools-export-ui-module',
    ),
    'title' => strip_tags($item
      ->getModuleDescription()),
  );

  // If we have an admin title, make it the first row.
  if (!empty($this->plugin['export']['admin_title'])) {
    $this->rows[$name]['data'][] = array(
      'data' => check_plain($item->{$this->plugin['export']['admin_title']}),
      'class' => array(
        'ctools-export-ui-title',
      ),
      'title' => strip_tags($item->name),
    );
  }

  // Machine Name.
  $this->rows[$name]['data'][] = $item->name;

  // Schedule settings.
  $label = $item
    ->getPlugin('scheduler')
    ->formatLabel($item);
  $label = str_replace("\n", '<br/>', $label);
  if ($behind = $item
    ->isBehindSchedule()) {
    $this->jobs_behind++;
    $label = "<em>{$label}</em><br/>" . format_interval($behind) . ' ' . t('behind schedule');
  }
  $this->rows[$name]['data'][] = array(
    'data' => $label,
    'class' => array(
      'ctools-export-ui-scheduled',
    ),
    'title' => strip_tags($item
      ->getPlugin('scheduler')
      ->formatLabelVerbose($item)),
  );
  $this->rows[$name]['data'][] = array(
    'data' => $item->log_entry
      ->formatStartTime(),
    'class' => array(
      'ctools-export-ui-start-time',
    ),
    'title' => strip_tags($item->log_entry
      ->formatInitMessage()),
  );
  $progress = $item->lock_id ? $item
    ->formatProgress() : '';
  $this->rows[$name]['data'][] = array(
    'data' => '<span class="duration-time" data-src="' . $item->log_entry
      ->getDuration() . '">' . $item->log_entry
      ->formatDuration() . '</span> <span class="duration-progress">' . $progress . '</span>',
    'class' => array(
      'ctools-export-ui-duration',
    ),
    'title' => strip_tags($item->log_entry
      ->formatEndTime()),
  );

  // Status.
  if ($item->lock_id && $item->log_entry->lid == $item->lock_id) {
    list($status, $title) = $item
      ->getPlugin('launcher')
      ->formatRunning($item);
  }
  elseif ($item->log_entry->start_time && !$item->log_entry->end_time) {
    list($status, $title) = $item
      ->getPlugin('launcher')
      ->formatUnfinished($item);
  }
  else {
    list($status, $title) = $item->log_entry
      ->formatSeverity();
    $title = $item->log_entry->message ? $item->log_entry->message : $title;
  }
  $this->rows[$name]['data'][] = array(
    'data' => $status,
    'class' => array(
      'ctools-export-ui-status',
    ),
    'title' => strip_tags($title),
  );

  // Storage.
  $this->rows[$name]['data'][] = array(
    'data' => check_plain($item->{$schema['export']['export type string']}),
    'class' => array(
      'ctools-export-ui-storage',
    ),
  );

  // Operations.
  $ops = theme('links__ctools_dropbutton', array(
    'links' => $operations,
    'attributes' => array(
      'class' => array(
        'links',
        'inline',
      ),
    ),
  ));
  $this->rows[$name]['data'][] = array(
    'data' => $ops,
    'class' => array(
      'ctools-export-ui-operations',
    ),
  );

  // Add an automatic mouseover of the description if one exists.
  if (!empty($this->plugin['export']['admin_description'])) {
    $this->rows[$name]['title'] = strip_tags($item->{$this->plugin['export']['admin_description']});
  }
}