function glossify_admin_settings in Glossify 6
Same name and namespace in other branches
- 5 glossify.module \glossify_admin_settings()
- 6.3 glossify.admin.inc \glossify_admin_settings()
Form builder for administrative settings.
1 string reference to 'glossify_admin_settings'
- glossify_menu in ./
glossify.module - Implementation of hook_menu().
File
- ./
glossify.admin.inc, line 13 - Glossify Administration
Code
function glossify_admin_settings() {
$conf_key = arg(3);
if (empty($conf_key)) {
$conf_key = 'global';
}
$configurations = variable_get('glossify_configurations', NULL);
$configuration = $configurations[$conf_key];
$form['config_id'] = array(
'#type' => 'hidden',
'#value' => $conf_key,
);
if ($conf_key !== 'global') {
$form['name'] = array(
'#type' => 'textfield',
'#title' => t('Configuration name'),
'#description' => t('The name that will be displayed on the tab.'),
'#default_value' => $conf_key !== 'add' ? $conf_key : '',
);
}
$form['from'] = array(
'#type' => 'select',
'#title' => t('"Link-FROM" content types - We look for keywords into their text and replace them with links'),
'#multiple' => TRUE,
'#options' => node_get_types('names'),
'#default_value' => $configuration['from'],
);
$form['to'] = array(
'#type' => 'select',
'#title' => t('"Link-TO" content types. (node-title = keyword)'),
'#multiple' => TRUE,
'#options' => node_get_types('names'),
'#default_value' => $configuration['to'],
);
$form['only_first'] = array(
'#type' => 'checkbox',
'#title' => t('Only link first occurance of term. On by default. If unchecked all occurences are replaced.'),
'#default_value' => $configuration['only_first'],
);
$form['unicode'] = array(
'#type' => 'checkbox',
'#title' => t('Do we need Unicode compatibility?. Check this if you need Unicode support. If not checked, non-latin words would not get autolinked.<br>
If you get php warnings with this setting=On - then please update/fix your PCRE PHP-library.'),
'#default_value' => $configuration['unicode'],
);
$form['teaser'] = array(
'#type' => 'checkbox',
'#title' => t('Link content in teaser'),
'#default_value' => $configuration['teaser'],
);
$form['style'] = array(
'#type' => 'checkboxes',
'#title' => t('Style of glossary terms.'),
'#options' => array(
'hovertip' => t('Hovertips'),
'links' => t('Links'),
'reference' => t('Reference section under content'),
),
'#default_value' => isset($configuration['style']) ? $configuration['style'] : array(),
'#description' => t('How the glossary should be styled. Note: "hovertip" style requires hovertip.module. If you choose anything other than links - it should work but for now it is untested territory - feedback welcome.'),
);
$form['break'] = array(
'#type' => 'checkbox',
'#title' => t('Check this to NOT break words. This means that the keyword "bla" will not linkify the bla-part of "blade". We use this regexp to make this work: "/\\b$keyword_term\\b/".'),
'#default_value' => $configuration['break'],
);
$form['language'] = array(
'#type' => 'checkbox',
'#title' => t('Link only to same language.'),
'#default_value' => $configuration['language'],
);
$form['methods'] = array(
'#type' => 'fieldset',
'#title' => t('Methods'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['methods']['use_title'] = array(
'#type' => 'checkbox',
'#title' => t('Make use of the title field of a node.'),
'#default_value' => $configuration['methods']['use_title'],
);
$form['methods']['internal'] = array(
'#type' => 'fieldset',
'#title' => t('Internal'),
'#collapsible' => TRUE,
'#collapsed' => $configuration['methods']['use_internal'] ? FALSE : TRUE,
);
$form['methods']['internal']['use_internal'] = array(
'#type' => 'checkbox',
'#title' => t('Attach 2 additional fields to the selected Node types.'),
'#default_value' => $configuration['methods']['use_internal'],
);
if (!module_exists('content')) {
$form['methods']['cck'] = array(
'#value' => t('If you wish to use CCK Fields for your Keywords get the <a href="http://drupal.org/project/cck">CCK module</a>.'),
);
}
else {
foreach (array_keys(content_fields()) as $key) {
$all_cck_field_names[$key] = $key;
}
$all_cck_field_names['none'] = 'none';
$form['methods']['cck'] = array(
'#type' => 'fieldset',
'#title' => t('CCK'),
'#collapsible' => TRUE,
'#collapsed' => $configuration['methods']['use_cck'] ? FALSE : TRUE,
);
$form['methods']['cck']['use_cck'] = array(
'#type' => 'checkbox',
'#title' => t('Make use of CCK.'),
'#description' => t('This is mostly here to provide compatibility with older versions, but it can also be used in conjunction with the module-internal fields.'),
'#default_value' => $configuration['methods']['use_cck'],
);
$form['methods']['cck']['keyword_field'] = array(
'#type' => 'select',
'#title' => t("CCK field to look into for synonyms of the node's title. For more than 1 content type - use the same cck field please."),
'#options' => $all_cck_field_names,
'#default_value' => isset($configuration['methods']['keyword_field']) || !empty($configuration['methods']['keyword_field']) ? $configuration['methods']['keyword_field'] : NULL,
'#description' => t('Select a CCK field for synonyms.'),
);
$form['methods']['cck']['override_field'] = array(
'#type' => 'select',
'#title' => t("CCK field to look into for a 'target url override'. For more than 1 content type - use the same cck field please."),
'#options' => $all_cck_field_names,
'#default_value' => isset($configuration['methods']['override_field']) || !empty($configuration['methods']['override_field']) ? $configuration['methods']['override_field'] : NULL,
'#description' => t("Select a CCK field for target override. After you create the cck field and then put something into it\n Example: 'node/34', 'url_alias', 'http://example.com/path' this will make the target url point to your override path."),
);
}
if (!module_exists('taxonomy')) {
$form['methods']['taxonomy'] = array(
'#value' => t('In order to use a Vocabulary for your Keywords you need to enable the Taxonomy module.'),
);
}
else {
$vocabularies = array();
foreach (taxonomy_get_vocabularies() as $vid => $voc) {
$vocabularies[$vid] = $voc->name;
}
$form['methods']['taxonomy'] = array(
'#type' => 'fieldset',
'#title' => t('Taxonomy'),
'#collapsible' => TRUE,
'#collapsed' => $configuration['methods']['use_taxonomy'] ? FALSE : TRUE,
);
$form['methods']['taxonomy']['use_taxonomy'] = array(
'#type' => 'checkbox',
'#title' => t('Make use of Taxonomy.'),
'#description' => t('Note that you also have to attach the selected Vocabulary to the selected content types.'),
'#default_value' => $configuration['methods']['use_taxonomy'],
);
$form['methods']['taxonomy']['vocabulary'] = array(
'#type' => 'select',
'#title' => t("Vocabulary to look into for synonyms of the node's title."),
'#multiple' => TRUE,
'#options' => $vocabularies,
'#default_value' => $configuration['methods']['vocabulary'],
'#description' => t('Select a Vocabulary for synonyms.'),
);
}
$form['buttons']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save configuration'),
);
if (in_array($conf_key, array(
'add',
'global',
))) {
$form['buttons']['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
);
}
if ($conf_key !== 'add' && $conf_key !== 'global') {
$form['buttons']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete configuration'),
);
}
if (!empty($_POST) && form_get_errors()) {
drupal_set_message(t('The settings have not been saved because of the errors.'), 'error');
}
$form['#validate'][] = 'glossify_admin_settings_validate';
$form['#submit'][] = 'glossify_admin_settings_submit';
$form['#theme'] = 'system_settings_form';
return $form;
}