Révision 41cc1b08
Ajouté par Assos Assos il y a presque 9 ans
drupal7/sites/all/modules/feeds/feeds.pages.inc | ||
---|---|---|
36 | 36 |
} |
37 | 37 |
} |
38 | 38 |
if (empty($rows)) { |
39 |
drupal_set_message(t('There are no importers, go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array('@importers' => url('admin/structure/feeds')))); |
|
39 |
// The feeds_ui module is enabled. |
|
40 |
if (module_exists('feeds_ui') && user_access('administer feeds')) { |
|
41 |
drupal_set_message(t('There are no importers, go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array('@importers' => url('admin/structure/feeds')))); |
|
42 |
} |
|
43 |
else { |
|
44 |
// The feeds_ui module is not enabled but the current user has access to |
|
45 |
// Modules to enable it. |
|
46 |
if (user_access('administer modules')) { |
|
47 |
drupal_set_message(t('The Feeds UI Admin module is not enabled and there are no importers, go to <a href="@modules">Modules</a> and enable Feeds Admin UI. Then go to <a href="@importers">Feed importers</a> to create one or enable an existing one.', array('@modules' => url('admin/modules'), '@importers' => url('admin/structure/feeds')))); |
|
48 |
} |
|
49 |
else { |
|
50 |
// The feeds_ui module is not enabled and the current user cannot |
|
51 |
// enable it. |
|
52 |
drupal_set_message(t("The Feeds UI Admin module is not enabled. Please contact the Administrator for your site and ask them to enable it.")); |
|
53 |
} |
|
54 |
} |
|
40 | 55 |
} |
41 | 56 |
$header = array( |
42 | 57 |
t('Import'), |
... | ... | |
48 | 63 |
/** |
49 | 64 |
* Render a feeds import form on import/[config] pages. |
50 | 65 |
*/ |
51 |
function feeds_import_form($form, &$form_state, $importer_id) {
|
|
52 |
$source = feeds_source($importer_id, empty($form['nid']['#value']) ? 0 : $form['nid']['#value']);
|
|
66 |
function feeds_import_form(array $form, array &$form_state, FeedsImporter $importer) {
|
|
67 |
$source = feeds_source($importer->id);
|
|
53 | 68 |
|
54 |
$form = array(); |
|
55 |
$form['#importer_id'] = $importer_id; |
|
69 |
$form['#importer_id'] = $importer->id; |
|
56 | 70 |
// @todo Move this into fetcher? |
57 | 71 |
$form['#attributes']['enctype'] = 'multipart/form-data'; |
58 | 72 |
$form['source_status'] = array( |
... | ... | |
111 | 125 |
|
112 | 126 |
// Add to schedule, make sure importer is scheduled, too. |
113 | 127 |
$source->schedule(); |
114 |
$source->importer->schedule(); |
|
115 | 128 |
} |
116 | 129 |
|
117 | 130 |
/** |
... | ... | |
155 | 168 |
* Used on both node pages and configuration pages. |
156 | 169 |
* Therefore $node may be missing. |
157 | 170 |
*/ |
158 |
function feeds_delete_tab_form($form, &$form_state, $importer_id, $node = NULL) {
|
|
171 |
function feeds_delete_tab_form(array $form, array &$form_state, FeedsImporter $importer = NULL, $node = NULL) {
|
|
159 | 172 |
if (empty($node)) { |
160 |
$source = feeds_source($importer_id);
|
|
173 |
$source = feeds_source($importer->id);
|
|
161 | 174 |
$form['#redirect'] = 'import/' . $source->id; |
162 | 175 |
} |
163 | 176 |
else { |
... | ... | |
199 | 212 |
* Used on both node pages and configuration pages. |
200 | 213 |
* Therefore $node may be missing. |
201 | 214 |
*/ |
202 |
function feeds_unlock_tab_form($form, &$form_state, $importer_id, $node = NULL) {
|
|
215 |
function feeds_unlock_tab_form($form, &$form_state, FeedsImporter $importer = NULL, $node = NULL) {
|
|
203 | 216 |
if (empty($node)) { |
204 |
$source = feeds_source($importer_id);
|
|
217 |
$source = feeds_source($importer->id);
|
|
205 | 218 |
$form['#redirect'] = 'import/' . $source->id; |
206 | 219 |
} |
207 | 220 |
else { |
... | ... | |
270 | 283 |
/** |
271 | 284 |
* Template generation |
272 | 285 |
*/ |
273 |
function feeds_importer_template($importer_id) { |
|
274 |
$importer = feeds_importer($importer_id); |
|
286 |
function feeds_importer_template(FeedsImporter $importer) { |
|
275 | 287 |
if ($importer->parser instanceof FeedsCSVParser) { |
276 | 288 |
return $importer->parser->getTemplate(); |
277 | 289 |
} |
... | ... | |
335 | 347 |
$element = $variables['element']; |
336 | 348 |
drupal_add_css(drupal_get_path('module', 'feeds') . '/feeds.css'); |
337 | 349 |
_form_set_class($element, array('form-file')); |
338 |
$description = '';
|
|
350 |
$summary = '';
|
|
339 | 351 |
if (!empty($element['#file_info'])) { |
340 | 352 |
$file = $element['#file_info']; |
341 | 353 |
$wrapper = file_stream_wrapper_get_instance_by_uri($file->uri); |
342 |
$description .= '<div class="file-info">';
|
|
343 |
$description .= '<div class="file-name">';
|
|
354 |
$summary .= '<div class="feeds-file-info">';
|
|
355 |
$summary .= '<div class="feeds-file-name">';
|
|
344 | 356 |
if ($wrapper) { |
345 |
$description .= l($file->filename, $wrapper->getExternalUrl());
|
|
357 |
$summary .= l(check_plain($file->filename), $wrapper->getExternalUrl());
|
|
346 | 358 |
} |
347 | 359 |
else { |
348 |
$description .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri)));
|
|
360 |
$summary .= t('URI scheme %scheme not available.', array('%scheme' => file_uri_scheme($uri)));
|
|
349 | 361 |
} |
350 |
$description .= '</div>';
|
|
351 |
$description .= '<div class="file-size">';
|
|
352 |
$description .= format_size($file->filesize);
|
|
353 |
$description .= '</div>';
|
|
354 |
$description .= '<div class="file-mime">';
|
|
355 |
$description .= check_plain($file->filemime);
|
|
356 |
$description .= '</div>';
|
|
357 |
$description .= '</div>';
|
|
362 |
$summary .= '</div>';
|
|
363 |
$summary .= '<div class="file-size">';
|
|
364 |
$summary .= format_size($file->filesize);
|
|
365 |
$summary .= '</div>';
|
|
366 |
$summary .= '<div class="feeds-file-mime">';
|
|
367 |
$summary .= check_plain($file->filemime);
|
|
368 |
$summary .= '</div>';
|
|
369 |
$summary .= '</div>';
|
|
358 | 370 |
} |
359 |
$description .= '<div class="file-upload">'; |
|
360 |
$description .= '<input type="file" name="' . $element['#name'] . '"' . ($element['#attributes'] ? ' ' . drupal_attributes($element['#attributes']) : '') . ' id="' . $element['#id'] . '" size="' . $element['#size'] . "\" />\n"; |
|
361 |
$description .= '</div>'; |
|
362 |
$element['#description'] = $description; |
|
371 |
// Prepend the summary to the form field. |
|
372 |
$element['#children'] = '<div class="feeds-file">' . $summary . '<div class="feeds-file-upload">' . $element['#children']; |
|
373 |
// Render file upload field using theme_form_element(). |
|
374 |
$output = theme('form_element', $element); |
|
375 |
// Close "feeds-file" and "feeds-file-upload" divs. |
|
376 |
$output .= '</div></div>'; |
|
363 | 377 |
|
364 |
// For some reason not unsetting #title leads to printing the title twice. |
|
365 |
unset($element['#title']); |
|
366 |
return theme('form_element', $element); |
|
378 |
return $output; |
|
367 | 379 |
} |
Formats disponibles : Unified diff
Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1
Install lib simplepie 1.3.1