Projet

Général

Profil

Révision ec2b0e7b

Ajouté par Assos Assos il y a presque 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/feeds/feeds.pages.inc
85 85
    ) + $source_form;
86 86
  }
87 87

  
88
  // Set submit button label based on settings.
89
  if ($source->importer->config['import_on_create']) {
90
    $submit = t('Import');
91
    if ($source->importer->config['process_in_background']) {
92
      // When processing the import in background, the import job is put in the queue.
93
      $submit = t('Schedule import');
94
    }
95
  }
96
  elseif ($source->importer->config['import_period'] != FEEDS_SCHEDULE_NEVER) {
97
    // The import would be scheduled according to the periodic import setting.
98
    $submit = t('Schedule import');
99
  }
100
  else {
101
    drupal_set_message(t('For this importer both "@import_period" and "@import_on_create" are turned off. It is possible that Feeds will not import the provided source.', array(
102
      '@import_period' => t('Periodic import'),
103
      '@import_on_create' => t('Import on submission'),
104
    )), 'warning', FALSE);
105
    $submit = t('Save');
106
  }
107

  
88 108
  $form['submit'] = array(
89 109
    '#type' => 'submit',
90
    '#value' => t('Import'),
110
    '#value' => $submit,
91 111
  );
112

  
113
  // Disable submit button if import is initiated.
92 114
  $progress = $source->progressImporting();
93 115
  if ($progress !== FEEDS_BATCH_COMPLETE) {
94 116
    $form['submit']['#disabled'] = TRUE;
95 117
    $form['submit']['#value'] =
96 118
      t('Importing (@progress %)', array('@progress' => number_format(100 * $progress, 0)));
119

  
120
    // Check if import task is queued.
121
    if ($source->isQueued()) {
122
      $form['source_status']['#value'] .= t('Run cron to continue the import.');
123
    }
97 124
  }
125

  
98 126
  return $form;
99 127
}
100 128

  
......
121 149
  // Refresh feed if import on create is selected.
122 150
  if ($source->importer->config['import_on_create']) {
123 151
    $source->startImport();
152
    if ($source->importer->config['process_in_background']) {
153
      drupal_set_message(t('Import scheduled.'));
154
    }
124 155
  }
125 156

  
126 157
  // Add to schedule, make sure importer is scheduled, too.
127
  $source->schedule();
158
  $source->ensureSchedule();
159

  
160
  // If an import is only triggered by periodic import, check if it is about to
161
  // be rescheduled so there is at least a message.
162
  if (!$source->importer->config['import_on_create']) {
163
    // Check if the importer is about to be rescheduled.
164
    $importers = feeds_reschedule();
165
    if (isset($importers[$form['#importer_id']])) {
166
      drupal_set_message(t('Rescheduling the import will happen on the next cron run.'), 'status');
167
    }
168
  }
128 169
}
129 170

  
130 171
/**
......
145 186
    '#value' => feeds_source_status($source),
146 187
  );
147 188
  $form = confirm_form($form, t('Import all content from source?'), 'node/' . $node->nid, '', t('Import'), t('Cancel'), 'confirm feeds update');
189

  
190
  // Change submit button label if processing in background.
191
  if ($source->importer->config['process_in_background']) {
192
    $form['actions']['submit']['#value'] = t('Schedule import');
193
  }
194

  
195
  // Disable submit button if import is initiated.
148 196
  $progress = $source->progressImporting();
149 197
  if ($progress !== FEEDS_BATCH_COMPLETE) {
150 198
    $form['actions']['submit']['#disabled'] = TRUE;
151 199
    $form['actions']['submit']['#value'] =
152 200
      t('Importing (@progress %)', array('@progress' => number_format(100 * $progress, 0)));
201

  
202
    // Check if import task is queued.
203
    if ($source->isQueued()) {
204
      $form['source_status']['#value'] .= t('Run cron to continue the import.');
205
    }
153 206
  }
207

  
154 208
  return $form;
155 209
}
156 210

  
......
159 213
 */
