Passed
Pull Request — master (#2976)
by Serghei
14:27
created
drupal/sites/default/boinc/modules/contrib/cck/modules/number/number.module 5 patches
Indentation   +204 added lines, -204 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_theme().
11 11
  */
12 12
 function number_theme() {
13
-  return array(
13
+    return array(
14 14
     'number' => array('arguments' => array('element' => NULL)),
15 15
     'number_formatter_default' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
16 16
     'number_formatter_us_0' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
@@ -23,156 +23,156 @@  discard block
 block discarded – undo
23 23
     'number_formatter_fr_1' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
24 24
     'number_formatter_fr_2' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
25 25
     'number_formatter_unformatted' => array('arguments' => array('element' => NULL)),
26
-  );
26
+    );
27 27
 }
28 28
 
29 29
 /**
30 30
  * Implementation of hook_field_info().
31 31
  */
32 32
 function number_field_info() {
33
-  return array(
33
+    return array(
34 34
     'number_integer' => array(
35
-      'label' => t('Integer'),
36
-      'description' => t('Store a number in the database as an integer.'),
35
+        'label' => t('Integer'),
36
+        'description' => t('Store a number in the database as an integer.'),
37 37
 //      'content_icon' => 'icon_content_number.png',
38 38
     ),
39 39
     'number_decimal' => array(
40
-      'label' => t('Decimal'),
41
-      'description' => t('Store a number in the database in a fixed decimal format.'),
40
+        'label' => t('Decimal'),
41
+        'description' => t('Store a number in the database in a fixed decimal format.'),
42 42
 //      'content_icon' => 'icon_content_number.png',
43 43
     ),
44 44
     'number_float' => array(
45
-      'label' => t('Float'),
46
-      'description' => t('Store a number in the database in a floating point format.'),
45
+        'label' => t('Float'),
46
+        'description' => t('Store a number in the database in a floating point format.'),
47 47
 //      'content_icon' => 'icon_content_number.png',
48 48
     ),
49
-  );
49
+    );
50 50
 }
51 51
 
52 52
 /**
53 53
  * Implementation of hook_field_settings().
54 54
  */
55 55
 function number_field_settings($op, $field) {
56
-  switch ($op) {
56
+    switch ($op) {
57 57
     case 'form':
58 58
       $form = array();
59
-      $form['min'] = array(
59
+        $form['min'] = array(
60 60
         '#type' => 'textfield',
61 61
         '#title' => t('Minimum'),
62 62
         '#element_validate' => array('_element_validate_number'),
63 63
         '#default_value' => is_numeric($field['min']) ? $field['min'] : '',
64
-      );
65
-      $form['max'] = array(
64
+        );
65
+        $form['max'] = array(
66 66
         '#type' => 'textfield',
67 67
         '#title' => t('Maximum'),
68 68
         '#element_validate' => array('_element_validate_number'),
69 69
         '#default_value' => is_numeric($field['max']) ? $field['max'] : '',
70
-      );
71
-      if ($field['type'] == 'number_decimal') {
70
+        );
71
+        if ($field['type'] == 'number_decimal') {
72 72
         $form['precision'] = array(
73
-          '#type' => 'select',
74
-          '#options' => drupal_map_assoc(range(10, 32)),
75
-          '#title' => t('Precision'),
76
-          '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
77
-          '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10,
73
+            '#type' => 'select',
74
+            '#options' => drupal_map_assoc(range(10, 32)),
75
+            '#title' => t('Precision'),
76
+            '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
77
+            '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10,
78 78
         );
79 79
         $form['scale'] = array(
80
-          '#type' => 'select',
81
-          '#options' => drupal_map_assoc(range(0, 10)),
82
-          '#title' => t('Scale'),
83
-          '#description' => t('The number of digits to the right of the decimal.'),
84
-          '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2,
80
+            '#type' => 'select',
81
+            '#options' => drupal_map_assoc(range(0, 10)),
82
+            '#title' => t('Scale'),
83
+            '#description' => t('The number of digits to the right of the decimal.'),
84
+            '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2,
85 85
         );
86 86
         $form['decimal'] = array(
87
-          '#type' => 'select',
88
-          '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'),
89
-          '#title' => t('Decimal marker'),
90
-          '#description' => t('The character users will input to mark the decimal point in forms.'),
91
-          '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.',
87
+            '#type' => 'select',
88
+            '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'),
89
+            '#title' => t('Decimal marker'),
90
+            '#description' => t('The character users will input to mark the decimal point in forms.'),
91
+            '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.',
92 92
         );
93
-      }
94
-      $form['append']['prefix'] = array(
93
+        }
94
+        $form['append']['prefix'] = array(
95 95
         '#type' => 'textfield',
96 96
         '#title' => t('Prefix'),
97 97
         '#size' => 60,
98 98
         '#default_value' => !empty($field['prefix']) ? $field['prefix'] : '',
99 99
         '#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
100
-      );
101
-      $form['append']['suffix'] = array(
100
+        );
101
+        $form['append']['suffix'] = array(
102 102
         '#type' => 'textfield',
103 103
         '#title' => t('Suffix'),
104 104
         '#size' => 60,
105 105
         '#default_value' => !empty($field['suffix']) ? $field['suffix'] : '',
106 106
         '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
107
-      );
108
-      $form['allowed_values_fieldset'] = array(
107
+        );
108
+        $form['allowed_values_fieldset'] = array(
109 109
         '#type' => 'fieldset',
110 110
         '#title' => t('Allowed values'),
111 111
         '#collapsible' => TRUE,
112 112
         '#collapsed' => TRUE,
113
-      );
114
-      $form['allowed_values_fieldset']['allowed_values'] = array(
113
+        );
114
+        $form['allowed_values_fieldset']['allowed_values'] = array(
115 115
         '#type' => 'textarea',
116 116
         '#title' => t('Allowed values list'),
117 117
         '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
118 118
         '#required' => FALSE,
119 119
         '#rows' => 10,
120 120
         '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
121
-      );
122
-      $form['allowed_values_fieldset']['advanced_options'] = array(
121
+        );
122
+        $form['allowed_values_fieldset']['advanced_options'] = array(
123 123
         '#type' => 'fieldset',
124 124
         '#title' => t('PHP code'),
125 125
         '#collapsible' => TRUE,
126 126
         '#collapsed' => empty($field['allowed_values_php']),
127
-      );
128
-      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
127
+        );
128
+        if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
129 129
         $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
130
-          '#type' => 'textarea',
131
-          '#title' => t('Code'),
132
-          '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
133
-          '#rows' => 6,
134
-          '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
130
+            '#type' => 'textarea',
131
+            '#title' => t('Code'),
132
+            '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
133
+            '#rows' => 6,
134
+            '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
135 135
         );
136
-      }
137
-      else {
136
+        }
137
+        else {
138 138
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
139
-          '#type' => 'item',
140
-          '#title' => t('Code'),
141
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
142
-          '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
139
+            '#type' => 'item',
140
+            '#title' => t('Code'),
141
+            '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
142
+            '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
143 143
         );
144
-      }
145
-      return $form;
144
+        }
145
+        return $form;
146 146
 
147 147
     case 'save':
148 148
       $values = array('prefix', 'suffix', 'min', 'max', 'allowed_values', 'allowed_values_php');
149
-      if ($field['type'] == 'number_decimal') {
149
+        if ($field['type'] == 'number_decimal') {
150 150
         $values = array_merge($values, array('precision', 'scale', 'decimal'));
151
-      }
152
-      return $values;
151
+        }
152
+        return $values;
153 153
 
154 154
     case 'database columns':
155 155
       if ($field['type'] == 'number_integer') {
156 156
         return array(
157
-          'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE),
157
+            'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE),
158 158
         );
159
-      }
160
-      if ($field['type'] == 'number_float') {
159
+        }
160
+        if ($field['type'] == 'number_float') {
161 161
         return array(
162
-          'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE),
162
+            'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE),
163 163
         );
164
-      }
165
-      if ($field['type'] == 'number_decimal') {
164
+        }
165
+        if ($field['type'] == 'number_decimal') {
166 166
         $precision = isset($field['precision']) ? $field['precision'] : 10;
167 167
         $scale = isset($field['scale']) ? $field['scale'] : 2;
168 168
         return array(
169
-          'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE),
169
+            'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE),
170 170
         );
171
-      }
171
+        }
172 172
 
173 173
     case 'views data':
174 174
       $allowed_values = content_allowed_values($field);
175
-      if (count($allowed_values)) {
175
+        if (count($allowed_values)) {
176 176
         $data = content_views_field_views_data($field);
177 177
         $db_info = content_database_info($field);
178 178
         $table_alias = content_views_tablename($field);
@@ -188,79 +188,79 @@  discard block
 block discarded – undo
188 188
         $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189 189
         $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE;
190 190
         return $data;
191
-      }
192
-      break;
193
-  }
191
+        }
192
+        break;
193
+    }
194 194
 }
195 195
 
196 196
 function _number_widget_settings_min_validate($element, &$form_state) {
197
-  $value = $form_state['values']['min'];
198
-  if ($value && !is_numeric($value)) {
197
+    $value = $form_state['values']['min'];
198
+    if ($value && !is_numeric($value)) {
199 199
     form_set_error('min', t('"Minimum" must be a number.'));
200
-  }
200
+    }
201 201
 }
202 202
 
203 203
 function _number_widget_settings_max_validate($element, &$form_state) {
204
-  $value = $form_state['values']['max'];
205
-  if ($value && !is_numeric($value)) {
204
+    $value = $form_state['values']['max'];
205
+    if ($value && !is_numeric($value)) {
206 206
     form_set_error('max', t('"Maximum" must be a number.'));
207
-  }
207
+    }
208 208
 }
209 209
 
210 210
 /**
211 211
  * Implementation of hook_field().
212 212
  */
213 213
 function number_field($op, &$node, $field, &$items, $teaser, $page) {
214
-  switch ($op) {
214
+    switch ($op) {
215 215
     case 'validate':
216 216
       $allowed_values = content_allowed_values($field);
217
-      if (is_array($items)) {
217
+        if (is_array($items)) {
218 218
         foreach ($items as $delta => $item) {
219
-          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
220
-          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
221
-          if ($item['value'] != '') {
219
+            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
220
+            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
221
+            if ($item['value'] != '') {
222 222
             if (is_numeric($field['min']) && $item['value'] < $field['min']) {
223
-              form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min'])));
223
+                form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min'])));
224 224
             }
225 225
             if (is_numeric($field['max']) && $item['value'] > $field['max']) {
226
-              form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max'])));
226
+                form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max'])));
227 227
             }
228 228
             if (count($allowed_values)) {
229
-              // We cannot use array_key_exists() because allowed values are
230
-              // stored as strings, and we need to compare numeric equality.
231
-              $valid = FALSE;
232
-              foreach ($allowed_values as $kay => $value) {
229
+                // We cannot use array_key_exists() because allowed values are
230
+                // stored as strings, and we need to compare numeric equality.
231
+                $valid = FALSE;
232
+                foreach ($allowed_values as $kay => $value) {
233 233
                 if ((float) $item['value'] == (float) $kay) {
234
-                  $valid = TRUE;
235
-                  break;
234
+                    $valid = TRUE;
235
+                    break;
236 236
                 }
237
-              }
238
-              if (!$valid) {
237
+                }
238
+                if (!$valid) {
239 239
                 form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
240
-              }
240
+                }
241
+            }
241 242
             }
242
-          }
243 243
         }
244
-      }
245
-      return $items;
246
-  }
244
+        }
245
+        return $items;
246
+    }
247 247
 }
248 248
 
249 249
 /**
250 250
  * Implementation of hook_content_is_empty().
251 251
  */
252 252
 function number_content_is_empty($item, $field) {
253
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
253
+    if (empty($item['value']) && (string)$item['value'] !== '0') {
254 254
     return TRUE;
255
-  }
256
-  return FALSE;
255
+    }
256
+    return FALSE;
257 257
 }
258 258
 
259 259
 /**
260 260
  * Implementation of hook_field_formatter_info().
261 261
  */
262 262
 function number_field_formatter_info() {
263
-  return array(
263
+    return array(
264 264
     'default' => array('label' => '9999',            'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
265 265
     'us_0'    => array('label' => '9,999',           'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
266 266
     'us_1'    => array('label' => '9,999.9',         'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
@@ -272,72 +272,72 @@  discard block
 block discarded – undo
272 272
     'fr_1'    => array('label' => '9 999, 9',        'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
273 273
     'fr_2'    => array('label' => '9 999, 99',       'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
274 274
     'unformatted' => array('label' => t('unformatted'), 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
275
-  );
275
+    );
276 276
 }
277 277
 
278 278
 /**
279 279
  * Proxy theme function for 'unformatted' number field formatter.
280 280
  */
281 281
 function theme_number_formatter_unformatted($element) {
282
-  return $element['#item']['value'];
282
+    return $element['#item']['value'];
283 283
 }
284 284
 
285 285
 /**
286 286
  * Proxy theme function for number field formatters.
287 287
  */
288 288
 function theme_number_formatter_generic($element) {
289
-  $field = content_fields($element['#field_name'], $element['#type_name']);
290
-  $value = $element['#item']['value'];
289
+    $field = content_fields($element['#field_name'], $element['#type_name']);
290
+    $value = $element['#item']['value'];
291 291
 
292
-  if (($allowed_values = content_allowed_values($field))) {
292
+    if (($allowed_values = content_allowed_values($field))) {
293 293
     if (isset($allowed_values[$value]) && $allowed_values[$value] != $value) {
294
-      return $allowed_values[$value];
294
+        return $allowed_values[$value];
295
+    }
295 296
     }
296
-  }
297 297
 
298
-  if (empty($value) && $value !== '0') {
298
+    if (empty($value) && $value !== '0') {
299 299
     return '';
300
-  }
300
+    }
301 301
 
302
-  switch ($element['#formatter']) {
302
+    switch ($element['#formatter']) {
303 303
     case 'us_0':
304 304
       $output = number_format($value, 0, '.', ',');
305
-      break;
305
+        break;
306 306
     case 'us_1':
307 307
       $output = number_format($value, 1, '.', ',');
308
-      break;
308
+        break;
309 309
     case 'us_2':
310 310
       $output = number_format($value, 2, '.', ',');
311
-      break;
311
+        break;
312 312
     case 'be_0':
313 313
       $output = number_format($value, 0, ',', '.');
314
-      break;
314
+        break;
315 315
     case 'be_1':
316 316
       $output = number_format($value, 1, ',', '.');
317
-      break;
317
+        break;
318 318
     case 'be_2':
319 319
       $output = number_format($value, 2, ',', '.');
320
-      break;
320
+        break;
321 321
     case 'fr_0':
322 322
       $output = number_format($value, 0, ', ', ' ');
323
-      break;
323
+        break;
324 324
     case 'fr_1':
325 325
       $output = number_format($value, 1, ', ', ' ');
326
-      break;
326
+        break;
327 327
     case 'fr_2':
328 328
       $output = number_format($value, 2, ', ', ' ');
329
-      break;
329
+        break;
330 330
     default:
331 331
       $output = $value;
332
-      break;
333
-  }
332
+        break;
333
+    }
334 334
 
335
-  $prefixes = isset($field['prefix']) ? array_map('content_filter_xss', explode('|', $field['prefix'])) : array('');
336
-  $suffixes = isset($field['suffix']) ? array_map('content_filter_xss', explode('|', $field['suffix'])) : array('');
337
-  $prefix = (count($prefixes) > 1) ? format_plural($value, $prefixes[0], $prefixes[1]) : $prefixes[0];
338
-  $suffix = (count($suffixes) > 1) ? format_plural($value, $suffixes[0], $suffixes[1]) : $suffixes[0];
335
+    $prefixes = isset($field['prefix']) ? array_map('content_filter_xss', explode('|', $field['prefix'])) : array('');
336
+    $suffixes = isset($field['suffix']) ? array_map('content_filter_xss', explode('|', $field['suffix'])) : array('');
337
+    $prefix = (count($prefixes) > 1) ? format_plural($value, $prefixes[0], $prefixes[1]) : $prefixes[0];
338
+    $suffix = (count($suffixes) > 1) ? format_plural($value, $suffixes[0], $suffixes[1]) : $suffixes[0];
339 339
 
340
-  return $prefix . $output . $suffix;
340
+    return $prefix . $output . $suffix;
341 341
 }
342 342
 
343 343
 /**
@@ -352,16 +352,16 @@  discard block
 block discarded – undo
352 352
  * differently.
353 353
  */
354 354
 function number_widget_info() {
355
-  return array(
355
+    return array(
356 356
     'number' => array(
357
-      'label' => t('Text field'),
358
-      'field types' => array('number_integer', 'number_decimal', 'number_float'),
359
-      'multiple values' => CONTENT_HANDLE_CORE,
360
-      'callbacks' => array(
357
+        'label' => t('Text field'),
358
+        'field types' => array('number_integer', 'number_decimal', 'number_float'),
359
+        'multiple values' => CONTENT_HANDLE_CORE,
360
+        'callbacks' => array(
361 361
         'default value' => CONTENT_CALLBACK_DEFAULT,
362
-      ),
362
+        ),
363 363
     ),
364
-  );
364
+    );
365 365
 }
366 366
 
367 367
 /**
@@ -377,13 +377,13 @@  discard block
 block discarded – undo
377 377
  * the validator can use. The regex can be overridden if necessary.
378 378
  */
379 379
 function number_elements() {
380
-  return array(
380
+    return array(
381 381
     'number' => array(
382
-      '#input' => TRUE,
383
-      '#columns' => array('value'), '#delta' => 0,
384
-      '#process' => array('number_process'),
382
+        '#input' => TRUE,
383
+        '#columns' => array('value'), '#delta' => 0,
384
+        '#process' => array('number_process'),
385 385
     ),
386
-  );
386
+    );
387 387
 }
388 388
 
389 389
 /**
@@ -418,11 +418,11 @@  discard block
 block discarded – undo
418 418
  *   the form item for a single element for this field
419 419
  */
420 420
 function number_widget(&$form, &$form_state, $field, $items, $delta = 0) {
421
-  $element = array(
421
+    $element = array(
422 422
     '#type' => $field['widget']['type'],
423 423
     '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
424
-  );
425
-  return $element;
424
+    );
425
+    return $element;
426 426
 }
427 427
 
428 428
 /**
@@ -434,13 +434,13 @@  discard block
 block discarded – undo
434 434
  * The $fields array is in $form['#field_info'][$element['#field_name']].
435 435
  */
436 436
 function number_process($element, $edit, $form_state, $form) {
437
-  $field_name = $element['#field_name'];
438
-  $field = $form['#field_info'][$field_name];
439
-  $field_key  = $element['#columns'][0];
437
+    $field_name = $element['#field_name'];
438
+    $field = $form['#field_info'][$field_name];
439
+    $field_key  = $element['#columns'][0];
440 440
 
441
-  $value = isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '';
442
-  $value = isset($field['decimal']) ? str_replace('.', $field['decimal'], $value) : $value;
443
-  $element[$field_key] = array(
441
+    $value = isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : '';
442
+    $value = isset($field['decimal']) ? str_replace('.', $field['decimal'], $value) : $value;
443
+    $element[$field_key] = array(
444 444
     '#type' => 'textfield',
445 445
     '#default_value' => $value,
446 446
     // Need to allow a slightly larger size that the field length to allow
@@ -457,117 +457,117 @@  discard block
 block discarded – undo
457 457
     '#type_name' => $element['#type_name'],
458 458
     '#delta' => $element['#delta'],
459 459
     '#columns' => $element['#columns'],
460
-  );
460
+    );
461 461
 
462
-  $prefixes = array();
463
-  $suffixes = array();
462
+    $prefixes = array();
463
+    $suffixes = array();
464 464
 
465
-  // Make sure we don't wipe out element validation added elsewhere.
466
-  if (empty($element['#element_validate'])) {
465
+    // Make sure we don't wipe out element validation added elsewhere.
466
+    if (empty($element['#element_validate'])) {
467 467
     $element['#element_validate'] = array();
468
-  }
469
-  if (!empty($field['prefix'])) {
468
+    }
469
+    if (!empty($field['prefix'])) {
470 470
     $prefixes = explode('|', $field['prefix']);
471 471
     $element[$field_key]['#field_prefix'] = content_filter_xss(array_pop($prefixes));
472
-  }
473
-  if (!empty($field['suffix'])) {
472
+    }
473
+    if (!empty($field['suffix'])) {
474 474
     $suffixes = explode('|', $field['suffix']);
475 475
     $element[$field_key]['#field_suffix'] = content_filter_xss(array_pop($suffixes));
476
-  }
477
-  switch ($field['type']) {
476
+    }
477
+    switch ($field['type']) {
478 478
     case 'number_float':
479 479
       $element['#element_validate'][] = 'number_float_validate';
480
-      break;
480
+        break;
481 481
     case 'number_integer':
482 482
       $element['#element_validate'][] = 'number_integer_validate';
483
-      break;
483
+        break;
484 484
     case 'number_decimal':
485 485
       $element['#element_validate'][] = 'number_decimal_validate';
486
-      $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.';
487
-      $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10;
488
-      $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2;
489
-      break;
490
-  }
491
-
492
-  // Used so that hook_field('validate') knows where to flag an error.
493
-  $element['_error_element'] = array(
486
+        $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.';
487
+        $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10;
488
+        $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2;
489
+        break;
490
+    }
491
+
492
+    // Used so that hook_field('validate') knows where to flag an error.
493
+    $element['_error_element'] = array(
494 494
     '#type' => 'value',
495 495
     '#value' => implode('][', array_merge($element['#parents'], array($field_key))),
496
-  );
496
+    );
497 497
 
498
-  return $element;
498
+    return $element;
499 499
 }
500 500
 
501 501
 /**
502 502
  * FAPI validation of an individual float element.
503 503
  */
504 504
 function number_float_validate($element, &$form_state) {
505
-  $field_name = $element['#field_name'];
506
-  $type_name = $element['#type_name'];
507
-  $field = content_fields($field_name, $type_name);
508
-  $field_key = $element['#columns'][0];
509
-  $value = $element['#value'][$field_key];
505
+    $field_name = $element['#field_name'];
506
+    $type_name = $element['#type_name'];
507
+    $field = content_fields($field_name, $type_name);
508
+    $field_key = $element['#columns'][0];
509
+    $value = $element['#value'][$field_key];
510 510
 
511
-  if (($element[$field_key]['#required'] || !empty($value))) {
511
+    if (($element[$field_key]['#required'] || !empty($value))) {
512 512
     $start = $value;
513 513
     $value = preg_replace('@[^-0-9\.]@', '', $value);
514 514
     if ($start != $value) {
515
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
516
-      form_set_error($error_field, t('Only numbers and decimals are allowed in %field.', array('%field' => t($field['widget']['label']))));
515
+        $error_field = implode('][', $element['#parents']) .']['. $field_key;
516
+        form_set_error($error_field, t('Only numbers and decimals are allowed in %field.', array('%field' => t($field['widget']['label']))));
517 517
     }
518 518
     else {
519
-      form_set_value($element[$field_key], $value, $form_state);
519
+        form_set_value($element[$field_key], $value, $form_state);
520
+    }
520 521
     }
521
-  }
522 522
 }
523 523
 
524 524
 /**
525 525
  * FAPI validation of an individual integer element.
526 526
  */
527 527
 function number_integer_validate($element, &$form_state) {
528
-  $field_name = $element['#field_name'];
529
-  $type_name = $element['#type_name'];
530
-  $field = content_fields($field_name, $type_name);
531
-  $field_key = $element['#columns'][0];
532
-  $value = $element['#value'][$field_key];
528
+    $field_name = $element['#field_name'];
529
+    $type_name = $element['#type_name'];
530
+    $field = content_fields($field_name, $type_name);
531
+    $field_key = $element['#columns'][0];
532
+    $value = $element['#value'][$field_key];
533 533
 
534
-  if (($element[$field_key]['#required'] || !empty($value))) {
534
+    if (($element[$field_key]['#required'] || !empty($value))) {
535 535
     $start = $value;
536 536
     $value = preg_replace('@[^-0-9]@', '', $value);
537 537
     if ($start != $value) {
538
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
539
-      form_set_error($error_field, t('Only numbers are allowed in %field.', array('%field' => t($field['widget']['label']))));
538
+        $error_field = implode('][', $element['#parents']) .']['. $field_key;
539
+        form_set_error($error_field, t('Only numbers are allowed in %field.', array('%field' => t($field['widget']['label']))));
540 540
     }
541 541
     else {
542
-      form_set_value($element[$field_key], $value, $form_state);
542
+        form_set_value($element[$field_key], $value, $form_state);
543
+    }
543 544
     }
544
-  }
545 545
 }
546 546
 
547 547
 /**
548 548
  * FAPI validation of an individual decimal element.
549 549
  */
550 550
 function number_decimal_validate($element, &$form_state) {
551
-  $field_name = $element['#field_name'];
552
-  $type_name = $element['#type_name'];
553
-  $field = content_fields($field_name, $type_name);
554
-  $field_key = $element['#columns'][0];
555
-  $value = $element['#value'][$field_key];
551
+    $field_name = $element['#field_name'];
552
+    $type_name = $element['#type_name'];
553
+    $field = content_fields($field_name, $type_name);
554
+    $field_key = $element['#columns'][0];
555
+    $value = $element['#value'][$field_key];
556 556
 
557
-  if (($element[$field_key]['#required'] || !empty($value))) {
557
+    if (($element[$field_key]['#required'] || !empty($value))) {
558 558
     $decimal = $element['#decimal'] ? $element['#decimal'] : '.';
559 559
     $start = $value;
560 560
     $value = preg_replace('@[^-0-9\\'. $decimal .']@', '', $value);
561 561
     if ($start != $value) {
562
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
563
-      form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $element['#decimal'], '%field' => t($field['widget']['label']))));
562
+        $error_field = implode('][', $element['#parents']) .']['. $field_key;
563
+        form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $element['#decimal'], '%field' => t($field['widget']['label']))));
564 564
     }
565 565
     else {
566
-      $value = str_replace($element['#decimal'], '.', $value);
567
-      $value = round($value, $element['#scale']);
568
-      form_set_value($element[$field_key], $value, $form_state);
566
+        $value = str_replace($element['#decimal'], '.', $value);
567
+        $value = round($value, $element['#scale']);
568
+        form_set_value($element[$field_key], $value, $form_state);
569
+    }
569 570
     }
570
-  }
571 571
 }
572 572
 
573 573
 /**
@@ -581,5 +581,5 @@  discard block
 block discarded – undo
581 581
  * $element['#delta]  is the position of this element in the group
582 582
  */
583 583
 function theme_number($element) {
584
-  return $element['#children'];
584
+    return $element['#children'];
585 585
 }
586 586
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -54,142 +54,142 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function number_field_settings($op, $field) {
56 56
   switch ($op) {
57
-    case 'form':
58
-      $form = array();
59
-      $form['min'] = array(
60
-        '#type' => 'textfield',
61
-        '#title' => t('Minimum'),
62
-        '#element_validate' => array('_element_validate_number'),
63
-        '#default_value' => is_numeric($field['min']) ? $field['min'] : '',
57
+  case 'form':
58
+    $form = array();
59
+    $form['min'] = array(
60
+      '#type' => 'textfield',
61
+      '#title' => t('Minimum'),
62
+      '#element_validate' => array('_element_validate_number'),
63
+      '#default_value' => is_numeric($field['min']) ? $field['min'] : '',
64
+    );
65
+    $form['max'] = array(
66
+      '#type' => 'textfield',
67
+      '#title' => t('Maximum'),
68
+      '#element_validate' => array('_element_validate_number'),
69
+      '#default_value' => is_numeric($field['max']) ? $field['max'] : '',
70
+    );
71
+    if ($field['type'] == 'number_decimal') {
72
+      $form['precision'] = array(
73
+        '#type' => 'select',
74
+        '#options' => drupal_map_assoc(range(10, 32)),
75
+        '#title' => t('Precision'),
76
+        '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
77
+        '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10,
64 78
       );
65
-      $form['max'] = array(
66
-        '#type' => 'textfield',
67
-        '#title' => t('Maximum'),
68
-        '#element_validate' => array('_element_validate_number'),
69
-        '#default_value' => is_numeric($field['max']) ? $field['max'] : '',
79
+      $form['scale'] = array(
80
+        '#type' => 'select',
81
+        '#options' => drupal_map_assoc(range(0, 10)),
82
+        '#title' => t('Scale'),
83
+        '#description' => t('The number of digits to the right of the decimal.'),
84
+        '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2,
70 85
       );
71
-      if ($field['type'] == 'number_decimal') {
72
-        $form['precision'] = array(
73
-          '#type' => 'select',
74
-          '#options' => drupal_map_assoc(range(10, 32)),
75
-          '#title' => t('Precision'),
76
-          '#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
77
-          '#default_value' => is_numeric($field['precision']) ? $field['precision'] : 10,
78
-        );
79
-        $form['scale'] = array(
80
-          '#type' => 'select',
81
-          '#options' => drupal_map_assoc(range(0, 10)),
82
-          '#title' => t('Scale'),
83
-          '#description' => t('The number of digits to the right of the decimal.'),
84
-          '#default_value' => is_numeric($field['scale']) ? $field['scale'] : 2,
85
-        );
86
-        $form['decimal'] = array(
87
-          '#type' => 'select',
88
-          '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'),
89
-          '#title' => t('Decimal marker'),
90
-          '#description' => t('The character users will input to mark the decimal point in forms.'),
91
-          '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.',
92
-        );
93
-      }
94
-      $form['append']['prefix'] = array(
95
-        '#type' => 'textfield',
96
-        '#title' => t('Prefix'),
97
-        '#size' => 60,
98
-        '#default_value' => !empty($field['prefix']) ? $field['prefix'] : '',
99
-        '#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
100
-      );
101
-      $form['append']['suffix'] = array(
102
-        '#type' => 'textfield',
103
-        '#title' => t('Suffix'),
104
-        '#size' => 60,
105
-        '#default_value' => !empty($field['suffix']) ? $field['suffix'] : '',
106
-        '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
86
+      $form['decimal'] = array(
87
+        '#type' => 'select',
88
+        '#options' => array('.' => 'decimal point', ',' => 'comma', ' ' => 'space'),
89
+        '#title' => t('Decimal marker'),
90
+        '#description' => t('The character users will input to mark the decimal point in forms.'),
91
+        '#default_value' => !empty($field['decimal']) ? $field['decimal'] : '.',
107 92
       );
108
-      $form['allowed_values_fieldset'] = array(
109
-        '#type' => 'fieldset',
110
-        '#title' => t('Allowed values'),
111
-        '#collapsible' => TRUE,
112
-        '#collapsed' => TRUE,
113
-      );
114
-      $form['allowed_values_fieldset']['allowed_values'] = array(
93
+    }
94
+    $form['append']['prefix'] = array(
95
+      '#type' => 'textfield',
96
+      '#title' => t('Prefix'),
97
+      '#size' => 60,
98
+      '#default_value' => !empty($field['prefix']) ? $field['prefix'] : '',
99
+      '#description' => t('Define a string that should be prefixed to the value, like $ or €. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
100
+    );
101
+    $form['append']['suffix'] = array(
102
+      '#type' => 'textfield',
103
+      '#title' => t('Suffix'),
104
+      '#size' => 60,
105
+      '#default_value' => !empty($field['suffix']) ? $field['suffix'] : '',
106
+      '#description' => t('Define a string that should suffixed to the value, like m², m/s², kb/s. Leave blank for none. Separate singular and plural values with a pipe (pound|pounds).'),
107
+    );
108
+    $form['allowed_values_fieldset'] = array(
109
+      '#type' => 'fieldset',
110
+      '#title' => t('Allowed values'),
111
+      '#collapsible' => TRUE,
112
+      '#collapsed' => TRUE,
113
+    );
114
+    $form['allowed_values_fieldset']['allowed_values'] = array(
115
+      '#type' => 'textarea',
116
+      '#title' => t('Allowed values list'),
117
+      '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
118
+      '#required' => FALSE,
119
+      '#rows' => 10,
120
+      '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
121
+    );
122
+    $form['allowed_values_fieldset']['advanced_options'] = array(
123
+      '#type' => 'fieldset',
124
+      '#title' => t('PHP code'),
125
+      '#collapsible' => TRUE,
126
+      '#collapsed' => empty($field['allowed_values_php']),
127
+    );
128
+    if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
129
+      $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
115 130
         '#type' => 'textarea',
116
-        '#title' => t('Allowed values list'),
117
-        '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
118
-        '#required' => FALSE,
119
-        '#rows' => 10,
120
-        '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
131
+        '#title' => t('Code'),
132
+        '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
133
+        '#rows' => 6,
134
+        '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
121 135
       );
122
-      $form['allowed_values_fieldset']['advanced_options'] = array(
123
-        '#type' => 'fieldset',
124
-        '#title' => t('PHP code'),
125
-        '#collapsible' => TRUE,
126
-        '#collapsed' => empty($field['allowed_values_php']),
136
+    }
137
+    else {
138
+      $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
139
+        '#type' => 'item',
140
+        '#title' => t('Code'),
141
+        '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
142
+        '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
127 143
       );
128
-      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
129
-        $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
130
-          '#type' => 'textarea',
131
-          '#title' => t('Code'),
132
-          '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
133
-          '#rows' => 6,
134
-          '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
135
-        );
136
-      }
137
-      else {
138
-        $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
139
-          '#type' => 'item',
140
-          '#title' => t('Code'),
141
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
142
-          '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
143
-        );
144
-      }
145
-      return $form;
144
+    }
145
+    return $form;
146 146
 
147
-    case 'save':
148
-      $values = array('prefix', 'suffix', 'min', 'max', 'allowed_values', 'allowed_values_php');
149
-      if ($field['type'] == 'number_decimal') {
150
-        $values = array_merge($values, array('precision', 'scale', 'decimal'));
151
-      }
152
-      return $values;
147
+  case 'save':
148
+    $values = array('prefix', 'suffix', 'min', 'max', 'allowed_values', 'allowed_values_php');
149
+    if ($field['type'] == 'number_decimal') {
150
+      $values = array_merge($values, array('precision', 'scale', 'decimal'));
151
+    }
152
+    return $values;
153 153
 
154
-    case 'database columns':
155
-      if ($field['type'] == 'number_integer') {
156
-        return array(
157
-          'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE),
158
-        );
159
-      }
160
-      if ($field['type'] == 'number_float') {
161
-        return array(
162
-          'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE),
163
-        );
164
-      }
165
-      if ($field['type'] == 'number_decimal') {
166
-        $precision = isset($field['precision']) ? $field['precision'] : 10;
167
-        $scale = isset($field['scale']) ? $field['scale'] : 2;
168
-        return array(
169
-          'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE),
170
-        );
171
-      }
154
+  case 'database columns':
155
+    if ($field['type'] == 'number_integer') {
156
+      return array(
157
+        'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE),
158
+      );
159
+    }
160
+    if ($field['type'] == 'number_float') {
161
+      return array(
162
+        'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE),
163
+      );
164
+    }
165
+    if ($field['type'] == 'number_decimal') {
166
+      $precision = isset($field['precision']) ? $field['precision'] : 10;
167
+      $scale = isset($field['scale']) ? $field['scale'] : 2;
168
+      return array(
169
+        'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE),
170
+      );
171
+    }
172 172
 
173
-    case 'views data':
174
-      $allowed_values = content_allowed_values($field);
175
-      if (count($allowed_values)) {
176
-        $data = content_views_field_views_data($field);
177
-        $db_info = content_database_info($field);
178
-        $table_alias = content_views_tablename($field);
179
-
180
-        // Filter: Add a 'many to one' filter.
181
-        $copy = $data[$table_alias][$field['field_name'] .'_value'];
182
-        $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
183
-        $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
184
-        $copy['filter']['numeric'] = TRUE;
185
-        unset($copy['field'], $copy['argument'], $copy['sort']);
186
-        $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
187
-        // Argument: swap the handler to the 'many to one' operator
188
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE;
190
-        return $data;
191
-      }
192
-      break;
173
+  case 'views data':
174
+    $allowed_values = content_allowed_values($field);
175
+    if (count($allowed_values)) {
176
+      $data = content_views_field_views_data($field);
177
+      $db_info = content_database_info($field);
178
+      $table_alias = content_views_tablename($field);
179
+
180
+      // Filter: Add a 'many to one' filter.
181
+      $copy = $data[$table_alias][$field['field_name'] .'_value'];
182
+      $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
183
+      $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
184
+      $copy['filter']['numeric'] = TRUE;
185
+      unset($copy['field'], $copy['argument'], $copy['sort']);
186
+      $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
187
+      // Argument: swap the handler to the 'many to one' operator
188
+      $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189
+      $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE;
190
+      return $data;
191
+    }
192
+    break;
193 193
   }
