You are here

abstract class field_timer_jquery_countdown_base in Field Timer 7.2

Base class for field_timer_jquery_countdown formatter.

Hierarchy

Expanded class hierarchy of field_timer_jquery_countdown_base

File

includes/field_timer_jquery_countdown.inc, line 13
Help file. Contains help classes to perform field_timer_jquery_countdown formatter related actions.

View source
abstract class field_timer_jquery_countdown_base extends field_timer_jquery_countdown_js_base {

  /**
   * @inheritdoc
   */
  public final function getFormatterDefinition() {
    return array(
      'label' => t('jQuery Countdown'),
      'description' => t('Use jQuery Countdown plugin to display countdown and timer.'),
    );
  }

  /**
   * @inheritdoc
   */
  public function getDefaultSettings() {
    return array(
      'type' => 'auto',
      'regional' => 'en',
      'format' => 'dHMS',
      'layout' => '',
      'compact' => 0,
      'significant' => 0,
      'timeSeparator' => ':',
      'padZeroes' => 0,
    );
  }

  /**
   * @inheritdoc
   */
  public function getSettingsSummary($settings, $field) {
    $summary = array();
    $types = $this
      ->formatterTypes();
    $regions = $this
      ->formatterRegions();
    $summary[] = t('Type: %type', array(
      '%type' => $types[$settings['type']],
    ));
    $summary[] = t('Region: %regional', array(
      '%regional' => $regions[$settings['regional']],
    ));
    $summary[] = t('Format: %format', array(
      '%format' => $settings['format'],
    ));
    $summary[] = t('Layout: %layout', array(
      '%layout' => $settings['layout'],
    ));
    $summary[] = t('Compact: %compact', array(
      '%compact' => $settings['compact'] ? t('Yes') : t('No'),
    ));
    $summary[] = t('Granularity: %significant', array(
      '%significant' => $settings['significant'],
    ));
    $summary[] = t('Time separator: %timeSeparator', array(
      '%timeSeparator' => $settings['timeSeparator'],
    ));
    $summary[] = t('Pad with zeroes: %padZeroes', array(
      '%padZeroes' => $settings['padZeroes'] ? t('Yes') : t('No'),
    ));
    return $summary;
  }

  /**
   * @inheritdoc
   */
  public function getSettingsForm($settings, $field) {
    $settings_form = array();
    $settings_form['type'] = array(
      '#type' => 'select',
      '#title' => t('Type'),
      '#options' => $this
        ->formatterTypes(),
      '#default_value' => $settings['type'],
    );
    $settings_form['regional'] = array(
      '#type' => 'select',
      '#title' => t('Region'),
      '#default_value' => $settings['regional'],
      '#options' => $this
        ->formatterRegions(),
    );
    $settings_form['format'] = array(
      '#type' => 'textfield',
      '#title' => t('Format'),
      '#default_value' => $settings['format'],
      '#description' => t('See !documentation for this parameter.', array(
        '!documentation' => l(t('documentation'), 'http://keith-wood.name/countdownRef.html', array(
          'fragment' => 'format',
        )),
      )),
    );
    $settings_form['layout'] = array(
      '#type' => 'textarea',
      '#rows' => 3,
      '#cols' => 60,
      '#title' => t('Layout'),
      '#default_value' => $settings['layout'],
      '#description' => t('See !documentation for this parameter.', array(
        '!documentation' => l(t('documentation'), 'http://keith-wood.name/countdownRef.html', array(
          'fragment' => 'layout',
        )),
      )),
    );
    $settings_form['compact'] = array(
      '#type' => 'checkbox',
      '#title' => t('Display in compact format'),
      '#default_value' => $settings['compact'],
    );
    $settings_form['significant'] = array(
      '#type' => 'select',
      '#title' => t('Granularity'),
      '#options' => range(0, 7),
      '#default_value' => $settings['significant'],
    );
    $settings_form['timeSeparator'] = array(
      '#type' => 'textfield',
      '#title' => t('Time separator'),
      '#default_value' => $settings['timeSeparator'],
    );
    $settings_form['padZeroes'] = array(
      '#type' => 'checkbox',
      '#title' => t('Pad with zeroes'),
      '#default_value' => $settings['padZeroes'],
    );
    return $settings_form;
  }

  /**
   * @inheritdoc
   */
  public function renderItems($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
    if (!$this
      ->loadLibrary()) {
      return array();
    }
    $info = entity_get_info($entity_type);
    $id_key = $info['entity keys']['id'];
    $elements = array();
    foreach ($items as $delta => $item) {
      $elements[$delta] = array(
        '#type' => 'markup',
        '#markup' => '<span id="jquery-countdown-' . $entity_type . '_' . $entity->{$id_key} . '_' . $field['field_name'] . '_' . $delta . '" class="jquery-countdown"></span>',
      );
    }
    $this
      ->loadJSandCSS($entity_type, $entity, $field, $instance, $langcode, $items, $display);
    return $elements;
  }

