function emimport_import in Embedded Media Field 5
1 string reference to 'emimport_import'
- emimport_menu in contrib/
emimport/ emimport.module - Implement hook_menu
File
- contrib/
emimport/ emimport.module, line 333
Code
function emimport_import($type = NULL, $form_values = NULL) {
$form = array();
if (!isset($type)) {
$list = array();
foreach (emimport_types_allowing_import() as $module => $types) {
foreach ($types as $type => $fields) {
$type = node_get_types('type', $type);
$type_url_str = str_replace('_', '-', $type->type);
$list[$type->type] = l(drupal_ucfirst($type->name), 'emimport/' . $type_url_str);
$list[$type->type] .= '<br />' . filter_xss_admin($type->description);
}
}
if (empty($list)) {
$form['list_types'] = array(
'#type' => 'markup',
'#value' => t('There are currently no content types that may import media sets from third party providers.'),
);
}
else {
$form['list_types'] = array(
'#type' => 'item',
'#title' => t('Select a type from the following list'),
'#description' => theme('item_list', $list),
);
}
return $form;
}
$media_type = array();
foreach (emimport_types_allowing_import() as $module => $types) {
foreach ($types as $content_type => $fields) {
if ($content_type == $type) {
$media_type = $fields;
$media_type_content_type = $content_type;
}
}
}
if (empty($media_type)) {
drupal_not_found();
}
$form['#multistep'] = TRUE;
$second_page = isset($form_values);
$url = $second_page ? $form_values['url'] : '';
$form['import'] = array(
'#type' => 'fieldset',
'#title' => t('Set import'),
'#collapsible' => $second_page,
'#collapsed' => $second_page,
);
$parsers = array();
foreach (emimport_types_allowing_import() as $module => $types) {
foreach ($types as $content_type => $fields) {
if ($content_type == $type) {
foreach ($fields as $field_name => $field) {
$providers = array();
$urls = array();
foreach (emfield_allowed_providers($field, $module) as $provider) {
if (emfield_include_hook($module, $provider->name, 'import')) {
$info = emfield_include_invoke($module, $provider->name, 'info');
$urls[] = l(t('@name @sets', array(
'@name' => $info['name'],
'@sets' => $info['import_sets_word'] ? $info['import_sets_word'] : t('sets'),
)), $info['url']);
$providers[$provider->name] = $info;
}
}
if (!empty($urls)) {
$textfield_title = t('@label set', array(
'@label' => $field['widget']['label'],
));
$textfield_description = t('Enter the URL or Embed Code of the media set here. The embedded third party content will be parsed and displayed appropriately from this.');
$textfield_description .= '<br />' . t('The following services are provided: !urls', array(
'!urls' => implode(', ', $urls),
));
$value = $second_page ? $form_values[$field_name] : '';
$parsers[] = array(
'#module' => $module,
'#type' => $content_type,
'#field' => $field,
'#value' => $value,
'#providers' => $providers,
);
$form['import']['fields'][$field_name] = array(
'#type' => 'textfield',
'#title' => $textfield_title,
'#description' => $textfield_description,
'#default_value' => $value,
'#disabled' => $second_page,
);
}
}
}
}
}
$form['parsers'] = array(
'#type' => 'value',
'#value' => $parsers,
);
if ($second_page) {
$form = array_merge($form, _emimport_import_codes($parsers, $form_values));
$button_text = t('Cancel');
}
else {
$form['#redirect'] = FALSE;
$button_text = t('Parse');
}
$form['parse'] = array(
'#type' => 'submit',
'#value' => $button_text,
);
return $form;
}