public function UltimateCronQueueSettings::settingsForm in Ultimate Cron 7.2
Settings form.
Overrides UltimateCronPlugin::settingsForm
File
- plugins/
ultimate_cron/ settings/ queue.class.php, line 260 - Queue settings for Ultimate Cron.
Class
- UltimateCronQueueSettings
- Queue settings plugin class.
Code
public function settingsForm(&$form, &$form_state, $job = NULL) {
$elements =& $form['settings'][$this->type][$this->name];
$values =& $form_state['values']['settings'][$this->type][$this->name];
$states = array();
if (!$job) {
$elements['enabled'] = array(
'#title' => t('Enable cron queue processing'),
'#description' => t('If enabled, cron queues will be processed by this plugin. If another cron queue plugin is installed, it may be necessary/beneficial to disable this plugin.'),
'#type' => 'checkbox',
'#default_value' => variable_get($this->key . '_enabled', TRUE),
'#fallback' => TRUE,
);
$states = array(
'#states' => array(
'visible' => array(
':input[name="settings[' . $this->type . '][' . $this->name . '][enabled]"]' => array(
'checked' => TRUE,
),
),
),
);
}
$elements['timeouts'] = array(
'#type' => 'fieldset',
'#title' => t('Timeouts'),
) + $states;
$elements['timeouts']['lease_time'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'lease_time',
),
'#title' => t("Queue lease time"),
'#type' => 'textfield',
'#default_value' => $values['lease_time'],
'#description' => t('Seconds to claim a cron queue item.'),
'#fallback' => TRUE,
'#required' => TRUE,
);
$elements['timeouts']['time'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'time',
),
'#title' => t('Time'),
'#type' => 'textfield',
'#default_value' => $values['time'],
'#description' => t('Time in seconds to process items during a cron run.'),
'#fallback' => TRUE,
'#required' => TRUE,
);
$elements['delays'] = array(
'#type' => 'fieldset',
'#title' => t('Delays'),
) + $states;
$elements['delays']['empty_delay'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'empty_delay',
),
'#title' => t("Empty delay"),
'#type' => 'textfield',
'#default_value' => $values['empty_delay'],
'#description' => t('Seconds to delay processing of queue if queue is empty (0 = end job).'),
'#fallback' => TRUE,
'#required' => TRUE,
);
$elements['delays']['item_delay'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'item_delay',
),
'#title' => t("Item delay"),
'#type' => 'textfield',
'#default_value' => $values['item_delay'],
'#description' => t('Seconds to wait between processing each item in a queue.'),
'#fallback' => TRUE,
'#required' => TRUE,
);
$elements['throttle'] = array(
'#title' => t('Throttle'),
'#type' => 'checkbox',
'#default_value' => $values['throttle'],
'#description' => t('Throttle queues using multiple threads.'),
);
$states = !$job ? $states : array(
'#states' => array(
'visible' => array(
':input[name="settings[' . $this->type . '][' . $this->name . '][throttle]"]' => array(
'checked' => TRUE,
),
),
),
);
$elements['throttling'] = array(
'#type' => 'fieldset',
'#title' => t('Throttling'),
) + $states;
$elements['throttling']['threads'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'threads',
),
'#title' => t('Threads'),
'#type' => 'textfield',
'#default_value' => $values['threads'],
'#description' => t('Number of threads to use for queues.'),
'#states' => array(
'visible' => array(
':input[name="settings[' . $this->type . '][' . $this->name . '][throttle]"]' => array(
'checked' => TRUE,
),
),
),
'#fallback' => TRUE,
'#required' => TRUE,
);
$elements['throttling']['threshold'] = array(
'#parents' => array(
'settings',
$this->type,
$this->name,
'threshold',
),
'#title' => t('Threshold'),
'#type' => 'textfield',
'#default_value' => $values['threshold'],
'#description' => t('Number of items in queue required to activate the next cron job.'),
'#states' => array(
'visible' => array(
':input[name="settings[' . $this->type . '][' . $this->name . '][throttle]"]' => array(
'checked' => TRUE,
),
),
),
'#fallback' => TRUE,
'#required' => TRUE,
);
}