You are here

function xbbcode_highlighter_settings in Extensible BBCode 5

1 string reference to 'xbbcode_highlighter_settings'
xbbcode_highlighter_menu in xbbcode_highlighter/xbbcode_highlighter.module

File

xbbcode_highlighter/xbbcode_highlighter.module, line 102

Code

function xbbcode_highlighter_settings($delta = '') {
  if (!$delta) {
    $result = db_query("select id,name,enabled from {xbbcode_highlighter}");
    while ($row = db_fetch_array($result)) {
      $rows[$row['id']] = $row;
    }
    $form['help'] = array(
      '#type' => 'item',
      '#value' => t("The highlighting module has auto-discovery for individual language classes. However, to provide well-formatted tooltips, individual descriptions and code samples must be entered manually."),
    );
    $form['#tree'] = true;
    $form['codes'] = array(
      '#type' => 'fieldset',
      '#title' => t("Languages"),
      '#collapsible' => true,
    );
    if (is_array($rows)) {
      foreach ($rows as $code => $row) {
        $form['codes'][$code] = array(
          '#type' => 'fieldset',
          '#title' => $row['name'],
          '#collapsed' => true,
        );
        $form['codes'][$code]['enabled'] = array(
          '#type' => 'checkbox',
          '#default_value' => $row['enabled'],
        );
        $form['codes'][$code]['name'] = array(
          '#type' => 'textfield',
          '#default_value' => $row['name'],
        );
      }
    }
    else {
      return array(
        'error' => array(
          '#type' => 'item',
          '#title' => t("Note"),
          '#value' => t("The highlighter module could find no installed classes. You will need to import some before the module can do anything."),
        ),
      );
    }
  }
  else {
    $row = db_fetch_array(db_query("select id,name,description,sample from {xbbcode_highlighter} WHERE id = '%s'", $delta));
    $form['code'] = array(
      '#type' => 'hidden',
      '#value' => $delta,
    );
    drupal_set_title(t("Info for !lang", array(
      '!lang' => $delta,
    )));
    $form['name'] = array(
      '#type' => 'textfield',
      '#title' => t("Name"),
      '#description' => t("The properly formatted and capitalized name of this language."),
      '#default_value' => $row['name'],
    );
    $form['description'] = array(
      '#type' => 'textarea',
      '#title' => t("Description"),
      '#description' => t("Write a sentence or two about the language."),
      '#default_value' => $row['description'],
    );
    $form['sample'] = array(
      '#type' => 'textarea',
      '#title' => t("Code sample"),
      '#description' => t("Provide a sample of code (such as a Hello World program) written in this language."),
      '#default_value' => $row['sample'],
    );
  }
  return system_settings_form($form);
}