You are here

function _typogrify_settings in Typogrify 5

Same name and namespace in other branches
  1. 6 typogrify.module \_typogrify_settings()
  2. 7 typogrify.module \_typogrify_settings()
1 call to _typogrify_settings()
typogrify_filter in ./typogrify.module

File

./typogrify.module, line 135

Code

function _typogrify_settings($format) {
  require_once dirname(__FILE__) . '/unicode-conversion.php';
  $form['typogrify_settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Typogrify'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['typogrify_settings']['help'] = array(
    '#type' => 'markup',
    '#value' => '<p>Enable the following typographic refinements:</p>',
  );

  // Smartypants settings
  // We impersonate Marksmarty to ensure that settings are honored by both marksmarty.module and typogrify.module
  if (!function_exists('marksmarty_filter')) {

    // Smartypants settings
    $form['typogrify_settings']["marksmarty_is_smarty_on_{$format}"] = array(
      '#type' => 'checkbox',
      '#title' => t('Use typographers quotation marks and dashes (!smartylink)', array(
        '!smartylink' => l('SmartyPants', 'http://daringfireball.net/projects/smartypants/'),
      )),
      '#default_value' => variable_get("marksmarty_is_smarty_on_{$format}", 1),
    );

    // Smartypants hyphenation settings
    // Uses the same values as the parse attributes in the
    // SmartyPants function (@see SmartyPants in smartypants.php)
    $form['typogrify_settings']["marksmarty_smarty_hyphens_{$format}"] = array(
      '#type' => 'select',
      '#title' => t('Hyphenation settings for SmartyPants'),
      '#default_value' => variable_get("marksmarty_smarty_hyphens_{$format}", 3),
      '#options' => array(
        1 => t('"--" for em-dashes; no en-dash support'),
        3 => t('"--" for em-dashes; "---" for en-dashes'),
        2 => t('"---" for em-dashes; "--" for en-dashes'),
      ),
    );
  }

  // Wrap ampersand settings
  $form['typogrify_settings']["typogrify_is_amp_on_{$format}"] = array(
    '#type' => 'checkbox',
    '#title' => t('Wrap ampersands'),
    '#default_value' => variable_get("typogrify_is_amp_on_{$format}", 1),
  );

  // Remove widows settings
  $form['typogrify_settings']["typogrify_is_widont_on_{$format}"] = array(
    '#type' => 'checkbox',
    '#title' => t('Remove widows'),
    '#default_value' => variable_get("typogrify_is_widont_on_{$format}", 1),
  );

  // Wrap caps settings
  $form['typogrify_settings']["typogrify_is_caps_on_{$format}"] = array(
    '#type' => 'checkbox',
    '#title' => t('Wrap caps'),
    '#default_value' => variable_get("typogrify_is_caps_on_{$format}", 1),
  );

  // Wrap initial quotes settings
  $form['typogrify_settings']["typogrify_is_initial_quotes_on_{$format}"] = array(
    '#type' => 'checkbox',
    '#title' => t('Wrap quotation marks'),
    '#default_value' => variable_get("typogrify_is_initial_quotes_on_{$format}", 1),
  );

  // Ligature Conversion Settings
  $form['typogrify_settings']['ligatures'] = array(
    '#type' => 'fieldset',
    '#title' => t('Ligatures'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  foreach ($ligature_map as $pair => $ligature) {
    $setting = 'typogrify_use_' . $pair . '_ligature_' . $format;
    $form['typogrify_settings']['ligatures'][$setting] = array(
      '#type' => 'checkbox',
      '#title' => t("Convert {$pair} to {$ligature}"),
      '#default_value' => variable_get($setting, 0),
    );
  }

  // Arrow Conversion Settings
  $form['typogrify_settings']['arrows'] = array(
    '#type' => 'fieldset',
    '#title' => t('Arrows'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  foreach ($arrow_map as $ascii => $unicode) {
    $setting = 'typogrify_use_unicode_for_' . $ascii . '_' . $format;
    $form['typogrify_settings']['arrows'][$setting] = array(
      '#type' => 'checkbox',
      '#title' => t("Convert {$ascii} to {$unicode}"),
      '#default_value' => variable_get($setting, 0),
    );
  }

  // Version Information Settings
  $version_strings = array();
  $version_strings[] = t('SmartyPants PHP version: !version', array(
    '!version' => l($GLOBALS['SmartyPantsPHPVersion'], 'http://www.michelf.com/projects/php-smartypants/'),
  ));
  $version_strings[] = t('PHP Typogrify Version: !version', array(
    '!version' => l('1.0', 'http://blog.hamstu.com/'),
  ));
  $form['typogrify_settings']['info']['typogrify_status'] = array(
    '#value' => theme('item_list', $version_strings, t('Version Information')),
  );
  return $form;
}