160 214
function feeds_import_tab_form_submit($form, &$form_state) {
161 215
  $form_state['redirect'] = $form['#redirect'];
162
  feeds_source($form['#importer_id'], $form['#feed_nid'])->startImport();
216
  $source = feeds_source($form['#importer_id'], $form['#feed_nid']);
217
  $source->startImport();
218
  $source->ensureSchedule();
219

  
220
  if ($source->importer->config['process_in_background']) {
221
    drupal_set_message(t('Import scheduled.'));
222
  }
163 223
}
164 224

  
165 225
/**
......
188 248
    '#value' => feeds_source_status($source),
189 249
  );
190 250
  $form = confirm_form($form, t('Delete all items from source?'), $form['#redirect'], '', t('Delete'), t('Cancel'), 'confirm feeds update');
251

  
252
  // Change submit button label if processing in background.
253
  if ($source->importer->config['process_in_background']) {
254
    $form['actions']['submit']['#value'] = t('Schedule delete');
255
  }
256

  
257
  // Disable submit button if clearing is initiated.
191 258
  $progress = $source->progressClearing();
192 259
  if ($progress !== FEEDS_BATCH_COMPLETE) {
193 260
    $form['actions']['submit']['#disabled'] = TRUE;
194 261
    $form['actions']['submit']['#value'] =
195 262
      t('Deleting (@progress %)', array('@progress' => number_format(100 * $progress, 0)));
263
    $form['source_status']['#value'] .= t('Run cron to continue the deletion of items.');
196 264
  }
265

  
197 266
  return $form;
198 267
}
199 268

  
......
203 272
function feeds_delete_tab_form_submit($form, &$form_state) {
204 273
  $form_state['redirect'] = $form['#redirect'];
205 274
  $feed_nid = empty($form['#feed_nid']) ? 0 : $form['#feed_nid'];
206
  feeds_source($form['#importer_id'], $feed_nid)->startClear();
275
  $source = feeds_source($form['#importer_id'], $feed_nid);
276
  $source->startClear();
277
  $source->ensureSchedule();
278

  
279
  if ($source->importer->config['process_in_background']) {
280
    drupal_set_message(t('Deletion of items scheduled.'));
281
  }
207 282
}
208 283

  
209 284
/**
......
252 327
 * Form submit handler. Resets all feeds state.
253 328
 */
254 329
function feeds_unlock_tab_form_submit($form, &$form_state) {
255
  drupal_set_message(t('Import Unlocked'));
256 330
  $form_state['redirect'] = $form['#redirect'];
257 331
  $feed_nid = empty($form['#feed_nid']) ? 0 : $form['#feed_nid'];
258 332
  $importer_id = $form['#importer_id'];
259 333

  
260
  //Is there a more API-friendly way to set the state?
261
  db_update('feeds_source')
262
    ->condition('id', $importer_id)
263
    ->condition('feed_nid', $feed_nid)
264
    ->fields(array('state' => FALSE))
265
    ->execute();
334
  feeds_source($importer_id, $feed_nid)
335
    ->unlock();
336
  drupal_set_message(t('Importer unlocked.'));
266 337
}
267 338

  
268 339
/**
......
305 376
  }
306 377
  $v['imported'] = $source->imported;
307 378
  $v['count'] = $source->itemCount();
379
  $v['next'] = $source->getNextImportTimeDetails();
308 380
  if (!empty($v)) {
309 381
    return theme('feeds_source_status', $v);
310 382
  }
......
335 407
      $items[] = t('No imported items.');
336 408
    }
337 409
  }
410

  
411
  if ($v['next']) {
412
    // Check if medium date format contains hours/minutes.
413
    $date_format = variable_get('date_format_medium');
414
    $use_custom_date_format = $date_format && !strpos($date_format, 'H:i');
415

  
416
    if (!empty($v['next']['message'])) {
417
      $items[] = t('Next import: @message.', array(
418
        '@message' => $v['next']['message'],
419
      ));
420
    }
421
    elseif ($v['next']['time'] > REQUEST_TIME) {
422
      $items[] = t('Next import: @date (via @method)', array(
423
        '@date' => $use_custom_date_format ? format_date($v['next']['time'], 'custom', 'Y/m/d H:i:s') : format_date($v['next']['time']),
424
        '@method' => $v['next']['method'],
425
      ));
426
    }
427
    else {
428
      $items[] = t('Next import: on next cron run (via @method).', array(
429
        '@method' => $v['next']['method'],
430
      ));
431
    }
432
  }
433
  else {
434
    $items[] = t('Next import: not scheduled.');
435
  }
338 436
  $output .= theme('item_list', array('items' => $items));
339 437
  $output .= '</div>';
340 438
  return $output;

Formats disponibles : Unified diff