194 194
 }
195 195
 
@@ -212,37 +212,37 @@  discard block
 block discarded – undo
212 212
  */
213 213
 function number_field($op, &$node, $field, &$items, $teaser, $page) {
214 214
   switch ($op) {
215
-    case 'validate':
216
-      $allowed_values = content_allowed_values($field);
217
-      if (is_array($items)) {
218
-        foreach ($items as $delta => $item) {
219
-          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
220
-          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
221
-          if ($item['value'] != '') {
222
-            if (is_numeric($field['min']) && $item['value'] < $field['min']) {
223
-              form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min'])));
224
-            }
225
-            if (is_numeric($field['max']) && $item['value'] > $field['max']) {
226
-              form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max'])));
227
-            }
228
-            if (count($allowed_values)) {
229
-              // We cannot use array_key_exists() because allowed values are
230
-              // stored as strings, and we need to compare numeric equality.
231
-              $valid = FALSE;
232
-              foreach ($allowed_values as $kay => $value) {
233
-                if ((float) $item['value'] == (float) $kay) {
234
-                  $valid = TRUE;
235
-                  break;
236
-                }
237
-              }
238
-              if (!$valid) {
239
-                form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
215
+  case 'validate':
216
+    $allowed_values = content_allowed_values($field);
217
+    if (is_array($items)) {
218
+      foreach ($items as $delta => $item) {
219
+        $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
220
+        if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
221
+        if ($item['value'] != '') {
222
+          if (is_numeric($field['min']) && $item['value'] < $field['min']) {
223
+            form_set_error($error_element, t('%name: the value may be no smaller than %min.', array('%name' => t($field['widget']['label']), '%min' => $field['min'])));
224
+          }
225
+          if (is_numeric($field['max']) && $item['value'] > $field['max']) {
226
+            form_set_error($error_element, t('%name: the value may be no larger than %max.', array('%name' => t($field['widget']['label']), '%max' => $field['max'])));
227
+          }
228
+          if (count($allowed_values)) {
229
+            // We cannot use array_key_exists() because allowed values are
230
+            // stored as strings, and we need to compare numeric equality.
231
+            $valid = FALSE;
232
+            foreach ($allowed_values as $kay => $value) {
233
+              if ((float) $item['value'] == (float) $kay) {
234
+                $valid = TRUE;
235
+                break;
240 236
               }
241 237
             }
238
+            if (!$valid) {
239
+              form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
240
+            }
242 241
           }
243 242
         }
244 243
       }
245
-      return $items;
244
+    }
245
+    return $items;
246 246
   }
247 247
 }
248 248
 
@@ -300,36 +300,36 @@  discard block
 block discarded – undo
300 300
   }
301 301
 
302 302
   switch ($element['#formatter']) {
303
-    case 'us_0':
304
-      $output = number_format($value, 0, '.', ',');
305
-      break;
306
-    case 'us_1':
307
-      $output = number_format($value, 1, '.', ',');
308
-      break;
309
-    case 'us_2':
310
-      $output = number_format($value, 2, '.', ',');
311
-      break;
312
-    case 'be_0':
313
-      $output = number_format($value, 0, ',', '.');
314
-      break;
315
-    case 'be_1':
316
-      $output = number_format($value, 1, ',', '.');
317
-      break;
318
-    case 'be_2':
319
-      $output = number_format($value, 2, ',', '.');
320
-      break;
321
-    case 'fr_0':
322
-      $output = number_format($value, 0, ', ', ' ');
323
-      break;
324
-    case 'fr_1':
325
-      $output = number_format($value, 1, ', ', ' ');
326
-      break;
327
-    case 'fr_2':
328
-      $output = number_format($value, 2, ', ', ' ');
329
-      break;
330
-    default:
331
-      $output = $value;
332
-      break;
303
+  case 'us_0':
304
+    $output = number_format($value, 0, '.', ',');
305
+    break;
306
+  case 'us_1':
307
+    $output = number_format($value, 1, '.', ',');
308
+    break;
309
+  case 'us_2':
310
+    $output = number_format($value, 2, '.', ',');
311
+    break;
312
+  case 'be_0':
313
+    $output = number_format($value, 0, ',', '.');
314
+    break;
315
+  case 'be_1':
316
+    $output = number_format($value, 1, ',', '.');
317
+    break;
318
+  case 'be_2':
319
+    $output = number_format($value, 2, ',', '.');
320
+    break;
321
+  case 'fr_0':
322
+    $output = number_format($value, 0, ', ', ' ');
323
+    break;
324
+  case 'fr_1':
325
+    $output = number_format($value, 1, ', ', ' ');
326
+    break;
327
+  case 'fr_2':
328
+    $output = number_format($value, 2, ', ', ' ');
329
+    break;
330
+  default:
331
+    $output = $value;
332
+    break;
333 333
   }
334 334
 
335 335
   $prefixes = isset($field['prefix']) ? array_map('content_filter_xss', explode('|', $field['prefix'])) : array('');
@@ -475,18 +475,18 @@  discard block
 block discarded – undo
475 475
     $element[$field_key]['#field_suffix'] = content_filter_xss(array_pop($suffixes));
476 476
   }
477 477
   switch ($field['type']) {
478
-    case 'number_float':
479
-      $element['#element_validate'][] = 'number_float_validate';
480
-      break;
481
-    case 'number_integer':
482
-      $element['#element_validate'][] = 'number_integer_validate';
483
-      break;
484
-    case 'number_decimal':
485
-      $element['#element_validate'][] = 'number_decimal_validate';
486
-      $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.';
487
-      $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10;
488
-      $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2;
489
-      break;
478
+  case 'number_float':
479
+    $element['#element_validate'][] = 'number_float_validate';
480
+    break;
481
+  case 'number_integer':
482
+    $element['#element_validate'][] = 'number_integer_validate';
483
+    break;
484
+  case 'number_decimal':
485
+    $element['#element_validate'][] = 'number_decimal_validate';
486
+    $element['#decimal'] = isset($field['decimal']) ? $field['decimal'] : '.';
487
+    $element['#precision'] = isset($field['precision']) ? $field['precision'] : 10;
488
+    $element['#scale'] = isset($field['scale']) ? $field['scale'] : 2;
489
+    break;
490 490
   }
491 491
 
492 492
   // Used so that hook_field('validate') knows where to flag an error.
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
139 139
           '#type' => 'item',
140 140
           '#title' => t('Code'),
141
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
141
+          '#value' => !empty($field['allowed_values_php']) ? '<code>'.check_plain($field['allowed_values_php']).'</code>' : t('&lt;none&gt;'),
142 142
           '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
143 143
         );
144 144
       }
@@ -178,15 +178,15 @@  discard block
 block discarded – undo
178 178
         $table_alias = content_views_tablename($field);
179 179
 
180 180
         // Filter: Add a 'many to one' filter.
181
-        $copy = $data[$table_alias][$field['field_name'] .'_value'];
181
+        $copy = $data[$table_alias][$field['field_name'].'_value'];
182 182
         $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
183 183
         $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
184 184
         $copy['filter']['numeric'] = TRUE;
185 185
         unset($copy['field'], $copy['argument'], $copy['sort']);
186
-        $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
186
+        $data[$table_alias][$field['field_name'].'_value_many_to_one'] = $copy;
187 187
         // Argument: swap the handler to the 'many to one' operator
188
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE;
188
+        $data[$table_alias][$field['field_name'].'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189
+        $data[$table_alias][$field['field_name'].'_value']['argument']['numeric'] = TRUE;
190 190
         return $data;
191 191
       }
192 192
       break;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
               // stored as strings, and we need to compare numeric equality.
231 231
               $valid = FALSE;
232 232
               foreach ($allowed_values as $kay => $value) {
233
-                if ((float) $item['value'] == (float) $kay) {
233
+                if ((float)$item['value'] == (float)$kay) {
234 234
                   $valid = TRUE;
235 235
                   break;
236 236
                 }
@@ -261,16 +261,16 @@  discard block
 block discarded – undo
261 261
  */
262 262
 function number_field_formatter_info() {
263 263
   return array(
264
-    'default' => array('label' => '9999',            'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
265
-    'us_0'    => array('label' => '9,999',           'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
266
-    'us_1'    => array('label' => '9,999.9',         'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
267
-    'us_2'    => array('label' => '9,999.99',        'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
268
-    'be_0'    => array('label' => '9.999',           'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
269
-    'be_1'    => array('label' => '9.999,9',         'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
270
-    'be_2'    => array('label' => '9.999,99',        'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
271
-    'fr_0'    => array('label' => '9 999',           'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
272
-    'fr_1'    => array('label' => '9 999, 9',        'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
273
-    'fr_2'    => array('label' => '9 999, 99',       'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
264
+    'default' => array('label' => '9999', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
265
+    'us_0'    => array('label' => '9,999', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
266
+    'us_1'    => array('label' => '9,999.9', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
267
+    'us_2'    => array('label' => '9,999.99', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
268
+    'be_0'    => array('label' => '9.999', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
269
+    'be_1'    => array('label' => '9.999,9', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
270
+    'be_2'    => array('label' => '9.999,99', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
271
+    'fr_0'    => array('label' => '9 999', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
272
+    'fr_1'    => array('label' => '9 999, 9', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
273
+    'fr_2'    => array('label' => '9 999, 99', 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_decimal', 'number_float')),
274 274
     'unformatted' => array('label' => t('unformatted'), 'multiple values' => CONTENT_HANDLE_CORE, 'field types' => array('number_integer', 'number_decimal', 'number_float')),
275 275
   );
276 276
 }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
   $prefix = (count($prefixes) > 1) ? format_plural($value, $prefixes[0], $prefixes[1]) : $prefixes[0];
338 338
   $suffix = (count($suffixes) > 1) ? format_plural($value, $suffixes[0], $suffixes[1]) : $suffixes[0];
339 339
 
340
-  return $prefix . $output . $suffix;
340
+  return $prefix.$output.$suffix;
341 341
 }
342 342
 
343 343
 /**
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
     $start = $value;
513 513
     $value = preg_replace('@[^-0-9\.]@', '', $value);
514 514
     if ($start != $value) {
515
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
515
+      $error_field = implode('][', $element['#parents']).']['.$field_key;
516 516
       form_set_error($error_field, t('Only numbers and decimals are allowed in %field.', array('%field' => t($field['widget']['label']))));
517 517
     }
518 518
     else {
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
     $start = $value;
536 536
     $value = preg_replace('@[^-0-9]@', '', $value);
537 537
     if ($start != $value) {
538
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
538
+      $error_field = implode('][', $element['#parents']).']['.$field_key;
539 539
       form_set_error($error_field, t('Only numbers are allowed in %field.', array('%field' => t($field['widget']['label']))));
540 540
     }
541 541
     else {
@@ -557,9 +557,9 @@  discard block
 block discarded – undo
557 557
   if (($element[$field_key]['#required'] || !empty($value))) {
558 558
     $decimal = $element['#decimal'] ? $element['#decimal'] : '.';
559 559
     $start = $value;
560
-    $value = preg_replace('@[^-0-9\\'. $decimal .']@', '', $value);
560
+    $value = preg_replace('@[^-0-9\\'.$decimal.']@', '', $value);
561 561
     if ($start != $value) {
562
-      $error_field = implode('][', $element['#parents']) .']['. $field_key;
562
+      $error_field = implode('][', $element['#parents']).']['.$field_key;
563 563
       form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $element['#decimal'], '%field' => t($field['widget']['label']))));
564 564
     }
565 565
     else {
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -133,8 +133,7 @@  discard block
 block discarded – undo
133 133
           '#rows' => 6,
134 134
           '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
135 135
         );
136
-      }
137
-      else {
136
+      } else {
138 137
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
139 138
           '#type' => 'item',
140 139
           '#title' => t('Code'),
@@ -514,8 +513,7 @@  discard block
 block discarded – undo
514 513
     if ($start != $value) {
515 514
       $error_field = implode('][', $element['#parents']) .']['. $field_key;
516 515
       form_set_error($error_field, t('Only numbers and decimals are allowed in %field.', array('%field' => t($field['widget']['label']))));
517
-    }
518
-    else {
516
+    } else {
519 517
       form_set_value($element[$field_key], $value, $form_state);
520 518
     }
521 519
   }
@@ -537,8 +535,7 @@  discard block
 block discarded – undo
537 535
     if ($start != $value) {
538 536
       $error_field = implode('][', $element['#parents']) .']['. $field_key;
539 537
       form_set_error($error_field, t('Only numbers are allowed in %field.', array('%field' => t($field['widget']['label']))));
540
-    }
541
-    else {
538
+    } else {
542 539
       form_set_value($element[$field_key], $value, $form_state);
543 540
     }
544 541
   }
@@ -561,8 +558,7 @@  discard block
 block discarded – undo
561 558
     if ($start != $value) {
562 559
       $error_field = implode('][', $element['#parents']) .']['. $field_key;
563 560
       form_set_error($error_field, t('Only numbers and the decimal character (%decimal) are allowed in %field.', array('%decimal' => $element['#decimal'], '%field' => t($field['widget']['label']))));
564
-    }
565
-    else {
561
+    } else {
566 562
       $value = str_replace($element['#decimal'], '.', $value);
567 563
       $value = round($value, $element['#scale']);
568 564
       form_set_value($element[$field_key], $value, $form_state);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -11,18 +11,18 @@  discard block
 block discarded – undo
11 11
  */
12 12
 function number_theme() {
13 13
   return array(
14
-    'number' => array('arguments' => array('element' => NULL)),
15
-    'number_formatter_default' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
16
-    'number_formatter_us_0' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
17
-    'number_formatter_us_1' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
18
-    'number_formatter_us_2' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
19
-    'number_formatter_be_0' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
20
-    'number_formatter_be_1' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
21
-    'number_formatter_be_2' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
22
-    'number_formatter_fr_0' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
23
-    'number_formatter_fr_1' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
24
-    'number_formatter_fr_2' => array('arguments' => array('element' => NULL), 'function' => 'theme_number_formatter_generic'),
25
-    'number_formatter_unformatted' => array('arguments' => array('element' => NULL)),
14
+    'number' => array('arguments' => array('element' => null)),
15
+    'number_formatter_default' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
16
+    'number_formatter_us_0' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
17
+    'number_formatter_us_1' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
18
+    'number_formatter_us_2' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
19
+    'number_formatter_be_0' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
20
+    'number_formatter_be_1' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
21
+    'number_formatter_be_2' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
22
+    'number_formatter_fr_0' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
23
+    'number_formatter_fr_1' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
24
+    'number_formatter_fr_2' => array('arguments' => array('element' => null), 'function' => 'theme_number_formatter_generic'),
25
+    'number_formatter_unformatted' => array('arguments' => array('element' => null)),
26 26
   );
27 27
 }
28 28
 
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
       $form['allowed_values_fieldset'] = array(
109 109
         '#type' => 'fieldset',
110 110
         '#title' => t('Allowed values'),
111
-        '#collapsible' => TRUE,
112
-        '#collapsed' => TRUE,
111
+        '#collapsible' => true,
112
+        '#collapsed' => true,
113 113
       );
114 114
       $form['allowed_values_fieldset']['allowed_values'] = array(
115 115
         '#type' => 'textarea',
116 116
         '#title' => t('Allowed values list'),
117 117
         '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
118
-        '#required' => FALSE,
118
+        '#required' => false,
119 119
         '#rows' => 10,
120 120
         '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
121 121
       );
122 122
       $form['allowed_values_fieldset']['advanced_options'] = array(
123 123
         '#type' => 'fieldset',
124 124
         '#title' => t('PHP code'),
125
-        '#collapsible' => TRUE,
125
+        '#collapsible' => true,
126 126
         '#collapsed' => empty($field['allowed_values_php']),
127 127
       );
128 128
       if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
     case 'database columns':
155 155
       if ($field['type'] == 'number_integer') {
156 156
         return array(
157
-          'value' => array('type' => 'int', 'not null' => FALSE, 'sortable' => TRUE),
157
+          'value' => array('type' => 'int', 'not null' => false, 'sortable' => true),
158 158
         );
159 159
       }
160 160
       if ($field['type'] == 'number_float') {
161 161
         return array(
162
-          'value' => array('type' => 'float', 'not null' => FALSE, 'sortable' => TRUE),
162
+          'value' => array('type' => 'float', 'not null' => false, 'sortable' => true),
163 163
         );
164 164
       }
165 165
       if ($field['type'] == 'number_decimal') {
166 166
         $precision = isset($field['precision']) ? $field['precision'] : 10;
167 167
         $scale = isset($field['scale']) ? $field['scale'] : 2;
168 168
         return array(
169
-          'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => FALSE, 'sortable' => TRUE),
169
+          'value' => array('type' => 'numeric', 'precision' => $precision, 'scale' => $scale, 'not null' => false, 'sortable' => true),
170 170
         );
171 171
       }
172 172
 
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
         $copy = $data[$table_alias][$field['field_name'] .'_value'];
182 182
         $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
183 183
         $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
184
-        $copy['filter']['numeric'] = TRUE;
184
+        $copy['filter']['numeric'] = true;
185 185
         unset($copy['field'], $copy['argument'], $copy['sort']);
186 186
         $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
187 187
         // Argument: swap the handler to the 'many to one' operator
188 188
         $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
189
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = TRUE;
189
+        $data[$table_alias][$field['field_name'] .'_value']['argument']['numeric'] = true;
190 190
         return $data;
191 191
       }
192 192
       break;
@@ -228,10 +228,10 @@  discard block
 block discarded – undo
228 228
             if (count($allowed_values)) {
229 229
               // We cannot use array_key_exists() because allowed values are
230 230
               // stored as strings, and we need to compare numeric equality.
231
-              $valid = FALSE;
231
+              $valid = false;
232 232
               foreach ($allowed_values as $kay => $value) {
233 233
                 if ((float) $item['value'] == (float) $kay) {
234
-                  $valid = TRUE;
234
+                  $valid = true;
235 235
                   break;
236 236
                 }
237 237
               }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
  */
252 252
 function number_content_is_empty($item, $field) {
253 253
   if (empty($item['value']) && (string)$item['value'] !== '0') {
254
-    return TRUE;
254
+    return true;
255 255
   }
256
-  return FALSE;
256
+  return false;
257 257
 }
258 258
 
259 259
 /**
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
 function number_elements() {
380 380
   return array(
381 381
     'number' => array(
382
-      '#input' => TRUE,
382
+      '#input' => true,
383 383
       '#columns' => array('value'), '#delta' => 0,
384 384
       '#process' => array('number_process'),
385 385
     ),
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 function number_widget(&$form, &$form_state, $field, $items, $delta = 0) {
421 421
   $element = array(
422 422
     '#type' => $field['widget']['type'],
423
-    '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
423
+    '#default_value' => isset($items[$delta]) ? $items[$delta] : null,
424 424
   );
425 425
   return $element;
426 426
 }
Please login to merge, or discard this patch.
boinc/modules/contrib/cck/modules/optionwidgets/optionwidgets.module 5 patches
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_form_alter.
11 11
  */
12 12
 function optionwidgets_form_alter(&$form, $form_state, $form_id) {
13
-  // Provide additional help for the field settings form.
14
-  if ($form_id == 'content_field_edit_form' && isset($form['widget'])) {
13
+    // Provide additional help for the field settings form.
14
+    if ($form_id == 'content_field_edit_form' && isset($form['widget'])) {
15 15
     $widget_type = $form['#field']['widget']['type'];
16 16
     $field_type = $form['#field']['type'];
17 17
     $label = $form['#field']['widget']['label'];
@@ -19,45 +19,45 @@  discard block
 block discarded – undo
19 19
     $output = '<p>'. t('Create a list of options as a list in <strong>Allowed values list</strong> or as an array in PHP code. These values will be the same for %field in all content types.', array('%field' => $label)) .'</p>';
20 20
 
21 21
     if ($widget_type == 'optionwidgets_onoff') {
22
-      $output .= '<p>'. t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") .'</p>';
22
+        $output .= '<p>'. t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") .'</p>';
23 23
     }
24 24
     elseif ($widget_type == 'optionwidgets_buttons') {
25
-      $output .= '<p>'. t("The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.") .'</p>';
25
+        $output .= '<p>'. t("The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.") .'</p>';
26 26
     }
27 27
 
28 28
     if (in_array($field_type, array('text', 'number_integer', 'number_float', 'number_decimal'))
29 29
     && in_array($widget_type, array('optionwidgets_onoff', 'optionwidgets_buttons', 'optionwidgets_select'))) {
30
-      $form['field']['allowed_values_fieldset']['#collapsed'] = FALSE;
31
-      $form['field']['allowed_values_fieldset']['#description'] = $output;
30
+        $form['field']['allowed_values_fieldset']['#collapsed'] = FALSE;
31
+        $form['field']['allowed_values_fieldset']['#description'] = $output;
32 32
 
33
-      // If no 'allowed values' were set yet, add a remainder in the messages area.
34
-      if (empty($form_state['post'])
33
+        // If no 'allowed values' were set yet, add a remainder in the messages area.
34
+        if (empty($form_state['post'])
35 35
       && empty($form['field']['allowed_values_fieldset']['allowed_values']['#default_value'])
36 36
       && empty($form['field']['allowed_values_fieldset']['advanced_options']['allowed_values_php']['#default_value'])) {
37 37
         drupal_set_message(t("You need to specify the 'allowed values' for this field."), 'warning');
38
-      }
38
+        }
39
+    }
39 40
     }
40
-  }
41 41
 }
42 42
 
43 43
 /**
44 44
  * Implementation of hook_theme().
45 45
  */
46 46
 function optionwidgets_theme() {
47
-  return array(
47
+    return array(
48 48
     'optionwidgets_select' => array(
49
-      'arguments' => array('element' => NULL),
49
+        'arguments' => array('element' => NULL),
50 50
     ),
51 51
     'optionwidgets_buttons' => array(
52
-      'arguments' => array('element' => NULL),
52
+        'arguments' => array('element' => NULL),
53 53
     ),
54 54
     'optionwidgets_onoff' => array(
55
-      'arguments' => array('element' => NULL),
55
+        'arguments' => array('element' => NULL),
56 56
     ),
57 57
     'optionwidgets_none' => array(
58
-      'arguments' => array('widget_type' => NULL, 'field_name' => NULL, 'node_type' => NULL),
59
-      ),
60
-  );
58
+        'arguments' => array('widget_type' => NULL, 'field_name' => NULL, 'node_type' => NULL),
59
+        ),
60
+    );
61 61
 }
62 62
 
63 63
 /**
@@ -75,32 +75,32 @@  discard block
 block discarded – undo
75 75
  */
76 76
 function optionwidgets_widget_info() {
77 77
 
78
-  return array(
78
+    return array(
79 79
     'optionwidgets_select' => array(
80
-      'label' => t('Select list'),
81
-      'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
82
-      'multiple values' => CONTENT_HANDLE_MODULE,
83
-      'callbacks' => array(
80
+        'label' => t('Select list'),
81
+        'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
82
+        'multiple values' => CONTENT_HANDLE_MODULE,
83
+        'callbacks' => array(
84 84
         'default value' => CONTENT_CALLBACK_DEFAULT,
85
-      ),
85
+        ),
86 86
     ),
87 87
     'optionwidgets_buttons' => array(
88
-      'label' => t('Check boxes/radio buttons'),
89
-      'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
90
-      'multiple values' => CONTENT_HANDLE_MODULE,
91
-      'callbacks' => array(
88
+        'label' => t('Check boxes/radio buttons'),
89
+        'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
90
+        'multiple values' => CONTENT_HANDLE_MODULE,
91
+        'callbacks' => array(
92 92
         'default value' => CONTENT_CALLBACK_DEFAULT,
93
-      ),
93
+        ),
94 94
     ),
95 95
     'optionwidgets_onoff' => array(
96
-      'label' => t('Single on/off checkbox'),
97
-      'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
98
-      'multiple values' => CONTENT_HANDLE_MODULE,
99
-      'callbacks' => array(
96
+        'label' => t('Single on/off checkbox'),
97
+        'field types' => array('text', 'number_integer', 'number_decimal', 'number_float'),
98
+        'multiple values' => CONTENT_HANDLE_MODULE,
99
+        'callbacks' => array(
100 100
         'default value' => CONTENT_CALLBACK_DEFAULT,
101
-      ),
101
+        ),
102 102
     ),
103
-  );
103
+    );
104 104
 }
105 105
 
106 106
 /**
@@ -113,22 +113,22 @@  discard block
 block discarded – undo
113 113
  * the same name as the hook_elements key.
114 114
  */
115 115
 function optionwidgets_elements() {
116
-  return array(
116
+    return array(
117 117
     'optionwidgets_select' => array(
118
-      '#input' => TRUE,
119
-      '#columns' => array('value'), '#delta' => 0,
120
-      '#process' => array('optionwidgets_select_process'),
121
-      ),
118
+        '#input' => TRUE,
119
+        '#columns' => array('value'), '#delta' => 0,
120
+        '#process' => array('optionwidgets_select_process'),
121
+        ),
122 122
     'optionwidgets_buttons' => array(
123
-      '#input' => TRUE,
124
-      '#columns' => array('value'), '#delta' => 0,
125
-      '#process' => array('optionwidgets_buttons_process'),
126
-      ),
123
+        '#input' => TRUE,
124
+        '#columns' => array('value'), '#delta' => 0,
125
+        '#process' => array('optionwidgets_buttons_process'),
126
+        ),
127 127
     'optionwidgets_onoff' => array(
128
-      '#input' => TRUE,
129
-      '#columns' => array('value'), '#delta' => 0,
130
-      '#process' => array('optionwidgets_onoff_process'),
131
-      ),
128
+        '#input' => TRUE,
129
+        '#columns' => array('value'), '#delta' => 0,
130
+        '#process' => array('optionwidgets_onoff_process'),
131
+        ),
132 132
     );
133 133
 }
134 134
 
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
  *   the form item for a single element for this field
165 165
  */
166 166
 function optionwidgets_widget(&$form, &$form_state, $field, $items, $delta = NULL) {
167
-  $element = array(
167
+    $element = array(
168 168
     '#type' => $field['widget']['type'],
169 169
     '#default_value' => !empty($items) ? $items : array(),
170
-  );
171
-  return $element;
170
+    );
171
+    return $element;
172 172
 }
173 173
 
174 174
 /**
@@ -180,17 +180,17 @@  discard block
 block discarded – undo
180 180
  * The $fields array is in $form['#field_info'][$element['#field_name']].
181 181
  */
182 182
 function optionwidgets_buttons_process($element, $edit, &$form_state, $form) {
183
-  $field_name = $element['#field_name'];
184
-  $field = $form['#field_info'][$field_name];
185
-  $field_key  = $element['#columns'][0];
183
+    $field_name = $element['#field_name'];
184
+    $field = $form['#field_info'][$field_name];
185
+    $field_key  = $element['#columns'][0];
186 186
 
187
-  // See if this element is in the database format or the transformed format,
188
-  // and transform it if necessary.
189
-  if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
187
+    // See if this element is in the database format or the transformed format,
188
+    // and transform it if necessary.
189
+    if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
190 190
     $element['#value'] = optionwidgets_data2form($element, $element['#default_value'], $field);
191
-  }
192
-  $options = optionwidgets_options($field);
193
-  $element[$field_key] = array(
191
+    }
192
+    $options = optionwidgets_options($field);
193
+    $element[$field_key] = array(
194 194
     '#type' => $field['multiple'] ? 'checkboxes' : 'radios',
195 195
     '#title' => $element['#title'],
196 196
     '#description' => $element['#description'],
@@ -198,19 +198,19 @@  discard block
 block discarded – undo
198 198
     '#multiple' => isset($element['#multiple']) ? $element['#multiple'] : $field['multiple'],
199 199
     '#options' => $options,
200 200
     '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
201
-  );
201
+    );
202 202
 
203
-  // Set #element_validate in a way that it will not wipe out other
204
-  // validation functions already set by other modules.
205
-  if (empty($element['#element_validate'])) {
203
+    // Set #element_validate in a way that it will not wipe out other
204
+    // validation functions already set by other modules.
205
+    if (empty($element['#element_validate'])) {
206 206
     $element['#element_validate'] = array();
207
-  }
208
-  array_unshift($element['#element_validate'], 'optionwidgets_validate');
207
+    }
208
+    array_unshift($element['#element_validate'], 'optionwidgets_validate');
209 209
 
210
-  // Make sure field info will be available to the validator which
211
-  // does not get the values in $form.
212
-  $form_state['#field_info'][$field['field_name']] = $field;
213
-  return $element;
210
+    // Make sure field info will be available to the validator which
211
+    // does not get the values in $form.
212
+    $form_state['#field_info'][$field['field_name']] = $field;
213
+    return $element;
214 214
 }
215 215
 
216 216
 /**
@@ -222,23 +222,23 @@  discard block
 block discarded – undo
222 222
  * The $fields array is in $form['#field_info'][$element['#field_name']].
223 223
  */
224 224
 function optionwidgets_select_process($element, $edit, &$form_state, $form) {
225
-  $field_name = $element['#field_name'];
226
-  $field = $form['#field_info'][$field_name];
227
-  $field_key  = $element['#columns'][0];
225
+    $field_name = $element['#field_name'];
226
+    $field = $form['#field_info'][$field_name];
227
+    $field_key  = $element['#columns'][0];
228 228
 
229
-  // See if this element is in the database format or the transformed format,
230
-  // and transform it if necessary.
231
-  if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
229
+    // See if this element is in the database format or the transformed format,
230
+    // and transform it if necessary.
231
+    if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
232 232
     $element['#value'] = optionwidgets_data2form($element, $element['#default_value'], $field);
233
-  }
233
+    }
234 234
 
235
-  $options = optionwidgets_options($field, FALSE);
235
+    $options = optionwidgets_options($field, FALSE);
236 236
 
237
-  // For this specific widget, HTML should be filtered out and entities left unencoded.
238
-  // See content_allowed_values / content_filter_xss / filter_xss.
239
-  content_allowed_values_filter_html($options);
237
+    // For this specific widget, HTML should be filtered out and entities left unencoded.
238
+    // See content_allowed_values / content_filter_xss / filter_xss.
239
+    content_allowed_values_filter_html($options);
240 240
 
241
-  $element[$field_key] = array(
241
+    $element[$field_key] = array(
242 242
     '#type' => 'select',
243 243
     '#title' => $element['#title'],
244 244
     '#description' => $element['#description'],
@@ -246,24 +246,24 @@  discard block
 block discarded – undo
246 246
     '#multiple' => isset($element['#multiple']) ? $element['#multiple'] : $field['multiple'],
247 247
     '#options' => $options,
248 248
     '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
249
-  );
249
+    );
250 250
 
251
-  // Set #element_validate in a way that it will not wipe out other
252
-  // validation functions already set by other modules.
253
-  if (empty($element['#element_validate'])) {
251
+    // Set #element_validate in a way that it will not wipe out other
252
+    // validation functions already set by other modules.
253
+    if (empty($element['#element_validate'])) {
254 254
     $element['#element_validate'] = array();
255
-  }
256
-  array_unshift($element['#element_validate'], 'optionwidgets_validate');
257
-
258
-  // Make sure field info will be available to the validator which
259
-  // does not get the values in $form.
260
-
261
-  // TODO for some reason putting the $field array into $form_state['storage']
262
-  // causes the node's hook_form_alter to be invoked twice, garbling the
263
-  // results. Need to investigate why that is happening (a core bug?), but
264
-  // in the meantime avoid using $form_state['storage'] to store anything.
265
-  $form_state['#field_info'][$field['field_name']] = $field;
266
-  return $element;
255
+    }
256
+    array_unshift($element['#element_validate'], 'optionwidgets_validate');
257
+
258
+    // Make sure field info will be available to the validator which
259
+    // does not get the values in $form.
260
+
261
+    // TODO for some reason putting the $field array into $form_state['storage']
262
+    // causes the node's hook_form_alter to be invoked twice, garbling the
263
+    // results. Need to investigate why that is happening (a core bug?), but
264
+    // in the meantime avoid using $form_state['storage'] to store anything.
265
+    $form_state['#field_info'][$field['field_name']] = $field;
266
+    return $element;
267 267
 }
268 268
 
269 269
 /**
@@ -275,64 +275,64 @@  discard block
 block discarded – undo
275 275
  * The $fields array is in $form['#field_info'][$element['#field_name']].
276 276
  */
277 277
 function optionwidgets_onoff_process($element, $edit, &$form_state, $form) {
278
-  $field_name = $element['#field_name'];
279
-  $field = $form['#field_info'][$field_name];
280
-  $field_key  = $element['#columns'][0];
278
+    $field_name = $element['#field_name'];
279
+    $field = $form['#field_info'][$field_name];
280
+    $field_key  = $element['#columns'][0];
281 281
 
282
-  // See if this element is in the database format or the transformed format,
283
-  // and transform it if necessary.
284
-  if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
282
+    // See if this element is in the database format or the transformed format,
283
+    // and transform it if necessary.
284
+    if (is_array($element['#value']) && !array_key_exists($field_key, $element['#value'])) {
285 285
     $element['#value'] = optionwidgets_data2form($element, $element['#default_value'], $field);
286
-  }
287
-  $options = optionwidgets_options($field);
288
-  $keys = array_keys($options);
289
-  $on_value = (!empty($keys) && isset($keys[1])) ? $keys[1] : NULL;
290
-  $element[$field_key] = array(
286
+    }
287
+    $options = optionwidgets_options($field);
288
+    $keys = array_keys($options);
289
+    $on_value = (!empty($keys) && isset($keys[1])) ? $keys[1] : NULL;
290
+    $element[$field_key] = array(
291 291
     '#type' => 'checkbox',
292 292
     '#title' => isset($options[$on_value]) ? $options[$on_value] : '',
293 293
     '#description' => $element['#description'],
294 294
     '#required' => isset($element['#required']) ? $element['#required'] : $field['required'],
295 295
     '#default_value' => isset($element['#value'][$field_key][0]) ? $element['#value'][$field_key][0] == $on_value : FALSE,
296 296
     '#return_value' => $on_value,
297
-  );
297
+    );
298 298
 
299
-  // Set #element_validate in a way that it will not wipe out other
300
-  // validation functions already set by other modules.
301
-  if (empty($element['#element_validate'])) {
299
+    // Set #element_validate in a way that it will not wipe out other
300
+    // validation functions already set by other modules.
301
+    if (empty($element['#element_validate'])) {
302 302
     $element['#element_validate'] = array();
303
-  }
304
-  array_unshift($element['#element_validate'], 'optionwidgets_validate');
303
+    }
304
+    array_unshift($element['#element_validate'], 'optionwidgets_validate');
305 305
 
306
-  // Make sure field info will be available to the validator which
307
-  // does not get the values in $form.
308
-  $form_state['#field_info'][$field['field_name']] = $field;
309
-  return $element;
306
+    // Make sure field info will be available to the validator which
307
+    // does not get the values in $form.
308
+    $form_state['#field_info'][$field['field_name']] = $field;
309
+    return $element;
310 310
 }
311 311
 
312 312
 /**
313 313
  * FAPI function to validate optionwidgets element.
314 314
  */
315 315
 function optionwidgets_validate($element, &$form_state) {
316
-  // Transpose selections from field => delta to delta => field,
317
-  // turning multiple selected options into multiple parent elements.
318
-  // Immediate parent is the delta, need to get back to parent's parent
319
-  // to create multiple elements.
320
-  $field = $form_state['#field_info'][$element['#field_name']];
321
-  $items = optionwidgets_form2data($element, $field);
322
-  form_set_value($element, $items, $form_state);
323
-
324
-  // Check we don't exceed the allowed number of values.
325
-  if ($field['multiple'] >= 2) {
316
+    // Transpose selections from field => delta to delta => field,
317
+    // turning multiple selected options into multiple parent elements.
318
+    // Immediate parent is the delta, need to get back to parent's parent
319
+    // to create multiple elements.
320
+    $field = $form_state['#field_info'][$element['#field_name']];
321
+    $items = optionwidgets_form2data($element, $field);
322
+    form_set_value($element, $items, $form_state);
323
+
324
+    // Check we don't exceed the allowed number of values.
325
+    if ($field['multiple'] >= 2) {
326 326
     // Filter out 'none' value (if present, will always be in key 0)
327 327
     $field_key = $element['#columns'][0];
328 328
     if (isset($items[0][$field_key]) && $items[0][$field_key] === '') {
329
-      unset($items[0]);
329
+        unset($items[0]);
330 330
     }
331 331
     if (count($items) > $field['multiple']) {
332
-      $field_key  = $element['#columns'][0];
333
-      form_error($element[$field_key], t('%name: this field cannot hold more than @count values.', array('%name' => t($field['widget']['label']), '@count' => $field['multiple'])));
332
+        $field_key  = $element['#columns'][0];
333
+        form_error($element[$field_key], t('%name: this field cannot hold more than @count values.', array('%name' => t($field['widget']['label']), '@count' => $field['multiple'])));
334
+    }
334 335
     }
335
-  }
336 336
 }
337 337
 
338 338
 /**
@@ -341,24 +341,24 @@  discard block
 block discarded – undo
341 341
  * transformation is needed.
342 342
  */
343 343
 function optionwidgets_data2form($element, $items, $field) {
344
-  $field_key  = $element['#columns'][0];
345
-  $options    = optionwidgets_options($field);
344
+    $field_key  = $element['#columns'][0];
345
+    $options    = optionwidgets_options($field);
346 346
 
347
-  $items_transposed = content_transpose_array_rows_cols($items);
348
-  $values = (isset($items_transposed[$field_key]) && is_array($items_transposed[$field_key])) ? $items_transposed[$field_key] : array();
349
-  $keys = array();
350
-  foreach ($values as $value) {
347
+    $items_transposed = content_transpose_array_rows_cols($items);
348
+    $values = (isset($items_transposed[$field_key]) && is_array($items_transposed[$field_key])) ? $items_transposed[$field_key] : array();
349
+    $keys = array();
350
+    foreach ($values as $value) {
351 351
     $key = array_search($value, array_keys($options));
352 352
     if (isset($key)) {
353
-      $keys[] = $value;
353
+        $keys[] = $value;
354
+    }
354 355
     }
355
-  }
356
-  if ($field['multiple'] || $element['#type'] == 'optionwidgets_onoff') {
356
+    if ($field['multiple'] || $element['#type'] == 'optionwidgets_onoff') {
357 357
     return array($field_key => $keys);
358
-  }
359
-  else {
358
+    }
359
+    else {
360 360
     return !empty($keys) ? array($field_key => $value) : array();
361
-  }
361
+    }
362 362
 }
363 363
 
364 364
 /**
@@ -367,22 +367,22 @@  discard block
 block discarded – undo
367 367
  * transformation is needed.
368 368
  */
369 369
 function optionwidgets_form2data($element, $field) {
370
-  $field_key = $element['#columns'][0];
371
-  $items = (array) $element[$field_key]['#value'];
372
-  $options = optionwidgets_options($field);
370
+    $field_key = $element['#columns'][0];
371
+    $items = (array) $element[$field_key]['#value'];
372
+    $options = optionwidgets_options($field);
373 373
 
374
-  $values = array_values($items);
374
+    $values = array_values($items);
375 375
 
376
-  if ($element['#type'] == 'optionwidgets_onoff' && ($values[0] === 0)) {
376
+    if ($element['#type'] == 'optionwidgets_onoff' && ($values[0] === 0)) {
377 377
     $keys = array_keys($options);
378 378
     $values = array(array_key_exists(0, $keys) ? $keys[0] : NULL);
379
-  }
379
+    }
380 380
 
381
-  if (empty($values)) {
381
+    if (empty($values)) {
382 382
     $values[] = NULL;
383
-  }
384
-  $result = content_transpose_array_rows_cols(array($field_key => $values));
385
-  return $result;
383
+    }
384
+    $result = content_transpose_array_rows_cols(array($field_key => $values));
385
+    return $result;
386 386
 }
387 387
 
388 388
 /**
@@ -399,18 +399,18 @@  discard block
 block discarded – undo
399 399
  *   when allowed values list is generated using PHP code.
400 400
  */
401 401
 function optionwidgets_options($field, $flatten = TRUE) {
402
-  $function = $field['module'] .'_allowed_values';
403
-  $options = function_exists($function) ? $function($field) : (array) content_allowed_values($field, $flatten);
404
-  // Add an empty choice for :
405
-  // - non required radios
406
-  // - non required selects
407
-  if (!$field['required']) {
402
+    $function = $field['module'] .'_allowed_values';
403
+    $options = function_exists($function) ? $function($field) : (array) content_allowed_values($field, $flatten);
404
+    // Add an empty choice for :
405
+    // - non required radios
406
+    // - non required selects
407
+    if (!$field['required']) {
408 408
     if ((in_array($field['widget']['type'], array('optionwidgets_buttons', 'nodereference_buttons', 'userreference_buttons')) && !$field['multiple'])
409 409
       || (in_array($field['widget']['type'], array('optionwidgets_select', 'nodereference_select', 'userreference_select')))) {
410
-      $options = array('' => theme('optionwidgets_none', $field)) + $options;
410
+        $options = array('' => theme('optionwidgets_none', $field)) + $options;
411
+    }
411 412
     }
412
-  }
413
-  return $options;
413
+    return $options;
414 414
 }
415 415
 
416 416
 /**
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
  *  The default theme will display N/A for a radio list and blank for a select.
419 419
  */
420 420
 function theme_optionwidgets_none($field) {
421
-  switch ($field['widget']['type']) {
421
+    switch ($field['widget']['type']) {
422 422
     case 'optionwidgets_buttons':
423 423
     case 'nodereference_buttons':
424 424
     case 'userreference_buttons':
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
       return t('- None -');
430 430
     default :
431 431
       return '';
432
-  }
432
+    }
433 433
 }
434 434
 
435 435
 /**
@@ -444,13 +444,13 @@  discard block
 block discarded – undo
444 444
  * $element['#delta]  is the position of this element in the group
445 445
  */
446 446
 function theme_optionwidgets_select($element) {
447
-  return $element['#children'];
447
+    return $element['#children'];
448 448
 }
449 449
 
450 450
 function theme_optionwidgets_onoff($element) {
451
-  return $element['#children'];
451
+    return $element['#children'];
452 452
 }
453 453
 
454 454
 function theme_optionwidgets_buttons($element) {
455
-  return $element['#children'];
455
+    return $element['#children'];
456 456
 }
457 457
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -419,16 +419,16 @@
 block discarded – undo
419 419
  */
420 420
 function theme_optionwidgets_none($field) {
421 421
   switch ($field['widget']['type']) {
422
-    case 'optionwidgets_buttons':
423
-    case 'nodereference_buttons':
424
-    case 'userreference_buttons':
425
-      return t('N/A');
426
-    case 'optionwidgets_select':
427
-    case 'nodereference_select':
428
-    case 'userreference_select':
429
-      return t('- None -');
430
-    default :
431
-      return '';
422
+  case 'optionwidgets_buttons':
423
+  case 'nodereference_buttons':
424
+  case 'userreference_buttons':
425
+    return t('N/A');
426
+  case 'optionwidgets_select':
427
+  case 'nodereference_select':
428
+  case 'userreference_select':
429
+    return t('- None -');
430
+  default :
431
+    return '';
432 432
   }
433 433
 }
434 434
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
     $field_type = $form['#field']['type'];
17 17
     $label = $form['#field']['widget']['label'];
18 18
 
19
-    $output = '<p>'. t('Create a list of options as a list in <strong>Allowed values list</strong> or as an array in PHP code. These values will be the same for %field in all content types.', array('%field' => $label)) .'</p>';
19
+    $output = '<p>'.t('Create a list of options as a list in <strong>Allowed values list</strong> or as an array in PHP code. These values will be the same for %field in all content types.', array('%field' => $label)).'</p>';
20 20
 
21 21
     if ($widget_type == 'optionwidgets_onoff') {
22
-      $output .= '<p>'. t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") .'</p>';
22
+      $output .= '<p>'.t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.").'</p>';
23 23
     }
24 24
     elseif ($widget_type == 'optionwidgets_buttons') {
25
-      $output .= '<p>'. t("The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.") .'</p>';
25
+      $output .= '<p>'.t("The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.").'</p>';
26 26
     }
27 27
 
28 28
     if (in_array($field_type, array('text', 'number_integer', 'number_float', 'number_decimal'))
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
       unset($items[0]);
330 330
     }
331 331
     if (count($items) > $field['multiple']) {
332
-      $field_key  = $element['#columns'][0];
332
+      $field_key = $element['#columns'][0];
333 333
       form_error($element[$field_key], t('%name: this field cannot hold more than @count values.', array('%name' => t($field['widget']['label']), '@count' => $field['multiple'])));
334 334
     }
335 335
   }
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
  */
369 369
 function optionwidgets_form2data($element, $field) {
370 370
   $field_key = $element['#columns'][0];
371
-  $items = (array) $element[$field_key]['#value'];
371
+  $items = (array)$element[$field_key]['#value'];
372 372
   $options = optionwidgets_options($field);
373 373
 
374 374
   $values = array_values($items);
@@ -399,8 +399,8 @@  discard block
 block discarded – undo
399 399
  *   when allowed values list is generated using PHP code.
400 400
  */
401 401
 function optionwidgets_options($field, $flatten = TRUE) {
402
-  $function = $field['module'] .'_allowed_values';
403
-  $options = function_exists($function) ? $function($field) : (array) content_allowed_values($field, $flatten);
402
+  $function = $field['module'].'_allowed_values';
403
+  $options = function_exists($function) ? $function($field) : (array)content_allowed_values($field, $flatten);
404 404
   // Add an empty choice for :
405 405
   // - non required radios
406 406
   // - non required selects
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,8 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
     if ($widget_type == 'optionwidgets_onoff') {
22 22
       $output .= '<p>'. t("For a 'single on/off checkbox' widget, define the 'off' value first, then the 'on' value in the <strong>Allowed values</strong> section. Note that the checkbox will be labeled with the label of the 'on' value.") .'</p>';
23
-    }
24
-    elseif ($widget_type == 'optionwidgets_buttons') {
23
+    } elseif ($widget_type == 'optionwidgets_buttons') {
25 24
       $output .= '<p>'. t("The 'checkboxes/radio buttons' widget will display checkboxes if the multiple values option is selected for this field, otherwise radios will be displayed.") .'</p>';
26 25
     }
27 26
 
@@ -355,8 +354,7 @@  discard block
 block discarded – undo
355 354
   }
356 355
   if ($field['multiple'] || $element['#type'] == 'optionwidgets_onoff') {
357 356
     return array($field_key => $keys);
358
-  }
359
-  else {
357
+  } else {
360 358
     return !empty($keys) ? array($field_key => $value) : array();
361 359
   }
362 360
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 
28 28
     if (in_array($field_type, array('text', 'number_integer', 'number_float', 'number_decimal'))
29 29
     && in_array($widget_type, array('optionwidgets_onoff', 'optionwidgets_buttons', 'optionwidgets_select'))) {
30
-      $form['field']['allowed_values_fieldset']['#collapsed'] = FALSE;
30
+      $form['field']['allowed_values_fieldset']['#collapsed'] = false;
31 31
       $form['field']['allowed_values_fieldset']['#description'] = $output;
32 32
 
33 33
       // If no 'allowed values' were set yet, add a remainder in the messages area.
@@ -46,16 +46,16 @@  discard block
 block discarded – undo
46 46
 function optionwidgets_theme() {
47 47
   return array(
48 48
     'optionwidgets_select' => array(
49
-      'arguments' => array('element' => NULL),
49
+      'arguments' => array('element' => null),
50 50
     ),
51 51
     'optionwidgets_buttons' => array(
52
-      'arguments' => array('element' => NULL),
52
+      'arguments' => array('element' => null),
53 53
     ),
54 54
     'optionwidgets_onoff' => array(
55
-      'arguments' => array('element' => NULL),
55
+      'arguments' => array('element' => null),
56 56
     ),
57 57
     'optionwidgets_none' => array(
58
-      'arguments' => array('widget_type' => NULL, 'field_name' => NULL, 'node_type' => NULL),
58
+      'arguments' => array('widget_type' => null, 'field_name' => null, 'node_type' => null),
59 59
       ),
60 60
   );
61 61
 }
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
 function optionwidgets_elements() {
116 116
   return array(
117 117
     'optionwidgets_select' => array(
118
-      '#input' => TRUE,
118
+      '#input' => true,
119 119
       '#columns' => array('value'), '#delta' => 0,
120 120
       '#process' => array('optionwidgets_select_process'),
121 121
       ),
122 122
     'optionwidgets_buttons' => array(
123
-      '#input' => TRUE,
123
+      '#input' => true,
124 124
       '#columns' => array('value'), '#delta' => 0,
125 125
       '#process' => array('optionwidgets_buttons_process'),
126 126
       ),
127 127
     'optionwidgets_onoff' => array(
128
-      '#input' => TRUE,
128
+      '#input' => true,
129 129
       '#columns' => array('value'), '#delta' => 0,
130 130
       '#process' => array('optionwidgets_onoff_process'),
131 131
       ),
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
  * @return
164 164
  *   the form item for a single element for this field
165 165
  */
166
-function optionwidgets_widget(&$form, &$form_state, $field, $items, $delta = NULL) {
166
+function optionwidgets_widget(&$form, &$form_state, $field, $items, $delta = null) {
167 167
   $element = array(
168 168
     '#type' => $field['widget']['type'],
169 169
     '#default_value' => !empty($items) ? $items : array(),
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
     '#required' => isset($element['#required']) ? $element['#required'] : $field['required'],
198 198
     '#multiple' => isset($element['#multiple']) ? $element['#multiple'] : $field['multiple'],
199 199
     '#options' => $options,
200
-    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
200
+    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : null,
201 201
   );
202 202
 
203 203
   // Set #element_validate in a way that it will not wipe out other
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
     $element['#value'] = optionwidgets_data2form($element, $element['#default_value'], $field);
233 233
   }
234 234
 
235
-  $options = optionwidgets_options($field, FALSE);
235
+  $options = optionwidgets_options($field, false);
236 236
 
237 237
   // For this specific widget, HTML should be filtered out and entities left unencoded.
238 238
   // See content_allowed_values / content_filter_xss / filter_xss.
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
     '#required' => isset($element['#required']) ? $element['#required'] : $field['required'],
246 246
     '#multiple' => isset($element['#multiple']) ? $element['#multiple'] : $field['multiple'],
247 247
     '#options' => $options,
248
-    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
248
+    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : null,
249 249
   );
250 250
 
251 251
   // Set #element_validate in a way that it will not wipe out other
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
   }
287 287
   $options = optionwidgets_options($field);
288 288
   $keys = array_keys($options);
289
-  $on_value = (!empty($keys) && isset($keys[1])) ? $keys[1] : NULL;
289
+  $on_value = (!empty($keys) && isset($keys[1])) ? $keys[1] : null;
290 290
   $element[$field_key] = array(
291 291
     '#type' => 'checkbox',
292 292
     '#title' => isset($options[$on_value]) ? $options[$on_value] : '',
293 293
     '#description' => $element['#description'],
294 294
     '#required' => isset($element['#required']) ? $element['#required'] : $field['required'],
295
-    '#default_value' => isset($element['#value'][$field_key][0]) ? $element['#value'][$field_key][0] == $on_value : FALSE,
295
+    '#default_value' => isset($element['#value'][$field_key][0]) ? $element['#value'][$field_key][0] == $on_value : false,
296 296
     '#return_value' => $on_value,
297 297
   );
298 298
 
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 
376 376
   if ($element['#type'] == 'optionwidgets_onoff' && ($values[0] === 0)) {
377 377
     $keys = array_keys($options);
378
-    $values = array(array_key_exists(0, $keys) ? $keys[0] : NULL);
378
+    $values = array(array_key_exists(0, $keys) ? $keys[0] : null);
379 379
   }
380 380
 
381 381
   if (empty($values)) {
382
-    $values[] = NULL;
382
+    $values[] = null;
383 383
   }
384 384
   $result = content_transpose_array_rows_cols(array($field_key => $values));
385 385
   return $result;
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
  *   FALSE can be used to support optgroups for select widgets
399 399
  *   when allowed values list is generated using PHP code.
400 400
  */
401
-function optionwidgets_options($field, $flatten = TRUE) {
401
+function optionwidgets_options($field, $flatten = true) {
402 402
   $function = $field['module'] .'_allowed_values';
403 403
   $options = function_exists($function) ? $function($field) : (array) content_allowed_values($field, $flatten);
404 404
   // Add an empty choice for :
Please login to merge, or discard this patch.
default/boinc/modules/contrib/cck/modules/content_copy/content_copy.module 5 patches
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -32,174 +32,174 @@  discard block
 block discarded – undo
32 32
  * Implementation of hook_menu().
33 33
  */
34 34
 function content_copy_menu() {
35
-  $items = array();
35
+    $items = array();
36 36
 
37
-  $items['admin/content/types/export'] = array(
37
+    $items['admin/content/types/export'] = array(
38 38
     'title' => 'Export',
39 39
     'page callback' => 'drupal_get_form',
40 40
     'page arguments' => array('content_copy_export_form'),
41 41
     'access arguments' => array('administer content types'),
42 42
     'type' => MENU_LOCAL_TASK,
43 43
     'weight' => 3,
44
-  );
45
-  $items['admin/content/types/import'] = array(
44
+    );
45
+    $items['admin/content/types/import'] = array(
46 46
     'title' => 'Import',
47 47
     'page callback' => 'drupal_get_form',
48 48
     'page arguments' => array('content_copy_import_form'),
49 49
     'access arguments' => array('administer content types'),
50 50
     'type' => MENU_LOCAL_TASK,
51 51
     'weight' => 4,
52
-  );
53
-  return $items;
52
+    );
53
+    return $items;
54 54
 }
55 55
 
56 56
 /**
57 57
  * Implementation of hook_theme().
58 58
  */
59 59
 function content_copy_theme() {
60
-  return array(
60
+    return array(
61 61
     'content_copy_export_form' => array(
62
-      'template' => 'content_copy_export_form',
63
-      'arguments' => array('form' => NULL),
62
+        'template' => 'content_copy_export_form',
63
+        'arguments' => array('form' => NULL),
64 64
     ),
65
-  );
65
+    );
66 66
 }
67 67
 
68 68
 /**
69 69
  *  A form to export field definitions.
70 70
  */
71 71
 function content_copy_export_form(&$form_state) {
72
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
72
+    include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
+    include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
74 74
 
75
-  $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76
-  $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
75
+    $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76
+    $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
77 77
 
78
-  $exportable_fields = array();
79
-  $groups = array();
78
+    $exportable_fields = array();
79
+    $groups = array();
80 80
 
81
-  $type_name = isset($form_values['type_name']) ? $form_values['type_name'] : '';
82
-  if ($type_name) {
81
+    $type_name = isset($form_values['type_name']) ? $form_values['type_name'] : '';
82
+    if ($type_name) {
83 83
     $type = content_types($type_name);
84 84
     $exportable_fields = content_copy_fields($type_name);
85 85
     if (module_exists('fieldgroup')) {
86
-      $groups = fieldgroup_groups($type_name);
86
+        $groups = fieldgroup_groups($type_name);
87
+    }
87 88
     }
88
-  }
89 89
 
90
-  // If a content type has been selected and there are no fields or groups to select,
91
-  // jump straight to export.
92
-  if ($step == 2 && !($groups) && !($exportable_fields)) {
90
+    // If a content type has been selected and there are no fields or groups to select,
91
+    // jump straight to export.
92
+    if ($step == 2 && !($groups) && !($exportable_fields)) {
93 93
     $step = 3;
94
-  }
94
+    }
95 95
 
96
-  $form['#step'] = $step;
97
-  $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
96
+    $form['#step'] = $step;
97
+    $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
98 98
 
99
-  switch ($step) {
99
+    switch ($step) {
100 100
     case 1: // Select a content type.
101 101
       $types  = content_copy_types();
102
-      $form['type_name'] = array(
102
+        $form['type_name'] = array(
103 103
         '#title' => t('Types'),
104 104
         '#type' => 'radios',
105 105
         '#options' => $types,
106 106
         '#description' => t('Select the content type to export.'),
107
-      );
108
-      break;
107
+        );
108
+        break;
109 109
 
110 110
     case 2: // Select groups and fields.
111 111
       $form['type_name'] = array(
112 112
         '#type' => 'hidden',
113 113
         '#value' => $type_name,
114
-      );
114
+        );
115 115
 
116
-      $form += array(
116
+        $form += array(
117 117
         '#fields' => $exportable_fields,
118 118
         '#groups' => array_keys($groups),
119
-      );
119
+        );
120 120
 
121
-      $fields_options = $groups_options = array();
121
+        $fields_options = $groups_options = array();
122 122
 
123
-      // Fields.
124
-      foreach ($exportable_fields as $field_name) {
123
+        // Fields.
124
+        foreach ($exportable_fields as $field_name) {
125 125
         $field = content_fields($field_name, $type_name);
126 126
         $fields_options[$field_name] = '';
127 127
         $weight = $field['widget']['weight'];
128 128
         $form[$field_name] = array(
129
-          'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
-          'field_name' => array('#value' => $field['field_name']),
131
-          'type' => array('#value' => $field['type']),
132
-          'weight' => array('#type' => 'value', '#value' => $weight),
133
-          'parent' => array('#type' => 'value', '#value' => ''),
134
-          '#row_type' => 'field',
129
+            'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
+            'field_name' => array('#value' => $field['field_name']),
131
+            'type' => array('#value' => $field['type']),
132
+            'weight' => array('#type' => 'value', '#value' => $weight),
133
+            'parent' => array('#type' => 'value', '#value' => ''),
134
+            '#row_type' => 'field',
135 135
         );
136
-      }
137
-      $form['fields'] = array(
136
+        }
137
+        $form['fields'] = array(
138 138
         '#type' => 'checkboxes',
139 139
         '#options' => $fields_options,
140 140
         '#default_value' => array_keys($fields_options),
141
-      );
141
+        );
142 142
 
143
-      // Groups.
144
-      foreach ($groups as $name => $group) {
143
+        // Groups.
144
+        foreach ($groups as $name => $group) {
145 145
         $groups_options[$name] = '';
146 146
         $weight = $group['weight'];
147 147
         $form[$name] = array(
148
-          'human_name' => array('#value' => check_plain($group['label'])),
149
-          'group_name' => array('#value' => $group['group_name']),
150
-          'weight' => array('#type' => 'value', '#value' => $weight),
151
-          '#row_type' => 'group',
148
+            'human_name' => array('#value' => check_plain($group['label'])),
149
+            'group_name' => array('#value' => $group['group_name']),
150
+            'weight' => array('#type' => 'value', '#value' => $weight),
151
+            '#row_type' => 'group',
152 152
         );
153 153
         foreach ($group['fields'] as $field_name => $field) {
154
-          // Do nothing for non-exportable (inactive) fields.
155
-          if (isset($form[$field_name])) {
154
+            // Do nothing for non-exportable (inactive) fields.
155
+            if (isset($form[$field_name])) {
156 156
             $form[$field_name]['parent']['#value'] = $name;
157
-          }
157
+            }
158
+        }
158 159
         }
159
-      }
160
-      if ($groups) {
160
+        if ($groups) {
161 161
         $form['groups'] = array(
162
-          '#type' => 'checkboxes',
163
-          '#options' => $groups_options,
164
-          '#default_value' => array_keys($groups_options),
162
+            '#type' => 'checkboxes',
163
+            '#options' => $groups_options,
164
+            '#default_value' => array_keys($groups_options),
165 165
         );
166
-      }
167
-      break;
166
+        }
167
+        break;
168 168
 
169 169
     case 3: // Display the export macro.
170 170
       $GLOBALS['content_copy']['count'] = 0;
171
-      $form['export'] = array(
171
+        $form['export'] = array(
172 172
         '#title' => t('Export data'),
173 173
         '#type' => 'textarea',
174 174
         '#cols' => 60,
175 175
         '#value' => content_copy_export($form_values),
176 176
         '#rows' => max(40, $GLOBALS['content_copy']['count']),
177 177
         '#description' => t('Copy the export text and paste it into another content type using the import function.'),
178
-      );
179
-      // The calls to drupal_execute('content_field_edit_form') in
180
-      // content_copy_export() affect the page title,
181
-      drupal_set_title(t('Content types'));
182
-      break;
183
-  }
184
-
185
-  if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
178
+        );
179
+        // The calls to drupal_execute('content_field_edit_form') in
180
+        // content_copy_export() affect the page title,
181
+        drupal_set_title(t('Content types'));
182
+        break;
183
+    }
184
+
185
+    if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
186 186
     $form['submit'] = array(
187
-      '#type' => 'submit',
188
-      '#value' => t('Export'),
187
+        '#type' => 'submit',
188
+        '#value' => t('Export'),
189 189
     );
190
-  }
190
+    }
191 191
 
192
-  $form['step'] = array(
192
+    $form['step'] = array(
193 193
     '#type' => 'value',
194 194
     '#value' => $step,
195
-  );
195
+    );
196 196
 
197
-  return $form;
197
+    return $form;
198 198
 }
199 199
 
200 200
 function content_copy_export_form_submit($form, &$form_state) {
201
-  $form_state['rebuild'] = TRUE;
202
-  $form_state['storage']['step'] = $form_state['values']['step'];
201
+    $form_state['rebuild'] = TRUE;
202
+    $form_state['storage']['step'] = $form_state['values']['step'];
203 203
 }
204 204
 
205 205
 
@@ -208,66 +208,66 @@  discard block
 block discarded – undo
208 208
  *   and save the form values as formatted text.
209 209
  */
210 210
 function content_copy_export($form_values) {
211
-  // Set a global variable to tell when to intervene with form_alter().
212
-  $GLOBALS['content_copy']['status'] = 'export';
211
+    // Set a global variable to tell when to intervene with form_alter().
212
+    $GLOBALS['content_copy']['status'] = 'export';
213 213
 
214
-  // Get the content type info by submitting the content type form.
215
-  $node_state = array('values' => array('type_name' => $form_values['type_name']));
216
-  module_load_include('inc', 'node', 'content_types');
217
-  drupal_execute('node_type_form', $node_state, node_get_types('type', $form_values['type_name']));
214
+    // Get the content type info by submitting the content type form.
215
+    $node_state = array('values' => array('type_name' => $form_values['type_name']));
216
+    module_load_include('inc', 'node', 'content_types');
217
+    drupal_execute('node_type_form', $node_state, node_get_types('type', $form_values['type_name']));
218 218
 
219
-  module_load_include('inc', 'content', 'includes/content.admin');
220
-  module_load_include('inc', 'content', 'includes/content.crud');
219
+    module_load_include('inc', 'content', 'includes/content.admin');
220
+    module_load_include('inc', 'content', 'includes/content.crud');
221 221
 
222
-  // Get an array of groups to export.
223
-  // Record a macro for each group by submitting the group edit form.
224
-  $groups = array();
225
-  if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
222
+    // Get an array of groups to export.
223
+    // Record a macro for each group by submitting the group edit form.
224
+    $groups = array();
225
+    if (!empty($form_values['groups']) && module_exists('fieldgroup')) {
226 226
     $groups = array_filter($form_values['groups']);
227 227
     foreach ($groups as $group) {
228
-      $group_state = array('values' => array('group_name' => $group));
229
-      drupal_execute('fieldgroup_group_edit_form', $group_state, $form_values['type_name'], $group, 'edit');
228
+        $group_state = array('values' => array('group_name' => $group));
229
+        drupal_execute('fieldgroup_group_edit_form', $group_state, $form_values['type_name'], $group, 'edit');
230
+    }
230 231
     }
231
-  }
232 232
 
233
-  // Get an array of fields to export
234
-  // Record a macro for each field by submitting the field settings form.
235
-  // Omit fields from the export if their module is not currently installed
236
-  // otherwise the system will generate errors when the macro tries to execute their forms.
237
-  if (!empty($form_values['fields'])) {
233
+    // Get an array of fields to export
234
+    // Record a macro for each field by submitting the field settings form.
235
+    // Omit fields from the export if their module is not currently installed
236
+    // otherwise the system will generate errors when the macro tries to execute their forms.
237
+    if (!empty($form_values['fields'])) {
238 238
     $type = content_types($form_values['type_name']);
239 239
     $fields = array_filter($form_values['fields']);
240 240
     foreach ($fields as $field_name) {
241
-      $field = $type['fields'][$field_name];
242
-      $field_types = _content_field_types();
243
-      $field_module = $field_types[$field['type']]['module'];
244
-      $widget_types = _content_widget_types();
245
-      $widget_module = $widget_types[$field['widget']['type']]['module'];
246
-      if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
241
+        $field = $type['fields'][$field_name];
242
+        $field_types = _content_field_types();
243
+        $field_module = $field_types[$field['type']]['module'];
244
+        $widget_types = _content_widget_types();
245
+        $widget_module = $widget_types[$field['widget']['type']]['module'];
246
+        if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
247 247
         $field_state = array('values' => content_field_instance_collapse($field));
248 248
         $field_state['values']['op'] = t('Save field settings');
249 249
         if (module_exists('fieldgroup')) {
250
-          // Avoid undefined index error by always creating this.
251
-          $field_state['values']['group'] = '';
252
-          $group_name = fieldgroup_get_group($form_values['type_name'], $field_name);
253
-          if (in_array($group_name, $groups)) {
250
+            // Avoid undefined index error by always creating this.
251
+            $field_state['values']['group'] = '';
252
+            $group_name = fieldgroup_get_group($form_values['type_name'], $field_name);
253
+            if (in_array($group_name, $groups)) {
254 254
             $field_state['values']['group'] = $group_name;
255
-          }
255
+            }
256 256
         }
257 257
         drupal_execute('content_field_edit_form', $field_state, $form_values['type_name'], $field_name);
258
-      }
258
+        }
259
+    }
259 260
     }
260
-  }
261 261
 
262
-  // Convert the macro array into formatted text.
263
-  $output = content_copy_get_macro();
262
+    // Convert the macro array into formatted text.
263
+    $output = content_copy_get_macro();
264 264
 
265
-  // Add weights of non-CCK fields.
266
-  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
265
+    // Add weights of non-CCK fields.
266
+    if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267 267
     $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
268
-  }
268
+    }
269 269
 
270
-  return $output;
270
+    return $output;
271 271
 }
272 272
 
273 273
 /**
@@ -294,37 +294,37 @@  discard block
 block discarded – undo
294 294
  * }
295 295
  */
296 296
 function content_copy_import_form(&$form_state, $type_name = '') {
297
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
297
+    include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
+    include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
299 299
 
300
-  $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301
-  $form['type_name'] = array(
300
+    $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301
+    $form['type_name'] = array(
302 302
     '#type' => 'select',
303 303
     '#options' => array('<create>' => t('<Create>')) + content_copy_types(),
304 304
     '#default_value' => $type_name,
305 305
     '#title' => t('Content type'),
306 306
     '#description' => t('Select the content type to import these fields into.<br/>Select &lt;Create&gt; to create a new content type to contain the fields.'),
307
-  );
308
-  $form['macro'] = array(
307
+    );
308
+    $form['macro'] = array(
309 309
     '#type' => 'textarea',
310 310
     '#rows' => 40,
311 311
     '#title' => t('Import data'),
312 312
     '#required' => TRUE,
313 313
     '#description' => t('Paste the text created by a content export into this field.'),
314
-  );
315
-  $form['submit'] = array(
314
+    );
315
+    $form['submit'] = array(
316 316
     '#type' => 'submit',
317 317
     '#value' => t('Import'),
318
-  );
319
-  // Read in a file if there is one and set it as the default macro value.
320
-  if (isset($_REQUEST['macro_file']) && $file = file_get_contents($_REQUEST['macro_file'])) {
318
+    );
319
+    // Read in a file if there is one and set it as the default macro value.
320
+    if (isset($_REQUEST['macro_file']) && $file = file_get_contents($_REQUEST['macro_file'])) {
321 321
     $form['macro']['#default_value'] = $file;
322 322
     if (isset($_REQUEST['type_name'])) {
323
-      $form['type_name']['#default_value'] = $_REQUEST['type_name'];
323
+        $form['type_name']['#default_value'] = $_REQUEST['type_name'];
324 324
     }
325 325
     $form['#prefix'] .= '<p class="error">'. t('A file has been pre-loaded for import.') .'</p>';
326
-  }
327
-  return $form;
326
+    }
327
+    return $form;
328 328
 }
329 329
 
330 330
 /**
@@ -334,90 +334,90 @@  discard block
 block discarded – undo
334 334
  *     2) execute the imported field macro to update the settings to the imported values
335 335
  */
336 336
 function content_copy_import_form_submit($form, &$form_state) {
337
-  $form_values = $form_state['values'];
337
+    $form_values = $form_state['values'];
338 338
 
339
-  // Get the content type we are importing into.
340
-  $type_name = $form_values['type_name'];
341
-  $type_label = node_get_types('name', $type_name);
339
+    // Get the content type we are importing into.
340
+    $type_name = $form_values['type_name'];
341
+    $type_label = node_get_types('name', $type_name);
342 342
 
343
-  $content = NULL;
344
-  // Convert the import formatted text back into a $content array.
345
-  // Return if errors generated or not an array.
346
-  // Use '@' to suppress errors about undefined constants in the macro.
347
-  @eval($form_values['macro']);
343
+    $content = NULL;
344
+    // Convert the import formatted text back into a $content array.
345
+    // Return if errors generated or not an array.
346
+    // Use '@' to suppress errors about undefined constants in the macro.
347
+    @eval($form_values['macro']);
348 348
 
349
-  // Preliminary error trapping, must have valid arrays to work with.
350
-  if (!isset($content) || !isset($content['type']) || !is_array($content) || !is_array($content['type'])) {
349
+    // Preliminary error trapping, must have valid arrays to work with.
350
+    if (!isset($content) || !isset($content['type']) || !is_array($content) || !is_array($content['type'])) {
351 351
     form_set_error('macro', t('The import data is not valid import text.'));
352 352
     return;
353
-  }
353
+    }
354 354
 
355
-  module_load_include('inc', 'content', 'includes/content.crud');
355
+    module_load_include('inc', 'content', 'includes/content.crud');
356 356
 
357
-  // Get all type and field info for this database.
358
-  $content_info = _content_type_info();
357
+    // Get all type and field info for this database.
358
+    $content_info = _content_type_info();
359 359
 
360
-  $imported_type = $content['type'];
361
-  $imported_type_name = $imported_type['type'];
362
-  $imported_type_label = $imported_type['name'];
360
+    $imported_type = $content['type'];
361
+    $imported_type_name = $imported_type['type'];
362
+    $imported_type_label = $imported_type['name'];
363 363
 
364
-  // It is allowed to import a type with no fields,
365
-  // so the fields array could be empty and must be cast as an array.
366
-  $imported_fields = isset($content['fields']) ? $content['fields'] : array();
364
+    // It is allowed to import a type with no fields,
365
+    // so the fields array could be empty and must be cast as an array.
366
+    $imported_fields = isset($content['fields']) ? $content['fields'] : array();
367 367
 
368
-  // Perform more pre-import error trapping.
369
-  // If there are potential problems, exit without doing the import.
370
-  $not_enabled = array();
368
+    // Perform more pre-import error trapping.
369
+    // If there are potential problems, exit without doing the import.
370
+    $not_enabled = array();
371 371
 
372
-  // The groups array could be empty and still valid, make sure to cast it as an array.
373
-  // If there are groups in the import, make sure the fieldgroup module is enabled.
374
-  $imported_groups = array();
375
-  if (isset($content['groups']) && module_exists('fieldgroup')) {
372
+    // The groups array could be empty and still valid, make sure to cast it as an array.
373
+    // If there are groups in the import, make sure the fieldgroup module is enabled.
374
+    $imported_groups = array();
375
+    if (isset($content['groups']) && module_exists('fieldgroup')) {
376 376
     $imported_groups = (array) $content['groups'];
377
-  }
378
-  elseif (isset($content['groups']) && is_array($content['groups'])) {
377
+    }
378
+    elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
380
-  }
380
+    }
381 381
 
382
-  // Make sure that all the field and widget modules in the import are enabled in this database.
383
-  foreach ($imported_fields as $import) {
382
+    // Make sure that all the field and widget modules in the import are enabled in this database.
383
+    foreach ($imported_fields as $import) {
384 384
     $field = content_field_instance_collapse($import);
385 385
     if (empty($field['module']) || empty($field['widget_module'])) {
386
-      $not_enabled[] = $field['field_name'];
386
+        $not_enabled[] = $field['field_name'];
387 387
     }
388 388
     else {
389
-      if (!module_exists($field['module'])) {
389
+        if (!module_exists($field['module'])) {
390 390
         $not_enabled[] = $field['module'];
391
-      }
392
-      if (!module_exists($field['widget_module'])) {
391
+        }
392
+        if (!module_exists($field['widget_module'])) {
393 393
         $not_enabled[] = $field['widget_module'];
394
-      }
394
+        }
395
+    }
395 396
     }
396
-  }
397 397
 
398
-  // If any required module is not enabled, set an error message and exit.
399
-  if ($not_enabled) {
398
+    // If any required module is not enabled, set an error message and exit.
399
+    if ($not_enabled) {
400 400
     form_set_error('macro', t('The following modules must be enabled for this import to work: %modules.', array(
401 401
         '%modules' => implode(', ', array_unique($not_enabled))
402 402
         )));
403
-  }
403
+    }
404 404
 
405
-  // Make sure the imported content type doesn't already exist in the database.
406
-  if ($form_values['type_name'] == '<create>') {
405
+    // Make sure the imported content type doesn't already exist in the database.
406
+    if ($form_values['type_name'] == '<create>') {
407 407
     if (in_array($imported_type_name, array_keys($content_info['content types']))) {
408
-      form_set_error('macro', t('The content type %type already exists in this database.', array(
408
+        form_set_error('macro', t('The content type %type already exists in this database.', array(
409 409
             '%type' => $imported_type_name
410 410
             )));
411 411
     }
412
-  }
412
+    }
413 413
 
414
-  if (form_get_errors()) {
414
+    if (form_get_errors()) {
415 415
     drupal_set_message(t('Exiting. No import performed.'), 'error');
416 416
     return;
417
-  }
417
+    }
418 418
 
419
-  // Create the content type, if requested.
420
-  if ($form_values['type_name'] == '<create>') {
419
+    // Create the content type, if requested.
420
+    if ($form_values['type_name'] == '<create>') {
421 421
 
422 422
     $type = (object) $imported_type;
423 423
     $values = $imported_type;
@@ -435,26 +435,26 @@  discard block
 block discarded – undo
435 435
     $content_info = _content_type_info();
436 436
 
437 437
     if (form_get_errors() || !isset($content_info['content types']) || !is_array($content_info['content types'][$type_name])) {
438
-       drupal_set_message(t('An error has occurred adding the content type %type.<br/>Please check the errors displayed for more details.', array(
438
+        drupal_set_message(t('An error has occurred adding the content type %type.<br/>Please check the errors displayed for more details.', array(
439 439
             '%type' => $imported_type_name
440 440
             )));
441
-       return;
441
+        return;
442
+    }
442 443
     }
443
-  }
444 444
 
445
-  // Create the groups for this type, if they don't already exist.
446
-  if (module_exists('fieldgroup') && $imported_groups) {
445
+    // Create the groups for this type, if they don't already exist.
446
+    if (module_exists('fieldgroup') && $imported_groups) {
447 447
     foreach ($imported_groups as $group) {
448
-      $group_name = $group['group_name'];
449
-      fieldgroup_save_group($type_name, $group);
448
+        $group_name = $group['group_name'];
449
+        fieldgroup_save_group($type_name, $group);
450 450
     }
451 451
     // Reset the static variable in fieldgroup_groups() with new data.
452 452
     fieldgroup_groups('', FALSE, TRUE);
453
-  }
453
+    }
454 454
 
455
-  // Iterate through the field forms in the import and execute each.
456
-  $rebuild = FALSE;
457
-  foreach ($imported_fields as $field) {
455
+    // Iterate through the field forms in the import and execute each.
456
+    $rebuild = FALSE;
457
+    foreach ($imported_fields as $field) {
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
460 460
     // If so, do nothing, fields can't be duplicated within a content type.
@@ -464,13 +464,13 @@  discard block
 block discarded – undo
464 464
     $field['type_name'] = $type_name;
465 465
 
466 466
     if (!empty($field['field_name']) && isset($content_info['content types'][$type_name]['fields'][$field_name])) {
467
-      drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
467
+        drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
468 468
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469 469
     }
470 470
     else {
471
-      $field = content_field_instance_create($field, FALSE);
472
-      $rebuild = TRUE;
473
-      drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
471
+        $field = content_field_instance_create($field, FALSE);
472
+        $rebuild = TRUE;
473
+        drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
474 474
         '%field_label' => $field['widget']['label'], '%field_name' => $field_name, '%type' => $type_label)));
475 475
     }
476 476
 
@@ -480,20 +480,20 @@  discard block
 block discarded – undo
480 480
     // restored. Hence, we need to update field group data for newly imported
481 481
     // field, but also for fields that already exist.
482 482
     if (module_exists('fieldgroup') && isset($imported_groups)) {
483
-      fieldgroup_update_fields($field);
483
+        fieldgroup_update_fields($field);
484
+    }
484 485
     }
485
-  }
486 486
 
487
-  // Clear caches and rebuild menu only if any field has been created.
488
-  if ($rebuild) {
487
+    // Clear caches and rebuild menu only if any field has been created.
488
+    if ($rebuild) {
489 489
     content_clear_type_cache(TRUE);
490 490
     menu_rebuild();
491
-  }
491
+    }
492 492
 
493
-  // Import weights of non-CCK fields.
494
-  if (isset($content['extra'])) {
493
+    // Import weights of non-CCK fields.
494
+    if (isset($content['extra'])) {
495 495
     variable_set('content_extra_weights_'. $type_name, $content['extra']);
496
-  }
496
+    }
497 497
 }
498 498
 
499 499
 /**
@@ -501,22 +501,22 @@  discard block
 block discarded – undo
501 501
  * Intervene to run form through macro when doing export
502 502
  */
503 503
 function content_copy_form_alter(&$form, $form_state, $form_id) {
504
-  $alter_forms = array('node_type_form', 'content_field_edit_form', 'fieldgroup_group_edit_form');
505
-  if (isset($GLOBALS['content_copy']) && isset($GLOBALS['content_copy']['status']) && $GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) {
504
+    $alter_forms = array('node_type_form', 'content_field_edit_form', 'fieldgroup_group_edit_form');
505
+    if (isset($GLOBALS['content_copy']) && isset($GLOBALS['content_copy']['status']) && $GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) {
506 506
     $form['#submit'][] = 'content_copy_record_macro';
507
-  }
507
+    }
508 508
 }
509 509
 
510 510
 /**
511 511
  * Get all the *active* fields for a content type.
512 512
  */
513 513
 function content_copy_fields($type_name) {
514
-  $fields = array();
515
-  if (!$type_name) {
514
+    $fields = array();
515
+    if (!$type_name) {
516 516
     return $fields;
517
-  }
518
-  $content_info = _content_type_info();
519
-  foreach ($content_info['content types'][$type_name]['fields'] as $field_name => $field) {
517
+    }
518
+    $content_info = _content_type_info();
519
+    foreach ($content_info['content types'][$type_name]['fields'] as $field_name => $field) {
520 520
     // Omit fields from the export if their module is not currently installed
521 521
     // otherwise the system will generate errors when the macro tries to execute their forms.
522 522
     $field_types = _content_field_types();
@@ -525,125 +525,125 @@  discard block
 block discarded – undo
525 525
     $widget_module = $widget_types[$field['widget']['type']]['module'];
526 526
 
527 527
     if (!$field['locked'] && !empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) {
528
-      $fields[] = $field_name;
528
+        $fields[] = $field_name;
529 529
     }
530
-  }
531
-  return $fields;
530
+    }
531
+    return $fields;
532 532
 }
533 533
 
534 534
 /**
535 535
  *  Get all content types.
536 536
  */
537 537
 function content_copy_types() {
538
-  $types = array();
539
-  $content_info = _content_type_info();
540
-  foreach ($content_info['content types'] as $type_name => $val) {
538
+    $types = array();
539
+    $content_info = _content_type_info();
540
+    foreach ($content_info['content types'] as $type_name => $val) {
541 541
     $types[$type_name] = check_plain($val['name']) .' ('. $type_name .')';
542
-  }
543
-  return $types;
542
+    }
543
+    return $types;
544 544
 }
545 545
 
546 546
 /**
547 547
  * A handler that stores the form submissions into a $GLOBALS array
548 548
  */
549 549
 function content_copy_record_macro($form, &$form_state) {
550
-  $edit = $form_state['values'];
551
-  $subs = isset($GLOBALS['content_copy']['submissions']) ? $GLOBALS['content_copy']['submissions'] : array();
550
+    $edit = $form_state['values'];
551
+    $subs = isset($GLOBALS['content_copy']['submissions']) ? $GLOBALS['content_copy']['submissions'] : array();
552 552
 
553
-  // Get the form values and store them in a $GLOBALS['content_copy']['submissions'] array.
554
-  // Update $GLOBALS['content_copy']['count'] with an approximation of the number of rows in this item.
555
-  // Count is used to approximate necessary size of textarea in form.
553
+    // Get the form values and store them in a $GLOBALS['content_copy']['submissions'] array.
554
+    // Update $GLOBALS['content_copy']['count'] with an approximation of the number of rows in this item.
555
+    // Count is used to approximate necessary size of textarea in form.
556 556
 
557
-  $form_id = $form_state['values']['form_id'];
558
-  if (isset($edit['type_name']) || isset($edit['submit']) || isset($edit['delete']) || isset($edit['form_id'])) {
557
+    $form_id = $form_state['values']['form_id'];
558
+    if (isset($edit['type_name']) || isset($edit['submit']) || isset($edit['delete']) || isset($edit['form_id'])) {
559 559
     unset($edit['type_name'], $edit['submit'], $edit['delete'], $edit['form_id'], $edit['previous_field']);
560
-  }
561
-  switch ($form_id) {
560
+    }
561
+    switch ($form_id) {
562 562
     case 'node_type_form':
563 563
       $subs['type'] = $edit;
564
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
-      break;
564
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
+        break;
566 566
 
567 567
     case 'fieldgroup_group_edit_form':
568 568
       $subs['groups'][] = $edit;
569
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
-      break;
569
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
+        break;
571 571
 
572 572
     default:
573 573
       if (isset($edit['field_widget_type'])) {
574 574
         $tmp = explode('-', $edit['field_widget_type']);
575 575
         $field_name = $tmp[0];
576
-      }
577
-      else {
576
+        }
577
+        else {
578 578
         $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
-      }
579
+        }
580 580
 
581
-      // The display settings are being fetched directly from the DB. During import,
582
-      // we'll re-insert the data directly as well.
583
-      //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
-      $row_info = db_fetch_array(db_query($query, $field_name));
581
+        // The display settings are being fetched directly from the DB. During import,
582
+        // we'll re-insert the data directly as well.
583
+        //
584
+        $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
+        $row_info = db_fetch_array(db_query($query, $field_name));
586 586
 
587
-      // If an error occurs, notify the user.
588
-      if ($db_err = db_error()) {
587
+        // If an error occurs, notify the user.
588
+        if ($db_err = db_error()) {
589 589
         drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
-             '%field_name' => $field_name,
591
-             '%db_err' => $db_err
590
+                '%field_name' => $field_name,
591
+                '%db_err' => $db_err
592 592
         )));
593
-      }
594
-      else {
593
+        }
594
+        else {
595 595
         // The db fetch occurred successfully, unserialize the data blob and
596 596
         // insert it into a new "display_settings" field of the data.
597 597
         if ($display_settings = unserialize($row_info['display_settings'])) {
598
-          $edit['display_settings'] = $display_settings;
598
+            $edit['display_settings'] = $display_settings;
599 599
         }
600
-      }
601
-      $subs['fields'][] = $edit;
602
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
-      break;
604
-  }
600
+        }
601
+        $subs['fields'][] = $edit;
602
+        $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
+        break;
604
+    }
605 605
 
606
-  $GLOBALS['content_copy']['submissions'] = $subs;
606
+    $GLOBALS['content_copy']['submissions'] = $subs;
607 607
 }
608 608
 
609 609
 /**
610 610
  * @return a code representation of the recorded macro.
611 611
  */
612 612
 function content_copy_get_macro() {
613
-  // Define the indexes for the evaluated code.
614
-  $string = "";
615
-  if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
613
+    // Define the indexes for the evaluated code.
614
+    $string = "";
615
+    if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+        $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
618 618
     }
619 619
     return $string;
620
-  }
620
+    }
621 621
 }
622 622
 
623 623
 function template_preprocess_content_copy_export_form($vars) {
624
-  $form = &$vars['form'];
624
+    $form = &$vars['form'];
625 625
 
626
-  if ($form['#step'] == 2) {
626
+    if ($form['#step'] == 2) {
627 627
     $order = _content_overview_order($form, $form['#fields'], $form['#groups']);
628 628
 
629 629
     $rows = array();
630 630
     foreach ($order as $key) {
631
-      $element = &$form[$key];
632
-      $row = new stdClass();
631
+        $element = &$form[$key];
632
+        $row = new stdClass();
633 633
 
634
-      $row->row_type = $element['#row_type'];
635
-      $checkbox_key = $element['#row_type'] == 'field' ? 'fields' : 'groups';
636
-      $row->checkbox = drupal_render($form[$checkbox_key][$key]);
637
-      foreach (element_children($element) as $child) {
634
+        $row->row_type = $element['#row_type'];
635
+        $checkbox_key = $element['#row_type'] == 'field' ? 'fields' : 'groups';
636
+        $row->checkbox = drupal_render($form[$checkbox_key][$key]);
637
+        foreach (element_children($element) as $child) {
638 638
         $row->{$child} = drupal_render($element[$child]);
639
-      }
640
-      $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';
641
-      $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
639
+        }
640
+        $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';
641
+        $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
642 642
 
643
-      $rows[] = $row;
643
+        $rows[] = $row;
644 644
     }
645 645
     $vars['rows'] = $rows;
646
-  }
646
+    }
647 647
 
648
-  $vars['submit'] = drupal_render($form);
648
+    $vars['submit'] = drupal_render($form);
649 649
 }
650 650
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -97,89 +97,89 @@  discard block
 block discarded – undo
97 97
   $form['#prefix'] = t('This form will process a content type and one or more fields from that type and export the settings. The export created by this process can be copied and pasted as an import into the current or any other database. The import will add the fields to an existing content type or create a new content type that includes the selected fields.');
98 98
 
99 99
   switch ($step) {
100
-    case 1: // Select a content type.
101
-      $types  = content_copy_types();
102
-      $form['type_name'] = array(
103
-        '#title' => t('Types'),
104
-        '#type' => 'radios',
105
-        '#options' => $types,
106
-        '#description' => t('Select the content type to export.'),
107
-      );
108
-      break;
100
+  case 1: // Select a content type.
101
+    $types  = content_copy_types();
102
+    $form['type_name'] = array(
103
+      '#title' => t('Types'),
104
+      '#type' => 'radios',
105
+      '#options' => $types,
106
+      '#description' => t('Select the content type to export.'),
107
+    );
108
+    break;
109 109
 
110
-    case 2: // Select groups and fields.
111
-      $form['type_name'] = array(
112
-        '#type' => 'hidden',
113
-        '#value' => $type_name,
114
-      );
110
+  case 2: // Select groups and fields.
111
+    $form['type_name'] = array(
112
+      '#type' => 'hidden',
113
+      '#value' => $type_name,
114
+    );
115 115
 
116
-      $form += array(
117
-        '#fields' => $exportable_fields,
118
-        '#groups' => array_keys($groups),
119
-      );
116
+    $form += array(
117
+      '#fields' => $exportable_fields,
118
+      '#groups' => array_keys($groups),
119
+    );
120 120
 
121
-      $fields_options = $groups_options = array();
122
-
123
-      // Fields.
124
-      foreach ($exportable_fields as $field_name) {
125
-        $field = content_fields($field_name, $type_name);
126
-        $fields_options[$field_name] = '';
127
-        $weight = $field['widget']['weight'];
128
-        $form[$field_name] = array(
129
-          'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
-          'field_name' => array('#value' => $field['field_name']),
131
-          'type' => array('#value' => $field['type']),
132
-          'weight' => array('#type' => 'value', '#value' => $weight),
133
-          'parent' => array('#type' => 'value', '#value' => ''),
134
-          '#row_type' => 'field',
135
-        );
136
-      }
137
-      $form['fields'] = array(
138
-        '#type' => 'checkboxes',
139
-        '#options' => $fields_options,
140
-        '#default_value' => array_keys($fields_options),
121
+    $fields_options = $groups_options = array();
122
+
123
+    // Fields.
124
+    foreach ($exportable_fields as $field_name) {
125
+      $field = content_fields($field_name, $type_name);
126
+      $fields_options[$field_name] = '';
127
+      $weight = $field['widget']['weight'];
128
+      $form[$field_name] = array(
129
+        'human_name' => array('#value' => check_plain($field['widget']['label'])),
130
+        'field_name' => array('#value' => $field['field_name']),
131
+        'type' => array('#value' => $field['type']),
132
+        'weight' => array('#type' => 'value', '#value' => $weight),
133
+        'parent' => array('#type' => 'value', '#value' => ''),
134
+        '#row_type' => 'field',
141 135
       );
136
+    }
137
+    $form['fields'] = array(
138
+      '#type' => 'checkboxes',
139
+      '#options' => $fields_options,
140
+      '#default_value' => array_keys($fields_options),
141
+    );
142 142
 
143
-      // Groups.
144
-      foreach ($groups as $name => $group) {
145
-        $groups_options[$name] = '';
146
-        $weight = $group['weight'];
147
-        $form[$name] = array(
148
-          'human_name' => array('#value' => check_plain($group['label'])),
149
-          'group_name' => array('#value' => $group['group_name']),
150
-          'weight' => array('#type' => 'value', '#value' => $weight),
151
-          '#row_type' => 'group',
152
-        );
153
-        foreach ($group['fields'] as $field_name => $field) {
154
-          // Do nothing for non-exportable (inactive) fields.
155
-          if (isset($form[$field_name])) {
156
-            $form[$field_name]['parent']['#value'] = $name;
157
-          }
143
+    // Groups.
144
+    foreach ($groups as $name => $group) {
145
+      $groups_options[$name] = '';
146
+      $weight = $group['weight'];
147
+      $form[$name] = array(
148
+        'human_name' => array('#value' => check_plain($group['label'])),
149
+        'group_name' => array('#value' => $group['group_name']),
150
+        'weight' => array('#type' => 'value', '#value' => $weight),
151
+        '#row_type' => 'group',
152
+      );
153
+      foreach ($group['fields'] as $field_name => $field) {
154
+        // Do nothing for non-exportable (inactive) fields.
155
+        if (isset($form[$field_name])) {
156
+          $form[$field_name]['parent']['#value'] = $name;
158 157
         }
159 158
       }
160
-      if ($groups) {
161
-        $form['groups'] = array(
162
-          '#type' => 'checkboxes',
163
-          '#options' => $groups_options,
164
-          '#default_value' => array_keys($groups_options),
165
-        );
166
-      }
167
-      break;
168
-
169
-    case 3: // Display the export macro.
170
-      $GLOBALS['content_copy']['count'] = 0;
171
-      $form['export'] = array(
172
-        '#title' => t('Export data'),
173
-        '#type' => 'textarea',
174
-        '#cols' => 60,
175
-        '#value' => content_copy_export($form_values),
176
-        '#rows' => max(40, $GLOBALS['content_copy']['count']),
177
-        '#description' => t('Copy the export text and paste it into another content type using the import function.'),
159
+    }
160
+    if ($groups) {
161
+      $form['groups'] = array(
162
+        '#type' => 'checkboxes',
163
+        '#options' => $groups_options,
164
+        '#default_value' => array_keys($groups_options),
178 165
       );
179
-      // The calls to drupal_execute('content_field_edit_form') in
180
-      // content_copy_export() affect the page title,
181
-      drupal_set_title(t('Content types'));
182
-      break;
166
+    }
167
+    break;
168
+
169
+  case 3: // Display the export macro.
170
+    $GLOBALS['content_copy']['count'] = 0;
171
+    $form['export'] = array(
172
+      '#title' => t('Export data'),
173
+      '#type' => 'textarea',
174
+      '#cols' => 60,
175
+      '#value' => content_copy_export($form_values),
176
+      '#rows' => max(40, $GLOBALS['content_copy']['count']),
177
+      '#description' => t('Copy the export text and paste it into another content type using the import function.'),
178
+    );
179
+    // The calls to drupal_execute('content_field_edit_form') in
180
+    // content_copy_export() affect the page title,
181
+    drupal_set_title(t('Content types'));
182
+    break;
183 183
   }
184 184
 
185 185
   if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
@@ -559,48 +559,48 @@  discard block
 block discarded – undo
559 559
     unset($edit['type_name'], $edit['submit'], $edit['delete'], $edit['form_id'], $edit['previous_field']);
560 560
   }
561 561
   switch ($form_id) {
562
-    case 'node_type_form':
563
-      $subs['type'] = $edit;
564
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
-      break;
566
-
567
-    case 'fieldgroup_group_edit_form':
568
-      $subs['groups'][] = $edit;
569
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
-      break;
571
-
572
-    default:
573
-      if (isset($edit['field_widget_type'])) {
574
-        $tmp = explode('-', $edit['field_widget_type']);
575
-        $field_name = $tmp[0];
576
-      }
577
-      else {
578
-        $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
-      }
562
+  case 'node_type_form':
563
+    $subs['type'] = $edit;
564
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
565
+    break;
566
+
567
+  case 'fieldgroup_group_edit_form':
568
+    $subs['groups'][] = $edit;
569
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
570
+    break;
571
+
572
+  default:
573
+    if (isset($edit['field_widget_type'])) {
574
+      $tmp = explode('-', $edit['field_widget_type']);
575
+      $field_name = $tmp[0];
576
+    }
577
+    else {
578
+      $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579
+    }
580 580
 
581
-      // The display settings are being fetched directly from the DB. During import,
582
-      // we'll re-insert the data directly as well.
583
-      //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
-      $row_info = db_fetch_array(db_query($query, $field_name));
586
-
587
-      // If an error occurs, notify the user.
588
-      if ($db_err = db_error()) {
589
-        drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
-             '%field_name' => $field_name,
591
-             '%db_err' => $db_err
592
-        )));
593
-      }
594
-      else {
595
-        // The db fetch occurred successfully, unserialize the data blob and
596
-        // insert it into a new "display_settings" field of the data.
597
-        if ($display_settings = unserialize($row_info['display_settings'])) {
598
-          $edit['display_settings'] = $display_settings;
599
-        }
581
+    // The display settings are being fetched directly from the DB. During import,
582
+    // we'll re-insert the data directly as well.
583
+    //
584
+    $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
585
+    $row_info = db_fetch_array(db_query($query, $field_name));
586
+
587
+    // If an error occurs, notify the user.
588
+    if ($db_err = db_error()) {
589
+      drupal_set_message(t("An error occurred when exporting the 'display settings' data for the field %field_name.<br/>The db error is: '%db_err'.", array(
590
+           '%field_name' => $field_name,
591
+           '%db_err' => $db_err
592
+      )));
593
+    }
594
+    else {
595
+      // The db fetch occurred successfully, unserialize the data blob and
596
+      // insert it into a new "display_settings" field of the data.
597
+      if ($display_settings = unserialize($row_info['display_settings'])) {
598
+        $edit['display_settings'] = $display_settings;
600 599
       }
601
-      $subs['fields'][] = $edit;
602
-      $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
-      break;
600
+    }
601
+    $subs['fields'][] = $edit;
602
+    $GLOBALS['content_copy']['count'] += sizeof($edit) + 5;
603
+    break;
604 604
   }
605 605
 
606 606
   $GLOBALS['content_copy']['submissions'] = $subs;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
  *  A form to export field definitions.
70 70
  */
71 71
 function content_copy_export_form(&$form_state) {
72
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
73
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
72
+  include_once('./'.drupal_get_path('module', 'content').'/includes/content.admin.inc');
73
+  include_once('./'.drupal_get_path('module', 'node').'/content_types.inc');
74 74
 
75 75
   $form_values = isset($form_state['values']) ? $form_state['values'] : array();
76 76
   $step = isset($form_state['storage']['step']) ? $form_state['storage']['step'] + 1 : 1;
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 99
   switch ($step) {
100 100
     case 1: // Select a content type.
101
-      $types  = content_copy_types();
101
+      $types = content_copy_types();
102 102
       $form['type_name'] = array(
103 103
         '#title' => t('Types'),
104 104
         '#type' => 'radios',
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
   $output = content_copy_get_macro();
264 264
 
265 265
   // Add weights of non-CCK fields.
266
-  if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267
-    $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
266
+  if ($extra = variable_get('content_extra_weights_'.$form_values['type_name'], array())) {
267
+    $output .= "\$content['extra']  = ".var_export((array)$extra, TRUE).";\n";
268 268
   }
269 269
 
270 270
   return $output;
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
  * }
295 295
  */
296 296
 function content_copy_import_form(&$form_state, $type_name = '') {
297
-  include_once('./'. drupal_get_path('module', 'content') .'/includes/content.admin.inc');
298
-  include_once('./'. drupal_get_path('module', 'node') .'/content_types.inc');
297
+  include_once('./'.drupal_get_path('module', 'content').'/includes/content.admin.inc');
298
+  include_once('./'.drupal_get_path('module', 'node').'/content_types.inc');
299 299
 
300 300
   $form['#prefix'] = t('This form will import field definitions exported from another content type or another database.<br/>Note that fields cannot be duplicated within the same content type, so imported fields will be added only if they do not already exist in the selected type.');
301 301
   $form['type_name'] = array(
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     if (isset($_REQUEST['type_name'])) {
323 323
       $form['type_name']['#default_value'] = $_REQUEST['type_name'];
324 324
     }
325
-    $form['#prefix'] .= '<p class="error">'. t('A file has been pre-loaded for import.') .'</p>';
325
+    $form['#prefix'] .= '<p class="error">'.t('A file has been pre-loaded for import.').'</p>';
326 326
   }
327 327
   return $form;
328 328
 }
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
   // If there are groups in the import, make sure the fieldgroup module is enabled.
374 374
   $imported_groups = array();
375 375
   if (isset($content['groups']) && module_exists('fieldgroup')) {
376
-    $imported_groups = (array) $content['groups'];
376
+    $imported_groups = (array)$content['groups'];
377 377
   }
378 378
   elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
@@ -419,7 +419,7 @@  discard block
 block discarded – undo
419 419
   // Create the content type, if requested.
420 420
   if ($form_values['type_name'] == '<create>') {
421 421
 
422
-    $type = (object) $imported_type;
422
+    $type = (object)$imported_type;
423 423
     $values = $imported_type;
424 424
     // Prevent a warning in node/content_types.inc
425 425
     $type->has_title = TRUE;
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
460 460
     // If so, do nothing, fields can't be duplicated within a content type.
461
-    $field_name   = $field['field_name'];
461
+    $field_name = $field['field_name'];
462 462
 
463 463
     // Might need to overwrite the content type name if a new type was created.
464 464
     $field['type_name'] = $type_name;
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
   // Import weights of non-CCK fields.
494 494
   if (isset($content['extra'])) {
495
-    variable_set('content_extra_weights_'. $type_name, $content['extra']);
495
+    variable_set('content_extra_weights_'.$type_name, $content['extra']);
496 496
   }
497 497
 }
498 498
 
@@ -538,7 +538,7 @@  discard block
 block discarded – undo
538 538
   $types = array();
539 539
   $content_info = _content_type_info();
540 540
   foreach ($content_info['content types'] as $type_name => $val) {
541
-    $types[$type_name] = check_plain($val['name']) .' ('. $type_name .')';
541
+    $types[$type_name] = check_plain($val['name']).' ('.$type_name.')';
542 542
   }
543 543
   return $types;
544 544
 }
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
       // The display settings are being fetched directly from the DB. During import,
582 582
       // we'll re-insert the data directly as well.
583 583
       //
584
-      $query = 'SELECT display_settings FROM {'. content_instance_tablename() .'} WHERE field_name = \'%s\'';
584
+      $query = 'SELECT display_settings FROM {'.content_instance_tablename().'} WHERE field_name = \'%s\'';
585 585
       $row_info = db_fetch_array(db_query($query, $field_name));
586 586
 
587 587
       // If an error occurs, notify the user.
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
   $string = "";
615 615
   if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+      $string .= "\$content['$form_type']  = ".var_export((array)$form, TRUE).";\n";
618 618
     }
619 619
     return $string;
620 620
   }
Please login to merge, or discard this patch.
Braces   +7 added lines, -11 removed lines patch added patch discarded remove patch
@@ -182,7 +182,8 @@  discard block
 block discarded – undo
182 182
       break;
183 183
   }
184 184
 
185
-  if ($step < 3) {  // Omit submit button on the textarea block to display the export data.
185
+  if ($step < 3) {
186
+// Omit submit button on the textarea block to display the export data.
186 187
     $form['submit'] = array(
187 188
       '#type' => 'submit',
188 189
       '#value' => t('Export'),
@@ -374,8 +375,7 @@  discard block
 block discarded – undo
374 375
   $imported_groups = array();
375 376
   if (isset($content['groups']) && module_exists('fieldgroup')) {
376 377
     $imported_groups = (array) $content['groups'];
377
-  }
378
-  elseif (isset($content['groups']) && is_array($content['groups'])) {
378
+  } elseif (isset($content['groups']) && is_array($content['groups'])) {
379 379
     $not_enabled[] = 'fieldgroup';
380 380
   }
381 381
 
@@ -384,8 +384,7 @@  discard block
 block discarded – undo
384 384
     $field = content_field_instance_collapse($import);
385 385
     if (empty($field['module']) || empty($field['widget_module'])) {
386 386
       $not_enabled[] = $field['field_name'];
387
-    }
388
-    else {
387
+    } else {
389 388
       if (!module_exists($field['module'])) {
390 389
         $not_enabled[] = $field['module'];
391 390
       }
@@ -466,8 +465,7 @@  discard block
 block discarded – undo
466 465
     if (!empty($field['field_name']) && isset($content_info['content types'][$type_name]['fields'][$field_name])) {
467 466
       drupal_set_message(t('The imported field %field_label (%field_name) was not added to %type because that field already exists in %type.', array(
468 467
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469
-    }
470
-    else {
468
+    } else {
471 469
       $field = content_field_instance_create($field, FALSE);
472 470
       $rebuild = TRUE;
473 471
       drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
@@ -573,8 +571,7 @@  discard block
 block discarded – undo
573 571
       if (isset($edit['field_widget_type'])) {
574 572
         $tmp = explode('-', $edit['field_widget_type']);
575 573
         $field_name = $tmp[0];
576
-      }
577
-      else {
574
+      } else {
578 575
         $field_name = isset($edit['field_name']) ? $edit['field_name'] : '';
579 576
       }
580 577
 
@@ -590,8 +587,7 @@  discard block
 block discarded – undo
590 587
              '%field_name' => $field_name,
591 588
              '%db_err' => $db_err
592 589
         )));
593
-      }
594
-      else {
590
+      } else {
595 591
         // The db fetch occurred successfully, unserialize the data blob and
596 592
         // insert it into a new "display_settings" field of the data.
597 593
         if ($display_settings = unserialize($row_info['display_settings'])) {
Please login to merge, or discard this patch.
Upper-Lower-Casing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
   return array(
61 61
     'content_copy_export_form' => array(
62 62
       'template' => 'content_copy_export_form',
63
-      'arguments' => array('form' => NULL),
63
+      'arguments' => array('form' => null),
64 64
     ),
65 65
   );
66 66
 }
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 }
199 199
 
200 200
 function content_copy_export_form_submit($form, &$form_state) {
201
-  $form_state['rebuild'] = TRUE;
201
+  $form_state['rebuild'] = true;
202 202
   $form_state['storage']['step'] = $form_state['values']['step'];
203 203
 }
204 204
 
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
   // Add weights of non-CCK fields.
266 266
   if ($extra = variable_get('content_extra_weights_'. $form_values['type_name'], array())) {
267
-    $output .= "\$content['extra']  = ". var_export((array) $extra, TRUE) .";\n";
267
+    $output .= "\$content['extra']  = ". var_export((array) $extra, true) .";\n";
268 268
   }
269 269
 
270 270
   return $output;
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
     '#type' => 'textarea',
310 310
     '#rows' => 40,
311 311
     '#title' => t('Import data'),
312
-    '#required' => TRUE,
312
+    '#required' => true,
313 313
     '#description' => t('Paste the text created by a content export into this field.'),
314 314
   );
315 315
   $form['submit'] = array(
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
   $type_name = $form_values['type_name'];
341 341
   $type_label = node_get_types('name', $type_name);
342 342
 
343
-  $content = NULL;
343
+  $content = null;
344 344
   // Convert the import formatted text back into a $content array.
345 345
   // Return if errors generated or not an array.
346 346
   // Use '@' to suppress errors about undefined constants in the macro.
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     $type = (object) $imported_type;
423 423
     $values = $imported_type;
424 424
     // Prevent a warning in node/content_types.inc
425
-    $type->has_title = TRUE;
425
+    $type->has_title = true;
426 426
     $type_form_state = array('values' => $values);
427 427
 
428 428
     // There's no API for creating node types, we still have to use drupal_execute().
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
       fieldgroup_save_group($type_name, $group);
450 450
     }
451 451
     // Reset the static variable in fieldgroup_groups() with new data.
452
-    fieldgroup_groups('', FALSE, TRUE);
452
+    fieldgroup_groups('', false, true);
453 453
   }
454 454
 
455 455
   // Iterate through the field forms in the import and execute each.
456
-  $rebuild = FALSE;
456
+  $rebuild = false;
457 457
   foreach ($imported_fields as $field) {
458 458
 
459 459
     // Make sure the field doesn't already exist in the type.
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
         '%field_label' => $field['label'], '%field_name' => $field_name, '%type' => $type_label)));
469 469
     }
470 470
     else {
471
-      $field = content_field_instance_create($field, FALSE);
472
-      $rebuild = TRUE;
471
+      $field = content_field_instance_create($field, false);
472
+      $rebuild = true;
473 473
       drupal_set_message(t('The field %field_label (%field_name) was added to the content type %type.', array(
474 474
         '%field_label' => $field['widget']['label'], '%field_name' => $field_name, '%type' => $type_label)));
475 475
     }
@@ -486,7 +486,7 @@  discard block
 block discarded – undo
486 486
 
487 487
   // Clear caches and rebuild menu only if any field has been created.
488 488
   if ($rebuild) {
489
-    content_clear_type_cache(TRUE);
489
+    content_clear_type_cache(true);
490 490
     menu_rebuild();
491 491
   }
492 492
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
   $string = "";
615 615
   if (array_key_exists('submissions', $GLOBALS['content_copy'])) {
616 616
     foreach ($GLOBALS['content_copy']['submissions'] as $form_type => $form) {
617
-      $string .= "\$content['$form_type']  = ". var_export((array) $form, TRUE) .";\n";
617
+      $string .= "\$content['$form_type']  = ". var_export((array) $form, true) .";\n";
618 618
     }
619 619
     return $string;
620 620
   }
Please login to merge, or discard this patch.
modules/contrib/cck/modules/content_permissions/content_permissions.module 4 patches
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,12 +5,12 @@  discard block
 block discarded – undo
5 5
  *  Implementation of hook_perm().
6 6
  */
7 7
 function content_permissions_perm() {
8
-  $perms = array();
9
-  foreach (content_fields() as $field) {
8
+    $perms = array();
9
+    foreach (content_fields() as $field) {
10 10
     $perms[] = 'edit '. $field['field_name'];
11 11
     $perms[] = 'view '. $field['field_name'];
12
-  }
13
-  return $perms;
12
+    }
13
+    return $perms;
14 14
 }
15 15
 
16 16
 /**
@@ -19,10 +19,10 @@  discard block
 block discarded – undo
19 19
  * @see content_access().
20 20
  */
21 21
 function content_permissions_field_access($op, $field, $account, $node = NULL) {
22
-  switch ($op) {
22
+    switch ($op) {
23 23
     case 'view':
24 24
     case 'edit':
25 25
       return user_access($op .' '. $field['field_name'], $account);
26
-  }
27
-  return TRUE;
26
+    }
27
+    return TRUE;
28 28
 }
Please login to merge, or discard this patch.
Switch Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@
 block discarded – undo
20 20
  */
21 21
 function content_permissions_field_access($op, $field, $account, $node = NULL) {
22 22
   switch ($op) {
23
-    case 'view':
24
-    case 'edit':
25
-      return user_access($op .' '. $field['field_name'], $account);
23
+  case 'view':
24
+  case 'edit':
25
+    return user_access($op .' '. $field['field_name'], $account);
26 26
   }
27 27
   return TRUE;
28 28
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -7,8 +7,8 @@  discard block
 block discarded – undo
7 7
 function content_permissions_perm() {
8 8
   $perms = array();
9 9
   foreach (content_fields() as $field) {
10
-    $perms[] = 'edit '. $field['field_name'];
11
-    $perms[] = 'view '. $field['field_name'];
10
+    $perms[] = 'edit '.$field['field_name'];
11
+    $perms[] = 'view '.$field['field_name'];
12 12
   }
13 13
   return $perms;
14 14
 }
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
   switch ($op) {
23 23
     case 'view':
24 24
     case 'edit':
25
-      return user_access($op .' '. $field['field_name'], $account);
25
+      return user_access($op.' '.$field['field_name'], $account);
26 26
   }
27 27
   return TRUE;
28 28
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
  *
19 19
  * @see content_access().
20 20
  */
21
-function content_permissions_field_access($op, $field, $account, $node = NULL) {
21
+function content_permissions_field_access($op, $field, $account, $node = null) {
22 22
   switch ($op) {
23 23
     case 'view':
24 24
     case 'edit':
25 25
       return user_access($op .' '. $field['field_name'], $account);
26 26
   }
27
-  return TRUE;
27
+  return true;
28 28
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/modules/text/text.module 5 patches
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -10,101 +10,101 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_theme().
11 11
  */
12 12
 function text_theme() {
13
-  return array(
13
+    return array(
14 14
     'text_textarea' => array(
15
-      'arguments' => array('element' => NULL),
15
+        'arguments' => array('element' => NULL),
16 16
     ),
17 17
     'text_textfield' => array(
18
-      'arguments' => array('element' => NULL),
18
+        'arguments' => array('element' => NULL),
19 19
     ),
20 20
     'text_formatter_default' => array(
21
-      'arguments' => array('element' => NULL),
21
+        'arguments' => array('element' => NULL),
22 22
     ),
23 23
     'text_formatter_plain' => array(
24
-      'arguments' => array('element' => NULL),
24
+        'arguments' => array('element' => NULL),
25 25
     ),
26 26
     'text_formatter_trimmed' => array(
27
-      'arguments' => array('element' => NULL),
27
+        'arguments' => array('element' => NULL),
28 28
     ),
29 29
     'text_formatter_foo' => array(
30
-      'arguments' => array('element' => NULL),
30
+        'arguments' => array('element' => NULL),
31 31
     ),
32
-  );
32
+    );
33 33
 }
34 34
 
35 35
 /**
36 36
  * Implementation of hook_field_info().
37 37
  */
38 38
 function text_field_info() {
39
-  return array(
39
+    return array(
40 40
     'text' => array(
41
-      'label' => t('Text'),
42
-      'description' => t('Store text in the database.'),
41
+        'label' => t('Text'),
42
+        'description' => t('Store text in the database.'),
43 43
 //      'content_icon' => 'icon_content_text.png',
44 44
     ),
45
-  );
45
+    );
46 46
 }
47 47
 
48 48
 /**
49 49
  * Implementation of hook_field_settings().
50 50
  */
51 51
 function text_field_settings($op, $field) {
52
-  switch ($op) {
52
+    switch ($op) {
53 53
     case 'form':
54 54
       $form = array();
55
-      $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
56
-      $form['text_processing'] = array(
55
+        $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
56
+        $form['text_processing'] = array(
57 57
         '#type' => 'radios',
58 58
         '#title' => t('Text processing'),
59 59
         '#default_value' => is_numeric($field['text_processing']) ? $field['text_processing'] : 0,
60 60
         '#options' => $options,
61
-      );
62
-      $form['max_length'] = array(
61
+        );
62
+        $form['max_length'] = array(
63 63
         '#type' => 'textfield',
64 64
         '#title' => t('Maximum length'),
65 65
         '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '',
66 66
         '#required' => FALSE,
67 67
         '#element_validate' => array('_element_validate_integer_positive'),
68 68
         '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
69
-      );
70
-      $form['allowed_values_fieldset'] = array(
69
+        );
70
+        $form['allowed_values_fieldset'] = array(
71 71
         '#type' => 'fieldset',
72 72
         '#title' => t('Allowed values'),
73 73
         '#collapsible' => TRUE,
74 74
         '#collapsed' => TRUE,
75
-      );
76
-      $form['allowed_values_fieldset']['allowed_values'] = array(
75
+        );
76
+        $form['allowed_values_fieldset']['allowed_values'] = array(
77 77
         '#type' => 'textarea',
78 78
         '#title' => t('Allowed values list'),
79 79
         '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
80 80
         '#required' => FALSE,
81 81
         '#rows' => 10,
82 82
         '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
83
-      );
84
-      $form['allowed_values_fieldset']['advanced_options'] = array(
83
+        );
84
+        $form['allowed_values_fieldset']['advanced_options'] = array(
85 85
         '#type' => 'fieldset',
86 86
         '#title' => t('PHP code'),
87 87
         '#collapsible' => TRUE,
88 88
         '#collapsed' => empty($field['allowed_values_php']),
89
-      );
90
-      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
89
+        );
90
+        if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
91 91
         $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
92
-          '#type' => 'textarea',
93
-          '#title' => t('Code'),
94
-          '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
95
-          '#rows' => 6,
96
-          '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
92
+            '#type' => 'textarea',
93
+            '#title' => t('Code'),
94
+            '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
95
+            '#rows' => 6,
96
+            '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
97 97
         );
98
-      }
99
-      else {
98
+        }
99
+        else {
100 100
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
101
-          '#type' => 'item',
102
-          '#title' => t('Code'),
103
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
104
-          '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
101
+            '#type' => 'item',
102
+            '#title' => t('Code'),
103
+            '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
104
+            '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
105 105
         );
106
-      }
107
-      return $form;
106
+        }
107
+        return $form;
108 108
 
109 109
     case 'save':
110 110
       return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php');
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
     case 'database columns':
113 113
       if (empty($field['max_length']) || $field['max_length'] > 255) {
114 114
         $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
115
-      }
116
-      else {
115
+        }
116
+        else {
117 117
         $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
118
-      }
119
-      if (!empty($field['text_processing'])) {
118
+        }
119
+        if (!empty($field['text_processing'])) {
120 120
         $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE);
121
-      }
122
-      return $columns;
121
+        }
122
+        return $columns;
123 123
 
124 124
     case 'views data':
125 125
       $allowed_values = content_allowed_values($field);
126
-      if (count($allowed_values)) {
126
+        if (count($allowed_values)) {
127 127
         $data = content_views_field_views_data($field);
128 128
         $db_info = content_database_info($field);
129 129
         $table_alias = content_views_tablename($field);
@@ -137,106 +137,106 @@  discard block
 block discarded – undo
137 137
         // Argument : swap the handler to the 'many to one' operator.
138 138
         $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
139 139
         return $data;
140
-      }
141
-  }
140
+        }
141
+    }
142 142
 }
