function finder_admin_edit in Finder 7
Same name and namespace in other branches
- 6 includes/finder.admin.inc \finder_admin_edit()
Admin finder edit page.
2 string references to 'finder_admin_edit'
- finder_i18nstrings_map_from_form in modules/
finder_i18nstrings/ finder_i18nstrings.module - Get a default map of which fields are translatable from the form.
- finder_menu in ./
finder.module - Implements hook_menu().
File
- includes/
finder.admin.inc, line 105 - The finder admin screens.
Code
function finder_admin_edit($form, &$form_state, $finder) {
// allow modules to change the finder here
finder_invoke_finderapi($finder, 'finder_admin_edit', $form, $form_state);
$form_state['storage']['finder'] = $finder;
// build the form
$form['#tree'] = TRUE;
$form['finder_id'] = array(
'#type' => 'value',
'#value' => $finder->finder_id ? $finder->finder_id : 'add',
'#weight' => 0,
);
$form['links'] = array(
'#finder' => $finder,
'#theme' => 'finder_admin_links',
'#weight' => 0,
);
$form['base'] = array(
'#type' => 'select',
'#title' => t('Finder type'),
'#default_value' => $finder->base,
'#options' => finder_admin_get_base_options(),
'#description' => t('You cannot change this.'),
'#required' => TRUE,
'#disabled' => TRUE,
'#weight' => 5,
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#default_value' => $finder->title,
'#size' => 40,
'#maxlength' => 255,
'#required' => TRUE,
'#weight' => 10,
);
$form['description'] = array(
'#type' => 'textfield',
'#title' => t('Description'),
'#default_value' => $finder->description,
'#size' => 80,
'#description' => t('This will appear on the finder administration page.'),
'#weight' => 20,
);
$form['path'] = array(
'#type' => 'textfield',
'#title' => t('Path'),
'#default_value' => $finder->path,
'#description' => t('Finder needs a URL path for some functionality. No leading or trailing slash.'),
'#size' => 30,
'#maxlength' => 128,
'#required' => TRUE,
'#weight' => 40,
);
$form['block'] = array(
'#type' => 'checkbox',
'#title' => t('Provide block'),
'#default_value' => $finder->block,
'#weight' => 50,
'#description' => t('Create a block for the finder form.'),
);
$form['settings'] = array(
'#weight' => 60,
);
$form['settings']['form_on_page'] = array(
'#type' => 'checkbox',
'#title' => t('Form on page'),
'#default_value' => $finder->settings['form_on_page'],
'#weight' => 10,
'#description' => t('Put a finder form on the path given above.'),
);
$form['settings']['form'] = array(
'#type' => 'fieldset',
'#title' => t('Form'),
'#weight' => 100,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['form']['prefix'] = array(
'#type' => 'text_format',
'#base_type' => 'textarea',
'#format' => isset($finder->settings['form']['prefix']['format']) ? $finder->settings['form']['prefix']['format'] : NULL,
'#title' => t('Prefix'),
'#default_value' => isset($finder->settings['form']['prefix']['value']) ? $finder->settings['form']['prefix']['value'] : '',
'#weight' => 10,
'#description' => t('Displayed before the form.'),
);
$form['settings']['form']['suffix'] = array(
'#type' => 'text_format',
'#base_type' => 'textarea',
'#format' => isset($finder->settings['form']['suffix']['format']) ? $finder->settings['form']['suffix']['format'] : NULL,
'#title' => t('Suffix'),
'#default_value' => isset($finder->settings['form']['suffix']['value']) ? $finder->settings['form']['suffix']['value'] : '',
'#weight' => 20,
'#description' => t('Displayed after the form.'),
);
$form['settings']['form']['button_text'] = array(
'#type' => 'textfield',
'#title' => t('Button text'),
'#default_value' => isset($finder->settings['form']['button_text']) ? $finder->settings['form']['button_text'] : t('Find'),
'#weight' => 100,
'#description' => t('Text to display on the submit button.'),
);
$form['settings']['form']['go_text'] = array(
'#type' => 'textfield',
'#title' => t('Go text'),
'#default_value' => isset($finder->settings['form']['go_text']) ? $finder->settings['form']['go_text'] : t('Go'),
'#weight' => 120,
'#description' => t('Text to display on the go button. Only used with <em>redirect to result</em> "go" button option under <em>Advanced</em>.'),
);
$form['settings']['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced'),
'#weight' => 200,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['advanced']['no_results'] = array(
'#type' => 'fieldset',
'#title' => t('No results output'),
'#weight' => 5,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$variables = array(
'keywords' => t('An array keyed by the Finder element ID, containing structured data about submitted keywords.'),
'form_state' => t('The Forms API form state array.'),
'finder' => t('Object containing data about this finder.'),
);
$form['settings']['advanced']['no_results']['no_results'] = finder_php_setting(array(
'#type' => 'textarea',
'#title' => t('No results output'),
'#default_value' => isset($finder->settings['advanced']['no_results']['no_results']) ? $finder->settings['advanced']['no_results']['no_results'] : t('There are no results to display'),
'#weight' => 5,
'#rows' => 1,
'#description' => t('
You can use a mixture of text and PHP code to print or return the
output when there are no results. PHP must be enclosed in PHP tags.
This can also be used to make context-aware redirects.'),
), array(
'keywords' => t('An array keyed by the Finder element ID, containing structured data about submitted keywords.'),
'form_state' => t('The Forms API form state array.'),
'finder' => t('Object containing data about this finder.'),
));
$form['settings']['advanced']['filter'] = array(
'#type' => 'checkbox',
'#title' => t('Show results on results page even before the form has been completed'),
'#default_value' => isset($finder->settings['advanced']['filter']) ? $finder->settings['advanced']['filter'] : 0,
'#weight' => 10,
'#description' => t('Allows this finder to behave more as a filter.'),
);
$form['settings']['advanced']['validate_empty'] = array(
'#type' => 'checkbox',
'#title' => t('Validate empty submission'),
'#default_value' => isset($finder->settings['advanced']['validate_empty']) ? $finder->settings['advanced']['validate_empty'] : 0,
'#weight' => 15,
'#description' => t('Prevent submission where all elements have empty values.'),
);
$form['settings']['advanced']['submission'] = array(
'#type' => 'checkbox',
'#title' => t('Use submit button'),
'#default_value' => isset($finder->settings['advanced']['submission']) ? $finder->settings['advanced']['submission'] : 1,
'#weight' => 20,
'#description' => t('Gives the finder a submit button.'),
);
$form['settings']['advanced']['ajax'] = array(
'#type' => 'checkbox',
'#title' => t('Use Ajax on submit button'),
'#default_value' => isset($finder->settings['advanced']['ajax']) ? $finder->settings['advanced']['ajax'] : 0,
'#weight' => 30,
'#description' => t('Dynamically update the form and results using Ajax instead of loading a whole new page.'),
);
$form['settings']['advanced']['ajax_effect'] = array(
'#type' => 'radios',
'#title' => t('Ajax effect'),
'#default_value' => isset($finder->settings['advanced']['ajax_effect']) ? $finder->settings['advanced']['ajax_effect'] : 'none',
'#weight' => 32,
'#description' => t('If using Ajax, this will be the transition effect when the update occurs.'),
'#options' => array(
'none' => t('None'),
'fade' => t('Fade'),
'slide' => t('Slide'),
),
);
$form['settings']['advanced']['ajax_remote'] = array(
'#type' => 'checkbox',
'#title' => t('Ajax block is remote control'),
'#default_value' => isset($finder->settings['advanced']['ajax_remote']) ? $finder->settings['advanced']['ajax_remote'] : 0,
'#weight' => 34,
'#description' => t('If Ajax is being used in a finder block that happens to be on the finder page, make the finder block act as a remote control for the finder page.'),
);
$form['settings']['advanced']['element_combination'] = array(
'#type' => 'radios',
'#title' => t('Multiple element result combination'),
'#default_value' => isset($finder->settings['advanced']['element_combination']) ? $finder->settings['advanced']['element_combination'] : 0,
'#weight' => 40,
'#description' => t('With multiple elements, how should the results of each element be combined on the results page?'),
'#options' => array(
0 => t('<em>Conjunction</em> - Match <em>all</em> elements using the AND operator.'),
1 => t('<em>Disjunction</em> - Match <em>any</em> element using the OR operator.'),
),
);
$form['settings']['advanced']['pager'] = array(
'#type' => 'textfield',
'#title' => t('Pager'),
'#default_value' => isset($finder->settings['advanced']['pager']) ? $finder->settings['advanced']['pager'] : '10',
'#description' => t('Number of items to show per results page. Set to 0 to disable pager.'),
'#size' => 5,
'#maxlength' => 8,
'#weight' => 50,
);
$form['settings']['advanced']['goto'] = array(
'#type' => 'radios',
'#title' => t('Redirect to result'),
'#default_value' => $finder->settings['advanced']['goto'] ? $finder->settings['advanced']['goto'] : '',
'#weight' => 80,
'#options' => array(
'' => t('Never redirect to result, always use results page.'),
'best' => t('Redirect to the only result, or show results page if there are multiple results.'),
'always' => t('Always redirect to the first result.'),
'go' => t('Use a seperate "go" button for the first result, otherwise use results page.'),
),
);
$form['settings']['advanced']['hide_args'] = array(
'#type' => 'checkbox',
'#title' => t('Hide URL arguments on results page'),
'#default_value' => isset($finder->settings['advanced']['hide_args']) ? $finder->settings['advanced']['hide_args'] : 0,
'#weight' => 160,
'#description' => t("Use the user's session to store submitted values across multiple pages. Also creates a token for multipage results to identify the stored submission"),
);
$form['settings']['advanced']['arg_sep'] = array(
'#type' => 'textfield',
'#title' => t('Multiple value URL arguments separator'),
'#default_value' => isset($finder->settings['advanced']['arg_sep']) ? $finder->settings['advanced']['arg_sep'] : ',',
'#weight' => 170,
'#description' => t('Must contain at least one character other than \' \', \'/\', \'_\', and \'-\'. If this string exists within a keyword, the keyword will be automatically enclosed in double quotes to prevent parsing issues.'),
'#size' => 5,
'#required' => TRUE,
);
$form['settings']['advanced']['empty_symbol'] = array(
'#type' => 'textfield',
'#title' => t('Empty value URL arguments symbol'),
'#default_value' => isset($finder->settings['advanced']['empty_symbol']) ? $finder->settings['advanced']['empty_symbol'] : '',
'#weight' => 172,
'#description' => t('Leave blank for default symbol (a space). You may need to set this to some other symbol or text if you are getting "forbidden" errors on results pages. Must contain at least one character other than \' \', \'/\', \'_\', and \'-\'.'),
'#size' => 5,
'#required' => FALSE,
);
$form['settings']['advanced']['show_links'] = array(
'#type' => 'checkbox',
'#title' => t('Show finder links'),
'#default_value' => isset($finder->settings['advanced']['show_links']) ? $finder->settings['advanced']['show_links'] : 1,
'#weight' => 180,
'#description' => t('Show the <em>finder links</em>.'),
);
$form['settings']['advanced']['show_admin_links'] = array(
'#type' => 'checkbox',
'#title' => t('Show finder admin links'),
'#default_value' => isset($finder->settings['advanced']['show_admin_links']) ? $finder->settings['advanced']['show_admin_links'] : 1,
'#weight' => 182,
'#description' => t('Show the <em>finder admin links</em>.'),
);
$form['settings']['advanced']['cache_finder_find'] = array(
'#type' => 'textfield',
'#title' => t('Cache duration of options and results'),
'#default_value' => isset($finder->settings['advanced']['cache_finder_find']) ? $finder->settings['advanced']['cache_finder_find'] : '0',
'#weight' => 190,
'#description' => t('Set to 0 to disable.'),
'#size' => 5,
'#required' => TRUE,
'#field_suffix' => t('minutes'),
);
if (!empty($finder->elements)) {
$form['elements'] = array(
'#title' => t('Elements'),
'#weight' => 2000,
'#theme' => 'finder_admin_edit_elements_table',
);
foreach ($finder->elements as $key => $value) {
if (empty($value->settings['choices']['field'])) {
drupal_set_message(t("Finder element %title is not configured.", array(
'%title' => $value->title,
)), 'error');
}
$element_output = '<div class="finder-element">';
$element_output .= '<div class="finder-element-title"><strong>' . check_plain($value->title) . '</strong></div>';
$element_output .= '<div class="finder-element-element">' . t('Element') . '<span class="finder-colon">:</span> <span>' . $value->element_handler['#title'] . '</span></div>';
$element_output .= '</div>';
$form['elements'][$value->finder_element_id]['value']['#markup'] = $element_output;
$form['elements'][$value->finder_element_id]['ops']['#markup'] = l(t('Edit'), 'admin/structure/finder/' . $finder->finder_id . '/' . $value->finder_element_id) . ' | ' . l(t('Delete'), 'admin/structure/finder/' . $finder->finder_id . '/' . $value->finder_element_id . '/delete');
$form['elements'][$value->finder_element_id]['weight'] = array(
'#type' => 'weight',
'#delta' => count($finder->elements),
'#default_value' => $key,
);
}
$form['elements']['#form'] = $form['elements'];
}
else {
$form['no_elements'] = array(
'#markup' => '
<div id="edit-no-elements-wrapper" class="form-item">
<label for="edit-path">' . t('Elements') . '<span class="finder-colon">:</span></label>' . t('There are currently no elements configured for this finder.') . '</div>
',
'#weight' => 100,
);
}
$form['add_element'] = array(
'#type' => 'select',
'#title' => t('Add element'),
'#default_value' => '',
'#options' => finder_admin_get_element_options(),
'#description' => t('Choose the form element to use and press %save_button.', array(
'%save_button' => t('Save finder'),
)),
'#weight' => 10000,
);
$form['actions'] = array(
'#type' => 'actions',
'#weight' => 10040,
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save finder'),
);
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete finder'),
);
$form['actions']['cancel'] = array(
'#markup' => l(t('Cancel'), 'admin/structure/finder'),
);
return $form;
}