function noderelationships_admin_settings_noderef in Node Relationships 6
Node reference extras form.
1 string reference to 'noderelationships_admin_settings_noderef'
- noderelationships_admin_page in ./
noderelationships.admin.inc - Menu callback; relationships administration.
File
- ./
noderelationships.admin.inc, line 214 - Implementation of the administration pages of the module.
Code
function noderelationships_admin_settings_noderef(&$form_state, $type) {
$form = array();
$reference_fields = noderelationships_get_reference_fields($type->type);
// If this type does not have relations, then we're done here.
if (empty($reference_fields)) {
drupal_set_message(t('Could not find node reference fields referring to other content types from %type.', array(
'%type' => $type->name,
)), 'warning');
return $form;
}
$admin_help_text = t('This panel allows you to configure extra settings for <em>Node Reference</em> fields defined in the content type %type-name.
You can modify and/or clone (recommended) the default view for the <em>Search and reference</em> feature should you need to add more fields, filters or change any other option to suit your needs.
These extra options are available only to node reference fields configured to use the autocomplete widget.', array(
'%type-name' => $type->name,
));
$form['help'] = array(
'#type' => 'markup',
'#value' => theme('noderelationships_admin_help', $admin_help_text),
);
// Obtain extra nodereference settings for this type.
$noderef_settings = noderelationships_settings_load($type->type, 'noderef');
$options_search_and_reference_view = array(
'' => '<' . t('none') . '>',
) + noderelationships_get_views('noderef');
$form['search_and_reference_view'] = array(
'#tree' => TRUE,
);
$form['view_in_new_window'] = array(
'#type' => 'checkboxes',
'#default_value' => $noderef_settings['view_in_new_window'],
'#options' => array(),
);
$form['edit_reference'] = array(
'#type' => 'checkboxes',
'#default_value' => $noderef_settings['edit_reference'],
'#options' => array(),
);
$form['create_and_reference'] = array(
'#type' => 'checkboxes',
'#default_value' => $noderef_settings['create_and_reference'],
'#options' => array(),
);
if (module_exists('translation')) {
$form['translate_and_reference'] = array(
'#type' => 'checkboxes',
'#default_value' => $noderef_settings['translate_and_reference'],
'#options' => array(),
);
}
$form['#noderelationships-type'] = $type->type;
$form['#noderelationships-relations'] = array();
foreach ($reference_fields as $field_name => $referenceable_types) {
$field = content_fields($field_name, $type->type);
$form['#noderelationships-relations'][$field_name] = array(
'referenceable_types' => $referenceable_types,
'field_name' => $field_name,
'field' => $field,
);
if ($field['widget']['type'] == 'nodereference_autocomplete') {
$form['view_in_new_window']['#options'][$field_name] = t('View reference in new window');
$form['edit_reference']['#options'][$field_name] = t('Edit reference');
$form['create_and_reference']['#options'][$field_name] = t('Create and reference');
if (isset($form['translate_and_reference'])) {
$form['translate_and_reference']['#options'][$field_name] = t('Translate and reference');
}
$form['search_and_reference_view'][$field_name] = array(
'#type' => 'select',
'#title' => t('Search and reference view'),
'#default_value' => !empty($noderef_settings['search_and_reference_view'][$field_name]) ? $noderef_settings['search_and_reference_view'][$field_name] : '',
'#options' => $options_search_and_reference_view,
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save settings'),
);
return $form;
}