143 143
 
144 144
 /**
145 145
  * Implementation of hook_field().
146 146
  */
147 147
 function text_field($op, &$node, $field, &$items, $teaser, $page) {
148
-  switch ($op) {
148
+    switch ($op) {
149 149
     case 'validate':
150 150
       $allowed_values = content_allowed_values($field);
151
-      if (is_array($items)) {
151
+        if (is_array($items)) {
152 152
         foreach ($items as $delta => $item) {
153
-          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
154
-          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
155
-          if (!empty($item['value'])) {
153
+            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
154
+            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
155
+            if (!empty($item['value'])) {
156 156
             if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
157
-              form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
157
+                form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
158 158
             }
159 159
             if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) {
160
-              form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length'])));
160
+                form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length'])));
161
+            }
161 162
             }
162
-          }
163 163
         }
164
-      }
165
-      return $items;
164
+        }
165
+        return $items;
166 166
 
167 167
     case 'sanitize':
168 168
       foreach ($items as $delta => $item) {
169 169
         if (!empty($field['text_processing'])) {
170
-          $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
170
+            $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
171 171
         }
172 172
         else {
173
-          $text = isset($item['value']) ? check_plain($item['value']) : '';
173
+            $text = isset($item['value']) ? check_plain($item['value']) : '';
174 174
         }
175 175
         $items[$delta]['safe'] = $text;
176
-      }
177
-  }
176
+        }
177
+    }
178 178
 }
