1 system.admin.inc system_cron_settings($form, &$form_state)

Form builder; Cron form.

Related topics

File

core/modules/system/system.admin.inc, line 1600
Admin page callbacks for the System module.

Code

function system_cron_settings($form, &$form_state) {
  global $base_url;
  $form['#config'] = 'system.core';
  $form['description'] = array(
    '#type' => 'help',
    '#markup' => t('Cron takes care of running periodic tasks like checking for updates and indexing content for search.'),
  );
  $form['run'] = array(
    '#type' => 'submit',
    '#value' => t('Run cron'),
    '#submit' => array('system_run_cron_submit'),
  );

  $status = '<p>' . t('Last run: %cron-last ago.', array('%cron-last' => format_interval(REQUEST_TIME - state_get('cron_last')),)) . '</p>';
  $form['status'] = array(
    '#markup' => $status,
  );

  $form['cron_url'] = array(
    '#type' => 'help',
    '#markup' => t('To run cron from outside the site, go to <a href="!cron">!cron</a>', array('!cron' => url($base_url . '/core/cron.php', array(
      'external' => TRUE,
      'query' => array('cron_key' => state_get('cron_key', 'backdrop')),
    )))),
  );

  $form['cron'] = array(
    '#title' => t('Cron configuration'),
    '#type' => 'fieldset',
  );
  $form['cron']['cron_safe_threshold'] = array(
    '#type' => 'select',
    '#title' => t('Run cron every'),
    '#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial</a>.', array('@url' => url('https://backdropcms.org/cron'))),
    '#default_value' => config('system.core')->get('cron_safe_threshold'),
    '#options' => array(0 => t('Never')) + backdrop_map_assoc(array(600, 1800, 3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
  );

  return system_settings_form($form);
}