You are here

function fontyourface_ui_settings_form in @font-your-face 7.2

Creates settings form.

3 string references to 'fontyourface_ui_settings_form'
fontdeck_form_alter in modules/fontdeck/fontdeck.module
Implements hook_form_alter().
fontyourface_ui_menu in modules/fontyourface_ui/fontyourface_ui.module
Implements hook_menu().
typekit_api_form_alter in modules/typekit_api/typekit_api.module
Implements hook_form_alter().

File

modules/fontyourface_ui/fontyourface_ui.module, line 551

Code

function fontyourface_ui_settings_form($form, &$form_state) {
  $form = array(
    'providers' => array(
      '#type' => 'fieldset',
      '#title' => t('Providers'),
    ),
    'advanced' => array(
      '#type' => 'fieldset',
      '#title' => t('Advanced'),
      'load_everywhere' => array(
        '#type' => 'checkbox',
        '#default_value' => variable_get('fontyourface_load_everywhere', TRUE),
        '#title' => t('Load fonts in all themes, including admin themes'),
        '#description' => t('If unchecked, fonts will be loaded only in the default theme.'),
      ),
      'detailed_logs' => array(
        '#type' => 'checkbox',
        '#default_value' => variable_get('fontyourface_detailed_logging', FALSE),
        '#title' => t('Keep detailed watchdog logs'),
        '#description' => t("Don't leave this on when testing is complete. It will make everything run a bit slower."),
      ),
      'update_advanced' => array(
        '#type' => 'submit',
        '#value' => t('Change advanced settings'),
      ),
    ),
    'preview' => array(
      '#type' => 'fieldset',
      '#title' => t('Preview'),
      'short_preview_text' => array(
        '#type' => 'textfield',
        '#default_value' => variable_get('fontyourface_short_preview_text', 'AaGg'),
        '#title' => t('Default short preview text'),
        '#description' => t('Provider-specific submodules may supply their own preview text, overriding this default.'),
      ),
      'update_preview' => array(
        '#type' => 'submit',
        '#value' => t('Change preview settings'),
      ),
    ),
  );
  foreach (module_implements('fontyourface_info') as $module) {
    $info_function = $module . '_fontyourface_info';
    $status_function = $module . '_fontyourface_status';
    $import_function = $module . '_fontyourface_import';
    $count_function = $module . '_fontyourface_count';
    $provider = $info_function();
    if (function_exists($count_function)) {
      $count = $count_function();
    }
    else {
      $count = db_query("SELECT COUNT(fid) AS total FROM {fontyourface_font} WHERE provider = :provider", array(
        ':provider' => $module,
      ))
        ->fetchField();
    }

    // else
    $tokens = array(
      '@provider' => $provider['name'],
      '@count' => (int) $count,
    );
    $status = t('@provider is enabled with @count fonts.', $tokens);
    if (function_exists($status_function)) {
      $status .= ' ' . $status_function();
    }

    // if
    $form['providers'][$module . '_import'] = array(
      '#prefix' => '<div>',
      '#suffix' => '</div>',
      'count' => array(
        '#type' => 'item',
        '#markup' => $status . ' ',
      ),
    );
    if (function_exists($import_function)) {
      $button_text = $count > 0 ? t('Update @provider fonts', $tokens) : t('Import @provider fonts', $tokens);
      $form['providers'][$module . '_import']['import'] = array(
        '#type' => 'submit',
        '#value' => $button_text,
      );
    }

    // if
  }

  // foreach
  return $form;
}