Projet

Général

Profil

Révision 01dfd3b5

Ajouté par Assos Assos il y a plus de 3 ans

Udpate to 7.77

Voir les différences:

drupal7/includes/common.inc
6653 6653
  $sort = isset($elements['#sorted']) ? !$elements['#sorted'] : $sort;
6654 6654

  
6655 6655
  // Filter out properties from the element, leaving only children.
6656
  $children = array();
6656
  $count = count($elements);
6657
  $child_weights = array();
6658
  $i = 0;
6657 6659
  $sortable = FALSE;
6658 6660
  foreach ($elements as $key => $value) {
6659 6661
    if (is_int($key) || $key === '' || $key[0] !== '#') {
6660
      $children[$key] = $value;
6661 6662
      if (is_array($value) && isset($value['#weight'])) {
6663
        $weight = $value['#weight'];
6662 6664
        $sortable = TRUE;
6663 6665
      }
6666
      else {
6667
        $weight = 0;
6668
      }
6669
      // Support weights with up to three digit precision and conserve the
6670
      // insertion order.
6671
      $child_weights[$key] = floor($weight * 1000) + $i / $count;
6664 6672
    }
6673
    $i++;
6665 6674
  }
6675

  
6666 6676
  // Sort the children if necessary.
6667 6677
  if ($sort && $sortable) {
6668
    uasort($children, 'element_sort');
6678
    asort($child_weights);
6669 6679
    // Put the sorted children back into $elements in the correct order, to
6670 6680
    // preserve sorting if the same element is passed through
6671 6681
    // element_children() twice.
6672
    foreach ($children as $key => $child) {
6682
    foreach ($child_weights as $key => $weight) {
6683
      $value = $elements[$key];
6673 6684
      unset($elements[$key]);
6674
      $elements[$key] = $child;
6685
      $elements[$key] = $value;
6675 6686
    }
6676 6687
    $elements['#sorted'] = TRUE;
6677 6688
  }
6678 6689

  
6679
  return array_keys($children);
6690
  return array_keys($child_weights);
6680 6691
}
6681 6692

  
6682 6693
/**

Formats disponibles : Unified diff