179 179
 
180 180
 /**
181 181
  * Implementation of hook_content_is_empty().
182 182
  */
183 183
 function text_content_is_empty($item, $field) {
184
-  if (empty($item['value']) && (string)$item['value'] !== '0') {
184
+    if (empty($item['value']) && (string)$item['value'] !== '0') {
185 185
     return TRUE;
186
-  }
187
-  return FALSE;
186
+    }
187
+    return FALSE;
188 188
 }
189 189
 
190 190
 /**
191 191
  * Implementation of hook_field_formatter_info().
192 192
  */
193 193
 function text_field_formatter_info() {
194
-  return array(
194
+    return array(
195 195
     'default' => array(
196
-      'label' => t('Default'),
197
-      'field types' => array('text'),
198
-      'multiple values' => CONTENT_HANDLE_CORE,
196
+        'label' => t('Default'),
197
+        'field types' => array('text'),
198
+        'multiple values' => CONTENT_HANDLE_CORE,
199 199
     ),
200 200
     'plain' => array(
201
-      'label' => t('Plain text'),
202
-      'field types' => array('text'),
203
-      'multiple values' => CONTENT_HANDLE_CORE,
201
+        'label' => t('Plain text'),
202
+        'field types' => array('text'),
203
+        'multiple values' => CONTENT_HANDLE_CORE,
204 204
     ),
205 205
     'trimmed' => array(
206
-      'label' => t('Trimmed'),
207
-      'field types' => array('text'),
208
-      'multiple values' => CONTENT_HANDLE_CORE,
206
+        'label' => t('Trimmed'),
207
+        'field types' => array('text'),
208
+        'multiple values' => CONTENT_HANDLE_CORE,
209 209
     ),
210
-  );
210
+    );
211 211
 }
