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

@@ -93,23 +93,17 @@ function feeds_ui_overview_form($form, &$form_status) {
$importer_form['status'] = array(
'#markup' => $status,
);
if (!$importer->disabled) {
$importer_form['operations'] = array(
'#markup' =>
l($edit, 'admin/structure/feeds/' . $importer->id) . ' | ' .
l(t('Export'), 'admin/structure/feeds/' . $importer->id . '/export') . ' | ' .
l(t('Clone'), 'admin/structure/feeds/' . $importer->id . '/clone') .
(empty($delete) ? '' : ' | ' . l($delete, 'admin/structure/feeds/' . $importer->id . '/delete')),
);
}
else {
$importer_form['operations']['#markup'] = ' ';
}
$importer_form['operations'] = array(
'#markup' =>
l($edit, 'admin/structure/feeds/' . $importer->id) . ' | ' .
l(t('Export'), 'admin/structure/feeds/' . $importer->id . '/export') . ' | ' .
l(t('Clone'), 'admin/structure/feeds/' . $importer->id . '/clone') .
(empty($delete) ? '' : ' | ' . l($delete, 'admin/structure/feeds/' . $importer->id . '/delete')),
);
$importer_form[$importer->id] = array(
'#type' => 'checkbox',
'#default_value' => !$importer->disabled,
'#attributes' => array('class' => array('feeds-ui-trigger-submit')),
);
if ($importer->disabled) {
@@ -122,7 +116,6 @@ function feeds_ui_overview_form($form, &$form_status) {
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -150,7 +143,6 @@ function feeds_ui_overview_form_submit($form, &$form_state) {
* of $from_importer.
*/
function feeds_ui_create_form($form, &$form_state, $from_importer = NULL) {
$form['#attached']['js'][] = drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js';
$form['#from_importer'] = $from_importer;
$form['name'] = array(
'#type' => 'textfield',
@@ -281,10 +273,10 @@ function feeds_ui_export_form($form, &$form_state, $importer) {
/**
* Edit feed configuration.
*/
function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
function feeds_ui_edit_page(FeedsImporter $importer, $active = 'help', $plugin_key = '') {
// Get plugins and configuration.
$plugins = FeedsPlugin::all();
$config = $importer->config;
// Base path for changing the active container.
$path = 'admin/structure/feeds/' . $importer->id;
@@ -299,12 +291,14 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$active_container['body'] = '<div class="help feeds-admin-ui">' . feeds_ui_edit_help() . '</div>';
unset($active_container['actions']);
break;
case 'fetcher':
case 'parser':
case 'processor':
$active_container['title'] = t('Select a !plugin_type', array('!plugin_type' => $active));
$active_container['body'] = drupal_get_form('feeds_ui_plugin_form', $importer, $active);
break;
case 'settings':
drupal_add_js(drupal_get_path('module', 'ctools') . '/js/dependent.js');
ctools_include('dependent');
@@ -319,8 +313,10 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$active_container['body'] = feeds_get_form($plugin, 'configForm');
}
break;
case 'mapping':
$active_container['title'] = t('Mapping for !processor', array('!processor' => $plugins[$config['processor']['plugin_key']]['name']));
$processor_name = isset($plugins[$config['processor']['plugin_key']]['name']) ? $plugins[$config['processor']['plugin_key']]['name'] : $plugins['FeedsMissingPlugin']['name'];
$active_container['title'] = t('Mapping for @processor', array('@processor' => $processor_name));
$active_container['body'] = drupal_get_form('feeds_ui_mapping_form', $importer);
break;
}
@@ -354,9 +350,9 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$config_info[] = $info;
// Fetcher.
$fetcher = $plugins[$config['fetcher']['plugin_key']];
$fetcher = isset($plugins[$config['fetcher']['plugin_key']]) ? $plugins[$config['fetcher']['plugin_key']] : $plugins['FeedsMissingPlugin'];
$actions = array();
if (feeds_get_form($importer->fetcher, 'configForm')) {
if ($importer->fetcher->hasConfigForm()) {
$actions = array(l(t('Settings'), $path . '/settings/' . $config['fetcher']['plugin_key']));
}
$info['title'] = t('Fetcher');
@@ -371,9 +367,9 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$config_info[] = $info;
// Parser.
$parser = $plugins[$config['parser']['plugin_key']];
$parser = isset($plugins[$config['parser']['plugin_key']]) ? $plugins[$config['parser']['plugin_key']] : $plugins['FeedsMissingPlugin'];
$actions = array();
if (feeds_get_form($importer->parser, 'configForm')) {
if ($importer->parser->hasConfigForm()) {
$actions = array(l(t('Settings'), $path . '/settings/' . $config['parser']['plugin_key']));
}
$info['title'] = t('Parser');
@@ -388,9 +384,9 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
$config_info[] = $info;
// Processor.
$processor = $plugins[$config['processor']['plugin_key']];
$processor = isset($plugins[$config['processor']['plugin_key']]) ? $plugins[$config['processor']['plugin_key']] : $plugins['FeedsMissingPlugin'];
$actions = array();
if (feeds_get_form($importer->processor, 'configForm')) {
if ($importer->processor->hasConfigForm()) {
$actions[] = l(t('Settings'), $path . '/settings/' . $config['processor']['plugin_key']);
}
$actions[] = l(t('Mapping'), $path . '/mapping');
@@ -427,24 +423,25 @@ function feeds_ui_edit_page($importer, $active = 'help', $plugin_key = '') {
function feeds_ui_plugin_form($form, &$form_state, $importer, $type) {
$plugins = FeedsPlugin::byType($type);
$form = array();
$form['#importer'] = $importer->id;
$form['#plugin_type'] = $type;
$importer_key = $importer->config[$type]['plugin_key'];
foreach ($plugins as $key => $plugin) {
$form['plugin_key'][$key] = array(
'#type' => 'radio',
'#parents' => array('plugin_key'),
'#title' => check_plain($plugin['name']),
'#description' => filter_xss(isset($plugin['help']) ? $plugin['help'] : $plugin['description']),
'#return_value' => $key,
'#default_value' => ($plugin['handler']['class'] == get_class($importer->$type)) ? $key : '',
'#default_value' => ($key == $importer_key) ? $key : '',
);
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -465,7 +462,6 @@ function feeds_ui_plugin_form_submit($form, &$form_state) {
*/
function theme_feeds_ui_plugin_form($variables) {
$form = $variables['form'];
drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
$output = '';
foreach (element_children($form['plugin_key']) as $key) {
@@ -495,21 +491,31 @@ function theme_feeds_ui_plugin_form($variables) {
* FeedsProcessor, a flag can tell whether mapping is supported or not.
*/
function feeds_ui_mapping_form($form, &$form_state, $importer) {
drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
$form = array();
$form['#importer'] = $importer->id;
$form['#mappings'] = $mappings = $importer->processor->getMappings();
$form['help']['#markup'] = feeds_ui_mapping_help();
$form['#prefix'] = '<div id="feeds-ui-mapping-form-wrapper">';
$form['#suffix'] = '</div>';
// Show message when target configuration gets changed.
if (!empty($form_state['mapping_settings'])) {
$form['#mapping_settings'] = $form_state['mapping_settings'];
$form['changed'] = array(
'#theme_wrappers' => array('container'),
'#attributes' => array('class' => array('messages', 'warning')),
'#markup' => t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'),
);
}
// Get mapping sources from parsers and targets from processor, format them
// for output.
// Some parsers do not define mapping sources but let them define on the fly.
if ($sources = $importer->parser->getMappingSources()) {
$source_options = _feeds_ui_format_options($sources);
foreach ($sources as $k => $source) {
if (!empty($source['deprecated'])) {
continue;
}
$legend['sources'][$k]['name']['#markup'] = empty($source['name']) ? $k : $source['name'];
$legend['sources'][$k]['description']['#markup'] = empty($source['description']) ? '' : $source['description'];
}
@@ -521,6 +527,9 @@ function feeds_ui_mapping_form($form, &$form_state, $importer) {
$target_options = _feeds_ui_format_options($targets);
$legend['targets'] = array();
foreach ($targets as $k => $target) {
if (!empty($target['deprecated'])) {
continue;
}
$legend['targets'][$k]['name']['#markup'] = empty($target['name']) ? $k : $target['name'];
$legend['targets'][$k]['description']['#markup'] = empty($target['description']) ? '' : $target['description'];
}
@@ -572,31 +581,36 @@ function feeds_ui_mapping_form($form, &$form_state, $importer) {
if (isset($source_options)) {
$form['source'] = array(
'#type' => 'select',
'#options' => array('' => t('Select a source')) + $source_options,
'#title' => t('Source'),
'#title_display' => 'invisible',
'#options' => $source_options,
'#empty_option' => t('- Select a source -'),
'#description' => t('An element from the feed.'),
);
}
else {
$form['source'] = array(
'#type' => 'textfield',
'#title' => t('Source'),
'#title_display' => 'invisible',
'#size' => 20,
'#default_value' => t('Name of source field'),
'#attributes' => array('class' => array('hide-text-on-focus')),
'#default_value' => '',
'#description' => t('The name of source field.'),
);
}
$form['target'] = array(
'#type' => 'select',
'#options' => array('' => t('Select a target')) + $target_options,
'#title' => t('Target'),
'#title_display' => 'invisible',
'#options' => $target_options,
'#empty_option' => t('- Select a target -'),
'#description' => t('The field that stores the data.'),
);
$form['add'] = array(
'#type' => 'submit',
'#value' => t('Add'),
'#submit' => array('feeds_ui_mapping_form_add_submit'),
'#validate' => array('feeds_ui_mapping_form_add_validate'),
);
$form['save'] = array(
$form['actions'] = array('#type' => 'actions');
$form['actions']['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#attributes' => array('class' => array('feeds-ui-hidden-submit')),
);
return $form;
}
@@ -626,12 +640,10 @@ function feeds_ui_mapping_settings_form($form, $form_state, $i, $mapping, $targe
}
if ($form_state['mapping_settings_edit'] === $i) {
// Build the form.
if (isset($target['form_callback'])) {
$settings_form = call_user_func($target['form_callback'], $mapping, $target, $form, $form_state);
}
else {
$settings_form = array();
$settings_form = array();
foreach ($target['form_callbacks'] as $callback) {
$settings_form += call_user_func($callback, $mapping, $target, $form, $form_state);
}
// Merge in the optional unique form.
@@ -656,13 +668,15 @@ function feeds_ui_mapping_settings_form($form, $form_state, $i, $mapping, $targe
}
else {
// Build the summary.
if (isset($target['summary_callback'])) {
$summary = call_user_func($target['summary_callback'], $mapping, $target, $form, $form_state);
}
else {
$summary = '';
$summary = array();
foreach ($target['summary_callbacks'] as $callback) {
$summary[] = call_user_func($callback, $mapping, $target, $form, $form_state);
}
// Filter out empty summary values.
$summary = implode('<br />', array_filter($summary));
// Append the optional unique summary.
if ($optional_unique_summary = feeds_ui_mapping_settings_optional_unique_summary($mapping, $target, $form, $form_state)) {
$summary .= ' ' . $optional_unique_summary;
@@ -685,6 +699,7 @@ function feeds_ui_mapping_settings_form($form, $form_state, $i, $mapping, $targe
);
}
}
return array();
}
/**
@@ -721,40 +736,36 @@ function feeds_ui_mapping_settings_form_callback($form, $form_state) {
}
/**
* Validation for source and target selection.
* Validation handler for feeds_ui_mapping_form().
*/
function feeds_ui_mapping_form_add_validate($form, &$form_state) {
if ($form_state['values']['source'] == '') {
form_set_error('source', t('You must select a mapping source.'));
}
if ($form_state['values']['target'] == '') {
form_set_error('target', t('You must select a mapping target.'));
function feeds_ui_mapping_form_validate($form, &$form_state) {
if (!strlen($form_state['values']['source']) xor !strlen($form_state['values']['target'])) {
// Check triggering_element here so we can react differently for ajax
// submissions.
switch ($form_state['triggering_element']['#name']) {
// Regular form submission.
case 'op':
if (!strlen($form_state['values']['source'])) {
form_error($form['source'], t('You must select a mapping source.'));
}
else {
form_error($form['target'], t('You must select a mapping target.'));
}
break;
// Be more relaxed on ajax submission.
default:
form_set_value($form['source'], '', $form_state);
form_set_value($form['target'], '', $form_state);
break;
}
}
}
/**
* Submit handler for add button on feeds_ui_mapping_form().
*/
function feeds_ui_mapping_form_add_submit($form, &$form_state) {
$importer = feeds_importer($form['#importer']);
try {
$mappings = $form['#mappings'];
$mappings[] = array(
'source' => $form_state['values']['source'],
'target' => $form_state['values']['target'],
'unique' => FALSE,
);
$importer->processor->addConfig(array('mappings' => $mappings));
$importer->save();
drupal_set_message(t('Mapping has been added.'));
}
catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
}
}
/**
* Submit handler for save button on feeds_ui_mapping_form().
* Submission handler for feeds_ui_mapping_form().
*/
function feeds_ui_mapping_form_submit($form, &$form_state) {
$importer = feeds_importer($form['#importer']);
@@ -787,6 +798,7 @@ function feeds_ui_mapping_form_submit($form, &$form_state) {
foreach ($remove_flags as $k) {
unset($mappings[$k]);
unset($form_state['values']['mapping_weight'][$k]);
drupal_set_message(t('Mapping has been removed.'), 'status', FALSE);
}
}
@@ -798,6 +810,23 @@ function feeds_ui_mapping_form_submit($form, &$form_state) {
}
$processor->addConfig(array('mappings' => $mappings));
if (strlen($form_state['values']['source']) && strlen($form_state['values']['target'])) {
try {
$mappings = $processor->getMappings();
$mappings[] = array(
'source' => $form_state['values']['source'],
'target' => $form_state['values']['target'],
'unique' => FALSE,
);
$processor->addConfig(array('mappings' => $mappings));
drupal_set_message(t('Mapping has been added.'));
}
catch (Exception $e) {
drupal_set_message($e->getMessage(), 'error');
}
}
$importer->save();
drupal_set_message(t('Your changes have been saved.'));
}
@@ -807,11 +836,17 @@ function feeds_ui_mapping_form_submit($form, &$form_state) {
* FeedsProcessor::getMappingTargets() and format them into
* a Form API options array.
*/
function _feeds_ui_format_options($options) {
function _feeds_ui_format_options($options, $show_deprecated = FALSE) {
$result = array();
foreach ($options as $k => $v) {
if (!$show_deprecated && is_array($v) && !empty($v['deprecated'])) {
continue;
}
if (is_array($v) && !empty($v['name'])) {
$result[$k] = $v['name'];
$result[$k] = $v['name'] . ' (' . $k . ')';
if (!empty($v['deprecated'])) {
$result[$k] .= ' - ' . t('DEPRECATED');
}
}
elseif (is_array($v)) {
$result[$k] = $k;
@@ -862,7 +897,6 @@ function feeds_ui_mapping_settings_optional_unique_form($mapping, $target, $form
*/
function theme_feeds_ui_overview_form($variables) {
$form = $variables['form'];
drupal_add_js(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.js');
drupal_add_css(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.css');
// Iterate through all importers and build a table.
@@ -908,7 +942,7 @@ function theme_feeds_ui_edit_page($variables) {
drupal_add_css(drupal_get_path('module', 'feeds_ui') . '/feeds_ui.css');
// Outer wrapper.
$output = '<div class="feeds-settings clear-block">';
$output = '<div class="feeds-settings clearfix">';
// Build left bar.
$output .= '<div class="left-bar">';
@@ -995,6 +1029,13 @@ function theme_feeds_ui_container($variables) {
function theme_feeds_ui_mapping_form($variables) {
$form = $variables['form'];
$targets = feeds_importer($form['#importer'])->processor->getMappingTargets();
$targets = _feeds_ui_format_options($targets, TRUE);
$sources = feeds_importer($form['#importer'])->parser->getMappingSources();
// Some parsers do not define source options.
$sources = $sources ? _feeds_ui_format_options($sources, TRUE) : array();
// Build the actual mapping table.
$header = array(
t('Source'),
@@ -1006,12 +1047,15 @@ function theme_feeds_ui_mapping_form($variables) {
$rows = array();
if (is_array($form['#mappings'])) {
foreach ($form['#mappings'] as $i => $mapping) {
// Some parsers do not define source options.
$source = isset($form['source']['#options'][$mapping['source']]) ? $form['source']['#options'][$mapping['source']] : $mapping['source'];
$target = isset($form['target']['#options'][$mapping['target']]) ? check_plain($form['target']['#options'][$mapping['target']]) : '<em>' . t('Missing') . '</em>';
$source = isset($sources[$mapping['source']]) ? check_plain($sources[$mapping['source']]) : check_plain($mapping['source']);
$target = isset($targets[$mapping['target']]) ? check_plain($targets[$mapping['target']]) : '<em>' . t('Missing') . '</em>';
// Add indicator to target if target configuration changed.
if (isset($form['#mapping_settings'][$i])) {
$target .= '<span class="warning">*</span>';
}
$rows[] = array(
'data' => array(
check_plain($source),
$source,
$target,
drupal_render($form['config'][$i]),
drupal_render($form['remove_flags'][$i]),
@@ -1036,7 +1080,12 @@ function theme_feeds_ui_mapping_form($variables) {
drupal_render($form['add']),
'',
);
$output = '<div class="help feeds-admin-ui">' . drupal_render($form['help']) . '</div>';
$output = '';
if (!empty($form['changed'])) {
// This form element is only available if target configuration changed.
$output .= drupal_render($form['changed']);
}
$output .= '<div class="help feeds-admin-ui">' . drupal_render($form['help']) . '</div>';
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => 'feeds-ui-mapping-overview')));
// Build the help table that explains available sources.
@@ -1057,7 +1106,7 @@ function theme_feeds_ui_mapping_form($variables) {
$rows = array();
foreach (element_children($form['legendset']['legend']['targets']) as $k) {
$rows[] = array(
check_plain(drupal_render($form['legendset']['legend']['targets'][$k]['name'])),
check_plain(drupal_render($form['legendset']['legend']['targets'][$k]['name']) . ' (' . $k . ')'),
check_plain(drupal_render($form['legendset']['legend']['targets'][$k]['description'])),
);
}
@@ -1075,3 +1124,114 @@ function theme_feeds_ui_mapping_form($variables) {
drupal_add_tabledrag('feeds-ui-mapping-overview', 'order', 'sibling', 'feeds-ui-mapping-weight');
return $output;
}
/**
* Page callback to import a Feeds importer.
*/
function feeds_ui_importer_import($form, &$form_state) {
$form['id'] = array(
'#type' => 'textfield',
'#title' => t('Importer id'),
'#description' => t('Enter the id to use for this importer if it is different from the source importer. Leave blank to use the id of the importer.'),
);
$form['id_override'] = array(
'#type' => 'checkbox',
'#title' => t('Replace an existing importer if one exists with the same id.'),
);
$form['bypass_validation'] = array(
'#type' => 'checkbox',
'#title' => t('Bypass importer validation'),
'#description' => t('Bypass the validation of plugins when importing.'),
);
$form['importer'] = array(
'#type' => 'textarea',
'#rows' => 10,
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Import'),
);
return $form;
}
/**
* Form validation handler for feeds_ui_importer_import().
*
* @see feeds_ui_importer_import_submit()
*/
function feeds_ui_importer_import_validate($form, &$form_state) {
$form_state['values']['importer'] = trim($form_state['values']['importer']);
$form_state['values']['id'] = trim($form_state['values']['id']);
if (!empty($form_state['values']['id']) && preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['id'])) {
form_error($form['id'], t('Feeds importer id must be alphanumeric with underscores only.'));
}
if (substr($form_state['values']['importer'], 0, 5) == '<?php') {
$form_state['values']['importer'] = substr($form_state['values']['importer'], 5);
}
$feeds_importer = NULL;
ob_start();
eval($form_state['values']['importer']);
ob_end_clean();
if (!is_object($feeds_importer)) {
return form_error($form['importer'], t('Unable to interpret Feeds importer code.'));
}
if (empty($feeds_importer->api_version) || $feeds_importer->api_version < 1) {
form_error($form['importer'], t('The importer is not compatible with this version of Feeds.'));
}
elseif (version_compare($feeds_importer->api_version, feeds_api_version(), '>')) {
form_error($form['importer'], t('That importer is created for the version %import_version of Feeds, but you only have version %api_version.', array(
'%import_version' => $feeds_importer->api_version,
'%api_version' => feeds_api_version())));
}
// Change to user-supplied id.
if ($form_state['values']['id']) {
$feeds_importer->id = $form_state['values']['id'];
}
$exists = feeds_ui_importer_machine_name_exists($feeds_importer->id);
if ($exists && !$form_state['values']['id_override']) {
if (feeds_importer($feeds_importer->id)->export_type != EXPORT_IN_CODE) {
return form_error($form['id'], t('Feeds importer already exists with that id.'));
}
}
if (!$form_state['values']['bypass_validation']) {
foreach (array('fetcher', 'parser', 'processor') as $type) {
$plugin = feeds_plugin($feeds_importer->config[$type]['plugin_key'], $feeds_importer->id);
if (get_class($plugin) == 'FeedsMissingPlugin') {
form_error($form['importer'], t('The plugin %plugin is unavailable.', array('%plugin' => $feeds_importer->config[$type]['plugin_key'])));
}
}
}
$form_state['importer'] = $feeds_importer;
}
/**
* Form submission handler for feeds_ui_importer_import().
*
* @see feeds_ui_importer_import_validate()
*/
function feeds_ui_importer_import_submit($form, &$form_state) {
$importer = $form_state['importer'];
// Create a copy of the importer to preserve config.
$save = feeds_importer($importer->id);
$save->setConfig($importer->config);
foreach (array('fetcher', 'parser', 'processor') as $type) {
$save->setPlugin($importer->config[$type]['plugin_key']);
$save->$type->setConfig($importer->config[$type]['config']);
}
$save->save();
drupal_set_message(t('Successfully imported the %id feeds importer.', array('%id' => $importer->id)));
$form_state['redirect'] = 'admin/structure/feeds';
}

View File

@@ -1,90 +1,106 @@
/* Feeds admin overview form. */
table.feeds-admin-importers thead th {
border: none;
}
}
table.feeds-admin-importers td.disabled {
color: #aaa;
}
}
table.feeds-admin-importers tr.disabled.odd,
table.feeds-admin-importers tr.disabled.even {
border-color: #eee;
}
}
table.feeds-admin-importers tr.disabled.odd {
background-color: #f5f5f5;
}
}
/* Feeds edit form layout. */
div.feeds-settings {
}
}
div.left-bar {
float: left;
position: relative;
width: 240px;
border-right: 1px solid #DDD;
padding: 10px 10px 0 0;
}
}
div.configuration {
padding: 10px 0 0 250px;
margin-left: -240px;
}
div.configuration-squeeze {
margin-left: 250px;
}
}
div.configuration-squeeze {
margin-left: 250px;
}
/* Container theming. */
div.feeds-container {
}
}
div.feeds-container h4 {
font-size: 1.2em;
font-weight: bold;
}
}
div.feeds-container.plain {
background-color: #EEE;
border-bottom: 1px solid #DDD;
border-top: 2px solid #DDD;
padding: 5px;
margin: 10px 0;
}
div.feeds-container.plain h4 {
font-size: 1.0em;
margin: 0;
padding: 0;
}
div.feeds-container-body p {
padding: 5px 0;
margin: 0;
}
div.feeds-container-body div.item-list ul {
margin: 0;
}
div.feeds-container-body div.item-list ul li {
list-style-type: none;
margin: 0;
padding: 0;
background-image: none;
}
ul.container-actions {
font-family: Arial, Helvetica;
float: right;
margin: 0;
}
ul.container-actions li {
list-style-type: none;
text-align: right;
background-image: none;
margin: 0;
padding: 0;
}
ul.container-actions .form-item,
ul.container-actions li form,
ul.container-actions li form input {
padding: 0;
margin: 0;
display: inline;
}
}
div.feeds-container.plain h4 {
font-size: 1.0em;
margin: 0;
padding: 0;
}
div.feeds-container-body p {
padding: 5px 0;
margin: 0;
}
div.feeds-container-body div.item-list ul {
margin: 0;
}
div.feeds-container-body div.item-list ul li {
list-style-type: none;
margin: 0;
padding: 0;
background-image: none;
}
ul.container-actions {
font-family: Arial, Helvetica;
float: right;
margin: 0;
}
ul.container-actions li {
list-style-type: none;
text-align: right;
background-image: none;
margin: 0;
padding: 0;
position: relative; /* Fix for IE 7 compatibility mode. */
}
ul.container-actions .form-item,
ul.container-actions li form,
ul.container-actions li form input {
padding: 0;
margin: 0;
display: inline;
}
/* Mapping form. */
#center table form {
margin: 0;
}
}

View File

@@ -7,9 +7,9 @@ configure = admin/structure/feeds
files[] = feeds_ui.test
; Information added by drupal.org packaging script on 2012-10-24
version = "7.x-2.0-alpha7"
; Information added by Drupal.org packaging script on 2016-02-21
version = "7.x-2.0-beta2"
core = "7.x"
project = "feeds"
datestamp = "1351111319"
datestamp = "1456055647"

View File

@@ -1,62 +0,0 @@
Drupal.behaviors.feeds = function() {
// Hide text in specific input fields.
$('.hide-text-on-focus').focus(function() {
$(this).val('');
});
// Hide submit buttons of .feeds-ui-hidden-submit class.
$('input.form-submit.feeds-ui-hidden-submit').hide();
/**
* Tune checkboxes on mapping forms.
* @see feeds_ui_mapping_form() in feeds_ui.admin.inc
*/
// Attach submit behavior to elements with feeds-ui-trigger-submit class.
$('.feeds-ui-trigger-submit').click(function() {
// Use click, not form.submit() - submit() would use the wrong submission
// handler.
$('input.form-submit.feeds-ui-hidden-submit').click();
});
// Replace checkbox with .feeds-ui-checkbox-link class with a link.
$('.feeds-ui-checkbox-link:not(.processed)').each(function(i) {
$(this).addClass('processed').after(
'<a href="#" onclick="return false;" class="feeds-ui-trigger-remove">' + $('label', this).text() + '</a>'
).hide();
});
// Check the box and then submit.
$('.feeds-ui-trigger-remove').click(function() {
// Use click, not form.submit() - submit() would use the wrong submission
// handler.
$(this).prev().children().children().children().attr('checked', 1);
$('input.form-submit.feeds-ui-hidden-submit').click();
});
// Replace radio with .feeds-ui-radio-link class with a link.
$('.feeds-ui-radio-link:not(.processed)').parent().each(function(i) {
checked = '';
if ($(this).children('input').attr('checked')) {
checked = ' checked';
}
$(this).addClass('processed').after(
'<a href="#" onclick="return false;" class="feeds-ui-check-submit' + checked + '" id="' + $(this).children('input').attr('id') + '">' + $(this).parent().text() + '</a>'
);
$(this).hide();
});
// Hide the the radio that is selected.
$('.feeds-ui-check-submit.checked').parent().hide();
// Check the radio and then submit.
$('.feeds-ui-check-submit').click(function() {
// Use click, not form.submit() - submit() would use the wrong submission
// handler.
$('#' + $(this).attr('id')).attr('checked', 1);
$('input.form-submit.feeds-ui-hidden-submit').click();
});
};

View File

@@ -35,6 +35,14 @@ function feeds_ui_menu() {
'file' => 'feeds_ui.admin.inc',
'type' => MENU_LOCAL_ACTION,
);
$items['admin/structure/feeds/import'] = array(
'title' => 'Import importer',
'page callback' => 'drupal_get_form',
'page arguments' => array('feeds_ui_importer_import'),
'access callback' => 'feeds_importer_import_access',
'file' => 'feeds_ui.admin.inc',
'type' => MENU_LOCAL_ACTION,
);
$items['admin/structure/feeds/%feeds_importer'] = array(
'title callback' => 'feeds_ui_importer_title',
'title arguments' => array(3),

View File

@@ -17,6 +17,10 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
);
}
public function setUp() {
parent::setUp(array('php'), array('use PHP for settings'));
}
/**
* UI functionality tests on
* feeds_ui_overview(),
@@ -87,7 +91,7 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
'content_type' => 'page',
'import_period' => 3600,
);
$this->drupalPost('admin/structure/feeds/test_feed/settings', $edit, 'Save');
$this->setSettings('test_feed', NULL, $edit);
// Assert results of change.
$this->assertText('Syndication feed');
@@ -98,11 +102,8 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
$this->assertLink('Basic page');
// Configure processor.
$edit = array(
'content_type' => 'article',
);
$this->drupalPost('admin/structure/feeds/test_feed/settings/FeedsNodeProcessor', $edit, 'Save');
$this->assertFieldByName('content_type', 'article');
$this->setSettings('test_feed', 'FeedsNodeProcessor', array('bundle' => 'article'));
$this->assertFieldByName('bundle', 'article');
// Create a feed node.
$edit = array(
@@ -114,4 +115,46 @@ class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
// @todo Refreshing/deleting feed items. Needs to live in feeds.test
}
public function testImporterImport() {
$name = $this->randomString();
$id = drupal_strtolower($this->randomName());
$this->createImporterConfiguration($name, $id);
$this->setPlugin($id, 'FeedsCSVParser');
$this->setPlugin($id, 'FeedsFileFetcher');
$this->setPlugin($id, 'FeedsUserProcessor');
$this->setSettings($id, 'FeedsFileFetcher', array('allowed_extensions' => 'xml'));
$this->setSettings($id, 'FeedsCSVParser', array('delimiter' => '|'));
$this->setSettings($id, 'FeedsUserProcessor', array('skip_hash_check' => TRUE));
$this->drupalGet('admin/structure/feeds/' . $id . '/export');
$export = $this->xpath('//textarea[1]/text()');
$export = (string) $export[0];
// Delete this importer.
$this->drupalPost('admin/structure/feeds/' . $id . '/delete', array(), t('Delete'));
// Try to import.
$this->drupalPost('admin/structure/feeds/import', array('importer' => $export), t('Import'));
$this->assertText("Successfully imported the $id feeds importer.");
// Check that the settings are correct.
$importer = feeds_importer($id);
$this->assertEqual('FeedsFileFetcher', get_class($importer->fetcher));
$this->assertEqual('FeedsCSVParser', get_class($importer->parser));
$this->assertEqual('FeedsUserProcessor', get_class($importer->processor));
$config = $importer->fetcher->getConfig();
$this->assertEqual('xml', $config['allowed_extensions']);
$config = $importer->parser->getConfig();
$this->assertEqual('|', $config['delimiter']);
$config = $importer->processor->getConfig();
$this->assertTrue($config['skip_hash_check']);
}
}