function job_scheduler_help in Job Scheduler 7.2
Implements hook_help().
@codingStandardsIgnoreStart
File
- ./
job_scheduler.module, line 13 - Main file for the Job Scheduler.
Code
function job_scheduler_help($path, $arg) {
switch ($path) {
case 'admin/help#job_scheduler':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Simple API for scheduling tasks once at a predetermined time or periodically at a fixed interval.') . '</p>';
$output .= '<h3>' . t('Usage') . '</h3>';
$output .= '<p>' . t('Declare scheduler.') . '</p>';
$output .= '<xmp>' . 'function example_cron_job_scheduler_info() {
$schedulers - array();
$schedulers[\'example_unpublish\'] - array(
\'worker callback\' -> \'example_unpublish_nodes\',
);
return $schedulers;
}' . '</xmp>';
$output .= '<p>' . t('Add a job.') . '</p>';
$output .= '<xmp>' . '$job - array(
\'type\' -> \'story\',
\'id\' -> 12,
\'period\' -> 3600,
\'periodic\' -> TRUE,
);
JobScheduler::get(\'example_unpublish\')->set($job);' . '</xmp>';
//
$output .= '<p>' . t('Work off a job.') . '</p>';
$output .= '<xmp>' . 'function example_unpublish_nodes($job) {
// Do stuff.
}' . '</xmp>';
$output .= '<p>' . t('Remove a job.') . '</p>';
$output .= '<xmp>' . '$job - array(
\'type\' -> \'story\',
\'id\' -> 12,
);
JobScheduler::get(\'example_unpublish\')->remove($job);' . '</xmp>';
$output .= '<p>' . t('Optionally jobs can declared together with a schedule in a: hook_cron_job_scheduler_info().') . '</p>';
$output .= '<xmp>' . 'function example_cron_job_scheduler_info() {
$schedulers - array();
$schedulers[\'example_unpublish\'] - array(
\'worker callback\' -> \'example_unpublish_nodes\',
\'jobs\' -> array(
array(
\'type\' -> \'story\',
\'id\' -> 12,
\'period\' -> 3600,
\'periodic\' -> TRUE,
),
)
);
return $schedulers;
}' . '</xmp>';
$output .= '<p>' . t("Jobs can have a 'crontab' instead of a period. Crontab syntax are Unix-like formatted crontab lines.") . '</p>';
$output .= '<p>' . t('Example of job with crontab.') . '</p>';
$output .= '<p>' . t("This will create a job that will be triggered from monday to friday, from january to july, every two hours.") . '</p>';
$output .= '<xmp>' . 'function example_cron_job_scheduler_info() {
$schedulers - array();
$schedulers[\'example_unpublish\'] - array(
\'worker callback\' -> \'example_unpublish_nodes\',
\'jobs\' -> array(
array(
\'type\' -> \'story\',
\'id\' -> 12,
\'crontab\' -> \'0 */2 * january-july mon-fri\',
\'periodic\' -> TRUE,
),
)
);
return $schedulers;
}' . '</xmp>';
$output .= '<p>' . t('Read more about crontab syntax: <a href="@url_crontab_sintax" target="blank">@url_crontab_sintax</a>', array(
'@url_crontab_sintax' => 'http://linux.die.net/man/5/crontab',
)) . '</p>';
return $output;
}
}