212 212
 
213 213
 /**
214 214
  * Theme function for 'default' text field formatter.
215 215
  */
216 216
 function theme_text_formatter_default($element) {
217
-  return ($allowed =_text_allowed_values($element)) ? $allowed : $element['#item']['safe'];
217
+    return ($allowed =_text_allowed_values($element)) ? $allowed : $element['#item']['safe'];
218 218
 }
219 219
 
220 220
 /**
221 221
  * Theme function for 'plain' text field formatter.
222 222
  */
223 223
 function theme_text_formatter_plain($element) {
224
-  return ($allowed =_text_allowed_values($element)) ? $allowed : strip_tags($element['#item']['safe']);
224
+    return ($allowed =_text_allowed_values($element)) ? $allowed : strip_tags($element['#item']['safe']);
225 225
 }
226 226
 
227 227
 /**
228 228
  * Theme function for 'trimmed' text field formatter.
229 229
  */
230 230
 function theme_text_formatter_trimmed($element) {
231
-  $field = content_fields($element['#field_name'], $element['#type_name']);
232
-  return ($allowed =_text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : NULL);
231
+    $field = content_fields($element['#field_name'], $element['#type_name']);
232
+    return ($allowed =_text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : NULL);
233 233
 }
234 234
 
235 235
 function _text_allowed_values($element) {
236
-  $field = content_fields($element['#field_name'], $element['#type_name']);
237
-  if (($allowed_values = content_allowed_values($field)) && isset($allowed_values[$element['#item']['value']])) {
236
+    $field = content_fields($element['#field_name'], $element['#type_name']);
237
+    if (($allowed_values = content_allowed_values($field)) && isset($allowed_values[$element['#item']['value']])) {
238 238
     return $allowed_values[$element['#item']['value']];
239
-  }
239
+    }
240 240
 }
241 241
 
242 242
 /**
@@ -251,24 +251,24 @@  discard block
 block discarded – undo
251 251
  * differently.
252 252
  */
253 253
 function text_widget_info() {
254
-  return array(
254
+    return array(
255 255
     'text_textfield' => array(
256
-      'label' => t('Text field'),
257
-      'field types' => array('text'),
258
-      'multiple values' => CONTENT_HANDLE_CORE,
259
-      'callbacks' => array(
256
+        'label' => t('Text field'),
257
+        'field types' => array('text'),
258
+        'multiple values' => CONTENT_HANDLE_CORE,
259
+        'callbacks' => array(
260 260
         'default value' => CONTENT_CALLBACK_DEFAULT,
261
-      ),
261
+        ),
262 262
     ),
263 263
     'text_textarea' => array(
264
-      'label' => t('Text area (multiple rows)'),
265
-      'field types' => array('text'),
266
-      'multiple values' => CONTENT_HANDLE_CORE,
267
-      'callbacks' => array(
264
+        'label' => t('Text area (multiple rows)'),
265
+        'field types' => array('text'),
266
+        'multiple values' => CONTENT_HANDLE_CORE,
267
+        'callbacks' => array(
268 268
         'default value' => CONTENT_CALLBACK_DEFAULT,
269
-      ),
269
+        ),
270 270
     ),
271
-  );
271
+    );
272 272
 }
273 273
 
274 274
 /**
@@ -284,56 +284,56 @@  discard block
 block discarded – undo
284 284
  * (see nodereference and userreference).
285 285
  */
286 286
 function text_elements() {
287
-  return array(
287
+    return array(
288 288
     'text_textfield' => array(
289
-      '#input' => TRUE,
290
-      '#columns' => array('value'), '#delta' => 0,
291
-      '#process' => array('text_textfield_process'),
292
-      '#autocomplete_path' => FALSE,
289
+        '#input' => TRUE,
290
+        '#columns' => array('value'), '#delta' => 0,
291
+        '#process' => array('text_textfield_process'),
292
+        '#autocomplete_path' => FALSE,
293 293
     ),
294 294
     'text_textarea' => array(
295
-      '#input' => TRUE,
296
-      '#columns' => array('value', 'format'), '#delta' => 0,
297
-      '#process' => array('text_textarea_process'),
298
-      '#filter_value' => FILTER_FORMAT_DEFAULT,
295
+        '#input' => TRUE,
296
+        '#columns' => array('value', 'format'), '#delta' => 0,
297
+        '#process' => array('text_textarea_process'),
298
+        '#filter_value' => FILTER_FORMAT_DEFAULT,
299 299
     ),
300
-  );
300
+    );
301 301
 }
302 302
 
303 303
 /**
304 304
  * Implementation of hook_widget_settings().
305 305
  */
306 306
 function text_widget_settings($op, $widget) {
307
-  switch ($op) {
307
+    switch ($op) {
308 308
     case 'form':
309 309
       $form = array();
310
-      $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5;
311
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
312
-      if ($widget['type'] == 'text_textfield') {
310
+        $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5;
311
+        $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
312
+        if ($widget['type'] == 'text_textfield') {
313 313
         $form['rows'] = array('#type' => 'hidden', '#value' => $rows);
314 314
         $form['size'] = array(
315
-          '#type' => 'textfield',
316
-          '#title' => t('Size of textfield'),
317
-          '#default_value' => $size,
318
-          '#element_validate' => array('_element_validate_integer_positive'),
319
-          '#required' => TRUE,
315
+            '#type' => 'textfield',
316
+            '#title' => t('Size of textfield'),
317
+            '#default_value' => $size,
318
+            '#element_validate' => array('_element_validate_integer_positive'),
319
+            '#required' => TRUE,
320 320
         );
321
-      }
322
-      else {
321
+        }
322
+        else {
323 323
         $form['rows'] = array(
324
-          '#type' => 'textfield',
325
-          '#title' => t('Rows'),
326
-          '#default_value' => $rows,
327
-          '#element_validate' => array('_element_validate_integer_positive'),
328
-          '#required' => TRUE,
324
+            '#type' => 'textfield',
325
+            '#title' => t('Rows'),
326
+            '#default_value' => $rows,
327
+            '#element_validate' => array('_element_validate_integer_positive'),
328
+            '#required' => TRUE,
329 329
         );
330 330
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
331
-      }
332
-      return $form;
331
+        }
332
+        return $form;
333 333
 
334 334
     case 'save':
335 335
       return array('rows', 'size');
336
-  }
336
+    }
337 337
 }
338 338
 
339 339
 /**
@@ -368,11 +368,11 @@  discard block
 block discarded – undo
368 368
  *   the form item for a single element for this field
369 369
  */
370 370
 function text_widget(&$form, &$form_state, $field, $items, $delta = 0) {
371
-  $element = array(
371
+    $element = array(
372 372
     '#type' => $field['widget']['type'],
373 373
     '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
374
-  );
375
-  return $element;
374
+    );
375
+    return $element;
376 376
 }
377 377
 
378 378
 /**
@@ -384,10 +384,10 @@  discard block
 block discarded – undo
384 384
  * The $fields array is in $form['#field_info'][$element['#field_name']].
385 385
  */
386 386
 function text_textfield_process($element, $edit, $form_state, $form) {
387
-  $field = $form['#field_info'][$element['#field_name']];
388
-  $field_key = $element['#columns'][0];
389
-  $delta = $element['#delta'];
390
-  $element[$field_key] = array(
387
+    $field = $form['#field_info'][$element['#field_name']];
388
+    $field_key = $element['#columns'][0];
389
+    $delta = $element['#delta'];
390
+    $element[$field_key] = array(
391 391
     '#type' => 'textfield',
392 392
     '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
393 393
     '#autocomplete_path' => $element['#autocomplete_path'],
@@ -402,24 +402,24 @@  discard block
 block discarded – undo
402 402
     '#type_name' => $element['#type_name'],
403 403
     '#delta' => $element['#delta'],
404 404
     '#columns' => $element['#columns'],
405
-  );
405
+    );
406 406
 
407
-  $element[$field_key]['#maxlength'] = !empty($field['max_length']) ? $field['max_length'] : NULL;
407
+    $element[$field_key]['#maxlength'] = !empty($field['max_length']) ? $field['max_length'] : NULL;
408 408
 
409
-  if (!empty($field['text_processing'])) {
409
+    if (!empty($field['text_processing'])) {
410 410
     $filter_key = $element['#columns'][1];
411 411
     $format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : FILTER_FORMAT_DEFAULT;
412 412
     $parents = array_merge($element['#parents'] , array($filter_key));
413 413
     $element[$filter_key] = filter_form($format, 1, $parents);
414
-  }
414
+    }
415 415
 
416
-  // Used so that hook_field('validate') knows where to flag an error.
417
-  $element['_error_element'] = array(
416
+    // Used so that hook_field('validate') knows where to flag an error.
417
+    $element['_error_element'] = array(
418 418
     '#type' => 'value',
419 419
     '#value' => implode('][', array_merge($element['#parents'], array($field_key))),
420
-  );
420
+    );
421 421
 
422
-  return $element;
422
+    return $element;
423 423
 }
424 424
 
425 425
 /**
@@ -431,9 +431,9 @@  discard block
 block discarded – undo
431 431
  * The $fields array is in $form['#field_info'][$element['#field_name']].
432 432
  */
433 433
 function text_textarea_process($element, $edit, $form_state, $form) {
434
-  $field = $form['#field_info'][$element['#field_name']];
435
-  $field_key   = $element['#columns'][0];
436
-  $element[$field_key] = array(
434
+    $field = $form['#field_info'][$element['#field_name']];
435
+    $field_key   = $element['#columns'][0];
436
+    $element[$field_key] = array(
437 437
     '#type' => 'textarea',
438 438
     '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
439 439
     '#rows' => !empty($field['widget']['rows']) ? $field['widget']['rows'] : 10,
@@ -447,22 +447,22 @@  discard block
 block discarded – undo
447 447
     '#type_name' => $element['#type_name'],
448 448
     '#delta' => $element['#delta'],
449 449
     '#columns' => $element['#columns'],
450
-  );
450
+    );
451 451
 
452
-  if (!empty($field['text_processing'])) {
452
+    if (!empty($field['text_processing'])) {
453 453
     $filter_key  = (count($element['#columns']) == 2) ? $element['#columns'][1] : 'format';
454 454
     $format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : FILTER_FORMAT_DEFAULT;
455 455
     $parents = array_merge($element['#parents'] , array($filter_key));
456 456
     $element[$filter_key] = filter_form($format, 1, $parents);
457
-  }
457
+    }
458 458
 
459
-  // Used so that hook_field('validate') knows where to flag an error.
460
-  $element['_error_element'] = array(
459
+    // Used so that hook_field('validate') knows where to flag an error.
460
+    $element['_error_element'] = array(
461 461
     '#type' => 'value',
462 462
     '#value' => implode('][', array_merge($element['#parents'], array($field_key))),
463
-  );
463
+    );
464 464
 
465
-  return $element;
465
+    return $element;
466 466
 }
467 467
 
468 468
 /**
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
  * $element['#delta]  is the position of this element in the group
478 478
  */
479 479
 function theme_text_textfield($element) {
480
-  return $element['#children'];
480
+    return $element['#children'];
481 481
 }
482 482
 
483 483
 function theme_text_textarea($element) {
484
-  return $element['#children'];
484
+    return $element['#children'];
485 485
 }
Please login to merge, or discard this patch.
Switch Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -50,94 +50,94 @@  discard block
 block discarded – undo
50 50
  */
51 51
 function text_field_settings($op, $field) {
52 52
   switch ($op) {
53
-    case 'form':
54
-      $form = array();
55
-      $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
56
-      $form['text_processing'] = array(
57
-        '#type' => 'radios',
58
-        '#title' => t('Text processing'),
59
-        '#default_value' => is_numeric($field['text_processing']) ? $field['text_processing'] : 0,
60
-        '#options' => $options,
61
-      );
62
-      $form['max_length'] = array(
63
-        '#type' => 'textfield',
64
-        '#title' => t('Maximum length'),
65
-        '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '',
66
-        '#required' => FALSE,
67
-        '#element_validate' => array('_element_validate_integer_positive'),
68
-        '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
69
-      );
70
-      $form['allowed_values_fieldset'] = array(
71
-        '#type' => 'fieldset',
72
-        '#title' => t('Allowed values'),
73
-        '#collapsible' => TRUE,
74
-        '#collapsed' => TRUE,
75
-      );
76
-      $form['allowed_values_fieldset']['allowed_values'] = array(
53
+  case 'form':
54
+    $form = array();
55
+    $options = array(0 => t('Plain text'), 1 => t('Filtered text (user selects input format)'));
56
+    $form['text_processing'] = array(
57
+      '#type' => 'radios',
58
+      '#title' => t('Text processing'),
59
+      '#default_value' => is_numeric($field['text_processing']) ? $field['text_processing'] : 0,
60
+      '#options' => $options,
61
+    );
62
+    $form['max_length'] = array(
63
+      '#type' => 'textfield',
64
+      '#title' => t('Maximum length'),
65
+      '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '',
66
+      '#required' => FALSE,
67
+      '#element_validate' => array('_element_validate_integer_positive'),
68
+      '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
69
+    );
70
+    $form['allowed_values_fieldset'] = array(
71
+      '#type' => 'fieldset',
72
+      '#title' => t('Allowed values'),
73
+      '#collapsible' => TRUE,
74
+      '#collapsed' => TRUE,
75
+    );
76
+    $form['allowed_values_fieldset']['allowed_values'] = array(
77
+      '#type' => 'textarea',
78
+      '#title' => t('Allowed values list'),
79
+      '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
80
+      '#required' => FALSE,
81
+      '#rows' => 10,
82
+      '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
83
+    );
84
+    $form['allowed_values_fieldset']['advanced_options'] = array(
85
+      '#type' => 'fieldset',
86
+      '#title' => t('PHP code'),
87
+      '#collapsible' => TRUE,
88
+      '#collapsed' => empty($field['allowed_values_php']),
89
+    );
90
+    if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
91
+      $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
77 92
         '#type' => 'textarea',
78
-        '#title' => t('Allowed values list'),
79
-        '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
80
-        '#required' => FALSE,
81
-        '#rows' => 10,
82
-        '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
93
+        '#title' => t('Code'),
94
+        '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
95
+        '#rows' => 6,
96
+        '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
83 97
       );
84
-      $form['allowed_values_fieldset']['advanced_options'] = array(
85
-        '#type' => 'fieldset',
86
-        '#title' => t('PHP code'),
87
-        '#collapsible' => TRUE,
88
-        '#collapsed' => empty($field['allowed_values_php']),
98
+    }
99
+    else {
100
+      $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
101
+        '#type' => 'item',
102
+        '#title' => t('Code'),
103
+        '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
104
+        '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
89 105
       );
90
-      if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
91
-        $form['allowed_values_fieldset']['advanced_options']['allowed_values_php'] = array(
92
-          '#type' => 'textarea',
93
-          '#title' => t('Code'),
94
-          '#default_value' => !empty($field['allowed_values_php']) ? $field['allowed_values_php'] : '',
95
-          '#rows' => 6,
96
-          '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
97
-        );
98
-      }
99
-      else {
100
-        $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
101
-          '#type' => 'item',
102
-          '#title' => t('Code'),
103
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
104
-          '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
105
-        );
106
-      }
107
-      return $form;
108
-
109
-    case 'save':
110
-      return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php');
111
-
112
-    case 'database columns':
113
-      if (empty($field['max_length']) || $field['max_length'] > 255) {
114
-        $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
115
-      }
116
-      else {
117
-        $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
118
-      }
119
-      if (!empty($field['text_processing'])) {
120
-        $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE);
121
-      }
122
-      return $columns;
123
-
124
-    case 'views data':
125
-      $allowed_values = content_allowed_values($field);
126
-      if (count($allowed_values)) {
127
-        $data = content_views_field_views_data($field);
128
-        $db_info = content_database_info($field);
129
-        $table_alias = content_views_tablename($field);
130
-
131
-        // Filter: Add a 'many to one' filter.
132
-        $copy = $data[$table_alias][$field['field_name'] .'_value'];
133
-        $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
134
-        $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
135
-        unset($copy['field'], $copy['argument'], $copy['sort']);
136
-        $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
137
-        // Argument : swap the handler to the 'many to one' operator.
138
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
139
-        return $data;
140
-      }
106
+    }
107
+    return $form;
108
+
109
+  case 'save':
110
+    return array('text_processing', 'max_length', 'allowed_values', 'allowed_values_php');
111
+
112
+  case 'database columns':
113
+    if (empty($field['max_length']) || $field['max_length'] > 255) {
114
+      $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
115
+    }
116
+    else {
117
+      $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
118
+    }
119
+    if (!empty($field['text_processing'])) {
120
+      $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE);
121
+    }
122
+    return $columns;
123
+
124
+  case 'views data':
125
+    $allowed_values = content_allowed_values($field);
126
+    if (count($allowed_values)) {
127
+      $data = content_views_field_views_data($field);
128
+      $db_info = content_database_info($field);
129
+      $table_alias = content_views_tablename($field);
130
+
131
+      // Filter: Add a 'many to one' filter.
132
+      $copy = $data[$table_alias][$field['field_name'] .'_value'];
133
+      $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
134
+      $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
135
+      unset($copy['field'], $copy['argument'], $copy['sort']);
136
+      $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
137
+      // Argument : swap the handler to the 'many to one' operator.
138
+      $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
139
+      return $data;
140
+    }
141 141
   }
142 142
 }
143 143
 
@@ -146,34 +146,34 @@  discard block
 block discarded – undo
146 146
  */
147 147
 function text_field($op, &$node, $field, &$items, $teaser, $page) {
148 148
   switch ($op) {
149
-    case 'validate':
150
-      $allowed_values = content_allowed_values($field);
151
-      if (is_array($items)) {
152
-        foreach ($items as $delta => $item) {
153
-          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
154
-          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
155
-          if (!empty($item['value'])) {
156
-            if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
157
-              form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
158
-            }
159
-            if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) {
160
-              form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length'])));
161
-            }
149
+  case 'validate':
150
+    $allowed_values = content_allowed_values($field);
151
+    if (is_array($items)) {
152
+      foreach ($items as $delta => $item) {
153
+        $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
154
+        if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
155
+        if (!empty($item['value'])) {
156
+          if (count($allowed_values) && !array_key_exists($item['value'], $allowed_values)) {
157
+            form_set_error($error_element, t('%name: illegal value.', array('%name' => t($field['widget']['label']))));
158
+          }
159
+          if (!empty($field['max_length']) && drupal_strlen($item['value']) > $field['max_length']) {
160
+            form_set_error($error_element, t('%name: the value may not be longer than %max characters.', array('%name' => $field['widget']['label'], '%max' => $field['max_length'])));
162 161
           }
163 162
         }
164 163
       }
165
-      return $items;
164
+    }
165
+    return $items;
166 166
 
167
-    case 'sanitize':
168
-      foreach ($items as $delta => $item) {
169
-        if (!empty($field['text_processing'])) {
170
-          $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
171
-        }
172
-        else {
173
-          $text = isset($item['value']) ? check_plain($item['value']) : '';
174
-        }
175
-        $items[$delta]['safe'] = $text;
167
+  case 'sanitize':
168
+    foreach ($items as $delta => $item) {
169
+      if (!empty($field['text_processing'])) {
170
+        $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
171
+      }
172
+      else {
173
+        $text = isset($item['value']) ? check_plain($item['value']) : '';
176 174
       }
175
+      $items[$delta]['safe'] = $text;
176
+    }
177 177
   }
178 178
 }
179 179
 
@@ -305,34 +305,34 @@  discard block
 block discarded – undo
305 305
  */
306 306
 function text_widget_settings($op, $widget) {
307 307
   switch ($op) {
308
-    case 'form':
309
-      $form = array();
310
-      $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5;
311
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
312
-      if ($widget['type'] == 'text_textfield') {
313
-        $form['rows'] = array('#type' => 'hidden', '#value' => $rows);
314
-        $form['size'] = array(
315
-          '#type' => 'textfield',
316
-          '#title' => t('Size of textfield'),
317
-          '#default_value' => $size,
318
-          '#element_validate' => array('_element_validate_integer_positive'),
319
-          '#required' => TRUE,
320
-        );
321
-      }
322
-      else {
323
-        $form['rows'] = array(
324
-          '#type' => 'textfield',
325
-          '#title' => t('Rows'),
326
-          '#default_value' => $rows,
327
-          '#element_validate' => array('_element_validate_integer_positive'),
328
-          '#required' => TRUE,
329
-        );
330
-        $form['size'] = array('#type' => 'hidden', '#value' => $size);
331
-      }
332
-      return $form;
308
+  case 'form':
309
+    $form = array();
310
+    $rows = (isset($widget['rows']) && is_numeric($widget['rows'])) ? $widget['rows'] : 5;
311
+    $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
312
+    if ($widget['type'] == 'text_textfield') {
313
+      $form['rows'] = array('#type' => 'hidden', '#value' => $rows);
314
+      $form['size'] = array(
315
+        '#type' => 'textfield',
316
+        '#title' => t('Size of textfield'),
317
+        '#default_value' => $size,
318
+        '#element_validate' => array('_element_validate_integer_positive'),
319
+        '#required' => TRUE,
320
+      );
321
+    }
322
+    else {
323
+      $form['rows'] = array(
324
+        '#type' => 'textfield',
325
+        '#title' => t('Rows'),
326
+        '#default_value' => $rows,
327
+        '#element_validate' => array('_element_validate_integer_positive'),
328
+        '#required' => TRUE,
329
+      );
330
+      $form['size'] = array('#type' => 'hidden', '#value' => $size);
331
+    }
332
+    return $form;
333 333
 
334
-    case 'save':
335
-      return array('rows', 'size');
334
+  case 'save':
335
+    return array('rows', 'size');
336 336
   }
337 337
 }
338 338
 
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
101 101
           '#type' => 'item',
102 102
           '#title' => t('Code'),
103
-          '#value' => !empty($field['allowed_values_php']) ? '<code>'. check_plain($field['allowed_values_php']) .'</code>' : t('&lt;none&gt;'),
103
+          '#value' => !empty($field['allowed_values_php']) ? '<code>'.check_plain($field['allowed_values_php']).'</code>' : t('&lt;none&gt;'),
104 104
           '#description' => empty($field['allowed_values_php']) ? t("You're not allowed to input PHP code.") : t('This PHP code was set by an administrator and will override the allowed values list above.'),
105 105
         );
106 106
       }
@@ -129,13 +129,13 @@  discard block
 block discarded – undo
129 129
         $table_alias = content_views_tablename($field);
130 130
 
131 131
         // Filter: Add a 'many to one' filter.
132
-        $copy = $data[$table_alias][$field['field_name'] .'_value'];
132
+        $copy = $data[$table_alias][$field['field_name'].'_value'];
133 133
         $copy['title'] = t('@label (!name) - Allowed values', array('@label' => t($field['widget']['label']), '!name' => $field['field_name']));
134 134
         $copy['filter']['handler'] = 'content_handler_filter_many_to_one';
135 135
         unset($copy['field'], $copy['argument'], $copy['sort']);
136
-        $data[$table_alias][$field['field_name'] .'_value_many_to_one'] = $copy;
136
+        $data[$table_alias][$field['field_name'].'_value_many_to_one'] = $copy;
137 137
         // Argument : swap the handler to the 'many to one' operator.
138
-        $data[$table_alias][$field['field_name'] .'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
138
+        $data[$table_alias][$field['field_name'].'_value']['argument']['handler'] = 'content_handler_argument_many_to_one';
139 139
         return $data;
140 140
       }
141 141
   }
@@ -214,14 +214,14 @@  discard block
 block discarded – undo
214 214
  * Theme function for 'default' text field formatter.
215 215
  */
216 216
 function theme_text_formatter_default($element) {
217
-  return ($allowed =_text_allowed_values($element)) ? $allowed : $element['#item']['safe'];
217
+  return ($allowed = _text_allowed_values($element)) ? $allowed : $element['#item']['safe'];
218 218
 }
