You are here

function cufon_admin in Cufón 6

Same name and namespace in other branches
  1. 7.2 includes/cufon.admin.inc \cufon_admin()

Administration settings page

1 string reference to 'cufon_admin'
cufon_menu in ./cufon.module
Implementation of hook_menu().

File

./cufon.admin.inc, line 11

Code

function cufon_admin() {
  drupal_add_css(drupal_get_path('module', 'cufon') . '/cufon-admin.css');
  $selectors = variable_get('cufon_selectors', array());
  $fonts = array(
    '------',
  );
  foreach (_cufon_find_fonts() as $family => $file) {
    $fonts[$family] = $family;
  }
  $form = array(
    'cufon_selectors' => array(
      '#type' => 'fieldset',
      '#tree' => TRUE,
      '#title' => t('CSS selectors'),
      '#description' => t('You may add as many selector / font combinations as you would like.  To add additional input fields, save to add @count more.', array(
        '@count' => CUFON_ADDITIONAL_FORM_ELEMENTS,
      )),
    ),
  );
  $i = 0;
  while ($i < count($selectors) + CUFON_ADDITIONAL_FORM_ELEMENTS) {
    $form['cufon_selectors'][$i] = array(
      'selector' => array(
        '#type' => 'textarea',
        '#title' => t('Selector'),
        '#cols' => 40,
        '#rows' => 3,
        '#prefix' => '<div class="cufon-selector">',
        '#suffix' => '</div>',
      ),
      'options' => array(
        '#tree' => TRUE,
        'fontFamily' => array(
          '#type' => 'select',
          '#title' => t('Font family'),
          '#options' => $fonts,
          '#prefix' => '<div class="cufon-font-family">',
          '#suffix' => '</div>',
        ),
        'hover' => array(
          '#type' => 'checkbox',
          '#title' => t('Enable hover state support'),
          '#default_value' => 0,
          '#description' => t('Adds support for <code>:hover</code> states.  For performance reasons, this is disabled by default.'),
          '#prefix' => '<div class="cufon-hover">',
          '#suffix' => '</div>',
        ),
        '#prefix' => '<div class="cufon-options">',
        '#suffix' => '</div>',
      ),
      '#prefix' => '<div class="cufon-settings-row clear-block">',
      '#suffix' => '</div>',
    );

    // Slightly hoary use of position
    if ($s = $selectors[$i]) {
      $form['cufon_selectors'][$i]['selector']['#default_value'] = $s['selector'];
      $form['cufon_selectors'][$i]['options']['fontFamily']['#default_value'] = $s['options']['fontFamily'];
      $form['cufon_selectors'][$i]['options']['hover']['#default_value'] = $s['options']['hover'];
    }
    $i++;
  }
  $form['#submit'][] = 'cufon_admin_submit';
  return system_settings_form($form);
}