You are here

function jst_timer_get_formats in Javascript Timer 8

Same name and namespace in other branches
  1. 7 widgets/jst_timer.module \jst_timer_get_formats()

Get a list of formats and handle default values.

2 calls to jst_timer_get_formats()
jst_timer_form_jstimer_admin_settings_alter in widgets/jst_timer.module
Implementation of hook_form_alter(). Add the timer widget specific settings to admin screen.
jst_timer_get_js_formats in widgets/jst_timer.module
Get a javascript array encoded list of timer formats.

File

widgets/jst_timer.module, line 565
Default widget implementation for an up and down timer. This widget does not use hook_ctwidget as it is always included.

Code

function jst_timer_get_formats() {
  $formats = \Drupal::configFactory()
    ->get('jstimer.settings')
    ->get('jst_timer_formats');
  if (count($formats) == 0) {

    // The first one is the global format.
    $formats[] = '<em>(%dow% %moy%%day%)</em><br/>%days% days + %hours%:%mins%:%secs%';
    $formats[] = 'Only %days% days, %hours% hours, %mins% minutes and %secs% seconds left';
    $formats[] = '%days% shopping days left';
    $formats[] = '<em>(%dow% %moy%%day%)</em><br/>%days% days + %hours%:%mins%:%secs%';
  }
  return $formats;
}