  /**
   * @inheritdoc
   */
  public function getFormatterName() {
    return 'field_timer_jquery_countdown';
  }

  /**
   * @inheritdoc
   */
  public function getPluginName() {
    return 'jquery.countdown';
  }
  protected function formatterRegions() {
    return array(
      'sq' => t('Albanian'),
      'ar' => t('Arabic'),
      'hy' => t('Armenian'),
      'bn' => t('Bengali/Bangla'),
      'bs' => t('Bosnian'),
      'bg' => t('Bulgarian'),
      'my' => t('Burmese'),
      'ca' => t('Catalan'),
      'zh-CN' => t('Chinese/Simplified'),
      'zh-TW' => t('Chinese/Traditional'),
      'hr' => t('Croatian'),
      'cs' => t('Czech'),
      'da' => t('Danish'),
      'nl' => t('Dutch'),
      'et' => t('Estonian'),
      'en' => t('English'),
      'fa' => t('Farsi/Persian'),
      'fi' => t('Finnish'),
      'fo' => t('Faroese'),
      'fr' => t('French'),
      'gl' => t('Galician'),
      'de' => t('German'),
      'el' => t('Greek'),
      'gu' => t('Gujarati'),
      'he' => t('Hebrew'),
      'hu' => t('Hungarian'),
      'id' => t('Indonesian'),
      'is' => t('Icelandic'),
      'it' => t('Italian'),
      'ja' => t('Japanese'),
      'kn' => t('Kannada'),
      'ko' => t('Korean'),
      'lv' => t('Latvian'),
      'lt' => t('Lithuanian'),
      'mk' => t('Macedonian'),
      'ml' => t('Malayalam'),
      'ms' => t('Malaysian'),
      'nb' => t('Norvegian'),
      'pl' => t('Polish'),
      'pt-BR' => t('Portuguese/Brazilian'),
      'ro' => t('Romanian'),
      'ru' => t('Russian'),
      'sr' => t('Serbian'),
      'sk' => t('Slovak'),
      'sl' => t('Slovenian'),
      'es' => t('Spanish'),
      'sv' => t('Swedish'),
      'th' => t('Thai'),
      'tr' => t('Turkish'),
      'uk' => t('Ukrainian'),
      'ur' => t('Urdu'),
      'uz' => t('Uzbek'),
      'vi' => t('Vietnamese'),
      'cy' => t('Welsh'),
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
field_timer_formatter_base::getTimestamp abstract protected function Convert field item value to timestamp. 16
field_timer_formatter_interface::getFieldType public function Get field type. 16
field_timer_formatter_js_base::$library_loaded protected property
field_timer_jquery_countdown_base::formatterRegions protected function
field_timer_jquery_countdown_base::getDefaultSettings public function @inheritdoc Overrides field_timer_formatter_interface::getDefaultSettings 1
field_timer_jquery_countdown_base::getFormatterDefinition final public function @inheritdoc Overrides field_timer_formatter_interface::getFormatterDefinition
field_timer_jquery_countdown_base::getFormatterName public function @inheritdoc Overrides field_timer_formatter_interface::getFormatterName
field_timer_jquery_countdown_base::getPluginName public function @inheritdoc Overrides field_timer_formatter_js_base::getPluginName
field_timer_jquery_countdown_base::getSettingsForm public function @inheritdoc Overrides field_timer_formatter_interface::getSettingsForm 1
field_timer_jquery_countdown_base::getSettingsSummary public function @inheritdoc Overrides field_timer_formatter_interface::getSettingsSummary 1
field_timer_jquery_countdown_base::renderItems public function @inheritdoc Overrides field_timer_formatter_interface::renderItems 1
field_timer_jquery_countdown_js_base::enableFormatter public function @inheritdoc Overrides field_timer_formatter_interface::enableFormatter
field_timer_jquery_countdown_js_base::formatterTypes protected function
field_timer_jquery_countdown_js_base::generateJSSettings protected function @inheritdoc Overrides field_timer_formatter_js_base::generateJSSettings 2
field_timer_jquery_countdown_js_base::generateJSSettingsArray protected function
field_timer_jquery_countdown_js_base::loadJSandCSS protected function @inheritdoc Overrides field_timer_formatter_js_base::loadJSandCSS 3
field_timer_jquery_countdown_js_base::loadLibrary protected function @inheritdoc Overrides field_timer_formatter_js_base::loadLibrary