function _emimport_import_codes in Embedded Media Field 5
1 call to _emimport_import_codes()
- emimport_import in contrib/
emimport/ emimport.module
File
- contrib/
emimport/ emimport.module, line 567
Code
function _emimport_import_codes($parsers = array()) {
$codes = array();
$found = FALSE;
foreach ($parsers as $parser) {
$module = $parser['#module'];
$type = $parser['#type'];
$field = $parser['#field'];
$value = $parser['#value'];
$providers = $parser['#providers'];
$form['info'] = array(
'#type' => 'value',
'#tree' => 1,
);
foreach ($providers as $provider => $info) {
$limit = _emfield_display_limit($module, $type, $field, $provider);
$items = emfield_include_invoke($module, $provider, 'import', $value, $limit);
if (!empty($items)) {
$codes['#module'] = $module;
$codes['#provider'] = $provider;
$codes['#set'] = $value;
$codes['#codes'] = $items;
$codes['#vid'] = _emfield_tags_vocabulary($module, $type, $field, $provider);
$codes['#content_type'] = $type;
// store the info in a tree
$form['info'][$field['field_name']] = array(
'#type' => 'value',
);
$form['info'][$field['field_name']]['provider'] = array(
'#type' => 'value',
'#value' => $provider,
);
$form['info'][$field['field_name']]['codes'] = array(
'#type' => 'value',
'#value' => $codes,
);
$form['info'][$field['field_name']]['module'] = array(
'#type' => 'value',
'#value' => $module,
);
$form['info'][$field['field_name']]['type'] = array(
'#type' => 'value',
'#value' => $type,
);
$form['info'][$field['field_name']]['field'] = array(
'#type' => 'value',
'#value' => $field,
);
// display the field/parsed thumbnails in their own fieldset
$form['fields'][$field['field_name']] = array(
'#type' => 'fieldset',
'#title' => t('Matched sets for @field', array(
'@field' => $field['widget']['label'],
)),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$count = 0;
foreach ($codes['#codes']['#set'] as $item) {
$form['fields'][$field['field_name']]['set_' . $item['#code']] = array(
'#type' => 'fieldset',
'#title' => t('Item - @title', array(
'@title' => $item['#title'],
)),
'#description' => t('Parsed from !link', array(
'!link' => l($item['#code'], emfield_include_invoke($module, $provider, 'embedded_link', $item['#code'], array()), array(
'target' => '_blank',
)),
)),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['fields'][$field['field_name']]['set_' . $item['#code']][$field['field_name'] . '_link_' . $item['#code']] = array(
'#type' => 'value',
'#value' => emfield_include_invoke($module, $provider, 'embedded_link', $item['#code']),
);
$form['fields'][$field['field_name']]['set_' . $item['#code']][$field['field_name'] . '_code_' . $item['#code']] = array(
'#type' => 'checkbox',
'#title' => t('Import this item'),
'#description' => theme('image', $item['#thumb'], $item['#title'], $item['#title'], array(), false),
'#default_value' => 1,
'#attributes' => array(
'checked' => 'checked',
),
);
$form['fields'][$field['field_name']]['set_' . $item['#code']]['overrides'] = array(
'#type' => 'fieldset',
'#title' => t('Overrides'),
'#description' => t('You may override the title and body of the imported node here.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['fields'][$field['field_name']]['set_' . $item['#code']]['overrides'][$field['field_name'] . '_title_' . $item['#code']] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#description' => t('This will be the title of this item, if imported.'),
'#default_value' => $item['#title'],
);
$form['fields'][$field['field_name']]['set_' . $item['#code']]['overrides'][$field['field_name'] . '_body_' . $item['#code']] = array(
'#type' => 'textarea',
'#title' => t('Body'),
'#description' => t('This will be the body of this item, if imported.'),
'#default_value' => $item['#body'],
'#size' => 10,
);
$vid = _emfield_tags_vocabulary($module, $type, $field, $provider);
if ($vid) {
$form['fields'][$field['field_name']]['set_' . $item['#code']]['overrides'][$field['field_name'] . '_tags_' . $item['#code']] = _emimport_form_tags($vid, $item['#tags']);
}
if ($limit && ++$count >= $limit) {
break;
}
}
$found = TRUE;
break;
}
}
}
if ($found) {
$form['found'] = array(
'#type' => 'value',
'#value' => TRUE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Import'),
);
}
return $form;
}