You are here

public static function JobSchedulerCronTab::translateNames in Job Scheduler 7.2

Replace element names by values.

1 call to JobSchedulerCronTab::translateNames()
JobSchedulerCronTab::parseElement in ./JobSchedulerCronTab.inc
Parse each text element. Recursive up to some point...

File

./JobSchedulerCronTab.inc, line 286
JobSchedulerCronTab class.

Class

JobSchedulerCronTab
Jose's cron tab parser = Better try only simple crontab strings.

Code

public static function translateNames($type, $string) {
  switch ($type) {
    case 'wday':
      $replace = array_merge(array(
        '-sunday' => '-7',
        '-sun' => '-7',
        'sunday-' => '0-',
        'sun-' => '0-',
      ), array_flip(array(
        'sunday',
        'monday',
        'tuesday',
        'wednesday',
        'thursday',
        'friday',
        'saturday',
      )), array_flip(array(
        'sun',
        'mon',
        'tue',
        'wed',
        'thu',
        'fri',
        'sat',
      )));
      break;
    case 'mon':
      $replace = array_merge(array_flip(array(
        'nomonth1',
        'january',
        'february',
        'march',
        'april',
        'may',
        'june',
        'july',
        'august',
        'september',
        'october',
        'november',
        'december',
      )), array_flip(array(
        'nomonth2',
        'jan',
        'feb',
        'mar',
        'apr',
        'may',
        'jun',
        'jul',
        'aug',
        'sep',
        'oct',
        'nov',
        'dec',
      )), array(
        'sept' => 9,
      ));
      break;
  }
  if (empty($replace)) {
    return $string;
  }
  else {
    return strtr($string, $replace);
  }
}