You are here

function datex_admin_form in Datex 7.3

Same name and namespace in other branches
  1. 7 datex.module \datex_admin_form()
  2. 7.2 datex.admin.inc \datex_admin_form()

Provides administration form for datex module (menu callback).

1 string reference to 'datex_admin_form'
datex_menu in ./datex.module
Implements hook_menu().

File

./datex.admin.inc, line 11
Datex administration forms.

Code

function datex_admin_form($form, $form_state) {
  $form['datex_api_intl_status'] = [
    '#type' => 'markup',
    '#title' => t('PHP-Intl status'),
    '#markup' => !DATEX_USE_INTL ? t("<h1><b><a href='http://php.net/manual/en/book.intl.php'>" . 'PHP-Intl</a> is not available in this environment. It is ' . "highly recommended that you enable it, else you'll have limited " . "functionality.</b></h1>") : t('PHP-Intl is available.'),
  ];
  $schema_options = [];
  foreach (array_keys(variable_get('datex_schema', [])) as $name) {
    $summary = '';
    $schema = variable_get('datex_schema');
    foreach ($schema[$name] as $sss_lang => $sss_display) {
      $available = _datex_available_calendars();
      $summary .= ' - ' . t('In language [@lang] display in [@display]', [
        '@display' => $available[$sss_display],
        '@lang' => $sss_lang,
      ]);
    }
    $path = 'admin/config/regional/date-time/datex/edit/' . $name;
    $schema_options[$name] = [
      'title' => [
        'data' => [
          '#type' => 'link',
          '#title' => check_plain($name),
          '#href' => $path,
          '#options' => [
            'inline',
          ],
        ],
      ],
      'summary' => empty($summary) ? t('Disabled') : nl2br($summary),
    ];
  }
  $form['schema_manage'] = [
    '#type' => 'fieldset',
    '#description' => t("Mark schemas to delete after saving, click it's name to edit."),
    '#title' => t('Manage Schemas'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#group' => 'datex_config',
  ];
  $form['schema_manage']['datex_schemas'] = [
    '#type' => 'tableselect',
    '#header' => [
      'title' => t('Title'),
      'summary' => t('Summary'),
    ],
    '#options' => $schema_options,
  ];
  $form['schema_manage']['datex_new_schema_machine_name'] = [
    '#title' => t('New schema'),
    '#type' => 'machine_name',
    '#maxlength' => 31,
    '#description' => t('Schema machine readable name containing only letters, numbers and underscores.'),
    '#machine_name' => [
      'exists' => '_datex_machine_name_exists',
    ],
    '#required' => FALSE,
  ];
  $form['datex_popup_theme'] = [];
  if (module_exists('datex_popup')) {
    if (!module_exists('jquery_update')) {
      drupal_set_message(t('jquery_update is not found, make sure you have' . ' latest version of jquery, else datex_popup will not work and probably' . ' will blow up your website.'), 'warning');
    }
    $form['datex_popup_theme'] = [
      '#type' => 'select',
      '#title' => t('Popup Theme'),
      '#options' => drupal_map_assoc([
        'none',
        'blue',
        'cheerup',
        'dark',
        'redblack',
      ]),
      '#default_value' => variable_get('datex_popup_theme', 'none'),
    ];
  }
  $form['datex_block_count'] = [
    '#type' => 'textfield',
    '#title' => t('Block count'),
    '#description' => t('How many blocks should datex create.'),
    '#default_value' => variable_get('datex_block_count', 1),
  ];
  $form['actions']['submit'] = [
    '#type' => 'submit',
    '#submit' => [
      '_datex_admin_form_submit',
    ],
    '#value' => t('Save'),
    '#name' => 'config',
  ];
  return $form;
}