contrib modules security updates

This commit is contained in:
Bachir Soussi Chiadmi
2016-10-13 12:10:40 +02:00
parent ffd758abc9
commit 747127f643
732 changed files with 67976 additions and 23207 deletions

View File

@@ -6,13 +6,12 @@
*/
/**
* Implements hook_feeds_processor_targets_alter().
*
* @see FeedsProcessor::getMappingTargets()
* Implements hook_feeds_processor_targets().
*/
function text_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_name) {
function text_feeds_processor_targets($entity_type, $bundle_name) {
$targets = array();
$text_types = array(
'list_text',
'text',
'text_long',
'text_with_summary',
@@ -26,54 +25,118 @@ function text_feeds_processor_targets_alter(&$targets, $entity_type, $bundle_nam
'callback' => 'text_feeds_set_target',
'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
);
if ($info['type'] == 'text_with_summary') {
// Allow mapping to summary.
$targets[$name . ':summary'] = array(
'name' => t('@name: Summary', array('@name' => $instance['label'])),
'callback' => 'text_feeds_set_target',
'description' => t('The @label field of the entity.', array('@label' => $instance['label'])),
'real_target' => $name,
);
}
}
if (!empty($instance['settings']['text_processing'])) {
$targets[$name]['summary_callbacks'] = array('text_feeds_summary_callback');
$targets[$name]['form_callbacks'] = array('text_feeds_form_callback');
}
}
return $targets;
}
/**
* Callback for mapping text fields.
*/
function text_feeds_set_target($source, $entity, $target, $value) {
if (empty($value)) {
return;
}
function text_feeds_set_target(FeedsSource $source, $entity, $target, array $values, array $mapping) {
$language = $mapping['language'];
if (!is_array($value)) {
$value = array($value);
}
list($field_name, $column) = explode(':', $target . ':value');
if (isset($source->importer->processor->config['input_format'])) {
if ($column === 'value' && isset($source->importer->processor->config['input_format'])) {
$format = $source->importer->processor->config['input_format'];
// Add in default values.
$mapping += array(
'format' => $format,
);
}
$info = field_info_field($target);
$field = isset($entity->$field_name) ? $entity->$field_name : array($language => array());
// Iterate over all values.
$field = isset($entity->$target) ? $entity->$target : array('und' => array());
$delta = 0;
foreach ($values as $value) {
// Allow for multiple mappings to the same target.
$delta = count($field['und']);
foreach ($value as $v) {
if ($info['cardinality'] == $delta) {
break;
if (is_object($value) && $value instanceof FeedsElement) {
$value = $value->getValue();
}
if (is_object($v) && ($v instanceof FeedsElement)) {
$v = $v->getValue();
}
if (is_scalar($value) && strlen($value)) {
if (is_scalar($v)) {
$field['und'][$delta]['value'] = $v;
$field[$language][$delta][$column] = (string) $value;
if (isset($format)) {
$field['und'][$delta]['format'] = $format;
if (isset($mapping['format'])) {
$field[$language][$delta]['format'] = $mapping['format'];
}
$delta++;
}
$delta++;
}
$entity->$target = $field;
$entity->$field_name = $field;
}
/**
* Summary callback for text field targets.
*
* Displays which text format will be used for the text field target.
*
* @see text_feeds_processor_targets()
* @see text_feeds_form_callback()
*/
function text_feeds_summary_callback(array $mapping, $target, array $form, array $form_state) {
global $user;
$formats = filter_formats($user);
// Processor-wide input format setting.
$importer = feeds_importer($form['#importer']);
$default_format = !empty($importer->processor->config['input_format']) ? $importer->processor->config['input_format'] : filter_fallback_format();
$mapping += array(
'format' => $default_format,
);
return t('Text format: %format', array('%format' => $formats[$mapping['format']]->name));
}
/**
* Form callback for text field targets.
*
* Allows to select a text format for the text field target.
*
* @see text_feeds_processor_targets()
* @see text_feeds_summary_callback()
*/
function text_feeds_form_callback(array $mapping, $target, array $form, array $form_state) {
global $user;
$formats_options = array();
$formats = filter_formats($user);
foreach ($formats as $id => $format) {
$formats_options[$id] = $format->name;
}
// Processor-wide text format setting.
$importer = feeds_importer($form['#importer']);
$default_format = !empty($importer->processor->config['input_format']) ? $importer->processor->config['input_format'] : filter_fallback_format();
$mapping += array(
'format' => $default_format,
);
return array(
'format' => array(
'#type' => 'select',
'#title' => t('Text format'),
'#options' => $formats_options,
'#default_value' => $mapping['format'],
),
);
}