You are here

function freelinking_settings in Freelinking 6.3

Same name and namespace in other branches
  1. 5 freelinking.module \freelinking_settings()
  2. 6 freelinking.module \freelinking_settings()
  3. 6.2 freelinking.module \freelinking_settings()
  4. 7.3 freelinking.forms.inc \freelinking_settings()

Build admin/settings page.

1 string reference to 'freelinking_settings'
freelinking_menu in ./freelinking.module
Implementation of hook_menu().

File

./freelinking.forms.inc, line 12
Freelinking 3

Code

function freelinking_settings() {
  $form = array();
  $plugins = freelinking_get_plugins();
  foreach ($plugins as $plugin => $definition) {
    $available_plugins[$plugin] = drupal_ucfirst($plugin);
    if (function_exists($definition['settings']) || isset($definition['token'])) {
      $plugin_with_settings[$plugin] = $definition['settings'];
    }
  }

  // set the default plugin
  $form['freelinking_default'] = array(
    '#title' => t('Plugin to use when not indicated in the freelink'),
    '#type' => 'select',
    '#multiple' => FALSE,
    '#options' => $available_plugins,
    '#default_value' => variable_get('freelinking_default', 'nodetitle'),
    '#description' => t('Default plugin to use when not specified in text. "Nodetitle" mimics previous versions of Freelinking.'),
  );
  $syntax['double_bracket'] = t('Standard') . ' - [[plugin:target|Title]]';
  $syntax['single_bracket'] = t('Single Bracket') . ' - [plugin:target|Title]';
  $syntax['markdown'] = 'Markdown - [Title](plugin:target)';
  $form['freelinking_match_syntax'] = array(
    '#title' => t('Match Syntax Mode'),
    '#type' => 'select',
    '#default_value' => variable_get('freelinking_match_syntax', 'double_bracket'),
    '#options' => $syntax,
    '#description' => t('What syntax to use in identifying freelinks.'),
  );

  // loop through plugin settings functions, adding a fieldset for each
  foreach ($plugin_with_settings as $plugin => $callback) {
    $form[$plugin] = array(
      '#title' => t('!plugin Plugin Settings', array(
        '!plugin' => drupal_ucfirst($plugin),
      )),
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    $form[$plugin]['settings'] = call_user_func($callback);

    // If failover is already defined, let it be.
    $failover = 'freelinking_' . $plugin . '_failover';

    //    if (empty($form[$plugin]['settings'][$failover])) {
    _freelinking_failover_form($form, $plugin, $plugins[$plugin], $failover);

    //    }
  }

  // endforeach looping through plugins with settings
  return system_settings_form($form);
}