219 219
 
220 220
 /**
221 221
  * Theme function for 'plain' text field formatter.
222 222
  */
223 223
 function theme_text_formatter_plain($element) {
224
-  return ($allowed =_text_allowed_values($element)) ? $allowed : strip_tags($element['#item']['safe']);
224
+  return ($allowed = _text_allowed_values($element)) ? $allowed : strip_tags($element['#item']['safe']);
225 225
 }
226 226
 
227 227
 /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function theme_text_formatter_trimmed($element) {
231 231
   $field = content_fields($element['#field_name'], $element['#type_name']);
232
-  return ($allowed =_text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : NULL);
232
+  return ($allowed = _text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : NULL);
233 233
 }
234 234
 
235 235
 function _text_allowed_values($element) {
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
   if (!empty($field['text_processing'])) {
410 410
     $filter_key = $element['#columns'][1];
411 411
     $format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : FILTER_FORMAT_DEFAULT;
412
-    $parents = array_merge($element['#parents'] , array($filter_key));
412
+    $parents = array_merge($element['#parents'], array($filter_key));
413 413
     $element[$filter_key] = filter_form($format, 1, $parents);
414 414
   }
415 415
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function text_textarea_process($element, $edit, $form_state, $form) {
434 434
   $field = $form['#field_info'][$element['#field_name']];
435
-  $field_key   = $element['#columns'][0];
435
+  $field_key = $element['#columns'][0];
436 436
   $element[$field_key] = array(
437 437
     '#type' => 'textarea',
438 438
     '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
@@ -450,9 +450,9 @@  discard block
 block discarded – undo
450 450
   );
451 451
 
452 452
   if (!empty($field['text_processing'])) {
453
-    $filter_key  = (count($element['#columns']) == 2) ? $element['#columns'][1] : 'format';
453
+    $filter_key = (count($element['#columns']) == 2) ? $element['#columns'][1] : 'format';
454 454
     $format = isset($element['#value'][$filter_key]) ? $element['#value'][$filter_key] : FILTER_FORMAT_DEFAULT;
455
-    $parents = array_merge($element['#parents'] , array($filter_key));
455
+    $parents = array_merge($element['#parents'], array($filter_key));
456 456
     $element[$filter_key] = filter_form($format, 1, $parents);
457 457
   }
458 458
 
Please login to merge, or discard this patch.
Braces   +4 added lines, -8 removed lines patch added patch discarded remove patch
@@ -95,8 +95,7 @@  discard block
 block discarded – undo
95 95
           '#rows' => 6,
96 96
           '#description' => t('Advanced usage only: PHP code that returns a keyed array of allowed values. Should not include &lt;?php ?&gt; delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'),
97 97
         );
98
-      }
99
-      else {
98
+      } else {
100 99
         $form['allowed_values_fieldset']['advanced_options']['markup_allowed_values_php'] = array(
101 100
           '#type' => 'item',
102 101
           '#title' => t('Code'),
@@ -112,8 +111,7 @@  discard block
 block discarded – undo
112 111
     case 'database columns':
113 112
       if (empty($field['max_length']) || $field['max_length'] > 255) {
114 113
         $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
115
-      }
116
-      else {
114
+      } else {
117 115
         $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
118 116
       }
119 117
       if (!empty($field['text_processing'])) {
@@ -168,8 +166,7 @@  discard block
 block discarded – undo
168 166
       foreach ($items as $delta => $item) {
169 167
         if (!empty($field['text_processing'])) {
170 168
           $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
171
-        }
172
-        else {
169
+        } else {
173 170
           $text = isset($item['value']) ? check_plain($item['value']) : '';
174 171
         }
175 172
         $items[$delta]['safe'] = $text;
@@ -318,8 +315,7 @@  discard block
 block discarded – undo
318 315
           '#element_validate' => array('_element_validate_integer_positive'),
319 316
           '#required' => TRUE,
320 317
         );
321
-      }
322
-      else {
318
+      } else {
323 319
         $form['rows'] = array(
324 320
           '#type' => 'textfield',
325 321
           '#title' => t('Rows'),
Please login to merge, or discard this patch.
Upper-Lower-Casing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -12,22 +12,22 @@  discard block
 block discarded – undo
12 12
 function text_theme() {
13 13
   return array(
14 14
     'text_textarea' => array(
15
-      'arguments' => array('element' => NULL),
15
+      'arguments' => array('element' => null),
16 16
     ),
17 17
     'text_textfield' => array(
18
-      'arguments' => array('element' => NULL),
18
+      'arguments' => array('element' => null),
19 19
     ),
20 20
     'text_formatter_default' => array(
21
-      'arguments' => array('element' => NULL),
21
+      'arguments' => array('element' => null),
22 22
     ),
23 23
     'text_formatter_plain' => array(
24
-      'arguments' => array('element' => NULL),
24
+      'arguments' => array('element' => null),
25 25
     ),
26 26
     'text_formatter_trimmed' => array(
27
-      'arguments' => array('element' => NULL),
27
+      'arguments' => array('element' => null),
28 28
     ),
29 29
     'text_formatter_foo' => array(
30
-      'arguments' => array('element' => NULL),
30
+      'arguments' => array('element' => null),
31 31
     ),
32 32
   );
33 33
 }
@@ -63,28 +63,28 @@  discard block
 block discarded – undo
63 63
         '#type' => 'textfield',
64 64
         '#title' => t('Maximum length'),
65 65
         '#default_value' => is_numeric($field['max_length']) ? $field['max_length'] : '',
66
-        '#required' => FALSE,
66
+        '#required' => false,
67 67
         '#element_validate' => array('_element_validate_integer_positive'),
68 68
         '#description' => t('The maximum length of the field in characters. Leave blank for an unlimited size.'),
69 69
       );
70 70
       $form['allowed_values_fieldset'] = array(
71 71
         '#type' => 'fieldset',
72 72
         '#title' => t('Allowed values'),
73
-        '#collapsible' => TRUE,
74
-        '#collapsed' => TRUE,
73
+        '#collapsible' => true,
74
+        '#collapsed' => true,
75 75
       );
76 76
       $form['allowed_values_fieldset']['allowed_values'] = array(
77 77
         '#type' => 'textarea',
78 78
         '#title' => t('Allowed values list'),
79 79
         '#default_value' => !empty($field['allowed_values']) ? $field['allowed_values'] : '',
80
-        '#required' => FALSE,
80
+        '#required' => false,
81 81
         '#rows' => 10,
82 82
         '#description' => t('The possible values this field can contain. Enter one value per line, in the format key|label. The key is the value that will be stored in the database, and it must match the field storage type (%type). The label is optional, and the key will be used as the label if no label is specified.<br />Allowed HTML tags: @tags', array('%type' => $field['type'], '@tags' => _content_filter_xss_display_allowed_tags())),
83 83
       );
84 84
       $form['allowed_values_fieldset']['advanced_options'] = array(
85 85
         '#type' => 'fieldset',
86 86
         '#title' => t('PHP code'),
87
-        '#collapsible' => TRUE,
87
+        '#collapsible' => true,
88 88
         '#collapsed' => empty($field['allowed_values_php']),
89 89
       );
90 90
       if (user_access('Use PHP input for field settings (dangerous - grant with care)')) {
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 
112 112
     case 'database columns':
113 113
       if (empty($field['max_length']) || $field['max_length'] > 255) {
114
-        $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
114
+        $columns['value'] = array('type' => 'text', 'size' => 'big', 'not null' => false, 'sortable' => true, 'views' => true);
115 115
       }
116 116
       else {
117
-        $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => FALSE, 'sortable' => TRUE, 'views' => TRUE);
117
+        $columns['value'] = array('type' => 'varchar', 'length' => $field['max_length'], 'not null' => false, 'sortable' => true, 'views' => true);
118 118
       }
119 119
       if (!empty($field['text_processing'])) {
120
-        $columns['format'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'views' => FALSE);
120
+        $columns['format'] = array('type' => 'int', 'unsigned' => true, 'not null' => false, 'views' => false);
121 121
       }
122 122
       return $columns;
123 123
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
     case 'sanitize':
168 168
       foreach ($items as $delta => $item) {
169 169
         if (!empty($field['text_processing'])) {
170
-          $text = isset($item['value']) ? check_markup($item['value'], $item['format'], FALSE) : '';
170
+          $text = isset($item['value']) ? check_markup($item['value'], $item['format'], false) : '';
171 171
         }
172 172
         else {
173 173
           $text = isset($item['value']) ? check_plain($item['value']) : '';
@@ -182,9 +182,9 @@  discard block
 block discarded – undo
182 182
  */
183 183
 function text_content_is_empty($item, $field) {
184 184
   if (empty($item['value']) && (string)$item['value'] !== '0') {
185
-    return TRUE;
185
+    return true;
186 186
   }
187
-  return FALSE;
187
+  return false;
188 188
 }
189 189
 
190 190
 /**
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function theme_text_formatter_trimmed($element) {
231 231
   $field = content_fields($element['#field_name'], $element['#type_name']);
232
-  return ($allowed =_text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : NULL);
232
+  return ($allowed =_text_allowed_values($element)) ? $allowed : node_teaser($element['#item']['safe'], $field['text_processing'] ? $element['#item']['format'] : null);
233 233
 }
234 234
 
235 235
 function _text_allowed_values($element) {
@@ -286,13 +286,13 @@  discard block
 block discarded – undo
286 286
 function text_elements() {
287 287
   return array(
288 288
     'text_textfield' => array(
289
-      '#input' => TRUE,
289
+      '#input' => true,
290 290
       '#columns' => array('value'), '#delta' => 0,
291 291
       '#process' => array('text_textfield_process'),
292
-      '#autocomplete_path' => FALSE,
292
+      '#autocomplete_path' => false,
293 293
     ),
294 294
     'text_textarea' => array(
295
-      '#input' => TRUE,
295
+      '#input' => true,
296 296
       '#columns' => array('value', 'format'), '#delta' => 0,
297 297
       '#process' => array('text_textarea_process'),
298 298
       '#filter_value' => FILTER_FORMAT_DEFAULT,
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
           '#title' => t('Size of textfield'),
317 317
           '#default_value' => $size,
318 318
           '#element_validate' => array('_element_validate_integer_positive'),
319
-          '#required' => TRUE,
319
+          '#required' => true,
320 320
         );
321 321
       }
322 322
       else {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
           '#title' => t('Rows'),
326 326
           '#default_value' => $rows,
327 327
           '#element_validate' => array('_element_validate_integer_positive'),
328
-          '#required' => TRUE,
328
+          '#required' => true,
329 329
         );
330 330
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
331 331
       }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
   $delta = $element['#delta'];
390 390
   $element[$field_key] = array(
391 391
     '#type' => 'textfield',
392
-    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
392
+    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : null,
393 393
     '#autocomplete_path' => $element['#autocomplete_path'],
394 394
     '#size' => !empty($field['widget']['size']) ? $field['widget']['size'] : 60,
395 395
     '#attributes' => array('class' => 'text'),
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
     '#columns' => $element['#columns'],
405 405
   );
406 406
 
407
-  $element[$field_key]['#maxlength'] = !empty($field['max_length']) ? $field['max_length'] : NULL;
407
+  $element[$field_key]['#maxlength'] = !empty($field['max_length']) ? $field['max_length'] : null;
408 408
 
409 409
   if (!empty($field['text_processing'])) {
410 410
     $filter_key = $element['#columns'][1];
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
   $field_key   = $element['#columns'][0];
436 436
   $element[$field_key] = array(
437 437
     '#type' => 'textarea',
438
-    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : NULL,
438
+    '#default_value' => isset($element['#value'][$field_key]) ? $element['#value'][$field_key] : null,
439 439
     '#rows' => !empty($field['widget']['rows']) ? $field['widget']['rows'] : 10,
440 440
     '#weight' => 0,
441 441
     // The following values were set by the content module and need
Please login to merge, or discard this patch.
cck/modules/userreference/panels/relationships/user_from_userref.inc 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_ctools_relationships().
11 11
  */
12 12
 function userreference_user_from_userref_ctools_relationships() {
13
-  return array(
13
+    return array(
14 14
     'title' => t('User from reference'),
15 15
     'keyword' => 'userreference',
16 16
     'description' => t('Adds a user from a user reference in a node context; if multiple users are referenced, this will get the first referenced user only.'),
@@ -18,48 +18,48 @@  discard block
 block discarded – undo
18 18
     'context' => 'userreference_user_from_userref_context',
19 19
     'settings form' => 'userreference_user_from_userref_settings_form',
20 20
     'settings form validate' => 'userreference_user_from_userref_settings_form_validate',
21
-  );
21
+    );
22 22
 }
23 23
 
24 24
 /**
25 25
  * Return a new ctools context based on an existing context.
26 26
  */
27 27
 function userreference_user_from_userref_context($context, $conf) {
28
-  // If unset it wants a generic, unfilled context, which is just NULL.
29
-  if (empty($context->data)) {
28
+    // If unset it wants a generic, unfilled context, which is just NULL.
29
+    if (empty($context->data)) {
30 30
     return ctools_context_create_empty('user', NULL);
31
-  }
31
+    }
32 32
 
33
-  // Prevent whitescreens on stale data.
34
-  if (empty($conf)) {
33
+    // Prevent whitescreens on stale data.
34
+    if (empty($conf)) {
35 35
     return ctools_context_create_empty('user', NULL);
36
-  }
36
+    }
37 37
 
38
-  if (isset($context->data->{$conf['field_name']}[0]['uid']) && ($uid = $context->data->{$conf['field_name']}[0]['uid'])) {
38
+    if (isset($context->data->{$conf['field_name']}[0]['uid']) && ($uid = $context->data->{$conf['field_name']}[0]['uid'])) {
39 39
     if ($account = user_load(array('uid' => $uid))) {
40
-      return ctools_context_create('user', $account);
40
+        return ctools_context_create('user', $account);
41
+    }
41 42
     }
42
-  }
43 43
 }
44 44
 
45 45
 /**
46 46
  * Settings form for the ctools relationship.
47 47
  */
48 48
 function userreference_user_from_userref_settings_form($conf) {
49
-  $options = array();
50
-  foreach (content_fields() as $field) {
49
+    $options = array();
50
+    foreach (content_fields() as $field) {
51 51
     if ($field['type'] == 'userreference') {
52
-      $options[$field['field_name']] = t($field['widget']['label']);
52
+        $options[$field['field_name']] = t($field['widget']['label']);
53
+    }
53 54
     }
54
-  }
55
-  $form['field_name'] = array(
55
+    $form['field_name'] = array(
56 56
     '#title' => t('User reference field'),
57 57
     '#type' => 'select',
58 58
     '#options' => $options,
59 59
     '#default_value' => isset($conf['field_name']) ? $conf['field_name'] : '',
60 60
     '#prefix' => '<div class="clear-block">',
61 61
     '#suffix' => '</div>',
62
-  );
62
+    );
63 63
 
64
-  return $form;
64
+    return $form;
65 65
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,12 +27,12 @@
 block discarded – undo
27 27
 function userreference_user_from_userref_context($context, $conf) {
28 28
   // If unset it wants a generic, unfilled context, which is just NULL.
29 29
   if (empty($context->data)) {
30
-    return ctools_context_create_empty('user', NULL);
30
+    return ctools_context_create_empty('user', null);
31 31
   }
32 32
 
33 33
   // Prevent whitescreens on stale data.
34 34
   if (empty($conf)) {
35
-    return ctools_context_create_empty('user', NULL);
35
+    return ctools_context_create_empty('user', null);
36 36
   }
37 37
 
38 38
   if (isset($context->data->{$conf['field_name']}[0]['uid']) && ($uid = $context->data->{$conf['field_name']}[0]['uid'])) {
Please login to merge, or discard this patch.
boinc/modules/contrib/cck/modules/userreference/userreference.rules.inc 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -10,39 +10,39 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_rules_action_info()
11 11
  */
12 12
 function userreference_rules_action_info() {
13
-  $info = array();
14
-  $info['userreference_rules_action_load'] = array(
13
+    $info = array();
14
+    $info['userreference_rules_action_load'] = array(
15 15
     'label' => t('Load a referenced user'),
16 16
     'arguments' => array(
17
-      'node' => array(
17
+        'node' => array(
18 18
         'type' => 'node',
19 19
         'label' => t('Content containing the user reference field'),
20
-      ),
20
+        ),
21 21
     ),
22 22
     'new variables' => array(
23
-      'referenced_user' => array(
23
+        'referenced_user' => array(
24 24
         'type' => 'user',
25 25
         'label' => t('Referenced user'),
26
-      ),
26
+        ),
27 27
     ),
28 28
     'module' => 'CCK',
29 29
     'help' => t('Note that if the field has multiple values, only the first user will be loaded.'),
30
-  );
31
-  return $info;
30
+    );
31
+    return $info;
32 32
 }
33 33
 
34 34
 function userreference_rules_action_load($node, $settings) {
35
-  $uid = $node->{$settings['field']}[0]['uid'];
36
-  if (isset($uid)) {
35
+    $uid = $node->{$settings['field']}[0]['uid'];
36
+    if (isset($uid)) {
37 37
     $user = user_load(array('uid' => $uid));
38 38
     return array('referenced_user' => $user);
39
-  }
39
+    }
40 40
 }
41 41
 
42 42
 function userreference_rules_action_load_form($settings, &$form) {
43
-  $settings += array('field' => '');
44
-  $options = content_rules_get_field_names_by_type('userreference');
45
-  $form['settings']['field'] = array(
43
+    $settings += array('field' => '');
44
+    $options = content_rules_get_field_names_by_type('userreference');
45
+    $form['settings']['field'] = array(
46 46
     '#type' => 'select',
47 47
     '#title' => t('Field'),
48 48
     '#default_value' => $settings['field'],
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     '#required' => TRUE,
51 51
     '#disabled' => empty($options),
52 52
     '#description' => empty($options) ? t('There are no userreference fields defined.') : '',
53
-  );
53
+    );
54 54
 }
55 55
 
56 56
 /**
@@ -58,5 +58,5 @@  discard block
 block discarded – undo
58 58
  * "workflow_ng_action_load_referenced_user" to the equivalent rules action.
59 59
  */
60 60
 function workflow_ng_action_load_referenced_user_upgrade(&$element) {
61
-  $element['#name'] = 'userreference_rules_action_load';
61
+    $element['#name'] = 'userreference_rules_action_load';
62 62
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@
 block discarded – undo
47 47
     '#title' => t('Field'),
48 48
     '#default_value' => $settings['field'],
49 49
     '#options' => $options,
50
-    '#required' => TRUE,
50
+    '#required' => true,
51 51
     '#disabled' => empty($options),
52 52
     '#description' => empty($options) ? t('There are no userreference fields defined.') : '',
53 53
   );
Please login to merge, or discard this patch.
boinc/modules/contrib/cck/modules/userreference/userreference.module 5 patches
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -10,258 +10,258 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_menu().
11 11
  */
12 12
 function userreference_menu() {
13
-  $items = array();
14
-  $items['userreference/autocomplete'] = array(
13
+    $items = array();
14
+    $items['userreference/autocomplete'] = array(
15 15
     'title' => 'Userreference autocomplete',
16 16
     'page callback' => 'userreference_autocomplete',
17 17
     'access arguments' => array('access content'),
18 18
     'type' => MENU_CALLBACK
19
-  );
20
-  return $items;
19
+    );
20
+    return $items;
21 21
 }
22 22
 
23 23
 /**
24 24
  * Implementation of hook_theme().
25 25
  */
26 26
 function userreference_theme() {
27
-  return array(
27
+    return array(
28 28
     'userreference_select' => array(
29
-      'arguments' => array('element' => NULL),
29
+        'arguments' => array('element' => NULL),
30 30
     ),
31 31
     'userreference_buttons' => array(
32
-      'arguments' => array('element' => NULL),
32
+        'arguments' => array('element' => NULL),
33 33
     ),
34 34
     'userreference_autocomplete' => array(
35
-      'arguments' => array('element' => NULL),
35
+        'arguments' => array('element' => NULL),
36 36
     ),
37 37
     'userreference_formatter_default' => array(
38
-      'arguments' => array('element'),
38
+        'arguments' => array('element'),
39 39
     ),
40 40
     'userreference_formatter_plain' => array(
41
-      'arguments' => array('element'),
41
+        'arguments' => array('element'),
42 42
     ),
43
-  );
43
+    );
44 44
 }
45 45
 
46 46
 /**
47 47
  * Implementaion of hook_ctools_plugin_directory().
48 48
  */
49 49
 function userreference_ctools_plugin_directory($module, $plugin) {
50
-  if ($module == 'ctools' && $plugin == 'relationships') {
50
+    if ($module == 'ctools' && $plugin == 'relationships') {
51 51
     return 'panels/' . $plugin;
52
-  }
52
+    }
53 53
 }
54 54
 
55 55
 /**
56 56
  * Implementation of hook_field_info().
57 57
  */
58 58
 function userreference_field_info() {
59
-  return array(
59
+    return array(
60 60
     'userreference' => array(
61
-      'label' => t('User reference'),
62
-      'description' => t('Store the ID of a related user as an integer value.'),
61
+        'label' => t('User reference'),
62
+        'description' => t('Store the ID of a related user as an integer value.'),
63 63
 //      'content_icon' => 'icon_content_noderef.png',
64 64
     ),
65
-  );
65
+    );
66 66
 }
67 67
 
68 68
 /**
69 69
  * Implementation of hook_field_settings().
70 70
  */
71 71
 function userreference_field_settings($op, $field) {
72
-  switch ($op) {
72
+    switch ($op) {
73 73
     case 'form':
74 74
       $form = array();
75
-      $form['referenceable_roles'] = array(
75
+        $form['referenceable_roles'] = array(
76 76
         '#type' => 'checkboxes',
77 77
         '#title' => t('User roles that can be referenced'),
78 78
         '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79 79
         '#options' => user_roles(1),
80
-      );
81
-      $form['referenceable_status'] = array(
80
+        );
81
+        $form['referenceable_status'] = array(
82 82
         '#type' => 'radios',
83 83
         '#title' => t('User status that can be referenced'),
84 84
         '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85 85
         '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
-      );
87
-      if (module_exists('views')) {
86
+        );
87
+        if (module_exists('views')) {
88 88
         $views = array('--' => '--');
89 89
         $all_views = views_get_all_views();
90 90
         foreach ($all_views as $view) {
91
-          // Only 'users' views that have fields will work for our purpose.
92
-          if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
91
+            // Only 'users' views that have fields will work for our purpose.
92
+            if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93 93
             if ($view->type == 'Default') {
94
-              $views[t('Default Views')][$view->name] = $view->name;
94
+                $views[t('Default Views')][$view->name] = $view->name;
95 95
             }
96 96
             else {
97
-              $views[t('Existing Views')][$view->name] = $view->name;
97
+                $views[t('Existing Views')][$view->name] = $view->name;
98
+            }
98 99
             }
99
-          }
100 100
         }
101 101
 
102 102
         $form['advanced'] = array(
103
-           '#type' => 'fieldset',
104
-           '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
106
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
-         );
103
+            '#type' => 'fieldset',
104
+            '#title' => t('Advanced - Users that can be referenced (View)'),
105
+            '#collapsible' => TRUE,
106
+            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
+            );
108 108
         if (count($views) > 1) {
109
-          $form['advanced']['advanced_view'] = array(
109
+            $form['advanced']['advanced_view'] = array(
110 110
             '#type' => 'select',
111 111
             '#title' => t('View used to select the users'),
112 112
             '#options' => $views,
113 113
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114 114
             '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
-          );
117
-          $form['advanced']['advanced_view_args'] = array(
115
+                t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
+            );
117
+            $form['advanced']['advanced_view_args'] = array(
118 118
             '#type' => 'textfield',
119 119
             '#title' => t('View arguments'),
120 120
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121 121
             '#required' => FALSE,
122 122
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
-          );
123
+            );
124 124
         }
125 125
         else {
126
-          $form['advanced']['no_view_help'] = array(
126
+            $form['advanced']['no_view_help'] = array(
127 127
             '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
-          );
128
+                t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
+            );
130
+        }
130 131
         }
131
-      }
132
-      return $form;
132
+        return $form;
133 133
 
134 134
     case 'save':
135 135
       $settings = array('referenceable_roles', 'referenceable_status');
136
-      if (module_exists('views')) {
136
+        if (module_exists('views')) {
137 137
         $settings[] = 'advanced_view';
138 138
         $settings[] = 'advanced_view_args';
139
-      }
140
-      return $settings;
139
+        }
140
+        return $settings;
141 141
 
142 142
     case 'database columns':
143 143
       $columns = array(
144 144
         'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
-      );
146
-      return $columns;
145
+        );
146
+        return $columns;
147 147
 
148 148
     case 'views data':
149 149
       $data = content_views_field_views_data($field);
150
-      $db_info = content_database_info($field);
151
-      $table_alias = content_views_tablename($field);
152
-
153
-      // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
-      // Argument: get the user name for summaries.
156
-      // We need to join a new instance of the users table.
157
-      $data["users_$table_alias"]['table']['join']['node'] = array(
150
+        $db_info = content_database_info($field);
151
+        $table_alias = content_views_tablename($field);
152
+
153
+        // Filter : swap the handler to the 'in' operator.
154
+        $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
+        // Argument: get the user name for summaries.
156
+        // We need to join a new instance of the users table.
157
+        $data["users_$table_alias"]['table']['join']['node'] = array(
158 158
         'table' => 'users',
159 159
         'field' => 'uid',
160 160
         'left_table' => $table_alias,
161 161
         'left_field' => $field['field_name'] .'_uid',
162
-      );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
-      // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
162
+        );
163
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
+        $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
+        // Relationship: Add a relationship for related user.
167
+        $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168 168
         'base' => 'users',
169 169
         'field' => $db_info['columns']['uid']['column'],
170 170
         'handler' => 'content_handler_relationship',
171 171
         'label' => t($field['widget']['label']),
172 172
         'content_field_name' => $field['field_name'],
173
-      );
174
-      return $data;
173
+        );
174
+        return $data;
175 175
 
176
-  }
176
+    }
177 177
 }
178 178
 
179 179
 /**
180 180
  * Implementation of hook_field().
181 181
  */
182 182
 function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
183
-  switch ($op) {
183
+    switch ($op) {
184 184
     case 'validate':
185 185
       // Extract uids to check.
186 186
       $ids = array();
187
-      foreach ($items as $delta => $item) {
187
+        foreach ($items as $delta => $item) {
188 188
         if (is_array($item) && !empty($item['uid'])) {
189
-          if (is_numeric($item['uid'])) {
189
+            if (is_numeric($item['uid'])) {
190 190
             $ids[] = $item['uid'];
191
-          }
192
-          else {
191
+            }
192
+            else {
193 193
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194 194
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195 195
             form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
196
-          }
196
+            }
197
+        }
197 198
         }
198
-      }
199
-      // Prevent performance hog if there are no ids to check.
200
-      if ($ids) {
199
+        // Prevent performance hog if there are no ids to check.
200
+        if ($ids) {
201 201
         $refs = _userreference_potential_references($field, '', NULL, $ids);
202 202
         foreach ($items as $delta => $item) {
203
-          if (is_array($item)) {
203
+            if (is_array($item)) {
204 204
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205 205
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206 206
             if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
-              form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
207
+                form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
208
+            }
208 209
             }
209
-          }
210 210
         }
211
-      }
212
-      return $items;
213
-  }
211
+        }
212
+        return $items;
213
+    }
214 214
 }
215 215
 
216 216
 /**
217 217
  * Implementation of hook_content_is_empty().
218 218
  */
219 219
 function userreference_content_is_empty($item, $field) {
220
-  if (empty($item['uid'])) {
220
+    if (empty($item['uid'])) {
221 221
     return TRUE;
222
-  }
223
-  return FALSE;
222
+    }
223
+    return FALSE;
224 224
 }
225 225
 
226 226
 /**
227 227
  * Implementation of hook_field_formatter_info().
228 228
  */
229 229
 function userreference_field_formatter_info() {
230
-  return array(
230
+    return array(
231 231
     'default' => array(
232
-      'label' => t('Default'),
233
-      'field types' => array('userreference'),
234
-      'multiple values' => CONTENT_HANDLE_CORE,
232
+        'label' => t('Default'),
233
+        'field types' => array('userreference'),
234
+        'multiple values' => CONTENT_HANDLE_CORE,
235 235
     ),
236 236
     'plain' => array(
237
-      'label' => t('Plain text'),
238
-      'field types' => array('userreference'),
239
-      'multiple values' => CONTENT_HANDLE_CORE,
237
+        'label' => t('Plain text'),
238
+        'field types' => array('userreference'),
239
+        'multiple values' => CONTENT_HANDLE_CORE,
240 240
     ),
241
-  );
241
+    );
242 242
 }
243 243
 
244 244
 /**
245 245
  * Theme function for 'default' userreference field formatter.
246 246
  */
247 247
 function theme_userreference_formatter_default($element) {
248
-  $output = '';
248
+    $output = '';
249 249
 
250
-  if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
250
+    if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
251 251
     $output = theme('username', $account);
252
-  }
253
-  return $output;
252
+    }
253
+    return $output;
254 254
 }
255 255
 
256 256
 /**
257 257
  * Theme function for 'plain' userreference field formatter.
258 258
  */
259 259
 function theme_userreference_formatter_plain($element) {
260
-  $output = '';
261
-  if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
260
+    $output = '';
261
+    if (isset($element['#item']['uid']) && $account = user_load(array('uid' => $element['#item']['uid']))) {
262 262
     $output = $account->name;
263
-  }
264
-  return $output;
263
+    }
264
+    return $output;
265 265
 }
266 266
 
267 267
 /**
@@ -279,32 +279,32 @@  discard block
 block discarded – undo
279 279
  * differently.
280 280
  */
281 281
 function userreference_widget_info() {
282
-  return array(
282
+    return array(
283 283
     'userreference_select' => array(
284
-      'label' => t('Select list'),
285
-      'field types' => array('userreference'),
286
-      'multiple values' => CONTENT_HANDLE_MODULE,
287
-      'callbacks' => array(
284
+        'label' => t('Select list'),
285
+        'field types' => array('userreference'),
286
+        'multiple values' => CONTENT_HANDLE_MODULE,
287
+        'callbacks' => array(
288 288
         'default value' => CONTENT_CALLBACK_DEFAULT,
289
-      ),
289
+        ),
290 290
     ),
291 291
     'userreference_buttons' => array(
292
-      'label' => t('Check boxes/radio buttons'),
293
-      'field types' => array('userreference'),
294
-      'multiple values' => CONTENT_HANDLE_MODULE,
295
-      'callbacks' => array(
292
+        'label' => t('Check boxes/radio buttons'),
293
+        'field types' => array('userreference'),
294
+        'multiple values' => CONTENT_HANDLE_MODULE,
295
+        'callbacks' => array(
296 296
         'default value' => CONTENT_CALLBACK_DEFAULT,
297
-      ),
297
+        ),
298 298
     ),
299 299
     'userreference_autocomplete' => array(
300
-      'label' => t('Autocomplete text field'),
301
-      'field types' => array('userreference'),
302
-      'multiple values' => CONTENT_HANDLE_CORE,
303
-      'callbacks' => array(
300
+        'label' => t('Autocomplete text field'),
301
+        'field types' => array('userreference'),
302
+        'multiple values' => CONTENT_HANDLE_CORE,
303
+        'callbacks' => array(
304 304
         'default value' => CONTENT_CALLBACK_DEFAULT,
305
-      ),
305
+        ),
306 306
     ),
307
-  );
307
+    );
308 308
 }
309 309
 
310 310
 /**
@@ -320,23 +320,23 @@  discard block
 block discarded – undo
320 320
  * (see nodereference and userreference).
321 321
  */
322 322
 function userreference_elements() {
323
-  return array(
323
+    return array(
324 324
     'userreference_select' => array(
325
-      '#input' => TRUE,
326
-      '#columns' => array('uid'), '#delta' => 0,
327
-      '#process' => array('userreference_select_process'),
325
+        '#input' => TRUE,
326
+        '#columns' => array('uid'), '#delta' => 0,
327
+        '#process' => array('userreference_select_process'),
328 328
     ),
329 329
     'userreference_buttons' => array(
330
-      '#input' => TRUE,
331
-      '#columns' => array('uid'), '#delta' => 0,
332
-      '#process' => array('userreference_buttons_process'),
330
+        '#input' => TRUE,
331
+        '#columns' => array('uid'), '#delta' => 0,
332
+        '#process' => array('userreference_buttons_process'),
333 333
     ),
334 334
     'userreference_autocomplete' => array(
335
-      '#input' => TRUE,
336
-      '#columns' => array('name'), '#delta' => 0,
337
-      '#process' => array('userreference_autocomplete_process'),
338
-      '#autocomplete_path' => FALSE,
339
-      ),
335
+        '#input' => TRUE,
336
+        '#columns' => array('name'), '#delta' => 0,
337
+        '#process' => array('userreference_autocomplete_process'),
338
+        '#autocomplete_path' => FALSE,
339
+        ),
340 340
     );
341 341
 }
342 342
 
@@ -344,45 +344,45 @@  discard block
 block discarded – undo
344 344
  * Implementation of hook_widget_settings().
345 345
  */
346 346
 function userreference_widget_settings($op, $widget) {
347
-  switch ($op) {
347
+    switch ($op) {
348 348
     case 'form':
349 349
       $form = array();
350
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
-      if ($widget['type'] == 'userreference_autocomplete') {
350
+        $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
+        $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
+        if ($widget['type'] == 'userreference_autocomplete') {
353 353
         $form['autocomplete_match'] = array(
354
-          '#type' => 'select',
355
-          '#title' => t('Autocomplete matching'),
356
-          '#default_value' => $match,
357
-          '#options' => array(
354
+            '#type' => 'select',
355
+            '#title' => t('Autocomplete matching'),
356
+            '#default_value' => $match,
357
+            '#options' => array(
358 358
             'starts_with' => t('Starts with'),
359 359
             'contains' => t('Contains'),
360
-          ),
361
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
360
+            ),
361
+            '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
362 362
         );
363 363
         $form['size'] = array(
364
-          '#type' => 'textfield',
365
-          '#title' => t('Size of textfield'),
366
-          '#default_value' => $size,
367
-          '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
364
+            '#type' => 'textfield',
365
+            '#title' => t('Size of textfield'),
366
+            '#default_value' => $size,
367
+            '#element_validate' => array('_element_validate_integer_positive'),
368
+            '#required' => TRUE,
369 369
         );
370
-      }
371
-      else {
370
+        }
371
+        else {
372 372
         $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373 373
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
-      }
375
-      $form['reverse_link'] = array(
374
+        }
375
+        $form['reverse_link'] = array(
376 376
         '#type' => 'checkbox',
377 377
         '#title' => t('Reverse link'),
378 378
         '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379 379
         '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
380
-      );
381
-      return $form;
380
+        );
381
+        return $form;
382 382
 
383 383
     case 'save':
384 384
       return array('autocomplete_match', 'size', 'reverse_link');
385
-  }
385
+    }
386 386
 }
387 387
 
388 388
 /**
@@ -417,30 +417,30 @@  discard block
 block discarded – undo
417 417
  *   the form item for a single element for this field
418 418
  */
419 419
 function userreference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
420
-  switch ($field['widget']['type']) {
420
+    switch ($field['widget']['type']) {
421 421
     case 'userreference_select':
422 422
       $element = array(
423 423
         '#type' => 'userreference_select',
424 424
         '#default_value' => $items,
425
-      );
426
-      break;
425
+        );
426
+        break;
427 427
 
428 428
     case 'userreference_buttons':
429 429
       $element = array(
430 430
         '#type' => 'userreference_buttons',
431 431
         '#default_value' => $items,
432
-      );
433
-      break;
432
+        );
433
+        break;
434 434
 
435 435
     case 'userreference_autocomplete':
