Projet

Général

Profil

Révision c304a780

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ctools/includes/wizard.inc
47 47
  // with form caching.
48 48
  ctools_form_include($form_state, 'wizard');
49 49

  
50
  // allow order array to be optional
50
  // Allow order array to be optional.
51 51
  if (empty($form_info['order'])) {
52 52
    foreach ($form_info['forms'] as $step_id => $params) {
53 53
      $form_info['order'][$step_id] = $params['title'];
......
83 83
      $form_info['cache location'] = 'storage';
84 84
    }
85 85

  
86
    // If absolutely nothing was set for the cache area to work on
86
    // If absolutely nothing was set for the cache area to work on.
87 87
    if (!isset($form_state[$form_info['cache location']])) {
88 88
      ctools_include('cache');
89 89
      $form_state[$form_info['cache location']] = ctools_cache_get($form_info['cache mechanism'], $form_info['cache key']);
......
199 199
        }
200 200
      }
201 201
    }
202
    else if (isset($form_state['ajax next'])) {
202
    elseif (isset($form_state['ajax next'])) {
203 203
      // Clear a few items off the form state so we don't double post:
204 204
      $next = $form_state['ajax next'];
205 205
      unset($form_state['ajax next']);
......
299 299
        '#wizard type' => 'next',
300 300
        '#weight' => -2000,
301 301
        '#limit_validation_errors' => array(),
302
        // hardcode the submit so that it doesn't try to save data.
302
        // Hardcode the submit so that it doesn't try to save data.
303 303
        '#submit' => array('ctools_wizard_submit'),
304 304
        '#attributes' => $button_attributes,
305 305
      );
......
325 325
    // end of the form list (i.e, there is a next) then it's "update and return"
326 326
    // to be clear. If this is the end of the path and there is no next, we
327 327
    // call it 'Finish'.
328

  
329 328
    // Even if there is no direct return path (some forms may not want you
330 329
    // leaving in the middle) the final button is always a Finish and it does
331 330
    // whatever the return action is.
332 331
    if (!empty($form_info['show return']) && !empty($form_state['next'])) {
333 332
      $form['buttons']['return'] = array(
334 333
        '#type' => 'submit',
335
        '#value' =>  $form_info['return text'],
334
        '#value' => $form_info['return text'],
336 335
        '#wizard type' => 'return',
337 336
        '#attributes' => $button_attributes,
338 337
      );
339 338
    }
340
    else if (empty($form_state['next']) || !empty($form_info['free trail'])) {
339
    elseif (empty($form_state['next']) || !empty($form_info['free trail'])) {
341 340
      $form['buttons']['return'] = array(
342 341
        '#type' => 'submit',
343 342
        '#value' => $form_info['finish text'],
......
352 351
        '#type' => 'submit',
353 352
        '#value' => $form_info['cancel text'],
354 353
        '#wizard type' => 'cancel',
355
        // hardcode the submit so that it doesn't try to save data.
354
        // Hardcode the submit so that it doesn't try to save data.
356 355
        '#limit_validation_errors' => array(),
357 356
        '#submit' => array('ctools_wizard_submit'),
358 357
        '#attributes' => $button_attributes,
......
370 369

  
371 370
    // Set up our submit handler after theirs. Since putting something here will
372 371
    // skip Drupal's autodetect, we autodetect for it.
373

  
374 372
    // We make sure ours is after theirs so that they get to change #next if
375 373
    // the want to.
376 374
    $form['#submit'] = array();
......
398 396

  
399 397
      $params = array($url, $options);
400 398
    }
401
    $form['#action'] =  call_user_func_array('url', $params);
399
    $form['#action'] = call_user_func_array('url', $params);
402 400
  }
403 401

  
404 402
  if (isset($info['wrapper']) && function_exists($info['wrapper'])) {
......
418 416
  if (isset($form_state['clicked_button']['#wizard type'])) {
419 417
    $type = $form_state['clicked_button']['#wizard type'];
420 418

  
421
    // if AJAX enabled, we proceed slightly differently here.
419
    // If AJAX enabled, we proceed slightly differently here.
422 420
    if (!empty($form_state['ajax'])) {
423 421
      if ($type == 'next') {
424 422
        $form_state['ajax next'] = $form_state['clicked_button']['#next'];
......
428 426
      if ($type == 'cancel' && isset($form_state['form_info']['cancel path'])) {
429 427
        $form_state['redirect'] = $form_state['form_info']['cancel path'];
430 428
      }
431
      else if ($type == 'next') {
429
      elseif ($type == 'next') {
432 430
        $form_state['redirect'] = ctools_wizard_get_path($form_state['form_info'], $form_state['clicked_button']['#next']);
433 431
        if (!empty($_GET['destination'])) {
434 432
          // We don't want drupal_goto redirect this request
......
437 435
          unset($_GET['destination']);
438 436
        }
439 437
      }
440
      else if (isset($form_state['form_info']['return path'])) {
438
      elseif (isset($form_state['form_info']['return path'])) {
441 439
        $form_state['redirect'] = $form_state['form_info']['return path'];
442 440
      }
443
      else if ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
441
      elseif ($type == 'finish' && isset($form_state['form_info']['cancel path'])) {
444 442
        $form_state['redirect'] = $form_state['form_info']['cancel path'];
445 443
      }
446 444
    }
......
503 501
  }
504 502

  
505 503
  $form_info = $form_info + $defaults;
506
  // set form callbacks if they aren't defined
504
  // Set form callbacks if they aren't defined.
507 505
  foreach ($form_info['forms'] as $step => $params) {
508 506
    if (!$params['form id']) {
509
       $form_callback = $hook . '_' . $step . '_form';
510
       $form_info['forms'][$step]['form id'] = $form_callback;
507
      $form_callback = $hook . '_' . $step . '_form';
508
      $form_info['forms'][$step]['form id'] = $form_callback;
511 509
    }
512 510
  }
513 511

  
514
  // set button callbacks
512
  // Set button callbacks.
515 513
  $callbacks = array(
516 514
    'back callback' => '_back',
517 515
    'next callback' => '_next',
......
521 519
  );
522 520

  
523 521
  foreach ($callbacks as $key => $callback) {
524
    // never overwrite if explicity defined
522
    // Never overwrite if explicity defined.
525 523
    if (empty($form_info[$key])) {
526 524
      $wizard_callback = $hook . $callback;
527
      if (function_exists($wizard_callback))  {
525
      if (function_exists($wizard_callback)) {
528 526
        $form_info[$key] = $wizard_callback;
529 527
      }
530 528
    }

Formats disponibles : Unified diff