function customfilter_export_form in Custom filter 7
Same name and namespace in other branches
- 5 customfilter.module \customfilter_export_form()
- 6 customfilter.admin.inc \customfilter_export_form()
- 7.2 customfilter.module \customfilter_export_form()
Create the form to export a filter.
This function create the form used in admin/settings/customfilter/tools.
@todo See if there is a better way to store the current step than using a session variable.
Parameters
$variables:
$form_state:
Return value
array return a form to be rendered by Drupal.
1 string reference to 'customfilter_export_form'
- customfilter_menu in ./
customfilter.module - Implements hook_menu().
File
- ./
customfilter.module, line 606 - Allows the users with the right permission to define custom filters.
Code
function customfilter_export_form($variables, &$form_state) {
$form = array();
$filters = _customfilter_get_filters();
if (isset($_SESSION['customfilter_storage'])) {
$form_state['storage'] = $_SESSION['customfilter_storage'];
}
else {
$form_state['storage'] = NULL;
}
$step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] : 1;
switch ($step) {
case 1:
if ($filters) {
foreach ($filters as $filter) {
$opt[$filter['fid']] = check_plain($filter['name']);
}
$form['#filters'] = $filters;
$form['filters'] = array(
'#type' => 'radios',
'#title' => t('Filters'),
'#description' => 'Choose the filter to export.',
'#options' => $opt,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Export',
);
}
else {
$form['filters'] = array(
'#value' => '<p>' . t('There are no custom filters defined.') . '</p>',
);
}
break;
case 2:
if ($form_state['storage']['export_data']) {
$form['export'] = array(
'#type' => 'textarea',
'#title' => t('Export data'),
'#description' => t('Copy the export text and paste it into the import form.'),
'#cols' => 60,
'#default_value' => $form_state['storage']['export_data'],
'#rows' => 40,
);
}
else {
$form['export'] = array(
'#value' => '<p>' . t('The selected filter has not been found in the database table.') . '</p>',
);
}
$form_state['storage']['step'] = 1;
break;
}
$_SESSION['customfilter_storage'] = $form_state['storage'];
return $form;
}