436 436
       $element = array(
437 437
         '#type' => 'userreference_autocomplete',
438 438
         '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439 439
         '#value_callback' => 'userreference_autocomplete_value',
440
-      );
441
-      break;
442
-  }
443
-  return $element;
440
+        );
441
+        break;
442
+    }
443
+    return $element;
444 444
 }
445 445
 
446 446
 /**
@@ -449,12 +449,12 @@  discard block
 block discarded – undo
449 449
  * Substitute in the user name for the uid.
450 450
  */
451 451
 function userreference_autocomplete_value($element, $edit = FALSE) {
452
-  $field_key  = $element['#columns'][0];
453
-  if (!empty($element['#default_value'][$field_key])) {
452
+    $field_key  = $element['#columns'][0];
453
+    if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
456
-  }
457
-  return array($field_key => NULL);
456
+    }
457
+    return array($field_key => NULL);
458 458
 }
459 459
 
460 460
 /**
@@ -466,11 +466,11 @@  discard block
 block discarded – undo
466 466
  * The $fields array is in $form['#field_info'][$element['#field_name']].
467 467
  */
468 468
 function userreference_select_process($element, $edit, $form_state, $form) {
469
-  // The userreference_select widget doesn't need to create its own
470
-  // element, it can wrap around the optionwidgets_select element.
471
-  // Add a validation step where the value can be unwrapped.
472
-  $field_key  = $element['#columns'][0];
473
-  $element[$field_key] = array(
469
+    // The userreference_select widget doesn't need to create its own
470
+    // element, it can wrap around the optionwidgets_select element.
471
+    // Add a validation step where the value can be unwrapped.
472
+    $field_key  = $element['#columns'][0];
473
+    $element[$field_key] = array(
474 474
     '#type' => 'optionwidgets_select',
475 475
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
476 476
     // The following values were set by the content module and need
@@ -482,12 +482,12 @@  discard block
 block discarded – undo
482 482
     '#type_name' => $element['#type_name'],
483 483
     '#delta' => $element['#delta'],
484 484
     '#columns' => $element['#columns'],
485
-  );
486
-  if (empty($element[$field_key]['#element_validate'])) {
485
+    );
486
+    if (empty($element[$field_key]['#element_validate'])) {
487 487
     $element[$field_key]['#element_validate'] = array();
488
-  }
489
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
490
-  return $element;
488
+    }
489
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
490
+    return $element;
491 491
 }
492 492
 
493 493
 /**
@@ -499,11 +499,11 @@  discard block
 block discarded – undo
499 499
  * The $fields array is in $form['#field_info'][$element['#field_name']].
500 500
  */
501 501
 function userreference_buttons_process($element, $edit, $form_state, $form) {
502
-  // The userreference_select widget doesn't need to create its own
503
-  // element, it can wrap around the optionwidgets_select element.
504
-  // Add a validation step where the value can be unwrapped.
505
-  $field_key  = $element['#columns'][0];
506
-  $element[$field_key] = array(
502
+    // The userreference_select widget doesn't need to create its own
503
+    // element, it can wrap around the optionwidgets_select element.
504
+    // Add a validation step where the value can be unwrapped.
505
+    $field_key  = $element['#columns'][0];
506
+    $element[$field_key] = array(
507 507
     '#type' => 'optionwidgets_buttons',
508 508
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
509 509
     // The following values were set by the content module and need
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
     '#type_name' => $element['#type_name'],
516 516
     '#delta' => $element['#delta'],
517 517
     '#columns' => $element['#columns'],
518
-  );
519
-  if (empty($element[$field_key]['#element_validate'])) {
518
+    );
519
+    if (empty($element[$field_key]['#element_validate'])) {
520 520
     $element[$field_key]['#element_validate'] = array();
521
-  }
522
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
523
-  return $element;
521
+    }
522
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_optionwidgets_validate');
523
+    return $element;
524 524
 }
525 525
 
526 526
 /**
@@ -531,13 +531,13 @@  discard block
 block discarded – undo
531 531
  *
532 532
  */
533 533
 function userreference_autocomplete_process($element, $edit, $form_state, $form) {
534
-  // The userreference autocomplete widget doesn't need to create its own
535
-  // element, it can wrap around the text_textfield element and add an autocomplete
536
-  // path and some extra processing to it.
537
-  // Add a validation step where the value can be unwrapped.
538
-  $field_key  = $element['#columns'][0];
534
+    // The userreference autocomplete widget doesn't need to create its own
535
+    // element, it can wrap around the text_textfield element and add an autocomplete
536
+    // path and some extra processing to it.
537
+    // Add a validation step where the value can be unwrapped.
538
+    $field_key  = $element['#columns'][0];
539 539
 
540
-  $element[$field_key] = array(
540
+    $element[$field_key] = array(
541 541
     '#type' => 'text_textfield',
542 542
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
543 543
     '#autocomplete_path' => 'userreference/autocomplete/'. $element['#field_name'],
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
     '#type_name' => $element['#type_name'],
551 551
     '#delta' => $element['#delta'],
552 552
     '#columns' => $element['#columns'],
553
-  );
554
-  if (empty($element[$field_key]['#element_validate'])) {
553
+    );
554
+    if (empty($element[$field_key]['#element_validate'])) {
555 555
     $element[$field_key]['#element_validate'] = array();
556
-  }
557
-  array_unshift($element[$field_key]['#element_validate'], 'userreference_autocomplete_validate');
556
+    }
557
+    array_unshift($element[$field_key]['#element_validate'], 'userreference_autocomplete_validate');
558 558
 
559
-  // Used so that hook_field('validate') knows where to flag an error.
560
-  $element['_error_element'] = array(
559
+    // Used so that hook_field('validate') knows where to flag an error.
560
+    $element['_error_element'] = array(
561 561
     '#type' => 'value',
562 562
     // Wrapping the element around a text_textfield element creates a
563 563
     // nested element, so the final id will look like 'field-name-0-uid-uid'.
564 564
     '#value' => implode('][', array_merge($element['#parents'], array($field_key, $field_key))),
565
-  );
566
-  return $element;
565
+    );
566
+    return $element;
567 567
 }
568 568
 
569 569
 /**
@@ -578,20 +578,20 @@  discard block
 block discarded – undo
578 578
  * like optionwidgets are using #element_validate to alter the value.
579 579
  */
580 580
 function userreference_optionwidgets_validate($element, &$form_state) {
581
-  $field_key  = $element['#columns'][0];
581
+    $field_key  = $element['#columns'][0];
582 582
 
583
-  $value = $form_state['values'];
584
-  $new_parents = array();
585
-  foreach ($element['#parents'] as $parent) {
583
+    $value = $form_state['values'];
584
+    $new_parents = array();
585
+    foreach ($element['#parents'] as $parent) {
586 586
     $value = $value[$parent];
587 587
     // Use === to be sure we get right results if parent is a zero (delta) value.
588 588
     if ($parent === $field_key) {
589
-      $element['#parents'] = $new_parents;
590
-      form_set_value($element, $value, $form_state);
591
-      break;
589
+        $element['#parents'] = $new_parents;
590
+        form_set_value($element, $value, $form_state);
591
+        break;
592 592
     }
593 593
     $new_parents[] = $parent;
594
-  }
594
+    }
595 595
 }
596 596
 
597 597
 /**
@@ -602,36 +602,36 @@  discard block
 block discarded – undo
602 602
  * back to its original location, 'field-name-0-uid'.
603 603
  */
604 604
 function userreference_autocomplete_validate($element, &$form_state) {
605
-  $field_name = $element['#field_name'];
606
-  $type_name = $element['#type_name'];
607
-  $field = content_fields($field_name, $type_name);
608
-  $field_key = $element['#columns'][0];
609
-  $value = $element['#value'][$field_key];
610
-  $uid = NULL;
611
-  if (!empty($value)) {
605
+    $field_name = $element['#field_name'];
606
+    $type_name = $element['#type_name'];
607
+    $field = content_fields($field_name, $type_name);
608
+    $field_key = $element['#columns'][0];
609
+    $value = $element['#value'][$field_key];
610
+    $uid = NULL;
611
+    if (!empty($value)) {
612 612
     $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
613 613
     if (empty($reference)) {
614
-      form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
614
+        form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615 615
     }
616 616
     else {
617
-      $uid = key($reference);
617
+        $uid = key($reference);
618
+    }
618 619
     }
619
-  }
620
-  form_set_value($element, $uid, $form_state);
620
+    form_set_value($element, $uid, $form_state);
621 621
 }
622 622
 
623 623
 /**
624 624
  * Implementation of hook_allowed_values().
625 625
  */
626 626
 function userreference_allowed_values($field) {
627
-  $references = _userreference_potential_references($field);
627
+    $references = _userreference_potential_references($field);
628 628
 
629
-  $options = array();
630
-  foreach ($references as $key => $value) {
629
+    $options = array();
630
+    foreach ($references as $key => $value) {
631 631
     $options[$key] = $value['rendered'];
632
-  }
632
+    }
633 633
 
634
-  return $options;
634
+    return $options;
635 635
 }
636 636
 
637 637
 /**
@@ -667,26 +667,26 @@  discard block
 block discarded – undo
667 667
  *   )
668 668
  */
669 669
 function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
670
-  static $results = array();
670
+    static $results = array();
671 671
 
672
-  // Create unique id for static cache.
673
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674
-  if (!isset($results[$cid])) {
672
+    // Create unique id for static cache.
673
+    $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674
+    if (!isset($results[$cid])) {
675 675
     $references = FALSE;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
677
-      $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
677
+        $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
678 678
     }
679 679
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
680 680
 
681 681
     if ($references === FALSE) {
682
-      $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
682
+        $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
683 683
     }
684 684
 
685 685
     // Store the results.
686 686
     $results[$cid] = !empty($references) ? $references : array();
687
-  }
687
+    }
688 688
 
689
-  return $results[$cid];
689
+    return $results[$cid];
690 690
 }
691 691
 
692 692
 /**
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
  * case of Views-defined referenceable users.
695 695
  */
696 696
 function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
697
-  $view_name = $field['advanced_view'];
697
+    $view_name = $field['advanced_view'];
698 698
 
699
-  if ($view = views_get_view($view_name)) {
699
+    if ($view = views_get_view($view_name)) {
700 700
     // We add a display, and let it derive from the 'default' display.
701 701
     // TODO: We should let the user pick a display in the fields settings - sort of requires AHAH...
702 702
     $display = $view->add_display('content_references');
@@ -713,12 +713,12 @@  discard block
 block discarded – undo
713 713
     // Additional options to let content_plugin_display_references::query()
714 714
     // narrow the results.
715 715
     $options = array(
716
-      'table' => 'users',
717
-      'field_string' => 'name',
718
-      'string' => $string,
719
-      'match' => $match,
720
-      'field_id' => 'uid',
721
-      'ids' => $ids,
716
+        'table' => 'users',
717
+        'field_string' => 'name',
718
+        'string' => $string,
719
+        'match' => $match,
720
+        'field_id' => 'uid',
721
+        'ids' => $ids,
722 722
     );
723 723
     $view->display_handler->set_option('content_options', $options);
724 724
 
@@ -731,26 +731,26 @@  discard block
 block discarded – undo
731 731
 
732 732
     // Get arguments for the view.
733 733
     if (!empty($field['advanced_view_args'])) {
734
-      // TODO: Support Tokens using token.module ?
735
-      $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
734
+        // TODO: Support Tokens using token.module ?
735
+        $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
736 736
     }
737 737
     else {
738
-      $view_args = array();
738
+        $view_args = array();
739 739
     }
740 740
 
741 741
     // We do need name field, so add it if not present (unlikely, but...)
742 742
     $fields = $view->get_items('field', $display);
743 743
     if (!isset($fields['name'])) {
744
-      $view->add_item($display, 'field', 'users', 'name');
744
+        $view->add_item($display, 'field', 'users', 'name');
745 745
     }
746 746
 
747 747
     // If not set, make all fields inline and define a separator.
748 748
     $options = $view->display_handler->get_option('row_options');
749 749
     if (empty($options['inline'])) {
750
-      $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
750
+        $options['inline'] = drupal_map_assoc(array_keys($view->get_items('field', $display)));
751 751
     }
752 752
     if (empty($options['separator'])) {
753
-      $options['separator'] = '-';
753
+        $options['separator'] = '-';
754 754
     }
755 755
     $view->display_handler->set_option('row_options', $options);
756 756
 
@@ -759,12 +759,12 @@  discard block
 block discarded – undo
759 759
 
760 760
     // Get the results.
761 761
     $result = $view->execute_display($display, $view_args);
762
-  }
763
-  else {
762
+    }
763
+    else {
764 764
     $result = FALSE;
765
-  }
765
+    }
766 766
 
767
-  return $result;
767
+    return $result;
768 768
 }
769 769
 
770 770
 /**
@@ -772,112 +772,112 @@  discard block
 block discarded – undo
772 772
  * referenceable users defined by user role and status
773 773
  */
774 774
 function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
775
-  $where = array();
776
-  $args = array();
777
-  $join = array();
775
+    $where = array();
776
+    $args = array();
777
+    $join = array();
778 778
 
779
-  if ($string !== '') {
779
+    if ($string !== '') {
780 780
     $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE";
781 781
     $match_clauses = array(
782
-      'contains' => "$like '%%%s%%'",
783
-      'equals' => "= '%s'",
784
-      'starts_with' => "$like '%s%%'",
782
+        'contains' => "$like '%%%s%%'",
783
+        'equals' => "= '%s'",
784
+        'starts_with' => "$like '%s%%'",
785 785
     );
786 786
     $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 787
     $args[] = $string;
788
-  }
789
-  elseif ($ids) {
788
+    }
789
+    elseif ($ids) {
790 790
     $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
791 791
     $args = array_merge($args, $ids);
792
-  }
793
-  else {
792
+    }
793
+    else {
794 794
     $where[] = "u.uid > 0";
795
-  }
795
+    }
796 796
 
797
-  $roles = array();
798
-  if (isset($field['referenceable_roles']) && is_array($field['referenceable_roles'])) {
797
+    $roles = array();
798
+    if (isset($field['referenceable_roles']) && is_array($field['referenceable_roles'])) {
799 799
     // keep only selected checkboxes
800 800
     $roles = array_filter($field['referenceable_roles']);
801 801
     // filter invalid values that seems to get through sometimes ??
802 802
     $roles = array_intersect(array_keys(user_roles(1)), $roles);
803
-  }
804
-  if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
803
+    }
804
+    if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
805 805
     $where[] = "r.rid IN (". implode($roles, ',') .")";
806 806
     $join[] = 'LEFT JOIN {users_roles} r ON u.uid = r.uid';
807
-  }
807
+    }
808 808
 
809
-  if (isset($field['referenceable_status']) && is_numeric($field['referenceable_status'])) {
809
+    if (isset($field['referenceable_status']) && is_numeric($field['referenceable_status'])) {
810 810
     $where[] = 'u.status = %d';
811 811
     $args[] = $field['referenceable_status'];
812
-  }
812
+    }
813 813
 
814
-  $users = array();
815
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
-  $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
817
-  while ($user = db_fetch_object($result)) {
814
+    $users = array();
815
+    $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
+    $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
817
+    while ($user = db_fetch_object($result)) {
818 818
     $users[$user->uid] = array(
819
-      'title' => $user->name,
820
-      'rendered' => check_plain($user->name),
819
+        'title' => $user->name,
820
+        'rendered' => check_plain($user->name),
821 821
     );
822
-  }
823
-  return $users;
822
+    }
823
+    return $users;
824 824
 }
825 825
 
826 826
 /**
827 827
  * Menu callback; Retrieve a pipe delimited string of autocomplete suggestions for existing users
828 828
  */
829 829
 function userreference_autocomplete($field_name, $string = '') {
830
-  $fields = content_fields();
831
-  $field = $fields[$field_name];
832
-  $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
833
-  $matches = array();
830
+    $fields = content_fields();
831
+    $field = $fields[$field_name];
832
+    $match = isset($field['widget']['autocomplete_match']) ? $field['widget']['autocomplete_match'] : 'contains';
833
+    $matches = array();
834 834
 
835
-  $references = _userreference_potential_references($field, $string, $match, array(), 10);
836
-  foreach ($references as $id => $row) {
835
+    $references = _userreference_potential_references($field, $string, $match, array(), 10);
836
+    foreach ($references as $id => $row) {
837 837
     // Add a class wrapper for a few required CSS overrides.
838 838
     $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
839
-  }
840
-  drupal_json($matches);
839
+    }
840
+    drupal_json($matches);
841 841
 }
842 842
 
843 843
 /**
844 844
  * Implementation of hook_user().
845 845
  */
846 846
 function userreference_user($type, &$edit, &$account) {
847
-  switch ($type) {
847
+    switch ($type) {
848 848
     case 'load':
849 849
       // Only add links if we are on the user 'view' page.
850 850
       if (arg(0) != 'user' || arg(2)) {
851 851
         return;
852
-      }
853
-      // find CCK userreference field tables
854
-      // search through them for matching user ids and load those nodes
855
-      $additions = array();
856
-      $types = content_types();
857
-
858
-      // Find the table and columns to search through, if the same
859
-      // table comes up in more than one content type, we only need
860
-      // to search it once.
861
-      $search_tables = array();
862
-      foreach ($types as $type_name => $type) {
852
+        }
853
+        // find CCK userreference field tables
854
+        // search through them for matching user ids and load those nodes
855
+        $additions = array();
856
+        $types = content_types();
857
+
858
+        // Find the table and columns to search through, if the same
859
+        // table comes up in more than one content type, we only need
860
+        // to search it once.
861
+        $search_tables = array();
862
+        foreach ($types as $type_name => $type) {
863 863
         foreach ($type['fields'] as $field) {
864
-          // Only add tables when reverse link has been selected.
865
-          if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
864
+            // Only add tables when reverse link has been selected.
865
+            if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866 866
             $db_info = content_database_info($field);
867 867
             $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
868
-          }
868
+            }
869
+        }
869 870
         }
870
-      }
871
-      foreach ($search_tables as $table => $columns) {
871
+        foreach ($search_tables as $table => $columns) {
872 872
         foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
-          while ($data = db_fetch_object($ids)) {
873
+            $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
+            while ($data = db_fetch_object($ids)) {
875 875
             $additions[$data->type][$data->nid] = $data->title;
876
-          }
876
+            }
877 877
         }
878
-      }
879
-      $account->userreference = $additions;
880
-      break;
878
+        }
879
+        $account->userreference = $additions;
880
+        break;
881 881
 
882 882
     case 'view':
883 883
       if (!empty($account->userreference)) {
@@ -885,28 +885,28 @@  discard block
 block discarded – undo
885 885
         $additions = array();
886 886
         $values = array();
887 887
         foreach ($account->userreference as $node_type => $nodes) {
888
-          foreach ($nodes as $nid => $title) {
888
+            foreach ($nodes as $nid => $title) {
889 889
             $values[$node_type][] = l($title, 'node/'. $nid);
890
-          }
891
-          if (isset($values[$node_type])) {
890
+            }
891
+            if (isset($values[$node_type])) {
892 892
             $additions[] = array(
893
-              '#type' => 'user_profile_item',
894
-              '#title' => check_plain($node_types[$node_type]['name']),
895
-              '#value' => theme('item_list', $values[$node_type]),
893
+                '#type' => 'user_profile_item',
894
+                '#title' => check_plain($node_types[$node_type]['name']),
895
+                '#value' => theme('item_list', $values[$node_type]),
896 896
             );
897
-          }
897
+            }
898 898
         }
899 899
         if ($additions) {
900
-          $account->content['userreference'] = $additions + array(
900
+            $account->content['userreference'] = $additions + array(
901 901
             '#type' => 'user_profile_category',
902 902
             '#attributes' => array('class' => 'user-member'),
903 903
             '#title' => t('Related content'),
904 904
             '#weight' => 10,
905
-          );
905
+            );
906 906
         }
907
-      }
908
-      break;
909
-  }
907
+        }
908
+        break;
909
+    }
910 910
 }
911 911
 
912 912
 /**
@@ -921,13 +921,13 @@  discard block
 block discarded – undo
921 921
  * $element['#delta]  is the position of this element in the group
922 922
  */
923 923
 function theme_userreference_select($element) {
924
-  return $element['#children'];
924
+    return $element['#children'];
925 925
 }
926 926
 
927 927
 function theme_userreference_buttons($element) {
928
-  return $element['#children'];
928
+    return $element['#children'];
929 929
 }
930 930
 
931 931
 function theme_userreference_autocomplete($element) {
932
-  return $element['#children'];
932
+    return $element['#children'];
933 933
 }
934 934
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -70,108 +70,108 @@  discard block
 block discarded – undo
70 70
  */
71 71
 function userreference_field_settings($op, $field) {
72 72
   switch ($op) {
73
-    case 'form':
74
-      $form = array();
75
-      $form['referenceable_roles'] = array(
76
-        '#type' => 'checkboxes',
77
-        '#title' => t('User roles that can be referenced'),
78
-        '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79
-        '#options' => user_roles(1),
80
-      );
81
-      $form['referenceable_status'] = array(
82
-        '#type' => 'radios',
83
-        '#title' => t('User status that can be referenced'),
84
-        '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85
-        '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
-      );
87
-      if (module_exists('views')) {
88
-        $views = array('--' => '--');
89
-        $all_views = views_get_all_views();
90
-        foreach ($all_views as $view) {
91
-          // Only 'users' views that have fields will work for our purpose.
92
-          if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93
-            if ($view->type == 'Default') {
94
-              $views[t('Default Views')][$view->name] = $view->name;
95
-            }
96
-            else {
97
-              $views[t('Existing Views')][$view->name] = $view->name;
98
-            }
73
+  case 'form':
74
+    $form = array();
75
+    $form['referenceable_roles'] = array(
76
+      '#type' => 'checkboxes',
77
+      '#title' => t('User roles that can be referenced'),
78
+      '#default_value' => isset($field['referenceable_roles']) && is_array($field['referenceable_roles']) ? array_filter($field['referenceable_roles']) : array(),
79
+      '#options' => user_roles(1),
80
+    );
81
+    $form['referenceable_status'] = array(
82
+      '#type' => 'radios',
83
+      '#title' => t('User status that can be referenced'),
84
+      '#default_value' => isset($field['referenceable_status']) ? $field['referenceable_status'] : '',
85
+      '#options' => array('' => t('All users'), 1 => t('Active users'), 0 => t('Blocked users')),
86
+    );
87
+    if (module_exists('views')) {
88
+      $views = array('--' => '--');
89
+      $all_views = views_get_all_views();
90
+      foreach ($all_views as $view) {
91
+        // Only 'users' views that have fields will work for our purpose.
92
+        if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93
+          if ($view->type == 'Default') {
94
+            $views[t('Default Views')][$view->name] = $view->name;
95
+          }
96
+          else {
97
+            $views[t('Existing Views')][$view->name] = $view->name;
99 98
           }
100
-        }
101
-
102
-        $form['advanced'] = array(
103
-           '#type' => 'fieldset',
104
-           '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
106
-           '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
-         );
108
-        if (count($views) > 1) {
109
-          $form['advanced']['advanced_view'] = array(
110
-            '#type' => 'select',
111
-            '#title' => t('View used to select the users'),
112
-            '#options' => $views,
113
-            '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
-            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
-          );
117
-          $form['advanced']['advanced_view_args'] = array(
118
-            '#type' => 'textfield',
119
-            '#title' => t('View arguments'),
120
-            '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
-            '#required' => FALSE,
122
-            '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
-          );
124
-        }
125
-        else {
126
-          $form['advanced']['no_view_help'] = array(
127
-            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
-              t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
-          );
130 99
         }
131 100
       }
132
-      return $form;
133 101
 
134
-    case 'save':
135
-      $settings = array('referenceable_roles', 'referenceable_status');
136
-      if (module_exists('views')) {
137
-        $settings[] = 'advanced_view';
138
-        $settings[] = 'advanced_view_args';
102
+      $form['advanced'] = array(
103
+         '#type' => 'fieldset',
104
+         '#title' => t('Advanced - Users that can be referenced (View)'),
105
+         '#collapsible' => TRUE,
106
+         '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107
+       );
108
+      if (count($views) > 1) {
109
+        $form['advanced']['advanced_view'] = array(
110
+          '#type' => 'select',
111
+          '#title' => t('View used to select the users'),
112
+          '#options' => $views,
113
+          '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
+          '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
115
+            t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116
+        );
117
+        $form['advanced']['advanced_view_args'] = array(
118
+          '#type' => 'textfield',
119
+          '#title' => t('View arguments'),
120
+          '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
+          '#required' => FALSE,
122
+          '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123
+        );
124
+      }
125
+      else {
126
+        $form['advanced']['no_view_help'] = array(
127
+          '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128
+            t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129
+        );
139 130
       }
140
-      return $settings;
131
+    }
132
+    return $form;
141 133
 
142
-    case 'database columns':
143
-      $columns = array(
144
-        'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
-      );
146
-      return $columns;
147
-
148
-    case 'views data':
149
-      $data = content_views_field_views_data($field);
150
-      $db_info = content_database_info($field);
151
-      $table_alias = content_views_tablename($field);
152
-
153
-      // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
-      // Argument: get the user name for summaries.
156
-      // We need to join a new instance of the users table.
157
-      $data["users_$table_alias"]['table']['join']['node'] = array(
158
-        'table' => 'users',
159
-        'field' => 'uid',
160
-        'left_table' => $table_alias,
161
-        'left_field' => $field['field_name'] .'_uid',
162
-      );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
-      // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168
-        'base' => 'users',
169
-        'field' => $db_info['columns']['uid']['column'],
170
-        'handler' => 'content_handler_relationship',
171
-        'label' => t($field['widget']['label']),
172
-        'content_field_name' => $field['field_name'],
173
-      );
174
-      return $data;
134
+  case 'save':
135
+    $settings = array('referenceable_roles', 'referenceable_status');
136
+    if (module_exists('views')) {
137
+      $settings[] = 'advanced_view';
138
+      $settings[] = 'advanced_view_args';
139
+    }
140
+    return $settings;
141
+
142
+  case 'database columns':
143
+    $columns = array(
144
+      'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
145
+    );
146
+    return $columns;
147
+
148
+  case 'views data':
149
+    $data = content_views_field_views_data($field);
150
+    $db_info = content_database_info($field);
151
+    $table_alias = content_views_tablename($field);
152
+
153
+    // Filter : swap the handler to the 'in' operator.
154
+    $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155
+    // Argument: get the user name for summaries.
156
+    // We need to join a new instance of the users table.
157
+    $data["users_$table_alias"]['table']['join']['node'] = array(
158
+      'table' => 'users',
159
+      'field' => 'uid',
160
+      'left_table' => $table_alias,
161
+      'left_field' => $field['field_name'] .'_uid',
162
+    );
163
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
+    $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
166
+    // Relationship: Add a relationship for related user.
167
+    $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
168
+      'base' => 'users',
169
+      'field' => $db_info['columns']['uid']['column'],
170
+      'handler' => 'content_handler_relationship',
171
+      'label' => t($field['widget']['label']),
172
+      'content_field_name' => $field['field_name'],
173
+    );
174
+    return $data;
175 175
 
176 176
   }
177 177
 }
@@ -181,35 +181,35 @@  discard block
 block discarded – undo
181 181
  */
