You are here

function geshifilter_admin_settings_form in GeSHi Filter for syntax highlighting 5

Admin page linked from menu

1 string reference to 'geshifilter_admin_settings_form'
geshifilter_menu in ./geshifilter.module
Implementation of hook_menu()

File

./geshifilter.module, line 115

Code

function geshifilter_admin_settings_form() {
  $form = array();

  // GeSHi library
  $form['geshi_library'] = array(
    '#type' => 'fieldset',
    '#title' => t('GeSHi library'),
    '#collapsible' => true,
  );
  $form['geshi_library']['geshifilter_geshi_dir'] = array(
    '#type' => 'textfield',
    '#title' => t('GeSHi Directory'),
    '#default_value' => variable_get('geshifilter_geshi_dir', drupal_get_path('module', 'geshifilter') . '/geshi'),
    '#description' => t('Location of directory where geshi.php is. i.e: "modules/geshifilter/geshi" (without quotes).'),
    '#required' => TRUE,
  );
  $form['geshi_library']['geshifilter_lang_dir'] = array(
    '#type' => 'textfield',
    '#title' => t('Languages directory'),
    '#default_value' => variable_get('geshifilter_lang_dir', drupal_get_path('module', 'geshifilter') . '/geshi/geshi'),
    '#description' => t('Location where GeSHi languages files reside. Languages files are files with the names of languages, ended with .php extension. i.e: "modules/geshifilter/geshi/geshi" (without quotes).'),
    '#required' => TRUE,
  );

  // load GeSHi library for defined constants and present the
  // GeSHi filter settings if successful
  if (_geshifilter_load_geshi()) {
    $form['geshi_theming'] = array(
      '#type' => 'fieldset',
      '#title' => t('Theming, styling and CSS'),
    );

    // Code container
    $form['geshi_theming']['geshifilter_code_container'] = array(
      '#type' => 'radios',
      '#title' => t('Code Container'),
      '#default_value' => variable_get('geshifilter_code_container', GESHI_HEADER_PRE),
      '#options' => array(
        GESHI_HEADER_PRE => t('Use <pre> container'),
        GESHI_HEADER_DIV => t('Use <div> container'),
        GESHI_HEADER_NONE => t('No container'),
      ),
      '#description' => t('Define the container element to put the highlighted source code in. (GeSHi documentation: !link).', array(
        '!link' => l('The Code Container', 'http://qbnz.com/highlighter/geshi-doc.html#the-code-container'),
      )),
    );

    // CSS mode
    $form['geshi_theming']['geshifilter_css_mode'] = array(
      '#type' => 'radios',
      '#title' => t('CSS mode'),
      '#default_value' => variable_get('geshifilter_css_mode', GESHIFILTER_CSS_INLINE),
      '#options' => array(
        GESHIFILTER_CSS_INLINE => t('Use in-line styles'),
        GESHIFILTER_CSS_CLASSES => t('Use CSS classes'),
      ),
      '#description' => t('Using CSS classes to highlight your code instead of in-lining the styles is more compliant (the style attribute is deprecating in XHTML 2.0) and results in far less outputted code (GeSHi documentation: !link).', array(
        '!link' => l('Using CSS Classes', 'http://qbnz.com/highlighter/geshi-doc.html#using-css-classes'),
      )),
    );

    // Line numbers
    $form['geshi_theming']['geshifilter_line_numbers'] = array(
      '#type' => 'radios',
      '#title' => t('Line Numbers'),
      '#default_value' => variable_get('geshifilter_line_numbers', GESHI_NO_LINE_NUMBERS),
      '#options' => array(
        GESHI_NO_LINE_NUMBERS => t('Disable line numbers'),
        GESHI_NORMAL_LINE_NUMBERS => t('Use normal line numbering'),
        GESHI_FANCY_LINE_NUMBERS => t('Use fancy line numbering'),
      ),
      '#description' => t('Add line numbers to code. Fancy line numbers means that you can specify a different style for each n<sup>th</sup> line number (GeSHi documentation: !link).', array(
        '!link' => l('Line Numbers', 'http://qbnz.com/highlighter/geshi-doc.html#line-numbers'),
      )),
    );
    $form['geshi_theming']['geshifilter_fancy_number'] = array(
      '#type' => 'textfield',
      '#size' => 2,
      '#maxlength' => 2,
      '#title' => t('Fancy number each'),
      '#default_value' => variable_get('geshifilter_fancy_number', 5),
      '#description' => t('Line numbers will be styled with a different style every n line numbers. (GeSHi documentation: !link).', array(
        '!link' => l('Line Numbers', 'http://qbnz.com/highlighter/geshi-doc.html#line-numbers'),
      )),
    );
    $form['geshi_theming']['geshifilter_start_attribute'] = array(
      '#type' => 'checkbox',
      '#title' => t('Allow <em>start</em> attribute'),
      '#default_value' => variable_get('geshifilter_start_attribute', FALSE),
      '#description' => t('Allow users to make the line numbers start at any number using the <em>start=number</em> attribute. This feature will break XHTML strict compliancy (GeSHi documentation: !link).', array(
        '!link' => l('Choosing a Start Number', 'http://qbnz.com/highlighter/geshi-doc.html#starting-line-numbers'),
      )),
    );

    // inline styles
    $form['inline'] = array(
      '#type' => 'fieldset',
      '#title' => t('In-line styles'),
      '#collapsible' => true,
      '#collapsed' => true,
    );
    $form['inline']['geshifilter_overall_style'] = array(
      '#type' => 'textfield',
      '#maxlength' => 255,
      '#title' => t('Overall code block style'),
      '#default_value' => variable_get('geshifilter_overall_style', ''),
      '#description' => t('Style the overall code block. For example, you can set the border style/colour, any margins and padding etc. (GeSHi documentation: !link).', array(
        '!link' => l('The Overall Styles', 'http://qbnz.com/highlighter/geshi-doc.html#the-overall-styles'),
      )),
    );
    $form['inline']['geshifilter_number_style'] = array(
      '#type' => 'textfield',
      '#maxlength' => 255,
      '#title' => t('Line number style'),
      '#default_value' => variable_get('geshifilter_number_style', ''),
      '#description' => t('(GeSHi documentation: !link).', array(
        '!link' => l('Line Number Styles', 'http://qbnz.com/highlighter/geshi-doc.html#line-number-styles'),
      )),
    );
    $form['inline']['geshifilter_fancy_number_style'] = array(
      '#type' => 'textfield',
      '#maxlength' => 255,
      '#title' => t('Fancy line number style'),
      '#default_value' => variable_get('geshifilter_fancy_number_style', 'font-weight: bold;'),
      '#description' => t('(GeSHi documentation: !link).', array(
        '!link' => l('Line Number Styles', 'http://qbnz.com/highlighter/geshi-doc.html#line-number-styles'),
      )),
    );
    $form['inline']['geshifilter_code_style'] = array(
      '#type' => 'textfield',
      '#maxlength' => 255,
      '#title' => t('Code style'),
      '#default_value' => variable_get('geshifilter_code_style', 'font-weight: normal;'),
      '#description' => t('Explicitly override the styles you set for line numbers (GeSHi documentation: !link).', array(
        '!link' => l('Styling Line Numbers', 'http://qbnz.com/highlighter/geshi-doc.html#styling-line-numbers'),
      )),
    );
  }
  return system_settings_form($form);
}