Projet

Général

Profil

Révision 8c72e82a

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform/includes/webform.components.inc
245 245
  $row_data = array(
246 246
    array('data' => $indents . filter_xss($component['name']), 'class' => array('webform-component-name')),
247 247
    array('data' => check_plain($form_key), 'class' => array('webform-component-formkey')) +
248
          ($component['form_key'] == $form_key ? array() : array('title' => $component['form_key'])),
248
          ((string) $component['form_key'] === (string) $form_key ? array() : array('title' => $component['form_key'])),
249 249
    array('data' => $form['add']['type']['#options'][$component['type']], 'class' => array('webform-component-type')),
250 250
    array('data' => ($value == '') ? '-' : check_plain($value), 'class' => array('webform-component-value')) +
251 251
          ($component['value'] == $value ? array() : array('title' => $component['value'])),
......
302 302
  $parents = array();
303 303
  if (isset($form_state['values']['components'])) {
304 304
    foreach ($form_state['values']['components'] as $cid => $component) {
305
      $form_key = $form['#node']->webform['components'][$cid]['form_key'];
306
      if (isset($parents[$component['pid']]) && ($existing = array_search($form_key, $parents[$component['pid']])) && $existing !== FALSE) {
305
      $form_key = (string) $form['#node']->webform['components'][$cid]['form_key'];
306
      if (isset($parents[$component['pid']]) && ($existing = array_search($form_key, $parents[$component['pid']], TRUE)) && $existing !== FALSE) {
307 307
        if (!isset($duplicates[$form_key])) {
308 308
          $duplicates[$form_key] = array($existing);
309 309
        }
......
721 721
  if (webform_component_feature($component_type, 'group')) {
722 722
    $question = t('Delete the %name fieldset?', array('%name' => $node->webform['components'][$cid]['name']));
723 723
    $description = t('This will immediately delete the %name @type component and all nested components within %name from the %webform webform. This cannot be undone.',
724
                     array('%name' => $node->webform['components'][$cid]['name'],
725
                           '@type' => webform_component_property($component_type, 'label'),
726
                           '%webform' => $node->title));
724
      array('%name' => $node->webform['components'][$cid]['name'],
725
        '@type' => webform_component_property($component_type, 'label'),
726
        '%webform' => $node->title));
727 727
  }
728 728
  else {
729 729
    $question = t('Delete the %name component?', array('%name' => $node->webform['components'][$cid]['name']));
......
764 764
 *
765 765
 * @param $component
766 766
 *   A full component containing fields from the component form.
767
 *
768
 * @return false|int
769
 *   On success return identifier for the components within node.
770
 *   FALSE on failure
767 771
 */
768 772
function webform_component_insert(&$component) {
769 773
  // Allow modules to modify the component before saving.
......
946 950
 *   The node object containing the current webform.
947 951
 * @param $component
948 952
 *   A full component containing fields from the component form.
953
 *
954
 * @return false|int
955
 *   On success return identifier for the components within node.
956
 *   FALSE on failure
949 957
 */
950 958
function webform_component_clone(&$node, &$component) {
951 959
  $original_cid = $component['cid'];
......
1019 1027
 *   email, required, conditional) on which this list of components will be
1020 1028
 *   restricted.
1021 1029
 * @param $prefix_group
1022
 *   TRUE to indent with a hyphen, or 'path" to Prepend enclosing group (e.g.
1030
 *   TRUE to indent with a hyphen, or 'path" to Prepend enclosing group (for example,
1023 1031
 *   fieldset) name(s)
1024 1032
 * @param $pagebreak_groups
1025 1033
 *   Determine if pagebreaks should be converted to option groups in the
1026 1034
 *   returned list of options.
1035
 *
1036
 * @return array
1027 1037
 */
1028 1038
function webform_component_list($node, $component_filter = NULL, $prepend_group = TRUE, $pagebreak_groups = FALSE) {
1029 1039
  $options = array();
......
1034 1044
  $feature = is_string($component_filter) ? $component_filter : NULL;
1035 1045

  
1036 1046
  foreach ($components as $cid => $component) {
1037
    // If this component is a group (e.g. fieldset), then remember its name, including any parents.
1047
    // If this component is a group (for example, fieldset), then remember its name, including any parents.
1038 1048
    if ($prepend_group && webform_component_feature($component['type'], 'group')) {
1039 1049
      $parent_names[$cid] = ($component['pid'] ? $parent_names[$component['pid']] : '') .
1040 1050
                            ($prepend_group === 'path' ? $component['name'] . ': ' : '-');
......
1043 1053
    // If this component is a pagebreak, then generate an option group, ensuring a unique name.
1044 1054
    if ($pagebreak_groups && $component['type'] == 'pagebreak') {
1045 1055
      $page_name = $component['name'];
1056

  
1057
      // When a $page_name consists only of digits, append a space to ensure it
1058
      // is never the same as a $cid.
1059
      if ((string) $page_name === (string) (int) $page_name) {
1060
        $page_name .= ' ';
1061
      }
1062

  
1046 1063
      $copy = 1;
1047 1064
      while (in_array($page_name, $page_names)) {
1048 1065
        $page_name = $component['name'] . '_' . ++$copy;
......
1144 1161
}
1145 1162

  
1146 1163
/**
1147
 * Find a components parents within a node.
1164
 * Find a component's parents within a node.
1165
 *
1166
 * @param object $node
1167
 *   The webform node.
1168
 * @param array $component
1169
 *   The component to start with.
1170
 * @param string|true $what_to_return
1171
 *   If TRUE, return complete component arrays. Otherwise, return the property
1172
 *   of each component named in this parametre.
1173
 *
1174
 * @return array
1175
 *   An array with a value for each parent and for the start component, in order
1176
 *   ending with start component. What the value is is controlled by
1177
 *   $what_to_return.
1148 1178
 */
1149
function webform_component_parent_keys($node, $component) {
1150
  $parents = array($component['form_key']);
1179
function webform_component_parent_keys($node, array $component, $what_to_return = 'form_key') {
1180
  $parents = array(($what_to_return === TRUE) ? $component : $component[$what_to_return]);
1151 1181
  $pid = $component['pid'];
1152 1182
  while ($pid) {
1153
    $parents[] = $node->webform['components'][$pid]['form_key'];
1183
    $parents[] = ($what_to_return === TRUE) ? $node->webform['components'][$pid] : $node->webform['components'][$pid][$what_to_return];
1154 1184
    $pid = $node->webform['components'][$pid]['pid'];
1155 1185
  }
1156 1186
  return array_reverse($parents);

Formats disponibles : Unified diff