182 182
 function userreference_field($op, &$node, $field, &$items, $teaser, $page) {
183 183
   switch ($op) {
184
-    case 'validate':
185
-      // Extract uids to check.
186
-      $ids = array();
187
-      foreach ($items as $delta => $item) {
188
-        if (is_array($item) && !empty($item['uid'])) {
189
-          if (is_numeric($item['uid'])) {
190
-            $ids[] = $item['uid'];
191
-          }
192
-          else {
193
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195
-            form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
196
-          }
184
+  case 'validate':
185
+    // Extract uids to check.
186
+    $ids = array();
187
+    foreach ($items as $delta => $item) {
188
+      if (is_array($item) && !empty($item['uid'])) {
189
+        if (is_numeric($item['uid'])) {
190
+          $ids[] = $item['uid'];
191
+        }
192
+        else {
193
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195
+          form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
197 196
         }
198 197
       }
199
-      // Prevent performance hog if there are no ids to check.
200
-      if ($ids) {
201
-        $refs = _userreference_potential_references($field, '', NULL, $ids);
202
-        foreach ($items as $delta => $item) {
203
-          if (is_array($item)) {
204
-            $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205
-            if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206
-            if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
-              form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
208
-            }
198
+    }
199
+    // Prevent performance hog if there are no ids to check.
200
+    if ($ids) {
201
+      $refs = _userreference_potential_references($field, '', NULL, $ids);
202
+      foreach ($items as $delta => $item) {
203
+        if (is_array($item)) {
204
+          $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
205
+          if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
206
+          if (!empty($item['uid']) && !isset($refs[$item['uid']])) {
207
+            form_set_error($error_element, t('%name: invalid user.', array('%name' => t($field['widget']['label']))));
209 208
           }
210 209
         }
211 210
       }
212
-      return $items;
211
+    }
212
+    return $items;
213 213
   }
214 214
 }
215 215
 
@@ -345,43 +345,43 @@  discard block
 block discarded – undo
345 345
  */
346 346
 function userreference_widget_settings($op, $widget) {
347 347
   switch ($op) {
348
-    case 'form':
349
-      $form = array();
350
-      $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
-      $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
-      if ($widget['type'] == 'userreference_autocomplete') {
353
-        $form['autocomplete_match'] = array(
354
-          '#type' => 'select',
355
-          '#title' => t('Autocomplete matching'),
356
-          '#default_value' => $match,
357
-          '#options' => array(
358
-            'starts_with' => t('Starts with'),
359
-            'contains' => t('Contains'),
360
-          ),
361
-          '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
362
-        );
363
-        $form['size'] = array(
364
-          '#type' => 'textfield',
365
-          '#title' => t('Size of textfield'),
366
-          '#default_value' => $size,
367
-          '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
369
-        );
370
-      }
371
-      else {
372
-        $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373
-        $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
-      }
375
-      $form['reverse_link'] = array(
376
-        '#type' => 'checkbox',
377
-        '#title' => t('Reverse link'),
378
-        '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379
-        '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
348
+  case 'form':
349
+    $form = array();
350
+    $match = isset($widget['autocomplete_match']) ? $widget['autocomplete_match'] : 'contains';
351
+    $size = (isset($widget['size']) && is_numeric($widget['size'])) ? $widget['size'] : 60;
352
+    if ($widget['type'] == 'userreference_autocomplete') {
353
+      $form['autocomplete_match'] = array(
354
+        '#type' => 'select',
355
+        '#title' => t('Autocomplete matching'),
356
+        '#default_value' => $match,
357
+        '#options' => array(
358
+          'starts_with' => t('Starts with'),
359
+          'contains' => t('Contains'),
360
+        ),
361
+        '#description' => t('Select the method used to collect autocomplete suggestions. Note that <em>Contains</em> can cause performance issues on sites with thousands of users.'),
380 362
       );
381
-      return $form;
363
+      $form['size'] = array(
364
+        '#type' => 'textfield',
365
+        '#title' => t('Size of textfield'),
366
+        '#default_value' => $size,
367
+        '#element_validate' => array('_element_validate_integer_positive'),
368
+        '#required' => TRUE,
369
+      );
370
+    }
371
+    else {
372
+      $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373
+      $form['size'] = array('#type' => 'hidden', '#value' => $size);
374
+    }
375
+    $form['reverse_link'] = array(
376
+      '#type' => 'checkbox',
377
+      '#title' => t('Reverse link'),
378
+      '#default_value' => isset($widget['reverse_link']) ? $widget['reverse_link'] : 0,
379
+      '#description' => t('If selected, a reverse link back to the referencing node will displayed on the referenced user record.'),
380
+    );
381
+    return $form;
382 382
 
383
-    case 'save':
384
-      return array('autocomplete_match', 'size', 'reverse_link');
383
+  case 'save':
384
+    return array('autocomplete_match', 'size', 'reverse_link');
385 385
   }
386 386
 }
387 387
 
@@ -418,27 +418,27 @@  discard block
 block discarded – undo
418 418
  */
419 419
 function userreference_widget(&$form, &$form_state, $field, $items, $delta = 0) {
420 420
   switch ($field['widget']['type']) {
421
-    case 'userreference_select':
422
-      $element = array(
423
-        '#type' => 'userreference_select',
424
-        '#default_value' => $items,
425
-      );
426
-      break;
421
+  case 'userreference_select':
422
+    $element = array(
423
+      '#type' => 'userreference_select',
424
+      '#default_value' => $items,
425
+    );
426
+    break;
427 427
 
428
-    case 'userreference_buttons':
429
-      $element = array(
430
-        '#type' => 'userreference_buttons',
431
-        '#default_value' => $items,
432
-      );
433
-      break;
428
+  case 'userreference_buttons':
429
+    $element = array(
430
+      '#type' => 'userreference_buttons',
431
+      '#default_value' => $items,
432
+    );
433
+    break;
434 434
 
435
-    case 'userreference_autocomplete':
436
-      $element = array(
437
-        '#type' => 'userreference_autocomplete',
438
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439
-        '#value_callback' => 'userreference_autocomplete_value',
440
-      );
441
-      break;
435
+  case 'userreference_autocomplete':
436
+    $element = array(
437
+      '#type' => 'userreference_autocomplete',
438
+      '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
439
+      '#value_callback' => 'userreference_autocomplete_value',
440
+    );
441
+    break;
442 442
   }
443 443
   return $element;
444 444
 }
@@ -845,67 +845,67 @@  discard block
 block discarded – undo
845 845
  */
846 846
 function userreference_user($type, &$edit, &$account) {
847 847
   switch ($type) {
848
-    case 'load':
849
-      // Only add links if we are on the user 'view' page.
850
-      if (arg(0) != 'user' || arg(2)) {
851
-        return;
852
-      }
853
-      // find CCK userreference field tables
854
-      // search through them for matching user ids and load those nodes
855
-      $additions = array();
856
-      $types = content_types();
857
-
858
-      // Find the table and columns to search through, if the same
859
-      // table comes up in more than one content type, we only need
860
-      // to search it once.
861
-      $search_tables = array();
862
-      foreach ($types as $type_name => $type) {
863
-        foreach ($type['fields'] as $field) {
864
-          // Only add tables when reverse link has been selected.
865
-          if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866
-            $db_info = content_database_info($field);
867
-            $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
868
-          }
848
+  case 'load':
849
+    // Only add links if we are on the user 'view' page.
850
+    if (arg(0) != 'user' || arg(2)) {
851
+      return;
852
+    }
853
+    // find CCK userreference field tables
854
+    // search through them for matching user ids and load those nodes
855
+    $additions = array();
856
+    $types = content_types();
857
+
858
+    // Find the table and columns to search through, if the same
859
+    // table comes up in more than one content type, we only need
860
+    // to search it once.
861
+    $search_tables = array();
862
+    foreach ($types as $type_name => $type) {
863
+      foreach ($type['fields'] as $field) {
864
+        // Only add tables when reverse link has been selected.
865
+        if ($field['type'] == 'userreference' && !empty($field['widget']['reverse_link'])) {
866
+          $db_info = content_database_info($field);
867
+          $search_tables[$db_info['table']][] = $db_info['columns']['uid']['column'];
869 868
         }
870 869
       }
871
-      foreach ($search_tables as $table => $columns) {
872
-        foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
-          while ($data = db_fetch_object($ids)) {
875
-            $additions[$data->type][$data->nid] = $data->title;
876
-          }
870
+    }
871
+    foreach ($search_tables as $table => $columns) {
872
+      foreach ($columns as $column) {
873
+        $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
874
+        while ($data = db_fetch_object($ids)) {
875
+          $additions[$data->type][$data->nid] = $data->title;
877 876
         }
878 877
       }
879
-      $account->userreference = $additions;
880
-      break;
878
+    }
879
+    $account->userreference = $additions;
880
+    break;
881 881
 
882
-    case 'view':
883
-      if (!empty($account->userreference)) {
884
-        $node_types = content_types();
885
-        $additions = array();
886
-        $values = array();
887
-        foreach ($account->userreference as $node_type => $nodes) {
888
-          foreach ($nodes as $nid => $title) {
889
-            $values[$node_type][] = l($title, 'node/'. $nid);
890
-          }
891
-          if (isset($values[$node_type])) {
892
-            $additions[] = array(
893
-              '#type' => 'user_profile_item',
894
-              '#title' => check_plain($node_types[$node_type]['name']),
895
-              '#value' => theme('item_list', $values[$node_type]),
896
-            );
897
-          }
882
+  case 'view':
883
+    if (!empty($account->userreference)) {
884
+      $node_types = content_types();
885
+      $additions = array();
886
+      $values = array();
887
+      foreach ($account->userreference as $node_type => $nodes) {
888
+        foreach ($nodes as $nid => $title) {
889
+          $values[$node_type][] = l($title, 'node/'. $nid);
898 890
         }
899
-        if ($additions) {
900
-          $account->content['userreference'] = $additions + array(
901
-            '#type' => 'user_profile_category',
902
-            '#attributes' => array('class' => 'user-member'),
903
-            '#title' => t('Related content'),
904
-            '#weight' => 10,
891
+        if (isset($values[$node_type])) {
892
+          $additions[] = array(
893
+            '#type' => 'user_profile_item',
894
+            '#title' => check_plain($node_types[$node_type]['name']),
895
+            '#value' => theme('item_list', $values[$node_type]),
905 896
           );
906 897
         }
907 898
       }
908
-      break;
899
+      if ($additions) {
900
+        $account->content['userreference'] = $additions + array(
901
+          '#type' => 'user_profile_category',
902
+          '#attributes' => array('class' => 'user-member'),
903
+          '#title' => t('Related content'),
904
+          '#weight' => 10,
905
+        );
906
+      }
907
+    }
908
+    break;
909 909
   }
910 910
 }
911 911
 
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
  */
49 49
 function userreference_ctools_plugin_directory($module, $plugin) {
50 50
   if ($module == 'ctools' && $plugin == 'relationships') {
51
-    return 'panels/' . $plugin;
51
+    return 'panels/'.$plugin;
52 52
   }
53 53
 }
54 54
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             '#title' => t('View used to select the users'),
112 112
             '#options' => $views,
113 113
             '#default_value' => isset($field['advanced_view']) ? $field['advanced_view'] : '--',
114
-            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>') .
114
+            '#description' =>  t('<p>Choose the "Views module" view that selects the users that can be referenced.<br />Note:</p>').
115 115
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
116 116
           );
117 117
           $form['advanced']['advanced_view_args'] = array(
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
         }
125 125
         else {
126 126
           $form['advanced']['no_view_help'] = array(
127
-            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
127
+            '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>').
128 128
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
129 129
           );
130 130
         }
@@ -151,20 +151,20 @@  discard block
 block discarded – undo
151 151
       $table_alias = content_views_tablename($field);
152 152
 
153 153
       // Filter : swap the handler to the 'in' operator.
154
-      $data[$table_alias][$field['field_name'] .'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
154
+      $data[$table_alias][$field['field_name'].'_uid']['filter']['handler'] = 'content_handler_filter_many_to_one';
155 155
       // Argument: get the user name for summaries.
156 156
       // We need to join a new instance of the users table.
157 157
       $data["users_$table_alias"]['table']['join']['node'] = array(
158 158
         'table' => 'users',
159 159
         'field' => 'uid',
160 160
         'left_table' => $table_alias,
161
-        'left_field' => $field['field_name'] .'_uid',
161
+        'left_field' => $field['field_name'].'_uid',
162 162
       );
163
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name table'] = "users_$table_alias";
165
-      $data[$table_alias][$field['field_name'] .'_uid']['argument']['name field'] = 'name';
163
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['handler'] = 'content_handler_argument_reference';
164
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['name table'] = "users_$table_alias";
165
+      $data[$table_alias][$field['field_name'].'_uid']['argument']['name field'] = 'name';
166 166
       // Relationship: Add a relationship for related user.
167
-      $data[$table_alias][$field['field_name'] .'_uid']['relationship'] = array(
167
+      $data[$table_alias][$field['field_name'].'_uid']['relationship'] = array(
168 168
         'base' => 'users',
169 169
         'field' => $db_info['columns']['uid']['column'],
170 170
         'handler' => 'content_handler_relationship',
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
  * Substitute in the user name for the uid.
450 450
  */
451 451
 function userreference_autocomplete_value($element, $edit = FALSE) {
452
-  $field_key  = $element['#columns'][0];
452
+  $field_key = $element['#columns'][0];
453 453
   if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
   // The userreference_select widget doesn't need to create its own
470 470
   // element, it can wrap around the optionwidgets_select element.
471 471
   // Add a validation step where the value can be unwrapped.
472
-  $field_key  = $element['#columns'][0];
472
+  $field_key = $element['#columns'][0];
473 473
   $element[$field_key] = array(
474 474
     '#type' => 'optionwidgets_select',
475 475
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -502,7 +502,7 @@  discard block
 block discarded – undo
502 502
   // The userreference_select widget doesn't need to create its own
503 503
   // element, it can wrap around the optionwidgets_select element.
504 504
   // Add a validation step where the value can be unwrapped.
505
-  $field_key  = $element['#columns'][0];
505
+  $field_key = $element['#columns'][0];
506 506
   $element[$field_key] = array(
507 507
     '#type' => 'optionwidgets_buttons',
508 508
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
   // element, it can wrap around the text_textfield element and add an autocomplete
536 536
   // path and some extra processing to it.
537 537
   // Add a validation step where the value can be unwrapped.
538
-  $field_key  = $element['#columns'][0];
538
+  $field_key = $element['#columns'][0];
539 539
 
540 540
   $element[$field_key] = array(
541 541
     '#type' => 'text_textfield',
542 542
     '#default_value' => isset($element['#value']) ? $element['#value'] : '',
543
-    '#autocomplete_path' => 'userreference/autocomplete/'. $element['#field_name'],
543
+    '#autocomplete_path' => 'userreference/autocomplete/'.$element['#field_name'],
544 544
     // The following values were set by the content module and need
545 545
     // to be passed down to the nested element.
546 546
     '#title' => $element['#title'],
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
  * like optionwidgets are using #element_validate to alter the value.
579 579
  */
580 580
 function userreference_optionwidgets_validate($element, &$form_state) {
581
-  $field_key  = $element['#columns'][0];
581
+  $field_key = $element['#columns'][0];
582 582
 
583 583
   $value = $form_state['values'];
584 584
   $new_parents = array();
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
   static $results = array();
671 671
 
672 672
   // Create unique id for static cache.
673
-  $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
673
+  $cid = $field['field_name'].':'.$match.':'.($string !== '' ? $string : implode('-', $ids)).':'.$limit;
674 674
   if (!isset($results[$cid])) {
675 675
     $references = FALSE;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
       'equals' => "= '%s'",
784 784
       'starts_with' => "$like '%s%%'",
785 785
     );
786
-    $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
786
+    $where[] = 'u.name '.(isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 787
     $args[] = $string;
788 788
   }
789 789
   elseif ($ids) {
790
-    $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
790
+    $where[] = 'u.uid IN ('.db_placeholders($ids).')';
791 791
     $args = array_merge($args, $ids);
792 792
   }
793 793
   else {
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
     $roles = array_intersect(array_keys(user_roles(1)), $roles);
803 803
   }
804 804
   if (!empty($roles) && !in_array(DRUPAL_AUTHENTICATED_RID, $roles)) {
805
-    $where[] = "r.rid IN (". implode($roles, ',') .")";
805
+    $where[] = "r.rid IN (".implode($roles, ',').")";
806 806
     $join[] = 'LEFT JOIN {users_roles} r ON u.uid = r.uid';
807 807
   }
808 808
 
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
   }
813 813
 
814 814
   $users = array();
815
-  $where_clause = $where ? 'WHERE ('. implode(') AND (', $where) .')' : '';
816
-  $result = db_query('SELECT u.name, u.uid FROM {users} u '. implode(' ', $join) ." $where_clause ORDER BY u.name ASC", $args);
815
+  $where_clause = $where ? 'WHERE ('.implode(') AND (', $where).')' : '';
816
+  $result = db_query('SELECT u.name, u.uid FROM {users} u '.implode(' ', $join)." $where_clause ORDER BY u.name ASC", $args);
817 817
   while ($user = db_fetch_object($result)) {
818 818
     $users[$user->uid] = array(
819 819
       'title' => $user->name,
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
   $references = _userreference_potential_references($field, $string, $match, array(), 10);
836 836
   foreach ($references as $id => $row) {
837 837
     // Add a class wrapper for a few required CSS overrides.
838
-    $matches[$row['title']] = '<div class="reference-autocomplete">'. $row['rendered'] . '</div>';
838
+    $matches[$row['title']] = '<div class="reference-autocomplete">'.$row['rendered'].'</div>';
839 839
   }
840 840
   drupal_json($matches);
841 841
 }
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
       }
871 871
       foreach ($search_tables as $table => $columns) {
872 872
         foreach ($columns as $column) {
873
-          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {". $table ."} f ON n.vid = f.vid WHERE f.". $column ."=". $account->uid. " AND n.status = 1"));
873
+          $ids = db_query(db_rewrite_sql("SELECT DISTINCT(n.nid), n.title, n.type FROM {node} n LEFT JOIN {".$table."} f ON n.vid = f.vid WHERE f.".$column."=".$account->uid." AND n.status = 1"));
874 874
           while ($data = db_fetch_object($ids)) {
875 875
             $additions[$data->type][$data->nid] = $data->title;
876 876
           }
@@ -886,7 +886,7 @@  discard block
 block discarded – undo
886 886
         $values = array();
887 887
         foreach ($account->userreference as $node_type => $nodes) {
888 888
           foreach ($nodes as $nid => $title) {
889
-            $values[$node_type][] = l($title, 'node/'. $nid);
889
+            $values[$node_type][] = l($title, 'node/'.$nid);
890 890
           }
891 891
           if (isset($values[$node_type])) {
892 892
             $additions[] = array(
Please login to merge, or discard this patch.
Braces   +9 added lines, -18 removed lines patch added patch discarded remove patch
@@ -92,8 +92,7 @@  discard block
 block discarded – undo
92 92
           if ($view->base_table == 'users' && !empty($view->display['default']->display_options['fields'])) {
93 93
             if ($view->type == 'Default') {
94 94
               $views[t('Default Views')][$view->name] = $view->name;
95
-            }
96
-            else {
95
+            } else {
97 96
               $views[t('Existing Views')][$view->name] = $view->name;
98 97
             }
99 98
           }
@@ -121,8 +120,7 @@  discard block
 block discarded – undo
121 120
             '#required' => FALSE,
122 121
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123 122
           );
124
-        }
125
-        else {
123
+        } else {
126 124
           $form['advanced']['no_view_help'] = array(
127 125
             '#value' => t('<p>The list of user that can be referenced can be based on a "Views module" view but no appropriate views were found. <br />Note:</p>') .
128 126
               t('<ul><li>Only views that have fields will work for this purpose.</li><li>This will discard the "Referenceable Roles" and "Referenceable Status" settings above. Use the view\'s "filters" section instead.</li><li>Use the view\'s "fields" section to display additional informations about candidate users on user creation/edition form.</li><li>Use the view\'s "sort criteria" section to determine the order in which candidate users will be displayed.</li></ul>'),
@@ -188,8 +186,7 @@  discard block
 block discarded – undo
188 186
         if (is_array($item) && !empty($item['uid'])) {
189 187
           if (is_numeric($item['uid'])) {
190 188
             $ids[] = $item['uid'];
191
-          }
192
-          else {
189
+          } else {
193 190
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
194 191
             if (is_array($item) && isset($item['_error_element'])) unset($item['_error_element']);
195 192
             form_set_error($error_element, t('%name: invalid input.', array('%name' => t($field['widget']['label']))));
@@ -367,8 +364,7 @@  discard block
 block discarded – undo
367 364
           '#element_validate' => array('_element_validate_integer_positive'),
368 365
           '#required' => TRUE,
369 366
         );
370
-      }
371
-      else {
367
+      } else {
372 368
         $form['autocomplete_match'] = array('#type' => 'hidden', '#value' => $match);
373 369
         $form['size'] = array('#type' => 'hidden', '#value' => $size);
374 370
       }
@@ -612,8 +608,7 @@  discard block
 block discarded – undo
612 608
     $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
613 609
     if (empty($reference)) {
614 610
       form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615
-    }
616
-    else {
611
+    } else {
617 612
       $uid = key($reference);
618 613
     }
619 614
   }
@@ -733,8 +728,7 @@  discard block
 block discarded – undo
733 728
     if (!empty($field['advanced_view_args'])) {
734 729
       // TODO: Support Tokens using token.module ?
735 730
       $view_args = array_map('trim', explode(',', $field['advanced_view_args']));
736
-    }
737
-    else {
731
+    } else {
738 732
       $view_args = array();
739 733
     }
740 734
 
@@ -759,8 +753,7 @@  discard block
 block discarded – undo
759 753
 
760 754
     // Get the results.
761 755
     $result = $view->execute_display($display, $view_args);
762
-  }
763
-  else {
756
+  } else {
764 757
     $result = FALSE;
765 758
   }
766 759
 
@@ -785,12 +778,10 @@  discard block
 block discarded – undo
785 778
     );
786 779
     $where[] = 'u.name '. (isset($match_clauses[$match]) ? $match_clauses[$match] : $match_clauses['contains']);
787 780
     $args[] = $string;
788
-  }
789
-  elseif ($ids) {
781
+  } elseif ($ids) {
790 782
     $where[] = 'u.uid IN (' . db_placeholders($ids) . ')';
791 783
     $args = array_merge($args, $ids);
792
-  }
793
-  else {
784
+  } else {
794 785
     $where[] = "u.uid > 0";
795 786
   }
796 787
 
Please login to merge, or discard this patch.
Upper-Lower-Casing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -26,13 +26,13 @@  discard block
 block discarded – undo
26 26
 function userreference_theme() {
27 27
   return array(
28 28
     'userreference_select' => array(
29
-      'arguments' => array('element' => NULL),
29
+      'arguments' => array('element' => null),
30 30
     ),
31 31
     'userreference_buttons' => array(
32
-      'arguments' => array('element' => NULL),
32
+      'arguments' => array('element' => null),
33 33
     ),
34 34
     'userreference_autocomplete' => array(
35
-      'arguments' => array('element' => NULL),
35
+      'arguments' => array('element' => null),
36 36
     ),
37 37
     'userreference_formatter_default' => array(
38 38
       'arguments' => array('element'),
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
         $form['advanced'] = array(
103 103
            '#type' => 'fieldset',
104 104
            '#title' => t('Advanced - Users that can be referenced (View)'),
105
-           '#collapsible' => TRUE,
105
+           '#collapsible' => true,
106 106
            '#collapsed' => !isset($field['advanced_view']) || $field['advanced_view'] == '--',
107 107
          );
108 108
         if (count($views) > 1) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             '#type' => 'textfield',
119 119
             '#title' => t('View arguments'),
120 120
             '#default_value' => isset($field['advanced_view_args']) ? $field['advanced_view_args'] : '',
121
-            '#required' => FALSE,
121
+            '#required' => false,
122 122
             '#description' => t('Provide a comma separated list of arguments to pass to the view.'),
123 123
           );
124 124
         }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
     case 'database columns':
143 143
       $columns = array(
144
-        'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => FALSE, 'index' => TRUE),
144
+        'uid' => array('type' => 'int', 'unsigned' => true, 'not null' => false, 'index' => true),
145 145
       );
146 146
       return $columns;
147 147
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
       }
199 199
       // Prevent performance hog if there are no ids to check.
200 200
       if ($ids) {
201
-        $refs = _userreference_potential_references($field, '', NULL, $ids);
201
+        $refs = _userreference_potential_references($field, '', null, $ids);
202 202
         foreach ($items as $delta => $item) {
203 203
           if (is_array($item)) {
204 204
             $error_element = isset($item['_error_element']) ? $item['_error_element'] : '';
@@ -218,9 +218,9 @@  discard block
 block discarded – undo
218 218
  */
219 219
 function userreference_content_is_empty($item, $field) {
220 220
   if (empty($item['uid'])) {
221
-    return TRUE;
221
+    return true;
222 222
   }
223
-  return FALSE;
223
+  return false;
224 224
 }
225 225
 
226 226
 /**
@@ -322,20 +322,20 @@  discard block
 block discarded – undo
322 322
 function userreference_elements() {
323 323
   return array(
324 324
     'userreference_select' => array(
325
-      '#input' => TRUE,
325
+      '#input' => true,
326 326
       '#columns' => array('uid'), '#delta' => 0,
327 327
       '#process' => array('userreference_select_process'),
328 328
     ),
329 329
     'userreference_buttons' => array(
330
-      '#input' => TRUE,
330
+      '#input' => true,
331 331
       '#columns' => array('uid'), '#delta' => 0,
332 332
       '#process' => array('userreference_buttons_process'),
333 333
     ),
334 334
     'userreference_autocomplete' => array(
335
-      '#input' => TRUE,
335
+      '#input' => true,
336 336
       '#columns' => array('name'), '#delta' => 0,
337 337
       '#process' => array('userreference_autocomplete_process'),
338
-      '#autocomplete_path' => FALSE,
338
+      '#autocomplete_path' => false,
339 339
       ),
340 340
     );
341 341
 }
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
           '#title' => t('Size of textfield'),
366 366
           '#default_value' => $size,
367 367
           '#element_validate' => array('_element_validate_integer_positive'),
368
-          '#required' => TRUE,
368
+          '#required' => true,
369 369
         );
370 370
       }
371 371
       else {
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
     case 'userreference_autocomplete':
436 436
       $element = array(
437 437
         '#type' => 'userreference_autocomplete',
438
-        '#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
438
+        '#default_value' => isset($items[$delta]) ? $items[$delta] : null,
439 439
         '#value_callback' => 'userreference_autocomplete_value',
440 440
       );
441 441
       break;
@@ -448,13 +448,13 @@  discard block
 block discarded – undo
448 448
  *
449 449
  * Substitute in the user name for the uid.
450 450
  */
451
-function userreference_autocomplete_value($element, $edit = FALSE) {
451
+function userreference_autocomplete_value($element, $edit = false) {
452 452
   $field_key  = $element['#columns'][0];
453 453
   if (!empty($element['#default_value'][$field_key])) {
454 454
     $value = db_result(db_query("SELECT name FROM {users} WHERE uid = '%d'", $element['#default_value'][$field_key]));
455 455
     return array($field_key => $value);
456 456
   }
457
-  return array($field_key => NULL);
457
+  return array($field_key => null);
458 458
 }
459 459
 
460 460
 /**
@@ -607,9 +607,9 @@  discard block
 block discarded – undo
607 607
   $field = content_fields($field_name, $type_name);
608 608
   $field_key = $element['#columns'][0];
609 609
   $value = $element['#value'][$field_key];
610
-  $uid = NULL;
610
+  $uid = null;
611 611
   if (!empty($value)) {
612
-    $reference = _userreference_potential_references($field, $value, 'equals', NULL, 1);
612
+    $reference = _userreference_potential_references($field, $value, 'equals', null, 1);
613 613
     if (empty($reference)) {
614 614
       form_error($element[$field_key], t('%name: found no valid user with that name.', array('%name' => t($field['widget']['label']))));
615 615
     }
@@ -666,19 +666,19 @@  discard block
 block discarded – undo
666 666
  *     ...
667 667
  *   )
668 668
  */
669
-function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
669
+function _userreference_potential_references($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
670 670
   static $results = array();
671 671
 
672 672
   // Create unique id for static cache.
673 673
   $cid = $field['field_name'] .':'. $match .':'. ($string !== '' ? $string : implode('-', $ids)) .':'. $limit;
674 674
   if (!isset($results[$cid])) {
675
-    $references = FALSE;
675
+    $references = false;
676 676
     if (module_exists('views') && !empty($field['advanced_view']) && $field['advanced_view'] != '--') {
677 677
       $references = _userreference_potential_references_views($field, $string, $match, $ids, $limit);
678 678
     }
679 679
     // If the view doesn't exist, we got FALSE, and fallback to the regular 'standard mode'.
680 680
 
681
-    if ($references === FALSE) {
681
+    if ($references === false) {
682 682
       $references = _userreference_potential_references_standard($field, $string, $match, $ids, $limit);
683 683
     }
684 684
 
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
  * Helper function for _userreference_potential_references():
694 694
  * case of Views-defined referenceable users.
695 695
  */
696
-function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
696
+function _userreference_potential_references_views($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
697 697
   $view_name = $field['advanced_view'];
698 698
 
699 699
   if ($view = views_get_view($view_name)) {
@@ -755,13 +755,13 @@  discard block
 block discarded – undo
755 755
     $view->display_handler->set_option('row_options', $options);
756 756
 
757 757
     // Make sure the query is not cached
758
-    $view->is_cacheable = FALSE;
758
+    $view->is_cacheable = false;
759 759
 
760 760
     // Get the results.
761 761
     $result = $view->execute_display($display, $view_args);
762 762
   }
763 763
   else {
764
-    $result = FALSE;
764
+    $result = false;
765 765
   }
766 766
 
767 767
   return $result;
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
  * Helper function for _userreference_potential_references():
772 772
  * referenceable users defined by user role and status
773 773
  */
774
-function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = NULL) {
774
+function _userreference_potential_references_standard($field, $string = '', $match = 'contains', $ids = array(), $limit = null) {
775 775
   $where = array();
776 776
   $args = array();
777 777
   $join = array();
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/cck/theme/theme.inc 5 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -6,43 +6,43 @@  discard block
 block discarded – undo
6 6
  * Theme preprocess function for content-admin-field-overview-form.tpl.php.
7 7
  */
8 8
 function template_preprocess_content_field_overview_form(&$vars) {
9
-  $form = &$vars['form'];
9
+    $form = &$vars['form'];
10 10
 
11
-  $vars['help'] = theme('advanced_help_topic', 'content', 'manage-fields') . t('Add fields and groups to the content type, and arrange them on content display and input forms.');
12
-  if (module_exists('fieldgroup')) {
11
+    $vars['help'] = theme('advanced_help_topic', 'content', 'manage-fields') . t('Add fields and groups to the content type, and arrange them on content display and input forms.');
12
+    if (module_exists('fieldgroup')) {
13 13
     $vars['help'] .= '<br/>'. t('You can add a field to a group by dragging it below and to the right of the group.');
14
-  }
15
-  if (!module_exists('advanced_help')) {
14
+    }
15
+    if (!module_exists('advanced_help')) {
16 16
     $vars['help'] .= '<br/>' . t('Note: Installing the <a href="!adv_help">Advanced help</a> module will let you access more and better help.', array('!adv_help' => 'http://drupal.org/project/advanced_help'));
17
-  }
17
+    }
18 18
 
19
-  $order = _content_overview_order($form, $form['#field_rows'], $form['#group_rows']);
20
-  $rows = array();
19
+    $order = _content_overview_order($form, $form['#field_rows'], $form['#group_rows']);
20
+    $rows = array();
21 21
 
22
-  // Identify the 'new item' keys in the form, they look like
23
-  // _add_new_field, add_new_group.
24
-  $keys = array_keys($form);
25
-  $add_rows = array();
26
-  foreach ($keys as $key) {
22
+    // Identify the 'new item' keys in the form, they look like
23
+    // _add_new_field, add_new_group.
24
+    $keys = array_keys($form);
25
+    $add_rows = array();
26
+    foreach ($keys as $key) {
27 27
     if (substr($key, 0, 4) == '_add') {
28
-      $add_rows[] = $key;
28
+        $add_rows[] = $key;
29
+    }
29 30
     }
30
-  }
31
-  while ($order) {
31
+    while ($order) {
32 32
     $key = reset($order);
33 33
     $element = &$form[$key];
34 34
 
35 35
     // Only display the 'Add' separator if the 'add' rows are still
36 36
     // at the end of the table.
37 37
     if (!isset($added_separator)) {
38
-      $remaining_rows = array_diff($order, $add_rows);
39
-      if (empty($remaining_rows) && empty($element['#depth'])) {
38
+        $remaining_rows = array_diff($order, $add_rows);
39
+        if (empty($remaining_rows) && empty($element['#depth'])) {
40 40
         $row = new stdClass();
41 41
         $row->row_type = 'separator';
42 42
         $row->class = 'tabledrag-leaf region';
43 43
         $rows[] = $row;
44 44
         $added_separator = TRUE;
45
-      }
45
+        }
46 46
     }
47 47
 
48 48
     $row = new stdClass();
@@ -53,18 +53,18 @@  discard block
 block discarded – undo
53 53
     $element['hidden_name']['#attributes']['class'] = 'field-name';
54 54
     // Add target classes for the update selects behavior.
55 55
     switch ($element['#row_type']) {
56
-      case 'add_new_field':
56
+        case 'add_new_field':
57 57
         $element['type']['#attributes']['class'] = 'content-field-type-select';
58 58
         $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
59 59
         break;
60
-      case 'add_existing_field':
60
+        case 'add_existing_field':
61 61
         $element['field_name']['#attributes']['class'] = 'content-field-select';
62 62
         $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
63 63
         $element['label']['#attributes']['class'] = 'content-label-textfield';
64 64
         break;
65 65
     }
66 66
     foreach (element_children($element) as $child) {
67
-      $row->{$child} = drupal_render($element[$child]);
67
+        $row->{$child} = drupal_render($element[$child]);
68 68
     }
69 69
     $row->label_class = 'label-'. strtr($element['#row_type'], '_', '-');
70 70
     $row->row_type = $element['#row_type'];
@@ -77,69 +77,69 @@  discard block
 block discarded – undo
77 77
 
78 78
     $rows[] = $row;
79 79
     array_shift($order);
80
-  }
81
-  $vars['rows'] = $rows;
82
-  $vars['submit'] = drupal_render($form);
80
+    }
81
+    $vars['rows'] = $rows;
82
+    $vars['submit'] = drupal_render($form);
83 83
 
84
-  // Add tabledrag behavior.
84
+    // Add tabledrag behavior.
85 85
 //  drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', FALSE, 1);
86
-  drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', TRUE, 1);
86
+    drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', TRUE, 1);
87 87
 //  drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight', NULL, NULL, FALSE);
88
-  drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight');
88
+    drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight');
89 89
 
90
-  // Add settings for the update selects behavior.
91
-  $js_fields = array();
92
-  foreach (array_keys(content_existing_field_options($form['#type_name'])) as $field_name) {
90
+    // Add settings for the update selects behavior.
91
+    $js_fields = array();
92
+    foreach (array_keys(content_existing_field_options($form['#type_name'])) as $field_name) {
93 93
     $field = content_fields($field_name);
94 94
     $js_fields[$field_name] = array('label' => $field['widget']['label'], 'type' => $field['type'], 'widget' => $field['widget']['type']);
95
-  }
96
-  drupal_add_js(array('contentWidgetTypes' => content_widget_type_options(), 'contentFields' => $js_fields), 'setting');
97
-  drupal_add_js(drupal_get_path('module', 'content') .'/content.js');
95
+    }
96
+    drupal_add_js(array('contentWidgetTypes' => content_widget_type_options(), 'contentFields' => $js_fields), 'setting');
97
+    drupal_add_js(drupal_get_path('module', 'content') .'/content.js');
98 98
 }
99 99
 
100 100
 /**
101 101
  * Theme preprocess function for content-admin-display-overview-form.tpl.php.
102 102
  */
103 103
 function template_preprocess_content_display_overview_form(&$vars) {
104
-  $form = &$vars['form'];
104
+    $form = &$vars['form'];
105 105
 
106
-  $contexts_selector = $form['#contexts'];
107
-  $vars['basic'] = $contexts_selector == 'basic';
108
-  $vars['contexts'] = content_build_modes($contexts_selector);
106
+    $contexts_selector = $form['#contexts'];
107
+    $vars['basic'] = $contexts_selector == 'basic';
108
+    $vars['contexts'] = content_build_modes($contexts_selector);
109 109
 
110
-  if ($contexts_selector == 'basic') {
110
+    if ($contexts_selector == 'basic') {
111 111
     $help = t("Configure how this content type's fields and field labels should be displayed when it's viewed in teaser and full-page mode.");
112
-  }
113
-  else {
112
+    }
113
+    else {
114 114
     $help = t("Configure how this content type's fields should be displayed when it's rendered in the following contexts.");
115
-  }
116
-  $help .= ' '. t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content'));
117
-  $vars['help'] = $help;
115
+    }
116
+    $help .= ' '. t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content'));
117
+    $vars['help'] = $help;
118 118
 
119
-  $order = _content_overview_order($form, $form['#fields'], $form['#groups']);
120
-  if (empty($order)) {
119
+    $order = _content_overview_order($form, $form['#fields'], $form['#groups']);
120
+    if (empty($order)) {
121 121
     $vars['rows'] = array();
122 122
     $vars['submit'] = '';
123 123
     return;
124
-  }
124
+    }
125 125
 
126
-  $rows = array();
127
-  foreach ($order as $key) {
126
+    $rows = array();
127
+    foreach ($order as $key) {
128 128
     $element = &$form[$key];
129 129
     $row = new stdClass();
130 130
     foreach (element_children($element) as $child) {
131
-      if (!array_key_exists('exclude', $element[$child])) {
131
+        if (!array_key_exists('exclude', $element[$child])) {
132 132
         $row->{$child} = drupal_render($element[$child]);
133
-      }
134
-      else {
133
+        }
134
+        else {
135 135
         $row->{$child}->format = drupal_render($element[$child]['format']);
136 136
         $row->{$child}->exclude = drupal_render($element[$child]['exclude']);
137
-      }
137
+        }
138 138
     }
139 139
     $row->label_class = in_array($key, $form['#groups']) ? 'label-group' : 'label-field';
140 140
     $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
141 141
     $rows[] = $row;
142
-  }
143
-  $vars['rows'] = $rows;
144
-  $vars['submit'] = drupal_render($form);
142
+    }
143
+    $vars['rows'] = $rows;
144
+    $vars['submit'] = drupal_render($form);
145 145
 }
146 146
\ No newline at end of file
Please login to merge, or discard this patch.
Switch Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -53,15 +53,15 @@
 block discarded – undo
53 53
     $element['hidden_name']['#attributes']['class'] = 'field-name';
54 54
     // Add target classes for the update selects behavior.
55 55
     switch ($element['#row_type']) {
56
-      case 'add_new_field':
57
-        $element['type']['#attributes']['class'] = 'content-field-type-select';
58
-        $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
59
-        break;
60
-      case 'add_existing_field':
61
-        $element['field_name']['#attributes']['class'] = 'content-field-select';
62
-        $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
63
-        $element['label']['#attributes']['class'] = 'content-label-textfield';
64
-        break;
56
+    case 'add_new_field':
57
+      $element['type']['#attributes']['class'] = 'content-field-type-select';
58
+      $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
59
+      break;
60
+    case 'add_existing_field':
61
+      $element['field_name']['#attributes']['class'] = 'content-field-select';
62
+      $element['widget_type']['#attributes']['class'] = 'content-widget-type-select';
63
+      $element['label']['#attributes']['class'] = 'content-label-textfield';
64
+      break;
65 65
     }
66 66
     foreach (element_children($element) as $child) {
67 67
       $row->{$child} = drupal_render($element[$child]);
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -8,12 +8,12 @@  discard block
 block discarded – undo
8 8
 function template_preprocess_content_field_overview_form(&$vars) {
9 9
   $form = &$vars['form'];
10 10
 
11
-  $vars['help'] = theme('advanced_help_topic', 'content', 'manage-fields') . t('Add fields and groups to the content type, and arrange them on content display and input forms.');
11
+  $vars['help'] = theme('advanced_help_topic', 'content', 'manage-fields').t('Add fields and groups to the content type, and arrange them on content display and input forms.');
12 12
   if (module_exists('fieldgroup')) {
13
-    $vars['help'] .= '<br/>'. t('You can add a field to a group by dragging it below and to the right of the group.');
13
+    $vars['help'] .= '<br/>'.t('You can add a field to a group by dragging it below and to the right of the group.');
14 14
   }
15 15
   if (!module_exists('advanced_help')) {
16
-    $vars['help'] .= '<br/>' . t('Note: Installing the <a href="!adv_help">Advanced help</a> module will let you access more and better help.', array('!adv_help' => 'http://drupal.org/project/advanced_help'));
16
+    $vars['help'] .= '<br/>'.t('Note: Installing the <a href="!adv_help">Advanced help</a> module will let you access more and better help.', array('!adv_help' => 'http://drupal.org/project/advanced_help'));
17 17
   }
18 18
 
19 19
   $order = _content_overview_order($form, $form['#field_rows'], $form['#group_rows']);
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
     foreach (element_children($element) as $child) {
67 67
       $row->{$child} = drupal_render($element[$child]);
68 68
     }
69
-    $row->label_class = 'label-'. strtr($element['#row_type'], '_', '-');
69
+    $row->label_class = 'label-'.strtr($element['#row_type'], '_', '-');
70 70
     $row->row_type = $element['#row_type'];
71 71
     $row->indentation = theme('indentation', isset($element['#depth']) ? $element['#depth'] : 0);
72 72
     $row->class = 'draggable';
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
     $js_fields[$field_name] = array('label' => $field['widget']['label'], 'type' => $field['type'], 'widget' => $field['widget']['type']);
95 95
   }
96 96
   drupal_add_js(array('contentWidgetTypes' => content_widget_type_options(), 'contentFields' => $js_fields), 'setting');
97
-  drupal_add_js(drupal_get_path('module', 'content') .'/content.js');
97
+  drupal_add_js(drupal_get_path('module', 'content').'/content.js');
98 98
 }
99 99
 
100 100
 /**
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
   else {
114 114
     $help = t("Configure how this content type's fields should be displayed when it's rendered in the following contexts.");
115 115
   }
116
-  $help .= ' '. t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content'));
116
+  $help .= ' '.t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content'));
117 117
   $vars['help'] = $help;
118 118
 
119 119
   $order = _content_overview_order($form, $form['#fields'], $form['#groups']);
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -109,8 +109,7 @@  discard block
 block discarded – undo
109 109
 
110 110
   if ($contexts_selector == 'basic') {
111 111
     $help = t("Configure how this content type's fields and field labels should be displayed when it's viewed in teaser and full-page mode.");
112
-  }
113
-  else {
112
+  } else {
114 113
     $help = t("Configure how this content type's fields should be displayed when it's rendered in the following contexts.");
115 114
   }
116 115
   $help .= ' '. t("Use the 'Exclude' checkbox to exclude an item from the !content value passed to the node template.", array('!content' => '$content'));
@@ -130,8 +129,7 @@  discard block
 block discarded – undo
130 129
     foreach (element_children($element) as $child) {
131 130
       if (!array_key_exists('exclude', $element[$child])) {
132 131
         $row->{$child} = drupal_render($element[$child]);
133
-      }
134
-      else {
132
+      } else {
135 133
         $row->{$child}->format = drupal_render($element[$child]['format']);
136 134
         $row->{$child}->exclude = drupal_render($element[$child]['exclude']);
137 135
       }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
         $row->row_type = 'separator';
42 42
         $row->class = 'tabledrag-leaf region';
43 43
         $rows[] = $row;
44
-        $added_separator = TRUE;
44
+        $added_separator = true;
45 45
       }
46 46
     }
47 47
 
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 
84 84
   // Add tabledrag behavior.
85 85
 //  drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', FALSE, 1);
86
-  drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', TRUE, 1);
86
+  drupal_add_tabledrag('content-field-overview', 'match', 'parent', 'group-parent', 'group-parent', 'field-name', true, 1);
87 87
 //  drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight', NULL, NULL, FALSE);
88 88
   drupal_add_tabledrag('content-field-overview', 'order', 'sibling', 'field-weight');
89 89
 
Please login to merge, or discard this patch.