function feed_import_generate_path_item in Feed Import 7.3
Generate field
Parameters
int $pos: Fieldset number
array $values: Array containing default values
bool $collapsed: Inicates if fieldset is collapsed
Return value
array Fieldset containing xpath inputs
1 call to feed_import_generate_path_item()
- feed_import_fields_form in ./
feed_import.module - Fields edit form
File
- ./
feed_import.module, line 2222 - User interface, cron functions for feed_import module
Code
function feed_import_generate_path_item($pos, array $values, $collapsed = FALSE) {
$container = 'container_' . $pos;
$item[$container] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => $collapsed,
'#title' => isset($values['field']) ? $values['field'] : t('Unspecified field'),
'#attributes' => array(
'id' => 'item_container_' . $pos,
),
);
$container =& $item[$container];
$container['field'] = array(
'#type' => 'value',
'#value' => $values['field'],
);
$container['paths'] = array(
'#type' => 'textarea',
'#default_value' => is_array($values['paths']) ? implode(PHP_EOL, $values['paths']) : $values['paths'],
'#title' => t('Paths'),
'#description' => t('Enter path to item. You can enter multiple paths (one per line) until one passes pre-filter.'),
);
$container['default_action'] = array(
'#type' => 'select',
'#options' => array(
FeedImportProcessor::ACTION_DEFAULT_VALUE => t('Provide a default value'),
FeedImportProcessor::ACTION_DEFAULT_FILTERED_VALUE => t('Provide a filtered default value'),
FeedImportProcessor::ACTION_IGNORE_FIELD => t('Ignore this field'),
FeedImportProcessor::ACTION_SKIP_ITEM => t('Skip importing this entity'),
),
'#default_value' => $values['default_action'],
'#title' => t('Action when filtered result is empty'),
'#description' => t('If the filtered result is empty you can choose what action to take next.'),
'#id' => 'default_action_' . $pos,
);
$container['default_value'] = array(
'#type' => 'textarea',
'#rows' => 2,
'#default_value' => $values['default_value'],
'#title' => t('Default value'),
'#description' => t('If no path passes pre-filter then use a default value.'),
'#prefix' => '<div style="display: none;" rel="default_action_' . $pos . '">',
'#suffix' => '</div>',
);
$options = module_invoke_all('feed_import_field_merge_classes');
foreach ($options as &$option) {
$option = $option['title'];
}
$container['update_mode'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => $values['update_mode'],
'#title' => t('Field update mode'),
'#description' => t('How to update existing entities.'),
);
$container['remove_container_' . $pos] = array(
'#type' => 'button',
'#name' => 'remove_container_' . $pos,
'#value' => t('Remove field'),
'#ajax' => array(
'event' => 'click',
'wrapper' => 'item_container_' . $pos,
'method' => 'replace',
'callback' => 'feed_import_ajax_remove_item',
),
);
return $item;
}