function freelinking_settings in Freelinking 7.3
Same name and namespace in other branches
- 5 freelinking.module \freelinking_settings()
- 6.3 freelinking.forms.inc \freelinking_settings()
- 6 freelinking.module \freelinking_settings()
- 6.2 freelinking.module \freelinking_settings()
Build admin/settings page.
1 string reference to 'freelinking_settings'
- freelinking_menu in ./
freelinking.module - Implements hook_menu().
File
- ./
freelinking.forms.inc, line 10 - Constructs freelinking & module admin forms.
Code
function freelinking_settings($form, &$form_state) {
$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'];
}
}
asort($available_plugins);
$available_plugins = array_merge(array(
'NONE' => t('-None-'),
), $available_plugins);
// 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 no indicator is specified. “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)';
$global_options = array(
'ignore_upi' => t('Ignore unknown plugin indicators'),
'ignore_code' => t('Ignore freelinking markup inside <code> blocks (N.I.)'),
);
$form['freelinking_options'] = array(
'#title' => t('Freelinking global options'),
'#type' => 'checkboxes',
'#description' => t('These options are not specific to a plugin. Options marked "(N.I.)" are placeholders for planned new features and not implemented yet.'),
'#options' => $global_options,
'#default_value' => variable_get('freelinking_options', array()),
);
$form['markup'] = array(
'#markup' => t('<div><strong>Increase performance</strong><br>Freelinking to nodes with access restrictions may cause access bypass if caching is enabled.</div>'),
);
$disable_cache = count(module_implements('node_grants'));
if ($disable_cache) {
variable_set('freelinking_enablecache', FALSE);
}
$form['freelinking_enablecache'] = array(
'#title' => t('Enable cache for freelinks'),
'#type' => 'checkbox',
'#default_value' => variable_get('freelinking_enablecache', FALSE),
'#disabled' => $disable_cache,
'#description' => $disable_cache ? t('Caching cannot be enabled because you have enabled modules defining node access restrictions.') : t('The cache may not be enabled even if this box is checked.'),
);
$form['freelinking_external_http_request'] = array(
'#type' => 'checkbox',
'#title' => t('Do not poll the URL for title and availability'),
'#default_value' => variable_get('freelinking_external_http_request', FALSE),
'#description' => t('Tick to not poll the URL (faster). Will show URL, nid, or short name instead of title. '),
);
// 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
$form['#submit'][] = 'freelinking_settings_submit';
return system_settings_form($form);
}