Passed
Push — master ( bc3853...aae742 )
by Kevin
01:22 queued 21s
created
drupal/sites/default/boinc/modules/contrib/cck/content.module 5 patches
Indentation   +931 added lines, -931 removed lines patch added patch discarded remove patch
@@ -16,88 +16,88 @@  discard block
 block discarded – undo
16 16
 define('CONTENT_HANDLE_MODULE', 0x0002);
17 17
 
18 18
 function content_help($path, $arg) {
19
-  switch ($path) {
19
+    switch ($path) {
20 20
     case 'admin/help#content':
21 21
       $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
-      $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
-      $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
-      return $output;
33
-  }
22
+        $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
+        $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
+        $output .= '<ul>';
25
+        $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
+        $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
+        $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
+        $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
+        $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
+        $output .= '</ul>';
31
+        $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
+        return $output;
33
+    }
34 34
 }
35 35
 
36 36
 /**
37 37
  * Implementation of hook_flush_caches.
38 38
  */
39 39
 function content_flush_caches() {
40
-  return array(content_cache_tablename());
40
+    return array(content_cache_tablename());
41 41
 }
42 42
 
43 43
 /**
44 44
  * Implementation of hook_init().
45 45
  */
46 46
 function content_init() {
47
-  drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
48
-  if (module_exists('token') && !function_exists('content_token_values')) {
47
+    drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
48
+    if (module_exists('token') && !function_exists('content_token_values')) {
49 49
     module_load_include('inc', 'content', 'includes/content.token');
50
-  }
51
-  if (module_exists('diff') && !function_exists('content_diff')) {
50
+    }
51
+    if (module_exists('diff') && !function_exists('content_diff')) {
52 52
     module_load_include('inc', 'content', 'includes/content.diff');
53
-  }
53
+    }
54 54
 }
55 55
 
56 56
 /**
57 57
  * Implementation of hook_perm().
58 58
  */
59 59
 function content_perm() {
60
-  return array('Use PHP input for field settings (dangerous - grant with care)');
60
+    return array('Use PHP input for field settings (dangerous - grant with care)');
61 61
 }
62 62
 
63 63
 /**
64 64
  * Implementation of hook_menu_alter().
65 65
  */
66 66
 function content_menu_alter(&$items) {
67
-  // Customize the content types page with our own callback
68
-  $items['admin/content/types']['page callback'] = 'content_types_overview';
69
-  $items['admin/content/types']['file'] = 'content.admin.inc';
70
-  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
67
+    // Customize the content types page with our own callback
68
+    $items['admin/content/types']['page callback'] = 'content_types_overview';
69
+    $items['admin/content/types']['file'] = 'content.admin.inc';
70
+    $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
71 71
 }
72 72
 
73 73
 /**
74 74
  * Implementation of hook_menu().
75 75
  */
76 76
 function content_menu() {
77
-  $items = array();
78
-  $items['admin/content/types/fields'] = array(
77
+    $items = array();
78
+    $items['admin/content/types/fields'] = array(
79 79
     'title' => 'Fields',
80 80
     'page callback' => 'content_fields_list',
81 81
     'access arguments' => array('administer content types'),
82 82
     'file' => 'includes/content.admin.inc',
83 83
     'type' => MENU_LOCAL_TASK,
84
-  );
85
-  // Callback for AHAH add more buttons.
86
-  $items['content/js_add_more'] = array(
84
+    );
85
+    // Callback for AHAH add more buttons.
86
+    $items['content/js_add_more'] = array(
87 87
     'page callback' => 'content_add_more_js',
88 88
     'access arguments' => array('access content'),
89 89
     'file' => 'includes/content.node_form.inc',
90 90
     'type' => MENU_CALLBACK,
91
-  );
91
+    );
92 92
 
93
-  // Make sure this doesn't fire until content_types is working,
94
-  // and tables are updated, needed to avoid errors on initial installation.
95
-  if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
93
+    // Make sure this doesn't fire until content_types is working,
94
+    // and tables are updated, needed to avoid errors on initial installation.
95
+    if (!defined('MAINTENANCE_MODE') && variable_get('content_schema_version', -1) >= 6007) {
96 96
     foreach (node_get_types() as $type) {
97
-      $type_name = $type->type;
98
-      $content_type = content_types($type_name);
99
-      $type_url_str = $content_type['url_str'];
100
-      $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
97
+        $type_name = $type->type;
98
+        $content_type = content_types($type_name);
99
+        $type_url_str = $content_type['url_str'];
100
+        $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
101 101
         'title' => 'Manage fields',
102 102
         'page callback' => 'drupal_get_form',
103 103
         'page arguments' => array('content_field_overview_form', $type_name),
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
         'file' => 'includes/content.admin.inc',
106 106
         'type' => MENU_LOCAL_TASK,
107 107
         'weight' => 1,
108
-      );
109
-      $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
108
+        );
109
+        $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
110 110
         'title' => 'Display fields',
111 111
         'page callback' => 'drupal_get_form',
112 112
         'page arguments' => array('content_display_overview_form', $type_name),
@@ -114,41 +114,41 @@  discard block
 block discarded – undo
114 114
         'file' => 'includes/content.admin.inc',
115 115
         'type' => MENU_LOCAL_TASK,
116 116
         'weight' => 2,
117
-      );
118
-      $contexts = content_build_modes('_tabs');
119
-      foreach ($contexts as $key => $tab) {
117
+        );
118
+        $contexts = content_build_modes('_tabs');
119
+        foreach ($contexts as $key => $tab) {
120 120
         $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array(
121
-          'title' => $tab['title'],
122
-          'page arguments' => array('content_display_overview_form', $type_name, $key),
123
-          'access arguments' => array('administer content types'),
124
-          'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
125
-          'weight' => $key == 'basic' ? 0 : 1,
121
+            'title' => $tab['title'],
122
+            'page arguments' => array('content_display_overview_form', $type_name, $key),
123
+            'access arguments' => array('administer content types'),
124
+            'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
125
+            'weight' => $key == 'basic' ? 0 : 1,
126 126
         );
127
-      }
128
-      // Cast as an array in case this is called before any fields have
129
-      // been added, like when a new content type is created.
130
-      foreach ((array) $content_type['fields'] as $field) {
127
+        }
128
+        // Cast as an array in case this is called before any fields have
129
+        // been added, like when a new content type is created.
130
+        foreach ((array) $content_type['fields'] as $field) {
131 131
         $field_name = $field['field_name'];
132 132
         $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name] = array(
133
-          'title' => $field['widget']['label'],
134
-          'page callback' => 'drupal_get_form',
135
-          'page arguments' => array('content_field_edit_form', $type_name, $field_name),
136
-          'access arguments' => array('administer content types'),
137
-          'file' => 'includes/content.admin.inc',
138
-          'type' => MENU_LOCAL_TASK,
133
+            'title' => $field['widget']['label'],
134
+            'page callback' => 'drupal_get_form',
135
+            'page arguments' => array('content_field_edit_form', $type_name, $field_name),
136
+            'access arguments' => array('administer content types'),
137
+            'file' => 'includes/content.admin.inc',
138
+            'type' => MENU_LOCAL_TASK,
139 139
         );
140 140
         $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name .'/remove'] = array(
141
-          'title' => 'Remove field',
142
-          'page callback' => 'drupal_get_form',
143
-          'page arguments' => array('content_field_remove_form', $type_name, $field_name),
144
-          'access arguments' => array('administer content types'),
145
-          'file' => 'includes/content.admin.inc',
146
-          'type' => MENU_CALLBACK,
141
+            'title' => 'Remove field',
142
+            'page callback' => 'drupal_get_form',
143
+            'page arguments' => array('content_field_remove_form', $type_name, $field_name),
144
+            'access arguments' => array('administer content types'),
145
+            'file' => 'includes/content.admin.inc',
146
+            'type' => MENU_CALLBACK,
147 147
         );
148
-      }
148
+        }
149
+    }
149 150
     }
150
-  }
151
-  return $items;
151
+    return $items;
152 152
 }
153 153
 
154 154
 /**
@@ -163,69 +163,69 @@  discard block
 block discarded – undo
163 163
  * the same name as the hook_elements key.
164 164
  */
165 165
 function content_elements() {
166
-  return array(
166
+    return array(
167 167
     'content_multiple_values' => array(),
168 168
     'content_field' => array(),
169
-  );
169
+    );
170 170
 }
171 171
 
172 172
 /**
173 173
  * Implementation of hook_theme().
174 174
  */
175 175
 function content_theme() {
176
-  $path = drupal_get_path('module', 'content') .'/theme';
177
-  require_once "./$path/theme.inc";
176
+    $path = drupal_get_path('module', 'content') .'/theme';
177
+    require_once "./$path/theme.inc";
178 178
 
179
-  return array(
179
+    return array(
180 180
     'content_field' => array(
181
-      'template' => 'content-field',
182
-      'arguments' => array('element' => NULL),
183
-      'path' => $path,
181
+        'template' => 'content-field',
182
+        'arguments' => array('element' => NULL),
183
+        'path' => $path,
184 184
     ),
185 185
     'content_overview_links' => array(
186
-      'arguments' => array(),
186
+        'arguments' => array(),
187 187
     ),
188 188
     'content_field_overview_form' => array(
189
-      'template' => 'content-admin-field-overview-form',
190
-      'file' => 'theme.inc',
191
-      'path' => $path,
192
-      'arguments' => array('form' => NULL),
189
+        'template' => 'content-admin-field-overview-form',
190
+        'file' => 'theme.inc',
191
+        'path' => $path,
192
+        'arguments' => array('form' => NULL),
193 193
     ),
194 194
     'content_display_overview_form' => array(
195
-      'template' => 'content-admin-display-overview-form',
196
-      'file' => 'theme.inc',
197
-      'path' => $path,
198
-      'arguments' => array('form' => NULL),
195
+        'template' => 'content-admin-display-overview-form',
196
+        'file' => 'theme.inc',
197
+        'path' => $path,
198
+        'arguments' => array('form' => NULL),
199 199
     ),
200 200
     'content_exclude' => array(
201
-      'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
201
+        'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
202 202
     ),
203 203
     'content_view_multiple_field' => array(
204
-      'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
204
+        'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
205 205
     ),
206 206
     'content_multiple_values' => array(
207
-      'arguments' => array('element' => NULL),
207
+        'arguments' => array('element' => NULL),
208 208
     ),
209
-  );
209
+    );
210 210
 }
211 211
 
212 212
 /**
213 213
  * Implementation of hook_views_api().
214 214
  */
215 215
 function content_views_api() {
216
-  return array(
216
+    return array(
217 217
     'api' => 2,
218 218
     'path' => drupal_get_path('module', 'content') . '/includes/views',
219
-  );
219
+    );
220 220
 }
221 221
 
222 222
 /**
223 223
  * Implementation of hook_ctools_plugin_directory().
224 224
  */
225 225
 function content_ctools_plugin_directory($module, $plugin) {
226
-  if ($module == 'ctools' && $plugin == 'content_types') {
226
+    if ($module == 'ctools' && $plugin == 'content_types') {
227 227
     return 'includes/panels/' . $plugin;
228
-  }
228
+    }
229 229
 }
230 230
 
231 231
 /**
@@ -237,28 +237,28 @@  discard block
 block discarded – undo
237 237
  * cache the loaded object structure and invalidate it during the update process.
238 238
  */
239 239
 function content_load(&$node) {
240
-  $cid = 'content:'. $node->nid .':'. $node->vid;
241
-  if ($cached = cache_get($cid, content_cache_tablename())) {
240
+    $cid = 'content:'. $node->nid .':'. $node->vid;
241
+    if ($cached = cache_get($cid, content_cache_tablename())) {
242 242
     foreach ($cached->data as $key => $value) {
243
-      $node->$key = $value;
243
+        $node->$key = $value;
244 244
     }
245
-  }
246
-  else {
245
+    }
246
+    else {
247 247
     $default_additions = _content_field_invoke_default('load', $node);
248 248
     if ($default_additions) {
249
-      foreach ($default_additions as $key => $value) {
249
+        foreach ($default_additions as $key => $value) {
250 250
         $node->$key = $value;
251
-      }
251
+        }
252 252
     }
253 253
     $additions = _content_field_invoke('load', $node);
254 254
     if ($additions) {
255
-      foreach ($additions as $key => $value) {
255
+        foreach ($additions as $key => $value) {
256 256
         $node->$key = $value;
257 257
         $default_additions[$key] = $value;
258
-      }
258
+        }
259 259
     }
260 260
     cache_set($cid, $default_additions, content_cache_tablename());
261
-  }
261
+    }
262 262
 }
263 263
 
264 264
 /**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
  *
267 267
  */
268 268
 function content_validate(&$node, $form = NULL) {
269
-  _content_field_invoke('validate', $node, $form);
270
-  _content_field_invoke_default('validate', $node, $form);
269
+    _content_field_invoke('validate', $node, $form);
270
+    _content_field_invoke_default('validate', $node, $form);
271 271
 }
272 272
 
273 273
 /**
@@ -275,8 +275,8 @@  discard block
 block discarded – undo
275 275
  *
276 276
  */
277 277
 function content_presave(&$node) {
278
-  _content_field_invoke('presave', $node);
279
-  _content_field_invoke_default('presave', $node);
278
+    _content_field_invoke('presave', $node);
279
+    _content_field_invoke_default('presave', $node);
280 280
 }
281 281
 
282 282
 /**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
  * Insert node type fields.
286 286
  */
287 287
 function content_insert(&$node) {
288
-  _content_field_invoke('insert', $node);
289
-  _content_field_invoke_default('insert', $node);
288
+    _content_field_invoke('insert', $node);
289
+    _content_field_invoke_default('insert', $node);
290 290
 }
291 291
 
292 292
 /**
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
  * Update node type fields.
296 296
  */
297 297
 function content_update(&$node) {
298
-  _content_field_invoke('update', $node);
299
-  _content_field_invoke_default('update', $node);
300
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
298
+    _content_field_invoke('update', $node);
299
+    _content_field_invoke_default('update', $node);
300
+    cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
301 301
 }
302 302
 
303 303
 /**
@@ -306,9 +306,9 @@  discard block
 block discarded – undo
306 306
  * Delete node type fields.
307 307
  */
308 308
 function content_delete(&$node) {
309
-  _content_field_invoke('delete', $node);
310
-  _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
309
+    _content_field_invoke('delete', $node);
310
+    _content_field_invoke_default('delete', $node);
311
+    cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
312 312
 }
313 313
 
314 314
 /**
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
  * Delete node type fields for a revision.
318 318
  */
319 319
 function content_delete_revision(&$node) {
320
-  _content_field_invoke('delete revision', $node);
321
-  _content_field_invoke_default('delete revision', $node);
322
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
320
+    _content_field_invoke('delete revision', $node);
321
+    _content_field_invoke_default('delete revision', $node);
322
+    cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
323 323
 }
324 324
 
325 325
 /**
@@ -328,12 +328,12 @@  discard block
 block discarded – undo
328 328
  * Generate field render arrays.
329 329
  */
330 330
 function content_view(&$node, $teaser = FALSE, $page = FALSE) {
331
-  // Let field modules sanitize their data for output.
332
-  _content_field_invoke('sanitize', $node, $teaser, $page);
331
+    // Let field modules sanitize their data for output.
332
+    _content_field_invoke('sanitize', $node, $teaser, $page);
333 333
 
334
-  // Merge fields.
335
-  $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
-  $node->content = array_merge((array) $node->content, $additions);
334
+    // Merge fields.
335
+    $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
+    $node->content = array_merge((array) $node->content, $additions);
337 337
 }
338 338
 
339 339
 /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
  *   The themed output for the field.
362 362
  */
363 363
 function content_view_field($field, $node, $teaser = FALSE, $page = FALSE) {
364
-  $output = '';
365
-  if (isset($node->$field['field_name'])) {
364
+    $output = '';
365
+    if (isset($node->$field['field_name'])) {
366 366
     $items = $node->$field['field_name'];
367 367
 
368 368
     // Use 'full'/'teaser' if not specified otherwise.
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
     $module = $field_types[$field['type']]['module'];
374 374
     $function = $module .'_field';
375 375
     if (function_exists($function)) {
376
-      $function('sanitize', $node, $field, $items, $teaser, $page);
377
-      $node->$field['field_name'] = $items;
376
+        $function('sanitize', $node, $field, $items, $teaser, $page);
377
+        $node->$field['field_name'] = $items;
378 378
     }
379 379
 
380 380
     $view = content_field('view', $node, $field, $items, $teaser, $page);
381 381
     // content_field('view') adds a wrapper to handle variables and 'excluded'
382 382
     // fields for node templates. We bypass it and render the actual field.
383 383
     $output = drupal_render($view[$field['field_name']]['field']);
384
-  }
385
-  return $output;
384
+    }
385
+    return $output;
386 386
 }
387 387
 
388 388
 /**
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
  * so that node templates can use it.
393 393
  */
394 394
 function content_alter(&$node, $teaser = FALSE, $page = FALSE) {
395
-  _content_field_invoke_default('alter', $node, $teaser, $page);
395
+    _content_field_invoke_default('alter', $node, $teaser, $page);
396 396
 }
397 397
 
398 398
 /**
@@ -401,70 +401,70 @@  discard block
 block discarded – undo
401 401
  * Generate field render arrays.
402 402
  */
403 403
 function content_prepare_translation(&$node) {
404
-  $default_additions = _content_field_invoke_default('prepare translation', $node);
405
-  $additions = _content_field_invoke('prepare translation', $node);
406
-  // Merge module additions after the default ones to enable overriding
407
-  // of field values.
408
-  $node = (object) array_merge((array) $node, $default_additions, $additions);
404
+    $default_additions = _content_field_invoke_default('prepare translation', $node);
405
+    $additions = _content_field_invoke('prepare translation', $node);
406
+    // Merge module additions after the default ones to enable overriding
407
+    // of field values.
408
+    $node = (object) array_merge((array) $node, $default_additions, $additions);
409 409
 }
410 410
 
411 411
 /**
412 412
  * Implementation of hook_nodeapi().
413 413
  */
414 414
 function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
415
-  // Prevent against invalid 'nodes' built by broken 3rd party code.
416
-  if (isset($node->type)) {
415
+    // Prevent against invalid 'nodes' built by broken 3rd party code.
416
+    if (isset($node->type)) {
417 417
     $type = content_types($node->type);
418 418
     // Save cycles if the type has no CCK fields.
419 419
     if (!empty($type['fields'])) {
420
-      $callback = 'content_'. str_replace(' ', '_', $op);
421
-      if (function_exists($callback)) {
420
+        $callback = 'content_'. str_replace(' ', '_', $op);
421
+        if (function_exists($callback)) {
422 422
         $callback($node, $a3, $a4);
423
-      }
423
+        }
424 424
     }
425 425
 
426 426
     // Special case for 'view' op, we want to adjust weights of non-cck fields
427 427
     // even if there are no actual fields for this type.
428 428
     if ($op == 'view') {
429
-      $node->content['#pre_render'][] = 'content_alter_extra_weights';
430
-      $node->content['#content_extra_fields'] = $type['extra'];
429
+        $node->content['#pre_render'][] = 'content_alter_extra_weights';
430
+        $node->content['#content_extra_fields'] = $type['extra'];
431
+    }
431 432
     }
432
-  }
433 433
 }
434 434
 
435 435
 /**
436 436
  *  Implementation of hook_form_alter().
437 437
  */
438 438
 function content_form_alter(&$form, $form_state, $form_id) {
439
-  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
439
+    if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
440 440
     $type = content_types($form['#node']->type);
441 441
     if (!empty($type['fields'])) {
442
-      module_load_include('inc', 'content', 'includes/content.node_form');
443
-      // Merge field widgets.
444
-      $form = array_merge($form, content_form($form, $form_state));
442
+        module_load_include('inc', 'content', 'includes/content.node_form');
443
+        // Merge field widgets.
444
+        $form = array_merge($form, content_form($form, $form_state));
445 445
     }
446 446
     $form['#pre_render'][] = 'content_alter_extra_weights';
447 447
     $form['#content_extra_fields'] = $type['extra'];
448
-  }
448
+    }
449 449
 }
450 450
 
451 451
 /**
452 452
  * Pre-render callback to adjust weights of non-CCK fields.
453 453
  */
454 454
 function content_alter_extra_weights($elements) {
455
-  if (isset($elements['#content_extra_fields'])) {
455
+    if (isset($elements['#content_extra_fields'])) {
456 456
     foreach ($elements['#content_extra_fields'] as $key => $value) {
457
-      // Some core 'fields' use a different key in node forms and in 'view'
458
-      // render arrays. Check we're not on a form first.
459
-      if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
457
+        // Some core 'fields' use a different key in node forms and in 'view'
458
+        // render arrays. Check we're not on a form first.
459
+        if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
460 460
         $elements[$value['view']]['#weight'] = $value['weight'];
461
-      }
462
-      elseif (isset($elements[$key])) {
461
+        }
462
+        elseif (isset($elements[$key])) {
463 463
         $elements[$key]['#weight'] = $value['weight'];
464
-      }
464
+        }
465
+    }
465 466
     }
466
-  }
467
-  return $elements;
467
+    return $elements;
468 468
 }
469 469
 
470 470
 /**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
  * included yet when the form is processed and invokes the callback.
473 473
  */
474 474
 function content_add_more_submit_proxy($form, &$form_state) {
475
-  module_load_include('inc', 'content', 'includes/content.node_form');
476
-  content_add_more_submit($form, $form_state);
475
+    module_load_include('inc', 'content', 'includes/content.node_form');
476
+    content_add_more_submit($form, $form_state);
477 477
 }
478 478
 
479 479
 /**
@@ -482,21 +482,21 @@  discard block
 block discarded – undo
482 482
  * Combine multiple values into a table with drag-n-drop reordering.
483 483
  */
484 484
 function theme_content_multiple_values($element) {
485
-  $field_name = $element['#field_name'];
486
-  $field = content_fields($field_name);
487
-  $output = '';
485
+    $field_name = $element['#field_name'];
486
+    $field = content_fields($field_name);
487
+    $output = '';
488 488
 
489
-  if ($field['multiple'] >= 1) {
489
+    if ($field['multiple'] >= 1) {
490 490
     $table_id = $element['#field_name'] .'_values';
491 491
     $order_class = $element['#field_name'] .'-delta-order';
492 492
     $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
493 493
 
494 494
     $header = array(
495
-      array(
495
+        array(
496 496
         'data' => t('!title: !required', array('!title' => $element['#title'], '!required' => $required)),
497 497
         'colspan' => 2
498
-      ),
499
-      t('Order'),
498
+        ),
499
+        t('Order'),
500 500
     );
501 501
     $rows = array();
502 502
 
@@ -504,25 +504,25 @@  discard block
 block discarded – undo
504 504
     // preview or failed validation)
505 505
     $items = array();
506 506
     foreach (element_children($element) as $key) {
507
-      if ($key !== $element['#field_name'] .'_add_more') {
507
+        if ($key !== $element['#field_name'] .'_add_more') {
508 508
         $items[] = &$element[$key];
509
-      }
509
+        }
510 510
     }
511 511
     usort($items, '_content_sort_items_value_helper');
512 512
 
513 513
     // Add the items as table rows.
514 514
     foreach ($items as $key => $item) {
515
-      $item['_weight']['#attributes']['class'] = $order_class;
516
-      $delta_element = drupal_render($item['_weight']);
517
-      $cells = array(
515
+        $item['_weight']['#attributes']['class'] = $order_class;
516
+        $delta_element = drupal_render($item['_weight']);
517
+        $cells = array(
518 518
         array('data' => '', 'class' => 'content-multiple-drag'),
519 519
         drupal_render($item),
520 520
         array('data' => $delta_element, 'class' => 'delta-order'),
521
-      );
522
-      $rows[] = array(
521
+        );
522
+        $rows[] = array(
523 523
         'data' => $cells,
524 524
         'class' => 'draggable',
525
-      );
525
+        );
526 526
     }
527 527
 
528 528
     $output .= theme('table', $header, $rows, array('id' => $table_id, 'class' => 'content-multiple-table'));
@@ -530,14 +530,14 @@  discard block
 block discarded – undo
530 530
     $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
531 531
 
532 532
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533
-  }
534
-  else {
533
+    }
534
+    else {
535 535
     foreach (element_children($element) as $key) {
536
-      $output .= drupal_render($element[$key]);
536
+        $output .= drupal_render($element[$key]);
537
+    }
537 538
     }
538
-  }
539 539
 
540
-  return $output;
540
+    return $output;
541 541
 }
542 542
 
543 543
 /**
@@ -552,29 +552,29 @@  discard block
 block discarded – undo
552 552
  *   field modules are installed, uninstalled, enabled or disabled.
553 553
  */
554 554
 function content_notify($op, $module) {
555
-  switch ($op) {
555
+    switch ($op) {
556 556
     case 'install':
557 557
       content_clear_type_cache();
558
-      break;
558
+        break;
559 559
     case 'uninstall':
560 560
       module_load_include('inc', 'content', 'includes/content.crud');
561
-      content_module_delete($module);
562
-      break;
561
+        content_module_delete($module);
562
+        break;
563 563
     case 'enable':
564 564
       content_associate_fields($module);
565
-      content_clear_type_cache();
566
-      break;
565
+        content_clear_type_cache();
566
+        break;
567 567
     case 'disable':
568 568
       // When CCK modules are disabled before content module's update is run
569 569
       // to add the active column, we can't do this.
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571 571
         return FALSE;
572
-      }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
576
-      break;
577
-  }
572
+        }
573
+        db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
+        db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
+        content_clear_type_cache(TRUE);
576
+        break;
577
+    }
578 578
 }
579 579
 
580 580
 /**
@@ -584,39 +584,39 @@  discard block
 block discarded – undo
584 584
  *   The name of the module to update on.
585 585
  */
586 586
 function content_associate_fields($module) {
587
-  // When CCK modules are enabled before content module's update is run,
588
-  // to add module and active columns, we can't do this.
589
-  if (variable_get('content_schema_version', -1) < 6007) {
587
+    // When CCK modules are enabled before content module's update is run,
588
+    // to add module and active columns, we can't do this.
589
+    if (variable_get('content_schema_version', -1) < 6007) {
590 590
     return FALSE;
591
-  }
592
-  $module_fields = module_invoke($module, 'field_info');
593
-  if ($module_fields) {
591
+    }
592
+    $module_fields = module_invoke($module, 'field_info');
593
+    if ($module_fields) {
594 594
     foreach ($module_fields as $name => $field_info) {
595
-      watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
-      db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
595
+        watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
+        db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
597 597
     }
598
-  }
599
-  $module_widgets = module_invoke($module, 'widget_info');
600
-  if ($module_widgets) {
598
+    }
599
+    $module_widgets = module_invoke($module, 'widget_info');
600
+    if ($module_widgets) {
601 601
     foreach ($module_widgets as $name => $widget_info) {
602
-      watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604
-    }
605
-  }
606
-  // This is called from updates and installs, so get the install-safe
607
-  // version of a fields array.
608
-  $fields_set = array();
609
-  module_load_include('install', 'content');
610
-  $types = content_types_install();
611
-  foreach ($types as $type_name => $fields) {
602
+        watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
+        db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604
+    }
605
+    }
606
+    // This is called from updates and installs, so get the install-safe
607
+    // version of a fields array.
608
+    $fields_set = array();
609
+    module_load_include('install', 'content');
610
+    $types = content_types_install();
611
+    foreach ($types as $type_name => $fields) {
612 612
     foreach ($fields as $field) {
613
-      if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
613
+        if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
614 614
         $columns = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
615 615
         db_query("UPDATE {". content_field_tablename() ."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
616 616
         $fields_set[] = $field['field_name'];
617
-      }
617
+        }
618
+    }
618 619
     }
619
-  }
620 620
 }
621 621
 
622 622
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  *   );
685 685
  */
686 686
 function content_field($op, &$node, $field, &$items, $teaser, $page) {
687
-  switch ($op) {
687
+    switch ($op) {
688 688
     case 'validate':
689 689
       // TODO: here we could validate that the number of multiple data is correct ?
690 690
       // We're controlling the number of fields to fill out and saving empty
@@ -699,107 +699,107 @@  discard block
 block discarded – undo
699 699
         include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700 700
         content_generate_fields($node, $field);
701 701
         $items = $node->{$field['field_name']};
702
-      }
703
-
704
-      // Manual node_save calls might not have all fields filled in.
705
-      // On node insert, we need to make sure all tables get at least an empty
706
-      // record, or subsequent edits, using drupal_write_record() in update mode,
707
-      // won't insert any data.
708
-      // Missing fields on node update are handled in content_storage().
709
-      if (empty($items) && !isset($node->nid)) {
702
+        }
703
+
704
+        // Manual node_save calls might not have all fields filled in.
705
+        // On node insert, we need to make sure all tables get at least an empty
706
+        // record, or subsequent edits, using drupal_write_record() in update mode,
707
+        // won't insert any data.
708
+        // Missing fields on node update are handled in content_storage().
709
+        if (empty($items) && !isset($node->nid)) {
710 710
         foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
711
+            $items[0][$column] = NULL;
712 712
         }
713 713
         $node->$field['field_name'] = $items;
714
-      }
714
+        }
715 715
 
716
-      // If there was an AHAH add more button in this field, don't save it.
717
-      // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
716
+        // If there was an AHAH add more button in this field, don't save it.
717
+        // TODO: is it still needed ?
718
+        unset($items[$field['field_name'] .'_add_more']);
719 719
 
720
-      if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
720
+        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 721
         // Reorder items to account for drag-n-drop reordering.
722 722
         $items = _content_sort_items($field, $items);
723
-      }
723
+        }
724 724
 
725
-      // Filter out empty values.
726
-      $items = content_set_empty($field, $items);
725
+        // Filter out empty values.
726
+        $items = content_set_empty($field, $items);
727 727
 
728
-      break;
728
+        break;
729 729
 
730 730
     case 'view':
731 731
       $addition = array();
732 732
 
733
-      // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
-      if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
733
+        // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
+        if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
735 735
         if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
736
-          // Reorder items to account for drag-n-drop reordering.
737
-          $items = _content_sort_items($field, $items);
736
+            // Reorder items to account for drag-n-drop reordering.
737
+            $items = _content_sort_items($field, $items);
738 738
         }
739 739
 
740 740
         // Filter out empty values.
741 741
         $items = content_set_empty($field, $items);
742
-      }
742
+        }
743 743
 
744
-      // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
-      if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
744
+        // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
+        if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746 746
         $context = $teaser ? 'teaser' : 'full';
747
-      }
748
-      else {
747
+        }
748
+        else {
749 749
         $context = $node->build_mode;
750
-      }
751
-      // The field may be missing info for $contexts added by modules
752
-      // enabled after the field was last edited.
753
-      $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
-      if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
750
+        }
751
+        // The field may be missing info for $contexts added by modules
752
+        // enabled after the field was last edited.
753
+        $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
+        if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755 755
         $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756 756
         $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757 757
 
758 758
         $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759 759
         // Do not include field labels when indexing content.
760 760
         if ($context == NODE_BUILD_SEARCH_INDEX) {
761
-          $label_display = 'hidden';
761
+            $label_display = 'hidden';
762 762
         }
763 763
 
764 764
         $element = array(
765
-          '#type' => 'content_field',
766
-          '#title' => check_plain(t($field['widget']['label'])),
767
-          '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
-          '#label_display' => $label_display,
770
-          '#node' => $node,
771
-          '#teaser' => $teaser,
772
-          '#page' => $page,
773
-          '#context' => $context,
774
-          '#single' => $single,
775
-          'items' => array(),
765
+            '#type' => 'content_field',
766
+            '#title' => check_plain(t($field['widget']['label'])),
767
+            '#field_name' => $field['field_name'],
768
+            '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
+            '#label_display' => $label_display,
770
+            '#node' => $node,
771
+            '#teaser' => $teaser,
772
+            '#page' => $page,
773
+            '#context' => $context,
774
+            '#single' => $single,
775
+            'items' => array(),
776 776
         );
777 777
 
778 778
         // Fill-in items.
779 779
         foreach ($items as $delta => $item) {
780
-          $element['items'][$delta] = array(
780
+            $element['items'][$delta] = array(
781 781
             '#item' => $item,
782 782
             '#weight' => $delta,
783
-          );
783
+            );
784 784
         }
785 785
 
786 786
         // Append formatter information either on each item ('single-value' formatter)
787 787
         // or at the upper 'items' level ('multiple-value' formatter)
788 788
         $format_info = array(
789
-          '#theme' => $theme,
790
-          '#field_name' => $field['field_name'],
791
-          '#type_name' => $node->type,
792
-          '#formatter' => $formatter_name,
793
-          '#node' => $node,
789
+            '#theme' => $theme,
790
+            '#field_name' => $field['field_name'],
791
+            '#type_name' => $node->type,
792
+            '#formatter' => $formatter_name,
793
+            '#node' => $node,
794 794
         );
795 795
         if ($single) {
796
-          foreach ($items as $delta => $item) {
796
+            foreach ($items as $delta => $item) {
797 797
             $element['items'][$delta] += $format_info;
798 798
             $element['items'][$delta]['#item']['#delta'] = $delta;
799
-          }
799
+            }
800 800
         }
801 801
         else {
802
-          $element['items'] += $format_info;
802
+            $element['items'] += $format_info;
803 803
         }
804 804
 
805 805
         // The wrapper lets us get the themed output for the whole field
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
         // and hide it from the $content variable if needed.
808 808
         // See 'preprocess_node' op and theme_content_field_wrapper()?
809 809
         $wrapper = array(
810
-          'field' => $element,
811
-          '#weight' => $field['widget']['weight'],
812
-          '#post_render' => array('content_field_wrapper_post_render'),
813
-          '#field_name' => $field['field_name'],
814
-          '#type_name' => $node->type,
815
-          '#context' => $context,
810
+            'field' => $element,
811
+            '#weight' => $field['widget']['weight'],
812
+            '#post_render' => array('content_field_wrapper_post_render'),
813
+            '#field_name' => $field['field_name'],
814
+            '#type_name' => $node->type,
815
+            '#context' => $context,
816 816
         );
817 817
 
818 818
         $addition = array($field['field_name'] => $wrapper);
819
-      }
820
-      return $addition;
819
+        }
820
+        return $addition;
821 821
 
822 822
     case 'alter':
823 823
       // Add back the formatted values in the 'view' element,
@@ -827,64 +827,64 @@  discard block
 block discarded – undo
827 827
       // The location of the field's rendered output depends on whether the
828 828
       // field is in a fieldgroup or not.
829 829
       $wrapper = NULL;
830
-      if (isset($node->content[$field['field_name']])) {
830
+        if (isset($node->content[$field['field_name']])) {
831 831
         $wrapper = $node->content[$field['field_name']];
832
-      }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
832
+        }
833
+        elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834 834
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
-      }
835
+        }
836 836
 
837
-      if ($wrapper) {
837
+        if ($wrapper) {
838 838
         $element = $wrapper['field'];
839 839
         // '#single' is not set if the field is hidden or inaccessible.
840 840
         if (isset($element['#single'])) {
841
-          if (!empty($element['#single'])) {
841
+            if (!empty($element['#single'])) {
842 842
             // Single value formatter.
843 843
             foreach (element_children($element['items']) as $delta) {
844
-              // '#chilren' is not set if the field is empty.
845
-              $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
844
+                // '#chilren' is not set if the field is empty.
845
+                $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846
+            }
846 847
             }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
848
+            elseif (isset($element['items']['#children']))  {
849 849
             // Multiple values formatter.
850 850
             $items[0]['view'] = $element['items']['#children'];
851
-          }
851
+            }
852 852
         }
853 853
         else {
854
-          // Hidden or inaccessible field.
855
-          $items[0]['view'] = '';
854
+            // Hidden or inaccessible field.
855
+            $items[0]['view'] = '';
856 856
         }
857
-      }
858
-      break;
857
+        }
858
+        break;
859 859
 
860 860
     case 'preprocess_node':
861 861
       // Add $FIELD_NAME_rendered variables.
862 862
       $addition = array();
863 863
 
864
-      // The location of the field's rendered output depends on whether the
865
-      // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
867
-      if (isset($node->content[$field['field_name']])) {
864
+        // The location of the field's rendered output depends on whether the
865
+        // field is in a fieldgroup or not.
866
+        $wrapper = NULL;
867
+        if (isset($node->content[$field['field_name']])) {
868 868
         $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
869
+        }
870
+        elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871 871
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
-      }
872
+        }
873 873
 
874
-      if ($wrapper) {
874
+        if ($wrapper) {
875 875
         // '#chilren' is not set if the field is empty.
876 876
         $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
-      }
877
+        }
878 878
 
879
-      return $addition;
879
+        return $addition;
880 880
 
881 881
     case 'prepare translation':
882 882
       $addition = array();
883
-      if (isset($node->translation_source->$field['field_name'])) {
883
+        if (isset($node->translation_source->$field['field_name'])) {
884 884
         $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
-      }
886
-      return $addition;
887
-  }
885
+        }
886
+        return $addition;
887
+    }
888 888
 }
889 889
 
890 890
 /**
@@ -899,24 +899,24 @@  discard block
 block discarded – undo
899 899
  *   returns filtered and adjusted item array
900 900
  */
901 901
 function content_set_empty($field, $items) {
902
-  // Filter out empty values.
903
-  $filtered = array();
904
-  $function = $field['module'] .'_content_is_empty';
905
-  foreach ((array) $items as $delta => $item) {
902
+    // Filter out empty values.
903
+    $filtered = array();
904
+    $function = $field['module'] .'_content_is_empty';
905
+    foreach ((array) $items as $delta => $item) {
906 906
     if (!$function($item, $field)) {
907
-      $filtered[] = $item;
907
+        $filtered[] = $item;
908
+    }
908 909
     }
909
-  }
910 910
 
911
-  // Make sure we store the right number of 'empty' values.
912
-  $empty = array();
913
-  foreach (array_keys($field['columns']) as $column) {
911
+    // Make sure we store the right number of 'empty' values.
912
+    $empty = array();
913
+    foreach (array_keys($field['columns']) as $column) {
914 914
     $empty[$column] = NULL;
915
-  }
916
-  $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917
-  $filtered = array_pad($filtered, $pad, $empty);
915
+    }
916
+    $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917
+    $filtered = array_pad($filtered, $pad, $empty);
918 918
 
919
-  return $filtered;
919
+    return $filtered;
920 920
 }
921 921
 
922 922
 /**
@@ -924,15 +924,15 @@  discard block
 block discarded – undo
924 924
  * user drag-n-drop reordering.
925 925
  */
926 926
 function _content_sort_items($field, $items) {
927
-  if ($field['multiple'] >= 1 && isset($items[0]['_weight'])) {
927
+    if ($field['multiple'] >= 1 && isset($items[0]['_weight'])) {
928 928
     usort($items, '_content_sort_items_helper');
929 929
     foreach ($items as $delta => $item) {
930
-      if (is_array($items[$delta])) {
930
+        if (is_array($items[$delta])) {
931 931
         unset($items[$delta]['_weight']);
932
-      }
932
+        }
933
+    }
933 934
     }
934
-  }
935
-  return $items;
935
+    return $items;
936 936
 }
937 937
 
938 938
 /**
@@ -940,50 +940,50 @@  discard block
 block discarded – undo
940 940
  * (copied form element_sort(), which acts on #weight keys)
941 941
  */
942 942
 function _content_sort_items_helper($a, $b) {
943
-  $a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
944
-  $b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
945
-  if ($a_weight == $b_weight) {
943
+    $a_weight = (is_array($a) && isset($a['_weight'])) ? $a['_weight'] : 0;
944
+    $b_weight = (is_array($b) && isset($b['_weight'])) ? $b['_weight'] : 0;
945
+    if ($a_weight == $b_weight) {
946 946
     return 0;
947
-  }
948
-  return ($a_weight < $b_weight) ? -1 : 1;
947
+    }
948
+    return ($a_weight < $b_weight) ? -1 : 1;
949 949
 }
950 950
 
951 951
 /**
952 952
  * Same as above, using ['_weight']['#value']
953 953
  */
954 954
 function _content_sort_items_value_helper($a, $b) {
955
-  $a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
956
-  $b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
957
-  if ($a_weight == $b_weight) {
955
+    $a_weight = (is_array($a) && isset($a['_weight']['#value'])) ? $a['_weight']['#value'] : 0;
956
+    $b_weight = (is_array($b) && isset($b['_weight']['#value'])) ? $b['_weight']['#value'] : 0;
957
+    if ($a_weight == $b_weight) {
958 958
     return 0;
959
-  }
960
-  return ($a_weight < $b_weight) ? -1 : 1;
959
+    }
960
+    return ($a_weight < $b_weight) ? -1 : 1;
961 961
 }
962 962
 
963 963
 /**
964 964
  * Handle storage ops for _content_field_invoke_default().
965 965
  */
966 966
 function content_storage($op, $node) {
967
-  // Don't try this before content module's update is run to add
968
-  // the active and module columns.
969
-  if (variable_get('content_schema_version', -1) < 6007) {
967
+    // Don't try this before content module's update is run to add
968
+    // the active and module columns.
969
+    if (variable_get('content_schema_version', -1) < 6007) {
970 970
     return FALSE;
971
-  }
971
+    }
972 972
 
973
-  $type_name = $node->type;
974
-  $type = content_types($type_name);
973
+    $type_name = $node->type;
974
+    $type = content_types($type_name);
975 975
 
976
-  switch ($op) {
976
+    switch ($op) {
977 977
     case 'load':
978 978
       // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979 979
       // warning: 61-join limit in MySQL ?
980 980
       $additions = array();
981
-      // For each table used by this content type,
982
-      foreach ($type['tables'] as $table) {
981
+        // For each table used by this content type,
982
+        foreach ($type['tables'] as $table) {
983 983
         $schema = drupal_get_schema($table);
984 984
         // The per-type table might not have any fields actually stored in it.
985 985
         if (!$schema['content fields']) {
986
-          continue;
986
+            continue;
987 987
         }
988 988
         $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989 989
 
@@ -994,25 +994,25 @@  discard block
 block discarded – undo
994 994
 
995 995
         // For each table row, populate the fields.
996 996
         while ($row = db_fetch_array($result)) {
997
-          // For each field stored in the table, add the field item.
998
-          foreach ($schema['content fields'] as $field_name) {
997
+            // For each field stored in the table, add the field item.
998
+            foreach ($schema['content fields'] as $field_name) {
999 999
             $item = array();
1000 1000
             $field = content_fields($field_name, $type_name);
1001 1001
             $db_info = content_database_info($field);
1002 1002
             // For each column declared by the field, populate the item.
1003 1003
             foreach ($db_info['columns'] as $column => $attributes) {
1004
-              $item[$column] = $row[$attributes['column']];
1004
+                $item[$column] = $row[$attributes['column']];
1005 1005
             }
1006 1006
 
1007 1007
             // Add the item to the field values for the node.
1008 1008
             if (!isset($additions[$field_name])) {
1009
-              $additions[$field_name] = array();
1009
+                $additions[$field_name] = array();
1010 1010
             }
1011 1011
             $additions[$field_name][] = $item;
1012
-          }
1012
+            }
1013 1013
         }
1014
-      }
1015
-      return $additions;
1014
+        }
1015
+        return $additions;
1016 1016
 
1017 1017
     case 'insert':
1018 1018
     case 'update':
@@ -1020,17 +1020,17 @@  discard block
 block discarded – undo
1020 1020
         $schema = drupal_get_schema($table);
1021 1021
         $record = array();
1022 1022
         foreach ($schema['content fields'] as $field_name) {
1023
-          if (isset($node->$field_name)) {
1023
+            if (isset($node->$field_name)) {
1024 1024
             $field = content_fields($field_name, $type_name);
1025 1025
             // Multiple fields need specific handling, we'll deal with them later on.
1026 1026
             if ($field['multiple']) {
1027
-              continue;
1027
+                continue;
1028 1028
             }
1029 1029
             $db_info = content_database_info($field);
1030 1030
             foreach ($db_info['columns'] as $column => $attributes) {
1031
-              $record[$attributes['column']] = $node->{$field_name}[0][$column];
1031
+                $record[$attributes['column']] = $node->{$field_name}[0][$column];
1032
+            }
1032 1033
             }
1033
-          }
1034 1034
         }
1035 1035
         // $record might be empty because
1036 1036
         // - the table stores a multiple field :
@@ -1038,59 +1038,59 @@  discard block
 block discarded – undo
1038 1038
         // - this is the per-type table and no field is actually stored in it :
1039 1039
         //   we still store the nid and vid
1040 1040
         if (count($record) || empty($schema['content fields'])) {
1041
-          $record['nid'] = $node->nid;
1042
-          $record['vid'] = $node->vid;
1043
-          // Can't rely on the insert/update op of the node to decide if this
1044
-          // is an insert or an update, a node or revision may have existed
1045
-          // before any fields were created, so there may not be an entry here.
1046
-
1047
-          // TODO - should we auto create an entry for all existing nodes when
1048
-          // fields are added to content types -- either a NULL value
1049
-          // or the default value? May need to offer the user an option of
1050
-          // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1041
+            $record['nid'] = $node->nid;
1042
+            $record['vid'] = $node->vid;
1043
+            // Can't rely on the insert/update op of the node to decide if this
1044
+            // is an insert or an update, a node or revision may have existed
1045
+            // before any fields were created, so there may not be an entry here.
1046
+
1047
+            // TODO - should we auto create an entry for all existing nodes when
1048
+            // fields are added to content types -- either a NULL value
1049
+            // or the default value? May need to offer the user an option of
1050
+            // how to handle that.
1051
+            if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052 1052
             content_write_record($table, $record, array('vid'));
1053
-          }
1054
-          else {
1053
+            }
1054
+            else {
1055 1055
             content_write_record($table, $record);
1056
-          }
1056
+            }
1057
+        }
1057 1058
         }
1058
-      }
1059 1059
 
1060
-      // Handle multiple fields.
1061
-      foreach ($type['fields'] as $field) {
1060
+        // Handle multiple fields.
1061
+        foreach ($type['fields'] as $field) {
1062 1062
         if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
-          $db_info = content_database_info($field);
1064
-          // Delete and insert, rather than update, in case a value was added.
1065
-          if ($op == 'update') {
1063
+            $db_info = content_database_info($field);
1064
+            // Delete and insert, rather than update, in case a value was added.
1065
+            if ($op == 'update') {
1066 1066
             db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
-          }
1068
-          foreach ($node->$field['field_name'] as $delta => $item) {
1067
+            }
1068
+            foreach ($node->$field['field_name'] as $delta => $item) {
1069 1069
             $record = array();
1070 1070
             foreach ($db_info['columns'] as $column => $attributes) {
1071
-              $record[$attributes['column']] = $item[$column];
1071
+                $record[$attributes['column']] = $item[$column];
1072 1072
             }
1073 1073
             $record['nid'] = $node->nid;
1074 1074
             $record['vid'] = $node->vid;
1075 1075
             $record['delta'] = $delta;
1076 1076
             content_write_record($db_info['table'], $record);
1077
-          }
1077
+            }
1078 1078
         }
1079
-      }
1080
-      break;
1079
+        }
1080
+        break;
1081 1081
 
1082 1082
     case 'delete':
1083 1083
       foreach ($type['tables'] as $table) {
1084 1084
         db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
-      }
1086
-      break;
1085
+        }
1086
+        break;
1087 1087
 
1088 1088
     case 'delete revision':
1089 1089
       foreach ($type['tables'] as $table) {
1090 1090
         db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
-      }
1092
-      break;
1093
-  }
1091
+        }
1092
+        break;
1093
+    }
1094 1094
 }
1095 1095
 
1096 1096
 /**
@@ -1125,108 +1125,108 @@  discard block
 block discarded – undo
1125 1125
  *   a new node.
1126 1126
  */
1127 1127
 function content_write_record($table, &$object, $update = array()) {
1128
-  // Standardize $update to an array.
1129
-  if (is_string($update)) {
1128
+    // Standardize $update to an array.
1129
+    if (is_string($update)) {
1130 1130
     $update = array($update);
1131
-  }
1131
+    }
1132 1132
 
1133
-  // Convert to an object if needed.
1134
-  if (is_array($object)) {
1133
+    // Convert to an object if needed.
1134
+    if (is_array($object)) {
1135 1135
     $object = (object) $object;
1136 1136
     $array = TRUE;
1137
-  }
1138
-  else {
1137
+    }
1138
+    else {
1139 1139
     $array = FALSE;
1140
-  }
1140
+    }
1141 1141
 
1142
-  $schema = drupal_get_schema($table);
1143
-  if (empty($schema)) {
1142
+    $schema = drupal_get_schema($table);
1143
+    if (empty($schema)) {
1144 1144
     return FALSE;
1145
-  }
1145
+    }
1146 1146
 
1147
-  $fields = $defs = $values = $serials = $placeholders = array();
1147
+    $fields = $defs = $values = $serials = $placeholders = array();
1148 1148
 
1149
-  // Go through our schema, build SQL, and when inserting, fill in defaults for
1150
-  // fields that are not set.
1151
-  foreach ($schema['fields'] as $field => $info) {
1149
+    // Go through our schema, build SQL, and when inserting, fill in defaults for
1150
+    // fields that are not set.
1151
+    foreach ($schema['fields'] as $field => $info) {
1152 1152
     // Special case -- skip serial types if we are updating.
1153 1153
     if ($info['type'] == 'serial' && count($update)) {
1154
-      continue;
1154
+        continue;
1155 1155
     }
1156 1156
 
1157 1157
     // For inserts, populate defaults from Schema if not already provided
1158 1158
     if (!isset($object->$field) && !count($update) && isset($info['default'])) {
1159
-      $object->$field = $info['default'];
1159
+        $object->$field = $info['default'];
1160 1160
     }
1161 1161
 
1162 1162
     // Track serial fields so we can helpfully populate them after the query.
1163 1163
     if ($info['type'] == 'serial') {
1164
-      $serials[] = $field;
1165
-      // Ignore values for serials when inserting data. Unsupported.
1166
-      unset($object->$field);
1164
+        $serials[] = $field;
1165
+        // Ignore values for serials when inserting data. Unsupported.
1166
+        unset($object->$field);
1167 1167
     }
1168 1168
 
1169 1169
     // Build arrays for the fields, placeholders, and values in our query.
1170 1170
     if (isset($object->$field) || array_key_exists($field, $object)) {
1171
-      $fields[] = $field;
1172
-      if (isset($object->$field)) {
1171
+        $fields[] = $field;
1172
+        if (isset($object->$field)) {
1173 1173
         $placeholders[] = db_type_placeholder($info['type']);
1174 1174
 
1175 1175
         if (empty($info['serialize'])) {
1176
-          $values[] = $object->$field;
1176
+            $values[] = $object->$field;
1177 1177
         }
1178 1178
         else {
1179
-          $values[] = serialize($object->$field);
1179
+            $values[] = serialize($object->$field);
1180
+        }
1180 1181
         }
1181
-      }
1182
-      else {
1182
+        else {
1183 1183
         $placeholders[] = 'NULL';
1184
-      }
1184
+        }
1185
+    }
1185 1186
     }
1186
-  }
1187 1187
 
1188
-  // Build the SQL.
1189
-  $query = '';
1190
-  if (!count($update)) {
1188
+    // Build the SQL.
1189
+    $query = '';
1190
+    if (!count($update)) {
1191 1191
     $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1192 1192
     $return = SAVED_NEW;
1193
-  }
1194
-  else {
1193
+    }
1194
+    else {
1195 1195
     $query = '';
1196 1196
     foreach ($fields as $id => $field) {
1197
-      if ($query) {
1197
+        if ($query) {
1198 1198
         $query .= ', ';
1199
-      }
1200
-      $query .= $field .' = '. $placeholders[$id];
1199
+        }
1200
+        $query .= $field .' = '. $placeholders[$id];
1201 1201
     }
1202 1202
 
1203 1203
     foreach ($update as $key) {
1204
-      $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1205
-      $values[] = $object->$key;
1204
+        $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1205
+        $values[] = $object->$key;
1206 1206
     }
1207 1207
 
1208 1208
     $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
1209 1209
     $return = SAVED_UPDATED;
1210
-  }
1210
+    }
1211 1211
 
1212
-  // Execute the SQL.
1213
-  if (db_query($query, $values)) {
1212
+    // Execute the SQL.
1213
+    if (db_query($query, $values)) {
1214 1214
     if ($serials) {
1215
-      // Get last insert ids and fill them in.
1216
-      foreach ($serials as $field) {
1215
+        // Get last insert ids and fill them in.
1216
+        foreach ($serials as $field) {
1217 1217
         $object->$field = db_last_insert_id($table, $field);
1218
-      }
1218
+        }
1219 1219
     }
1220 1220
 
1221 1221
     // If we began with an array, convert back so we don't surprise the caller.
1222 1222
     if ($array) {
1223
-      $object = (array) $object;
1223
+        $object = (array) $object;
1224 1224
     }
1225 1225
 
1226 1226
     return $return;
1227
-  }
1227
+    }
1228 1228
 
1229
-  return FALSE;
1229
+    return FALSE;
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1236,12 +1236,12 @@  discard block
 block discarded – undo
1236 1236
  * called so that the default database handling can occur.
1237 1237
  */
1238 1238
 function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
1239
-  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240
-  $type = content_types($type_name);
1241
-  $field_types = _content_field_types();
1239
+    $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240
+    $type = content_types($type_name);
1241
+    $field_types = _content_field_types();
1242 1242
 
1243
-  $return = array();
1244
-  foreach ($type['fields'] as $field) {
1243
+    $return = array();
1244
+    foreach ($type['fields'] as $field) {
1245 1245
     $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1246 1246
 
1247 1247
     // Make sure AHAH 'add more' button isn't sent to the fields for processing.
@@ -1250,52 +1250,52 @@  discard block
 block discarded – undo
1250 1250
     $module = $field_types[$field['type']]['module'];
1251 1251
     $function = $module .'_field';
1252 1252
     if (function_exists($function)) {
1253
-      $result = $function($op, $node, $field, $items, $teaser, $page);
1254
-      if (is_array($result)) {
1253
+        $result = $function($op, $node, $field, $items, $teaser, $page);
1254
+        if (is_array($result)) {
1255 1255
         $return = array_merge($return, $result);
1256
-      }
1257
-      else if (isset($result)) {
1256
+        }
1257
+        else if (isset($result)) {
1258 1258
         $return[] = $result;
1259
-      }
1259
+        }
1260 1260
     }
1261 1261
     // test for values in $items in case modules added items on insert
1262 1262
     if (isset($node->$field['field_name']) || count($items)) {
1263
-      $node->$field['field_name'] = $items;
1263
+        $node->$field['field_name'] = $items;
1264
+    }
1264 1265
     }
1265
-  }
1266
-  return $return;
1266
+    return $return;
1267 1267
 }
1268 1268
 
1269 1269
 /**
1270 1270
  * Invoke content.module's version of a field hook.
1271 1271
  */
1272 1272
 function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
1273
-  $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274
-  $type = content_types($type_name);
1275
-  $field_types = _content_field_types();
1276
-
1277
-  $return = array();
1278
-  // The operations involving database queries are better off handled by table
1279
-  // rather than by field.
1280
-  if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1273
+    $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274
+    $type = content_types($type_name);
1275
+    $field_types = _content_field_types();
1276
+
1277
+    $return = array();
1278
+    // The operations involving database queries are better off handled by table
1279
+    // rather than by field.
1280
+    if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1281 1281
     return content_storage($op, $node);
1282
-  }
1283
-  else {
1282
+    }
1283
+    else {
1284 1284
     foreach ($type['fields'] as $field) {
1285
-      $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286
-      $result = content_field($op, $node, $field, $items, $teaser, $page);
1287
-      if (is_array($result)) {
1285
+        $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286
+        $result = content_field($op, $node, $field, $items, $teaser, $page);
1287
+        if (is_array($result)) {
1288 1288
         $return = array_merge($return, $result);
1289
-      }
1290
-      else if (isset($result)) {
1289
+        }
1290
+        else if (isset($result)) {
1291 1291
         $return[] = $result;
1292
-      }
1293
-      if (isset($node->$field['field_name'])) {
1292
+        }
1293
+        if (isset($node->$field['field_name'])) {
1294 1294
         $node->$field['field_name'] = $items;
1295
-      }
1295
+        }
1296
+    }
1296 1297
     }
1297
-  }
1298
-  return $return;
1298
+    return $return;
1299 1299
 }
1300 1300
 
1301 1301
 /**
@@ -1308,19 +1308,19 @@  discard block
 block discarded – undo
1308 1308
  * info to avoid foreach errors elsewhere in the code.
1309 1309
  */
1310 1310
 function content_types($type_name = NULL) {
1311
-  // handle type name with either an underscore or a dash
1312
-  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1311
+    // handle type name with either an underscore or a dash
1312
+    $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1313 1313
 
1314
-  $info = _content_type_info();
1315
-  if (isset($info['content types'])) {
1314
+    $info = _content_type_info();
1315
+    if (isset($info['content types'])) {
1316 1316
     if (!isset($type_name)) {
1317
-      return $info['content types'];
1317
+        return $info['content types'];
1318 1318
     }
1319 1319
     if (isset($info['content types'][$type_name])) {
1320
-      return $info['content types'][$type_name];
1320
+        return $info['content types'][$type_name];
1321
+    }
1321 1322
     }
1322
-  }
1323
-  return array('tables' => array(), 'fields' => array(), 'extra' => array());
1323
+    return array('tables' => array(), 'fields' => array(), 'extra' => array());
1324 1324
 }
1325 1325
 
1326 1326
 /**
@@ -1337,36 +1337,36 @@  discard block
 block discarded – undo
1337 1337
  * but empty, as sometimes happens in the formatter.
1338 1338
  */
1339 1339
 function content_fields($field_name = NULL, $content_type_name = NULL) {
1340
-  $info = _content_type_info();
1341
-  if (isset($info['fields'])) {
1340
+    $info = _content_type_info();
1341
+    if (isset($info['fields'])) {
1342 1342
     if (empty($field_name)) {
1343
-      return $info['fields'];
1343
+        return $info['fields'];
1344 1344
     }
1345 1345
     if (isset($info['fields'][$field_name])) {
1346
-      if (empty($content_type_name)) {
1346
+        if (empty($content_type_name)) {
1347 1347
         return $info['fields'][$field_name];
1348
-      }
1349
-      if (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
1348
+        }
1349
+        if (isset($info['content types'][$content_type_name]['fields'][$field_name])) {
1350 1350
         return $info['content types'][$content_type_name]['fields'][$field_name];
1351
-      }
1351
+        }
1352
+    }
1352 1353
     }
1353
-  }
1354 1354
 }
1355 1355
 
1356 1356
 /**
1357 1357
  * Return a list of field types.
1358 1358
  */
1359 1359
 function _content_field_types() {
1360
-  $info = _content_type_info();
1361
-  return isset($info['field types']) ? $info['field types'] : array();
1360
+    $info = _content_type_info();
1361
+    return isset($info['field types']) ? $info['field types'] : array();
1362 1362
 }
1363 1363
 
1364 1364
 /**
1365 1365
  * Return a list of widget types.
1366 1366
  */
1367 1367
 function _content_widget_types() {
1368
-  $info = _content_type_info();
1369
-  return isset($info['widget types']) ? $info['widget types'] : array();
1368
+    $info = _content_type_info();
1369
+    return isset($info['widget types']) ? $info['widget types'] : array();
1370 1370
 }
1371 1371
 
1372 1372
 /**
@@ -1374,16 +1374,16 @@  discard block
 block discarded – undo
1374 1374
  * defaulting to 'default' if none is found.
1375 1375
  */
1376 1376
 function _content_get_formatter($formatter_name, $field_type) {
1377
-  $field_types = _content_field_types();
1378
-  $formatters = $field_types[$field_type]['formatters'];
1377
+    $field_types = _content_field_types();
1378
+    $formatters = $field_types[$field_type]['formatters'];
1379 1379
 
1380
-  if (!isset($formatters[$formatter_name]) && $formatter_name != 'hidden') {
1380
+    if (!isset($formatters[$formatter_name]) && $formatter_name != 'hidden') {
1381 1381
     // This might happen when the selected formatter has been renamed in the
1382 1382
     // module, or if the module has been disabled since then.
1383 1383
     $formatter_name = 'default';
1384
-  }
1384
+    }
1385 1385
 
1386
-  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1386
+    return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1387 1387
 }
1388 1388
 
1389 1389
 /**
@@ -1393,10 +1393,10 @@  discard block
 block discarded – undo
1393 1393
  *   If TRUE, clear the cache and fetch the information from the database again.
1394 1394
  */
1395 1395
 function _content_type_info($reset = FALSE) {
1396
-  global $language;
1397
-  static $info;
1396
+    global $language;
1397
+    static $info;
1398 1398
 
1399
-  if ($reset || !isset($info)) {
1399
+    if ($reset || !isset($info)) {
1400 1400
     // Make sure this function doesn't run until the tables have been created,
1401 1401
     // For instance: when first enabled and called from content_menu(),
1402 1402
     // or when uninstalled and some subsequent field module uninstall
@@ -1405,38 +1405,38 @@  discard block
 block discarded – undo
1405 1405
     // Don't try this before content module's update is run
1406 1406
     // to add module and active columns to the table.
1407 1407
     if (variable_get('content_schema_version', -1) < 6007) {
1408
-      return array();
1408
+        return array();
1409 1409
     }
1410 1410
 
1411 1411
     if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1412
-      $info = $cached->data;
1412
+        $info = $cached->data;
1413 1413
     }
1414 1414
     else {
1415
-      $info = array(
1415
+        $info = array(
1416 1416
         'field types' => array(),
1417 1417
         'widget types' => array(),
1418 1418
         'fields' => array(),
1419 1419
         'content types' => array(),
1420
-      );
1420
+        );
1421 1421
 
1422
-      // Populate field types.
1423
-      foreach (module_list() as $module) {
1422
+        // Populate field types.
1423
+        foreach (module_list() as $module) {
1424 1424
         $module_field_types = module_invoke($module, 'field_info');
1425 1425
         if ($module_field_types) {
1426
-          foreach ($module_field_types as $name => $field_info) {
1426
+            foreach ($module_field_types as $name => $field_info) {
1427 1427
             // Truncate names to match the value that is stored in the database.
1428 1428
             $db_name = substr($name, 0, 32);
1429 1429
             $info['field types'][$db_name] = $field_info;
1430 1430
             $info['field types'][$db_name]['module'] = $module;
1431 1431
             $info['field types'][$db_name]['formatters'] = array();
1432
-          }
1432
+            }
1433
+        }
1433 1434
         }
1434
-      }
1435 1435
 
1436
-      // Populate widget types and formatters for known field types.
1437
-      foreach (module_list() as $module) {
1436
+        // Populate widget types and formatters for known field types.
1437
+        foreach (module_list() as $module) {
1438 1438
         if ($module_widgets = module_invoke($module, 'widget_info')) {
1439
-          foreach ($module_widgets as $name => $widget_info) {
1439
+            foreach ($module_widgets as $name => $widget_info) {
1440 1440
             // Truncate names to match the value that is stored in the database.
1441 1441
             $db_name = substr($name, 0, 32);
1442 1442
             $info['widget types'][$db_name] = $widget_info;
@@ -1444,44 +1444,44 @@  discard block
 block discarded – undo
1444 1444
             // Replace field types with db_compatible version of known field types.
1445 1445
             $info['widget types'][$db_name]['field types'] = array();
1446 1446
             foreach ($widget_info['field types'] as $field_type) {
1447
-              $field_type_db_name = substr($field_type, 0, 32);
1448
-              if (isset($info['field types'][$field_type_db_name])) {
1447
+                $field_type_db_name = substr($field_type, 0, 32);
1448
+                if (isset($info['field types'][$field_type_db_name])) {
1449 1449
                 $info['widget types'][$db_name]['field types'][] = $field_type_db_name;
1450
-              }
1450
+                }
1451
+            }
1451 1452
             }
1452
-          }
1453 1453
         }
1454 1454
 
1455 1455
         if ($module_formatters = module_invoke($module, 'field_formatter_info')) {
1456
-          foreach ($module_formatters as $name => $formatter_info) {
1456
+            foreach ($module_formatters as $name => $formatter_info) {
1457 1457
             foreach ($formatter_info['field types'] as $field_type) {
1458
-              // Truncate names to match the value that is stored in the database.
1459
-              $db_name = substr($field_type, 0, 32);
1460
-              if (isset($info['field types'][$db_name])) {
1458
+                // Truncate names to match the value that is stored in the database.
1459
+                $db_name = substr($field_type, 0, 32);
1460
+                if (isset($info['field types'][$db_name])) {
1461 1461
                 $info['field types'][$db_name]['formatters'][$name] = $formatter_info;
1462 1462
                 $info['field types'][$db_name]['formatters'][$name]['module'] = $module;
1463
-              }
1463
+                }
1464 1464
             }
1465
-          }
1465
+            }
1466
+        }
1466 1467
         }
1467
-      }
1468 1468
 
1469
-      // Populate actual field instances.
1470
-      module_load_include('inc', 'content', 'includes/content.crud');
1471
-      foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1469
+        // Populate actual field instances.
1470
+        module_load_include('inc', 'content', 'includes/content.crud');
1471
+        foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1472 1472
         $type = (array) $data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
1475 1475
         $type['tables'] = array();
1476 1476
         if ($fields = content_field_instance_read(array('type_name' => $type_name))) {
1477
-          foreach ($fields as $field) {
1477
+            foreach ($fields as $field) {
1478 1478
             $db_info = content_database_info($field);
1479 1479
             $type['tables'][$db_info['table']] = $db_info['table'];
1480 1480
 
1481 1481
             // Allow external modules to translate field strings.
1482 1482
             $field_strings = array(
1483
-              'widget_label' => $field['widget']['label'],
1484
-              'widget_description' => $field['widget']['description'],
1483
+                'widget_label' => $field['widget']['label'],
1484
+                'widget_description' => $field['widget']['description'],
1485 1485
             );
1486 1486
             drupal_alter('content_field_strings', $field_strings, $field['type_name'], $field['field_name']);
1487 1487
             $field['widget']['label'] = $field_strings['widget_label'];
@@ -1491,11 +1491,11 @@  discard block
 block discarded – undo
1491 1491
             // This means that content_fields($field_name) (no type name)
1492 1492
             // returns the last instance loaded.
1493 1493
             $info['fields'][$field['field_name']] = $field;
1494
-          }
1495
-          // Make sure the per-type table is added, even if no field is actually
1496
-          // stored in it.
1497
-          $table = _content_tablename($type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1498
-          $type['tables'][$table] = $table;
1494
+            }
1495
+            // Make sure the per-type table is added, even if no field is actually
1496
+            // stored in it.
1497
+            $table = _content_tablename($type['type'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1498
+            $type['tables'][$table] = $table;
1499 1499
         }
1500 1500
 
1501 1501
         // Gather information about non-CCK 'fields'.
@@ -1503,21 +1503,21 @@  discard block
 block discarded – undo
1503 1503
         drupal_alter('content_extra_fields', $extra, $type_name);
1504 1504
         // Add saved weights.
1505 1505
         foreach (variable_get('content_extra_weights_'. $type_name, array()) as $key => $value) {
1506
-          // Some stored entries might not exist anymore, for instance if uploads
1507
-          // have been disabled, or vocabularies removed...
1508
-          if (isset($extra[$key])) {
1506
+            // Some stored entries might not exist anymore, for instance if uploads
1507
+            // have been disabled, or vocabularies removed...
1508
+            if (isset($extra[$key])) {
1509 1509
             $extra[$key]['weight'] = $value;
1510
-          }
1510
+            }
1511 1511
         }
1512 1512
         $type['extra'] = $extra;
1513 1513
 
1514 1514
         $info['content types'][$type_name] = $type;
1515
-      }
1515
+        }
1516 1516
 
1517
-      cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1517
+        cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1518
+    }
1518 1519
     }
1519
-  }
1520
-  return $info;
1520
+    return $info;
1521 1521
 }
1522 1522
 
1523 1523
 /**
@@ -1525,20 +1525,20 @@  discard block
 block discarded – undo
1525 1525
  *  React to change in node types
1526 1526
  */
1527 1527
 function content_node_type($op, $info) {
1528
-  switch ($op) {
1528
+    switch ($op) {
1529 1529
     case 'insert':
1530 1530
       module_load_include('inc', 'content', 'includes/content.crud');
1531
-      content_type_create($info);
1532
-      break;
1531
+        content_type_create($info);
1532
+        break;
1533 1533
     case 'update':
1534 1534
       module_load_include('inc', 'content', 'includes/content.crud');
1535
-      content_type_update($info);
1536
-      break;
1535
+        content_type_update($info);
1536
+        break;
1537 1537
     case 'delete':
1538 1538
       module_load_include('inc', 'content', 'includes/content.crud');
1539
-      content_type_delete($info);
1540
-      break;
1541
-  }
1539
+        content_type_delete($info);
1540
+        break;
1541
+    }
1542 1542
 }
1543 1543
 
1544 1544
 /**
@@ -1546,19 +1546,19 @@  discard block
 block discarded – undo
1546 1546
  * information is changed.
1547 1547
  */
1548 1548
 function content_clear_type_cache($rebuild_schema = FALSE) {
1549
-  cache_clear_all('*', content_cache_tablename(), TRUE);
1550
-  _content_type_info(TRUE);
1549
+    cache_clear_all('*', content_cache_tablename(), TRUE);
1550
+    _content_type_info(TRUE);
1551 1551
 
1552
-  // Refresh the schema to pick up new information.
1553
-  if ($rebuild_schema) {
1552
+    // Refresh the schema to pick up new information.
1553
+    if ($rebuild_schema) {
1554 1554
     $schema = drupal_get_schema(NULL, TRUE);
1555
-  }
1555
+    }
1556 1556
 
1557
-  if (module_exists('views')) {
1557
+    if (module_exists('views')) {
1558 1558
     // Needed because this can be called from .install files
1559 1559
     module_load_include('module', 'views');
1560 1560
     views_invalidate_cache();
1561
-  }
1561
+    }
1562 1562
 }
1563 1563
 
1564 1564
 /**
@@ -1577,38 +1577,38 @@  discard block
 block discarded – undo
1577 1577
  *       database column that stores the data.
1578 1578
  */
1579 1579
 function content_database_info($field) {
1580
-  $db_info = array();
1581
-  if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1580
+    $db_info = array();
1581
+    if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1582 1582
     $db_info['table'] = _content_tablename($field['field_name'], CONTENT_DB_STORAGE_PER_FIELD);
1583
-  }
1584
-  else {
1583
+    }
1584
+    else {
1585 1585
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586
-  }
1586
+    }
1587 1587
 
1588
-  $db_info['columns'] = (array) $field['columns'];
1589
-  // Generate column names for this field from generic column names.
1590
-  foreach ($db_info['columns'] as $column_name => $attributes) {
1588
+    $db_info['columns'] = (array) $field['columns'];
1589
+    // Generate column names for this field from generic column names.
1590
+    foreach ($db_info['columns'] as $column_name => $attributes) {
1591 1591
     $db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
1592
-  }
1592
+    }
1593 1593
 
1594
-  return $db_info;
1594
+    return $db_info;
1595 1595
 }
1596 1596
 
1597 1597
 /**
1598 1598
  * Helper function for identifying the storage type for a field.
1599 1599
  */
1600 1600
 function content_storage_type($field) {
1601
-  if ($field['multiple'] > 0) {
1601
+    if ($field['multiple'] > 0) {
1602 1602
     return CONTENT_DB_STORAGE_PER_FIELD;
1603
-  }
1604
-  else {
1603
+    }
1604
+    else {
1605 1605
     module_load_include('inc', 'content', 'includes/content.crud');
1606 1606
     $instances = content_field_instance_read(array('field_name' => $field['field_name']));
1607 1607
     if (count($instances) > 1) {
1608
-      return CONTENT_DB_STORAGE_PER_FIELD;
1608
+        return CONTENT_DB_STORAGE_PER_FIELD;
1609
+    }
1609 1610
     }
1610
-  }
1611
-  return CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
1611
+    return CONTENT_DB_STORAGE_PER_CONTENT_TYPE;
1612 1612
 }
1613 1613
 
1614 1614
 /**
@@ -1625,20 +1625,20 @@  discard block
 block discarded – undo
1625 1625
  *   The transposed array.
1626 1626
  */
1627 1627
 function content_transpose_array_rows_cols($array) {
1628
-  $result = array();
1629
-  if (is_array($array)) {
1628
+    $result = array();
1629
+    if (is_array($array)) {
1630 1630
     foreach ($array as $key1 => $value1) {
1631
-      if (is_array($value1)) {
1631
+        if (is_array($value1)) {
1632 1632
         foreach ($value1 as $key2 => $value2) {
1633
-          if (!isset($result[$key2])) {
1633
+            if (!isset($result[$key2])) {
1634 1634
             $result[$key2] = array();
1635
-          }
1636
-          $result[$key2][$key1] = $value2;
1635
+            }
1636
+            $result[$key2][$key1] = $value2;
1637 1637
         }
1638
-      }
1638
+        }
1639
+    }
1639 1640
     }
1640
-  }
1641
-  return $result;
1641
+    return $result;
1642 1642
 }
1643 1643
 
1644 1644
 /**
@@ -1650,18 +1650,18 @@  discard block
 block discarded – undo
1650 1650
  *   A flattened array.
1651 1651
  */
1652 1652
 function content_array_flatten($array) {
1653
-  $result = array();
1654
-  if (is_array($array)) {
1653
+    $result = array();
1654
+    if (is_array($array)) {
1655 1655
     foreach ($array as $key => $value) {
1656
-      if (is_array($value)) {
1656
+        if (is_array($value)) {
1657 1657
         $result += content_array_flatten($value);
1658
-      }
1659
-      else {
1658
+        }
1659
+        else {
1660 1660
         $result[$key] = $value;
1661
-      }
1661
+        }
1662
+    }
1662 1663
     }
1663
-  }
1664
-  return $result;
1664
+    return $result;
1665 1665
 }
1666 1666
 
1667 1667
 /**
@@ -1680,46 +1680,46 @@  discard block
 block discarded – undo
1680 1680
  *   when allowed values list is generated using PHP code.
1681 1681
  */
1682 1682
 function content_allowed_values($field, $flatten = TRUE) {
1683
-  static $allowed_values;
1683
+    static $allowed_values;
1684 1684
 
1685
-  $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1686
-  if (isset($allowed_values[$cid])) {
1685
+    $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1686
+    if (isset($allowed_values[$cid])) {
1687 1687
     return $allowed_values[$cid];
1688
-  }
1688
+    }
1689 1689
 
1690
-  $allowed_values[$cid] = array();
1690
+    $allowed_values[$cid] = array();
1691 1691
 
1692
-  if (isset($field['allowed_values_php'])) {
1692
+    if (isset($field['allowed_values_php'])) {
1693 1693
     ob_start();
1694 1694
     $result = eval($field['allowed_values_php']);
1695 1695
     if (is_array($result)) {
1696
-      if ($flatten) {
1696
+        if ($flatten) {
1697 1697
         $result = content_array_flatten($result);
1698
-      }
1699
-      $allowed_values[$cid] = $result;
1698
+        }
1699
+        $allowed_values[$cid] = $result;
1700 1700
     }
1701 1701
     ob_end_clean();
1702
-  }
1702
+    }
1703 1703
 
1704
-  if (empty($allowed_values[$cid]) && isset($field['allowed_values'])) {
1704
+    if (empty($allowed_values[$cid]) && isset($field['allowed_values'])) {
1705 1705
     $list = explode("\n", $field['allowed_values']);
1706 1706
     $list = array_map('trim', $list);
1707 1707
     $list = array_filter($list, 'strlen');
1708 1708
     foreach ($list as $opt) {
1709
-      // Sanitize the user input with a permissive filter.
1710
-      $opt = content_filter_xss($opt);
1711
-      if (strpos($opt, '|') !== FALSE) {
1709
+        // Sanitize the user input with a permissive filter.
1710
+        $opt = content_filter_xss($opt);
1711
+        if (strpos($opt, '|') !== FALSE) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713 1713
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714
-      }
1715
-      else {
1714
+        }
1715
+        else {
1716 1716
         $allowed_values[$cid][$opt] = $opt;
1717
-      }
1717
+        }
1718 1718
     }
1719 1719
     // Allow external modules to translate allowed values list.
1720 1720
     drupal_alter('content_allowed_values', $allowed_values[$cid], $field);
1721
-  }
1722
-  return $allowed_values[$cid];
1721
+    }
1722
+    return $allowed_values[$cid];
1723 1723
 }
1724 1724
 
1725 1725
 /**
@@ -1730,14 +1730,14 @@  discard block
 block discarded – undo
1730 1730
  * @see content_handler_filter_many_to_one::allowed_values()
1731 1731
  */
1732 1732
 function content_allowed_values_filter_html(&$options) {
1733
-  foreach ($options as $key => $opt) {
1733
+    foreach ($options as $key => $opt) {
1734 1734
     if (is_array($opt)) {
1735
-      content_allowed_values_filter_html($options[$key]);
1735
+        content_allowed_values_filter_html($options[$key]);
1736 1736
     }
1737 1737
     else {
1738
-      $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1738
+        $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1739
+    }
1739 1740
     }
1740
-  }
1741 1741
 }
1742 1742
 
1743 1743
 /**
@@ -1748,21 +1748,21 @@  discard block
 block discarded – undo
1748 1748
  * (so check_plain() is not acceptable).
1749 1749
  */
1750 1750
 function content_filter_xss($string) {
1751
-  return filter_xss($string, _content_filter_xss_allowed_tags());
1751
+    return filter_xss($string, _content_filter_xss_allowed_tags());
1752 1752
 }
1753 1753
 
1754 1754
 /**
1755 1755
  * List of tags allowed by content_filter_xss().
1756 1756
  */
1757 1757
 function _content_filter_xss_allowed_tags() {
1758
-  return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1758
+    return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1759 1759
 }
1760 1760
 
1761 1761
 /**
1762 1762
  * Human-readable list of allowed tags, for display in help texts.
1763 1763
  */
1764 1764
 function _content_filter_xss_display_allowed_tags() {
1765
-  return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1765
+    return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1766 1766
 }
1767 1767
 
1768 1768
 /**
@@ -1790,52 +1790,52 @@  discard block
 block discarded – undo
1790 1790
  *   functions as necessary.
1791 1791
  */
1792 1792
 function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
1793
-  if (!is_array($field)) {
1793
+    if (!is_array($field)) {
1794 1794
     $field = content_fields($field);
1795
-  }
1795
+    }
1796 1796
 
1797
-  if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1797
+    if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798 1798
     $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1799 1799
 
1800 1800
     $element = array(
1801
-      '#theme' => $theme,
1802
-      '#field_name' => $field['field_name'],
1803
-      '#type_name' => isset($node->type) ? $node->type :'',
1804
-      '#formatter' => $formatter_name,
1805
-      '#node' => $node,
1806
-      '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1801
+        '#theme' => $theme,
1802
+        '#field_name' => $field['field_name'],
1803
+        '#type_name' => isset($node->type) ? $node->type :'',
1804
+        '#formatter' => $formatter_name,
1805
+        '#node' => $node,
1806
+        '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1807 1807
     );
1808 1808
 
1809 1809
     if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {
1810
-      // Single value formatter.
1810
+        // Single value formatter.
1811 1811
 
1812
-      // hook_field('sanitize') expects an array of items, so we build one.
1813
-      $items = array($item);
1814
-      $function = $field['module'] .'_field';
1815
-      if (function_exists($function)) {
1812
+        // hook_field('sanitize') expects an array of items, so we build one.
1813
+        $items = array($item);
1814
+        $function = $field['module'] .'_field';
1815
+        if (function_exists($function)) {
1816 1816
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1817
-      }
1817
+        }
1818 1818
 
1819
-      $element['#item'] = $items[0];
1819
+        $element['#item'] = $items[0];
1820 1820
     }
1821 1821
     else {
1822
-      // Multiple values formatter.
1823
-      $items = $item;
1824
-      $function = $field['module'] .'_field';
1825
-      if (function_exists($function)) {
1822
+        // Multiple values formatter.
1823
+        $items = $item;
1824
+        $function = $field['module'] .'_field';
1825
+        if (function_exists($function)) {
1826 1826
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1827
-      }
1827
+        }
1828 1828
 
1829
-      foreach ($items as $delta => $item) {
1829
+        foreach ($items as $delta => $item) {
1830 1830
         $element[$delta] = array(
1831
-          '#item' => $item,
1832
-          '#weight' => $delta,
1831
+            '#item' => $item,
1832
+            '#weight' => $delta,
1833 1833
         );
1834
-      }
1834
+        }
1835 1835
     }
1836 1836
 
1837 1837
     return theme($theme, $element);
1838
-  }
1838
+    }
1839 1839
 }
1840 1840
 
1841 1841
 /**
@@ -1851,31 +1851,31 @@  discard block
 block discarded – undo
1851 1851
  *   - a string tab id: the build modes in this tab.
1852 1852
  */
1853 1853
 function content_build_modes($selector = NULL) {
1854
-  static $info;
1854
+    static $info;
1855 1855
 
1856
-  if (!isset($info)) {
1856
+    if (!isset($info)) {
1857 1857
     $data = array();
1858 1858
     foreach (module_implements('content_build_modes') as $module) {
1859
-      $function = $module .'_content_build_modes';
1860
-      $data = array_merge($data, (array) $function());
1859
+        $function = $module .'_content_build_modes';
1860
+        $data = array_merge($data, (array) $function());
1861 1861
     }
1862 1862
     $flat = array();
1863 1863
     foreach ($data as $tab) {
1864
-      // Use the + operator to preserve numeric indexes (core build modes).
1865
-      $flat += (array) $tab['build modes'];
1864
+        // Use the + operator to preserve numeric indexes (core build modes).
1865
+        $flat += (array) $tab['build modes'];
1866 1866
     }
1867 1867
     $info = array('tabs' => $data, 'build modes' => $flat);
1868
-  }
1868
+    }
1869 1869
 
1870
-  if ($selector === '_tabs') {
1870
+    if ($selector === '_tabs') {
1871 1871
     return $info['tabs'];
1872
-  }
1873
-  elseif (isset($selector) && isset($info['tabs'][$selector])) {
1872
+    }
1873
+    elseif (isset($selector) && isset($info['tabs'][$selector])) {
1874 1874
     return isset($info['tabs'][$selector]) ? $info['tabs'][$selector]['build modes'] : array();
1875
-  }
1876
-  else {
1875
+    }
1876
+    else {
1877 1877
     return $info['build modes'];
1878
-  }
1878
+    }
1879 1879
 }
1880 1880
 
1881 1881
 /**
@@ -1914,60 +1914,60 @@  discard block
 block discarded – undo
1914 1914
  * );
1915 1915
  */
1916 1916
 function node_content_build_modes() {
1917
-  return array(
1917
+    return array(
1918 1918
     'basic' => array(
1919
-      'title' => t('Basic'),
1920
-      'build modes' => array(
1919
+        'title' => t('Basic'),
1920
+        'build modes' => array(
1921 1921
         'teaser' => array(
1922
-          'title' => t('Teaser'),
1923
-          'views style' => TRUE,
1922
+            'title' => t('Teaser'),
1923
+            'views style' => TRUE,
1924 1924
         ),
1925 1925
         'full' => array(
1926
-          'title' => t('Full node'),
1927
-          'views style' => TRUE,
1926
+            'title' => t('Full node'),
1927
+            'views style' => TRUE,
1928
+        ),
1928 1929
         ),
1929
-      ),
1930 1930
     ),
1931 1931
     'rss' => array(
1932
-      'title' => t('RSS'),
1933
-      'build modes' => array(
1932
+        'title' => t('RSS'),
1933
+        'build modes' => array(
1934 1934
         NODE_BUILD_RSS => array(
1935
-          'title' => t('RSS'),
1936
-          'views style' => FALSE,
1935
+            'title' => t('RSS'),
1936
+            'views style' => FALSE,
1937
+        ),
1937 1938
         ),
1938
-      ),
1939 1939
     ),
1940
-  );
1940
+    );
1941 1941
 }
1942 1942
 function search_content_build_modes() {
1943
-  return array(
1943
+    return array(
1944 1944
     'search' => array(
1945
-      'title' => t('Search'),
1946
-      'build modes' => array(
1945
+        'title' => t('Search'),
1946
+        'build modes' => array(
1947 1947
         NODE_BUILD_SEARCH_INDEX => array(
1948
-          'title' => t('Search Index'),
1949
-          'views style' => FALSE,
1948
+            'title' => t('Search Index'),
1949
+            'views style' => FALSE,
1950 1950
         ),
1951 1951
         NODE_BUILD_SEARCH_RESULT => array(
1952
-          'title' => t('Search Result'),
1953
-          'views style' => FALSE,
1952
+            'title' => t('Search Result'),
1953
+            'views style' => FALSE,
1954
+        ),
1954 1955
         ),
1955
-      ),
1956 1956
     ),
1957
-  );
1957
+    );
1958 1958
 }
1959 1959
 function book_content_build_modes() {
1960
-  return array(
1960
+    return array(
1961 1961
     'print' => array(
1962
-      'title' => t('Print'),
1963
-      'build modes' => array(
1962
+        'title' => t('Print'),
1963
+        'build modes' => array(
1964 1964
         NODE_BUILD_PRINT => array(
1965
-          'title' => t('Print'),
1966
-          'views style' => TRUE,
1965
+            'title' => t('Print'),
1966
+            'views style' => TRUE,
1967
+        ),
1967 1968
         ),
1968
-      ),
1969 1969
     ),
1970
-  );
1970
+    );
1971 1971
 }
1972 1972
 
1973 1973
 /**
@@ -1981,19 +1981,19 @@  discard block
 block discarded – undo
1981 1981
  *   A string containing the generated name for the database table
1982 1982
  */
1983 1983
 function _content_tablename($name, $storage, $version = NULL) {
1984
-  if (is_null($version)) {
1984
+    if (is_null($version)) {
1985 1985
     $version = variable_get('content_schema_version', 0);
1986
-  }
1986
+    }
1987 1987
 
1988
-  if ($version < 1003) {
1988
+    if ($version < 1003) {
1989 1989
     $version = 0;
1990
-  }
1991
-  else {
1990
+    }
1991
+    else {
1992 1992
     $version = 1003;
1993
-  }
1993
+    }
1994 1994
 
1995
-  $name = str_replace('-', '_', $name);
1996
-  switch ("$version-$storage") {
1995
+    $name = str_replace('-', '_', $name);
1996
+    switch ("$version-$storage") {
1997 1997
     case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998 1998
       return "node_$name";
1999 1999
     case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
@@ -2002,7 +2002,7 @@  discard block
 block discarded – undo
2002 2002
       return "content_type_$name";
2003 2003
     case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004 2004
       return "content_$name";
2005
-  }
2005
+    }
2006 2006
 }
2007 2007
 
2008 2008
 /**
@@ -2014,10 +2014,10 @@  discard block
 block discarded – undo
2014 2014
  * with 'content_field'.
2015 2015
  */
2016 2016
 function content_field_tablename($version = NULL) {
2017
-  if (is_null($version)) {
2017
+    if (is_null($version)) {
2018 2018
     $version = variable_get('content_schema_version', 0);
2019
-  }
2020
-  return $version < 6001 ? 'node_field' : 'content_node_field';
2019
+    }
2020
+    return $version < 6001 ? 'node_field' : 'content_node_field';
2021 2021
 }
2022 2022
 
2023 2023
 /**
@@ -2026,10 +2026,10 @@  discard block
 block discarded – undo
2026 2026
  * Needed because the table name changes depending on version.
2027 2027
  */
2028 2028
 function content_instance_tablename($version = NULL) {
2029
-  if (is_null($version)) {
2029
+    if (is_null($version)) {
2030 2030
     $version = variable_get('content_schema_version', 0);
2031
-  }
2032
-  return $version < 6001 ? 'node_field_instance' : 'content_node_field_instance';
2031
+    }
2032
+    return $version < 6001 ? 'node_field_instance' : 'content_node_field_instance';
2033 2033
 }
2034 2034
 
2035 2035
 /**
@@ -2040,12 +2040,12 @@  discard block
 block discarded – undo
2040 2040
  * update 6000 runs, so the cache table will be used instead.
2041 2041
  */
2042 2042
 function content_cache_tablename() {
2043
-  if (variable_get('content_schema_version', -1) < 6000) {
2043
+    if (variable_get('content_schema_version', -1) < 6000) {
2044 2044
     return 'cache';
2045
-  }
2046
-  else {
2045
+    }
2046
+    else {
2047 2047
     return 'cache_content';
2048
-  }
2048
+    }
2049 2049
 }
2050 2050
 
2051 2051
 /**
@@ -2056,45 +2056,45 @@  discard block
 block discarded – undo
2056 2056
  * otherwise the function will return the whole thing.
2057 2057
  */
2058 2058
 function content_table_schema($field = NULL) {
2059
-  $schema = array(
2059
+    $schema = array(
2060 2060
     'fields' => array(
2061
-      'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
-      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2061
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2063 2063
     ),
2064 2064
     'primary key' => array('vid'),
2065 2065
     'indexes' => array(
2066
-      'nid'    => array('nid'),
2066
+        'nid'    => array('nid'),
2067 2067
     ),
2068
-  );
2068
+    );
2069 2069
 
2070
-  // Add delta column if needed.
2071
-  if (!empty($field['multiple'])) {
2070
+    // Add delta column if needed.
2071
+    if (!empty($field['multiple'])) {
2072 2072
     $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0);
2073 2073
     $schema['primary key'][] = 'delta';
2074
-  }
2075
-  $schema['content fields'] = array();
2074
+    }
2075
+    $schema['content fields'] = array();
2076 2076
 
2077
-  // Add field columns column if needed.
2078
-  // This function is called from install files where it is not safe
2079
-  // to use content_fields() or content_database_info(), so we
2080
-  // just used the column values stored in the $field.
2081
-  // We also need the schema to include fields from disabled modules
2082
-  // or there will be no way to delete those fields.
2077
+    // Add field columns column if needed.
2078
+    // This function is called from install files where it is not safe
2079
+    // to use content_fields() or content_database_info(), so we
2080
+    // just used the column values stored in the $field.
2081
+    // We also need the schema to include fields from disabled modules
2082
+    // or there will be no way to delete those fields.
2083 2083
 
2084
-  if (!empty($field['columns'])) {
2084
+    if (!empty($field['columns'])) {
2085 2085
     foreach ($field['columns'] as $column => $attributes) {
2086
-      $column_name =  $field['field_name'] .'_'. $column;
2087
-      if (isset($attributes['index']) && $attributes['index']) {
2086
+        $column_name =  $field['field_name'] .'_'. $column;
2087
+        if (isset($attributes['index']) && $attributes['index']) {
2088 2088
         $schema['indexes'][$column_name] = array($column_name);
2089 2089
         unset($attributes['index']);
2090
-      }
2091
-      unset($attributes['column']);
2092
-      unset($attributes['sortable']);
2093
-      $schema['fields'][$column_name] = $attributes;
2090
+        }
2091
+        unset($attributes['column']);
2092
+        unset($attributes['sortable']);
2093
+        $schema['fields'][$column_name] = $attributes;
2094 2094
     }
2095 2095
     $schema['content fields'][] = $field['field_name'];
2096
-  }
2097
-  return $schema;
2096
+    }
2097
+    return $schema;
2098 2098
 }
2099 2099
 
2100 2100
 /**
@@ -2112,26 +2112,26 @@  discard block
 block discarded – undo
2112 2112
  *   TRUE if the table exists. Otherwise FALSE.
2113 2113
  */
2114 2114
 function content_db_index_exists($table, $name) {
2115
-  global $db_type;
2116
-  if ($db_type == 'mysql' || $db_type == 'mysqli') {
2115
+    global $db_type;
2116
+    if ($db_type == 'mysql' || $db_type == 'mysqli') {
2117 2117
     if (version_compare(db_version(), '5.0.3') < 0) {
2118
-      // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
-      $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120
-      while ($row = db_fetch_array($result)) {
2118
+        // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
+        $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120
+        while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122
-          return TRUE;
2122
+            return TRUE;
2123
+        }
2123 2124
         }
2124
-      }
2125
-      return FALSE;
2125
+        return FALSE;
2126 2126
     }
2127 2127
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128
-  }
2129
-  elseif ($db_type == 'pgsql') {
2128
+    }
2129
+    elseif ($db_type == 'pgsql') {
2130 2130
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2131
     // the table name and suffixed by '_idx'.
2132 2132
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2133
-  }
2134
-  return FALSE;
2133
+    }
2134
+    return FALSE;
2135 2135
 }
2136 2136
 
2137 2137
 /**
@@ -2152,15 +2152,15 @@  discard block
 block discarded – undo
2152 2152
  *
2153 2153
  */
2154 2154
 function content_callback($entity, $op, $field) {
2155
-  switch ($entity) {
2155
+    switch ($entity) {
2156 2156
     case 'field':
2157 2157
       $info = module_invoke($field['module'], "field_info");
2158
-      return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2158
+        return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2159 2159
 
2160 2160
     case 'widget':
2161 2161
       $info = module_invoke($field['widget']['module'], "widget_info");
2162
-      return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163
-  }
2162
+        return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163
+    }
2164 2164
 }
2165 2165
 
2166 2166
 /**
@@ -2182,20 +2182,20 @@  discard block
 block discarded – undo
2182 2182
  *    CONTENT_HANDLE_MODULE  - the implementing module handles this operation.
2183 2183
  */
2184 2184
 function content_handle($entity, $op, $object) {
2185
-  switch ($entity) {
2185
+    switch ($entity) {
2186 2186
     case 'field':
2187 2187
       $info = module_invoke($object['module'], "field_info");
2188
-      return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2188
+        return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189 2189
 
2190 2190
     case 'widget':
2191 2191
       $info = module_invoke($object['widget']['module'], "widget_info");
2192
-      return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2192
+        return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193 2193
 
2194 2194
     case 'formatter':
2195 2195
       // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196 2196
       // We let content_handle deal with them only for code consistency.
2197 2197
       return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2198
-  }
2198
+    }
2199 2199
 }
2200 2200
 
2201 2201
 /**
@@ -2211,22 +2211,22 @@  discard block
 block discarded – undo
2211 2211
  *    The default value for that field.
2212 2212
  */
2213 2213
 function content_default_value(&$form, &$form_state, $field, $delta) {
2214
-  $widget_types = _content_widget_types();
2215
-  $module = $widget_types[$field['widget']['type']]['module'];
2214
+    $widget_types = _content_widget_types();
2215
+    $module = $widget_types[$field['widget']['type']]['module'];
2216 2216
 
2217
-  $default_value = array();
2218
-  if (!empty($field['widget']['default_value_php'])) {
2217
+    $default_value = array();
2218
+    if (!empty($field['widget']['default_value_php'])) {
2219 2219
     ob_start();
2220 2220
     $result = eval($field['widget']['default_value_php']);
2221 2221
     ob_end_clean();
2222 2222
     if (is_array($result)) {
2223
-      $default_value = $result;
2223
+        $default_value = $result;
2224
+    }
2224 2225
     }
2225
-  }
2226
-  elseif (!empty($field['widget']['default_value'])) {
2226
+    elseif (!empty($field['widget']['default_value'])) {
2227 2227
     $default_value = $field['widget']['default_value'];
2228
-  }
2229
-  return (array) $default_value;
2228
+    }
2229
+    return (array) $default_value;
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2247,33 +2247,33 @@  discard block
 block discarded – undo
2247 2247
  *   FALSE if the operation is denied.
2248 2248
  */
2249 2249
 function content_access($op, $field, $account = NULL, $node = NULL) {
2250
-  global $user;
2250
+    global $user;
2251 2251
 
2252
-  if (is_null($account)) {
2252
+    if (is_null($account)) {
2253 2253
     $account = $user;
2254
-  }
2255
-  // Check for valid field data.
2256
-  if (!isset($field['field_name'])) {
2254
+    }
2255
+    // Check for valid field data.
2256
+    if (!isset($field['field_name'])) {
2257 2257
     return FALSE;
2258
-  }
2259
-  $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260
-  foreach ($access as $value) {
2258
+    }
2259
+    $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260
+    foreach ($access as $value) {
2261 2261
     if ($value === FALSE) {
2262
-      return FALSE;
2262
+        return FALSE;
2263
+    }
2263 2264
     }
2264
-  }
2265
-  return TRUE;
2265
+    return TRUE;
2266 2266
 }
2267 2267
 
2268
- /**
2269
- * Hide specified fields from the $content variable in node templates.
2270
- */
2268
+    /**
2269
+     * Hide specified fields from the $content variable in node templates.
2270
+     */
2271 2271
 function content_field_wrapper_post_render($content, $element) {
2272
-  $field = content_fields($element['#field_name'], $element['#type_name']);
2273
-  if (theme('content_exclude', $content, $field, $element['#context'])) {
2272
+    $field = content_fields($element['#field_name'], $element['#type_name']);
2273
+    if (theme('content_exclude', $content, $field, $element['#context'])) {
2274 2274
     return '';
2275
-  }
2276
-  return $content;
2275
+    }
2276
+    return $content;
2277 2277
 }
2278 2278
 
2279 2279
 
@@ -2329,17 +2329,17 @@  discard block
 block discarded – undo
2329 2329
  *   as set on the Manage fields screen.
2330 2330
  */
2331 2331
 function theme_content_exclude($content, $object, $context) {
2332
-  // The field may be missing info for $contexts added by modules
2333
-  // enabled after the field was last edited.
2334
-  if (empty($object['display_settings'])
2332
+    // The field may be missing info for $contexts added by modules
2333
+    // enabled after the field was last edited.
2334
+    if (empty($object['display_settings'])
2335 2335
     || empty($object['display_settings'][$context])
2336 2336
     || !is_array($object['display_settings'][$context])
2337 2337
     || empty($object['display_settings'][$context]['exclude'])) {
2338 2338
     return FALSE;
2339
-  }
2340
-  else {
2339
+    }
2340
+    else {
2341 2341
     return TRUE;
2342
-  }
2342
+    }
2343 2343
 }
2344 2344
 
2345 2345
 /**
@@ -2358,48 +2358,48 @@  discard block
 block discarded – undo
2358 2358
  * doesn't get called when the theme overrides the template. Bug in theme layer ?
2359 2359
  */
2360 2360
 function template_preprocess_content_field(&$variables) {
2361
-  $element = $variables['element'];
2362
-  $field = content_fields($element['#field_name'], $element['#node']->type);
2361
+    $element = $variables['element'];
2362
+    $field = content_fields($element['#field_name'], $element['#node']->type);
2363 2363
 
2364
-  $variables['node'] = $element['#node'];
2365
-  $variables['field'] = $field;
2366
-  $variables['items'] = array();
2364
+    $variables['node'] = $element['#node'];
2365
+    $variables['field'] = $field;
2366
+    $variables['items'] = array();
2367 2367
 
2368
-  if ($element['#single']) {
2368
+    if ($element['#single']) {
2369 2369
     // Single value formatter.
2370 2370
     foreach (element_children($element['items']) as $delta) {
2371
-      $variables['items'][$delta] = $element['items'][$delta]['#item'];
2372
-      // Use isset() to avoid undefined index message on #children when field values are empty.
2373
-      $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2371
+        $variables['items'][$delta] = $element['items'][$delta]['#item'];
2372
+        // Use isset() to avoid undefined index message on #children when field values are empty.
2373
+        $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2374
     }
2375
-  }
2376
-  else  {
2375
+    }
2376
+    else  {
2377 2377
     // Multiple values formatter.
2378 2378
     // We display the 'all items' output as $items[0], as if it was the
2379 2379
     // output of a single valued field.
2380 2380
     // Raw values are still exposed for all items.
2381 2381
     foreach (element_children($element['items']) as $delta) {
2382
-      $variables['items'][$delta] = $element['items'][$delta]['#item'];
2382
+        $variables['items'][$delta] = $element['items'][$delta]['#item'];
2383 2383
     }
2384 2384
     $variables['items'][0]['view'] = $element['items']['#children'];
2385
-  }
2385
+    }
2386 2386
 
2387
-  $variables['teaser'] = $element['#teaser'];
2388
-  $variables['page'] = $element['#page'];
2387
+    $variables['teaser'] = $element['#teaser'];
2388
+    $variables['page'] = $element['#page'];
2389 2389
 
2390
-  $field_empty = TRUE;
2390
+    $field_empty = TRUE;
2391 2391
 
2392
-  foreach ($variables['items'] as $delta => $item) {
2392
+    foreach ($variables['items'] as $delta => $item) {
2393 2393
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394
-      $variables['items'][$delta]['empty'] = TRUE;
2394
+        $variables['items'][$delta]['empty'] = TRUE;
2395 2395
     }
2396 2396
     else {
2397
-      $field_empty = FALSE;
2398
-      $variables['items'][$delta]['empty'] = FALSE;
2397
+        $field_empty = FALSE;
2398
+        $variables['items'][$delta]['empty'] = FALSE;
2399
+    }
2399 2400
     }
2400
-  }
2401 2401
 
2402
-  $additions = array(
2402
+    $additions = array(
2403 2403
     'field_type' => $field['type'],
2404 2404
     'field_name' => $field['field_name'],
2405 2405
     'field_type_css' => strtr($field['type'], '_', '-'),
@@ -2408,13 +2408,13 @@  discard block
 block discarded – undo
2408 2408
     'label_display' => $element['#label_display'],
2409 2409
     'field_empty' => $field_empty,
2410 2410
     'template_files' => array(
2411
-      'content-field',
2412
-      'content-field-'. $element['#field_name'],
2413
-      'content-field-'. $element['#node']->type,
2414
-      'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2411
+        'content-field',
2412
+        'content-field-'. $element['#field_name'],
2413
+        'content-field-'. $element['#node']->type,
2414
+        'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2415 2415
     ),
2416
-  );
2417
-  $variables = array_merge($variables, $additions);
2416
+    );
2417
+    $variables = array_merge($variables, $additions);
2418 2418
 }
2419 2419
 
2420 2420
 /**
@@ -2425,8 +2425,8 @@  discard block
 block discarded – undo
2425 2425
  * - Adds the formatted values in the 'view' key of the items.
2426 2426
  */
2427 2427
 function content_preprocess_node(&$vars) {
2428
-  $additions = _content_field_invoke_default('preprocess_node', $vars['node']);
2429
-  $vars = array_merge($vars, $additions);
2428
+    $additions = _content_field_invoke_default('preprocess_node', $vars['node']);
2429
+    $vars = array_merge($vars, $additions);
2430 2430
 }
2431 2431
 
2432 2432
 /**
@@ -2438,10 +2438,10 @@  discard block
 block discarded – undo
2438 2438
  * @param $field
2439 2439
  */
2440 2440
 function content_content_fieldapi($op, $field) {
2441
-  if (module_exists('devel')) {
2441
+    if (module_exists('devel')) {
2442 2442
     //dsm($op);
2443 2443
     //dsm($field);
2444
-  }
2444
+    }
2445 2445
 }
2446 2446
 
2447 2447
 /**
@@ -2450,115 +2450,115 @@  discard block
 block discarded – undo
2450 2450
  * Informations for non-CCK 'node fields' defined in core.
2451 2451
  */
2452 2452
 function content_content_extra_fields($type_name) {
2453
-  $type = node_get_types('type', $type_name);
2454
-  $extra = array();
2453
+    $type = node_get_types('type', $type_name);
2454
+    $extra = array();
2455 2455
 
2456
-  if ($type->has_title) {
2456
+    if ($type->has_title) {
2457 2457
     $extra['title'] = array(
2458
-      'label' => $type->title_label,
2459
-      'description' => t('Node module form.'),
2460
-      'weight' => -5
2458
+        'label' => $type->title_label,
2459
+        'description' => t('Node module form.'),
2460
+        'weight' => -5
2461 2461
     );
2462
-  }
2463
-  if ($type->has_body) {
2462
+    }
2463
+    if ($type->has_body) {
2464 2464
     $extra['body_field'] = array(
2465
-      'label' => $type->body_label,
2466
-      'description' => t('Node module form.'),
2467
-      'weight' => 0,
2468
-      'view' => 'body'
2465
+        'label' => $type->body_label,
2466
+        'description' => t('Node module form.'),
2467
+        'weight' => 0,
2468
+        'view' => 'body'
2469 2469
     );
2470
-  }
2471
-  $extra['revision_information'] = array(
2470
+    }
2471
+    $extra['revision_information'] = array(
2472 2472
     'label' => t('Revision information'),
2473 2473
     'description' => t('Node module form.'),
2474 2474
     'weight' => 20
2475
-  );
2476
-  $extra['author'] = array(
2475
+    );
2476
+    $extra['author'] = array(
2477 2477
     'label' => t('Authoring information'),
2478 2478
     'description' => t('Node module form.'),
2479 2479
     'weight' => 20,
2480
-  );
2481
-  $extra['options'] = array(
2480
+    );
2481
+    $extra['options'] = array(
2482 2482
     'label' => t('Publishing options'),
2483 2483
     'description' => t('Node module form.'),
2484 2484
     'weight' => 25,
2485
-   );
2486
-  if (module_exists('comment')) {
2485
+    );
2486
+    if (module_exists('comment')) {
2487 2487
     $extra['comment_settings'] = array(
2488
-      'label' => t('Comment settings'),
2489
-      'description' => t('Comment module form.'),
2490
-      'weight' => 30
2488
+        'label' => t('Comment settings'),
2489
+        'description' => t('Comment module form.'),
2490
+        'weight' => 30
2491 2491
     );
2492
-  }
2493
-  if (module_exists('locale') && variable_get("language_content_type_$type_name", 0)) {
2492
+    }
2493
+    if (module_exists('locale') && variable_get("language_content_type_$type_name", 0)) {
2494 2494
     $extra['language'] = array(
2495
-      'label' => t('Language'),
2496
-      'description' => t('Locale module form.'),
2497
-      'weight' => 0
2495
+        'label' => t('Language'),
2496
+        'description' => t('Locale module form.'),
2497
+        'weight' => 0
2498 2498
     );
2499
-  }
2500
-  if (module_exists('translation') && translation_supported_type($type_name)) {
2499
+    }
2500
+    if (module_exists('translation') && translation_supported_type($type_name)) {
2501 2501
     $extra['translation'] = array(
2502
-      'label' => t('Translation settings'),
2503
-      'description' => t('Translation module form.'),
2504
-      'weight' => 30
2502
+        'label' => t('Translation settings'),
2503
+        'description' => t('Translation module form.'),
2504
+        'weight' => 30
2505 2505
     );
2506
-  }
2507
-  if (module_exists('menu')) {
2506
+    }
2507
+    if (module_exists('menu')) {
2508 2508
     $extra['menu'] = array(
2509
-      'label' => t('Menu settings'),
2510
-      'description' => t('Menu module form.'),
2511
-      'weight' => -2
2509
+        'label' => t('Menu settings'),
2510
+        'description' => t('Menu module form.'),
2511
+        'weight' => -2
2512 2512
     );
2513
-  }
2514
-  if (module_exists('taxonomy') && taxonomy_get_vocabularies($type_name)) {
2513
+    }
2514
+    if (module_exists('taxonomy') && taxonomy_get_vocabularies($type_name)) {
2515 2515
     $extra['taxonomy'] = array(
2516
-      'label' => t('Taxonomy'),
2517
-      'description' => t('Taxonomy module form.'),
2518
-      'weight' => -3
2516
+        'label' => t('Taxonomy'),
2517
+        'description' => t('Taxonomy module form.'),
2518
+        'weight' => -3
2519 2519
     );
2520
-  }
2521
-  if (module_exists('book')) {
2520
+    }
2521
+    if (module_exists('book')) {
2522 2522
     $extra['book'] = array(
2523
-      'label' => t('Book'),
2524
-      'description' => t('Book module form.'),
2525
-      'weight' => 10
2523
+        'label' => t('Book'),
2524
+        'description' => t('Book module form.'),
2525
+        'weight' => 10
2526 2526
     );
2527
-  }
2528
-  if (module_exists('path')) {
2527
+    }
2528
+    if (module_exists('path')) {
2529 2529
     $extra['path'] = array(
2530
-      'label' => t('Path settings'),
2531
-      'description' => t('Path module form.'),
2532
-      'weight' => 30
2530
+        'label' => t('Path settings'),
2531
+        'description' => t('Path module form.'),
2532
+        'weight' => 30
2533 2533
     );
2534
-  }
2535
-  if ($type_name == 'poll' && module_exists('poll')) {
2534
+    }
2535
+    if ($type_name == 'poll' && module_exists('poll')) {
2536 2536
     $extra['title'] = array(
2537
-      'label' => t('Poll title'),
2538
-      'description' => t('Poll module title.'),
2539
-      'weight' => -5
2537
+        'label' => t('Poll title'),
2538
+        'description' => t('Poll module title.'),
2539
+        'weight' => -5
2540 2540
     );
2541 2541
     $extra['choice_wrapper'] = array(
2542
-      'label' => t('Poll choices'),
2543
-      'description' => t('Poll module choices.'),
2544
-      'weight' => -4
2542
+        'label' => t('Poll choices'),
2543
+        'description' => t('Poll module choices.'),
2544
+        'weight' => -4
2545 2545
     );
2546 2546
     $extra['settings'] = array(
2547
-      'label' => t('Poll settings'),
2548
-      'description' => t('Poll module settings.'),
2549
-      'weight' => -3
2547
+        'label' => t('Poll settings'),
2548
+        'description' => t('Poll module settings.'),
2549
+        'weight' => -3
2550 2550
     );
2551
-  }
2552
-  if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2551
+    }
2552
+    if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2553 2553
     $extra['attachments'] = array(
2554
-      'label' => t('File attachments'),
2555
-      'description' => t('Upload module form.'),
2556
-      'weight' => 30,
2557
-      'view' => 'files'
2554
+        'label' => t('File attachments'),
2555
+        'description' => t('Upload module form.'),
2556
+        'weight' => 30,
2557
+        'view' => 'files'
2558 2558
     );
2559
-  }
2559
+    }
2560 2560
 
2561
-  return $extra;
2561
+    return $extra;
2562 2562
 }
2563 2563
 
2564 2564
 /**
@@ -2579,18 +2579,18 @@  discard block
 block discarded – undo
2579 2579
  *   by content.module.
2580 2580
  */
2581 2581
 function content_extra_field_weight($type_name, $pseudo_field_name) {
2582
-  $type = content_types($type_name);
2582
+    $type = content_types($type_name);
2583 2583
 
2584
-  // If we don't have the requested item, this may be because the cached
2585
-  // information for 'extra' fields hasn't been refreshed yet.
2586
-  if (!isset($type['extra'][$pseudo_field_name])) {
2584
+    // If we don't have the requested item, this may be because the cached
2585
+    // information for 'extra' fields hasn't been refreshed yet.
2586
+    if (!isset($type['extra'][$pseudo_field_name])) {
2587 2587
     content_clear_type_cache();
2588 2588
     $type = content_types($type_name);
2589
-  }
2589
+    }
2590 2590
 
2591
-  if (isset($type['extra'][$pseudo_field_name])) {
2591
+    if (isset($type['extra'][$pseudo_field_name])) {
2592 2592
     return $type['extra'][$pseudo_field_name]['weight'];
2593
-  }
2593
+    }
2594 2594
 }
2595 2595
 
2596 2596
 /**
@@ -2617,68 +2617,68 @@  discard block
 block discarded – undo
2617 2617
  * Do we want to eliminate them from the results?
2618 2618
  */
2619 2619
 function content_max_delta($field_name, $type_name = NULL) {
2620
-  $fields = content_fields();
2621
-  $field = $fields[$field_name];
2620
+    $fields = content_fields();
2621
+    $field = $fields[$field_name];
2622 2622
 
2623
-  // Non-multiple value fields don't use the delta column,
2624
-  // but could exist in multiple databases. If any value
2625
-  // exists in any examined table, the max delta will be zero.
2626
-  if (empty($field['multiple'])) {
2623
+    // Non-multiple value fields don't use the delta column,
2624
+    // but could exist in multiple databases. If any value
2625
+    // exists in any examined table, the max delta will be zero.
2626
+    if (empty($field['multiple'])) {
2627 2627
     $content_types = content_types();
2628 2628
     foreach ($content_types as $content_type) {
2629
-      if (empty($type_name) || $content_type['type'] == $type_name) {
2629
+        if (empty($type_name) || $content_type['type'] == $type_name) {
2630 2630
         foreach ($content_type['fields'] as $field) {
2631
-          $db_info = content_database_info($field);
2632
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2631
+            $db_info = content_database_info($field);
2632
+            if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2633 2633
             return 0;
2634
-          }
2634
+            }
2635
+        }
2635 2636
         }
2636
-      }
2637 2637
     }
2638
-  }
2639
-  // Multiple value fields always share the same table and use the delta.
2640
-  // If we want to find delta values for a particular type, we join
2641
-  // in the node table to limit the type.
2642
-  else {
2638
+    }
2639
+    // Multiple value fields always share the same table and use the delta.
2640
+    // If we want to find delta values for a particular type, we join
2641
+    // in the node table to limit the type.
2642
+    else {
2643 2643
     $db_info = content_database_info($field);
2644 2644
     if (!empty($type_name)) {
2645
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2645
+        $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646 2646
     }
2647 2647
     else {
2648
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2648
+        $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2649 2649
     }
2650 2650
     if ($delta >= 0) {
2651
-      return $delta;
2651
+        return $delta;
2652 2652
     }
2653
-  }
2654
-  // If we got this far, there is no data for this field.
2655
-  return NULL;
2653
+    }
2654
+    // If we got this far, there is no data for this field.
2655
+    return NULL;
2656 2656
 }
2657 2657
 
2658 2658
 /**
2659 2659
  * Helper function to identify inactive fields.
2660 2660
  */
2661 2661
 function content_inactive_fields($type_name = NULL) {
2662
-  module_load_include('inc', 'content', 'includes/content.crud');
2663
-  if (!empty($type_name)) {
2662
+    module_load_include('inc', 'content', 'includes/content.crud');
2663
+    if (!empty($type_name)) {
2664 2664
     $param = array('type_name' => $type_name);
2665 2665
     $inactive = array($type_name => array());
2666
-  }
2667
-  else {
2666
+    }
2667
+    else {
2668 2668
     $param = array();
2669 2669
     $inactive = array();
2670
-  }
2671
-  $all = content_field_instance_read($param, TRUE);
2672
-  $active = array_keys(content_fields());
2673
-  foreach ($all as $field) {
2670
+    }
2671
+    $all = content_field_instance_read($param, TRUE);
2672
+    $active = array_keys(content_fields());
2673
+    foreach ($all as $field) {
2674 2674
     if (!in_array($field['field_name'], $active)) {
2675
-      $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2675
+        $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2676
+    }
2676 2677
     }
2677
-  }
2678
-  if (!empty($type_name)) {
2678
+    if (!empty($type_name)) {
2679 2679
     return $inactive[$type_name];
2680
-  }
2681
-  return $inactive;
2680
+    }
2681
+    return $inactive;
2682 2682
 }
2683 2683
 
2684 2684
  
@@ -2689,21 +2689,21 @@  discard block
 block discarded – undo
2689 2689
  * if the fields have other (shared) instances that are still active.
2690 2690
  */
2691 2691
 function content_inactive_instances($type_name = NULL) {
2692
-  module_load_include('inc', 'content', 'includes/content.crud');
2693
-  if (!empty($type_name)) {
2692
+    module_load_include('inc', 'content', 'includes/content.crud');
2693
+    if (!empty($type_name)) {
2694 2694
     $param = array('type_name' => $type_name);
2695 2695
     $inactive = array($type_name => array());
2696
-  }
2697
-  else {
2696
+    }
2697
+    else {
2698 2698
     $param = array();
2699 2699
     $inactive = array();
2700
-  }
2701
-  $all = content_field_instance_read($param, TRUE);
2702
-  foreach ($all as $field) {
2700
+    }
2701
+    $all = content_field_instance_read($param, TRUE);
2702
+    foreach ($all as $field) {
2703 2703
     $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2704
-  }
2705
-  if (!empty($type_name)) {
2704
+    }
2705
+    if (!empty($type_name)) {
2706 2706
     return $inactive[$type_name];
2707
-  }
2708
-  return $inactive;
2707
+    }
2708
+    return $inactive;
2709 2709
 }
Please login to merge, or discard this patch.
Switch Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 
18 18
 function content_help($path, $arg) {
19 19
   switch ($path) {
20
-    case 'admin/help#content':
21
-      $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
-      $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
-      $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
-      return $output;
20
+  case 'admin/help#content':
21
+    $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
+    $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
+    $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
24
+    $output .= '<ul>';
25
+    $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
+    $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
+    $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
+    $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
+    $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
30
+    $output .= '</ul>';
31
+    $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
32
+    return $output;
33 33
   }
34 34
 }
35 35
 
@@ -553,27 +553,27 @@  discard block
 block discarded – undo
553 553
  */
554 554
 function content_notify($op, $module) {
555 555
   switch ($op) {
556
-    case 'install':
557
-      content_clear_type_cache();
558
-      break;
559
-    case 'uninstall':
560
-      module_load_include('inc', 'content', 'includes/content.crud');
561
-      content_module_delete($module);
562
-      break;
563
-    case 'enable':
564
-      content_associate_fields($module);
565
-      content_clear_type_cache();
566
-      break;
567
-    case 'disable':
568
-      // When CCK modules are disabled before content module's update is run
569
-      // to add the active column, we can't do this.
570
-      if (variable_get('content_schema_version', -1) < 6007) {
571
-        return FALSE;
572
-      }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
576
-      break;
556
+  case 'install':
557
+    content_clear_type_cache();
558
+    break;
559
+  case 'uninstall':
560
+    module_load_include('inc', 'content', 'includes/content.crud');
561
+    content_module_delete($module);
562
+    break;
563
+  case 'enable':
564
+    content_associate_fields($module);
565
+    content_clear_type_cache();
566
+    break;
567
+  case 'disable':
568
+    // When CCK modules are disabled before content module's update is run
569
+    // to add the active column, we can't do this.
570
+    if (variable_get('content_schema_version', -1) < 6007) {
571
+      return FALSE;
572
+    }
573
+    db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
+    db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
+    content_clear_type_cache(TRUE);
576
+    break;
577 577
   }
578 578
 }
579 579
 
@@ -685,38 +685,53 @@  discard block
 block discarded – undo
685 685
  */
686 686
 function content_field($op, &$node, $field, &$items, $teaser, $page) {
687 687
   switch ($op) {
688
-    case 'validate':
689
-      // TODO: here we could validate that the number of multiple data is correct ?
690
-      // We're controlling the number of fields to fill out and saving empty
691
-      // ones if a specified number is requested, so no reason to do any validation
692
-      // here right now, but if later create a method to indicate whether
693
-      // 'required' means all values must be filled out, we can come back
694
-      // here and check that they're not empty.
695
-      break;
696
-
697
-    case 'presave':
698
-      if (!empty($node->devel_generate)) {
699
-        include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700
-        content_generate_fields($node, $field);
701
-        $items = $node->{$field['field_name']};
702
-      }
688
+  case 'validate':
689
+    // TODO: here we could validate that the number of multiple data is correct ?
690
+    // We're controlling the number of fields to fill out and saving empty
691
+    // ones if a specified number is requested, so no reason to do any validation
692
+    // here right now, but if later create a method to indicate whether
693
+    // 'required' means all values must be filled out, we can come back
694
+    // here and check that they're not empty.
695
+    break;
696
+
697
+  case 'presave':
698
+    if (!empty($node->devel_generate)) {
699
+      include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
700
+      content_generate_fields($node, $field);
701
+      $items = $node->{$field['field_name']};
702
+    }
703 703
 
704
-      // Manual node_save calls might not have all fields filled in.
705
-      // On node insert, we need to make sure all tables get at least an empty
706
-      // record, or subsequent edits, using drupal_write_record() in update mode,
707
-      // won't insert any data.
708
-      // Missing fields on node update are handled in content_storage().
709
-      if (empty($items) && !isset($node->nid)) {
710
-        foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
712
-        }
713
-        $node->$field['field_name'] = $items;
704
+    // Manual node_save calls might not have all fields filled in.
705
+    // On node insert, we need to make sure all tables get at least an empty
706
+    // record, or subsequent edits, using drupal_write_record() in update mode,
707
+    // won't insert any data.
708
+    // Missing fields on node update are handled in content_storage().
709
+    if (empty($items) && !isset($node->nid)) {
710
+      foreach (array_keys($field['columns']) as $column) {
711
+        $items[0][$column] = NULL;
714 712
       }
713
+      $node->$field['field_name'] = $items;
714
+    }
715 715
 
716
-      // If there was an AHAH add more button in this field, don't save it.
717
-      // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
716
+    // If there was an AHAH add more button in this field, don't save it.
717
+    // TODO: is it still needed ?
718
+    unset($items[$field['field_name'] .'_add_more']);
719
+
720
+    if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721
+      // Reorder items to account for drag-n-drop reordering.
722
+      $items = _content_sort_items($field, $items);
723
+    }
724
+
725
+    // Filter out empty values.
726
+    $items = content_set_empty($field, $items);
719 727
 
728
+    break;
729
+
730
+  case 'view':
731
+    $addition = array();
732
+
733
+    // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
+    if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
720 735
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 736
         // Reorder items to account for drag-n-drop reordering.
722 737
         $items = _content_sort_items($field, $items);
@@ -724,166 +739,151 @@  discard block
 block discarded – undo
724 739
 
725 740
       // Filter out empty values.
726 741
       $items = content_set_empty($field, $items);
742
+    }
727 743
 
728
-      break;
729
-
730
-    case 'view':
731
-      $addition = array();
744
+    // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
+    if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746
+      $context = $teaser ? 'teaser' : 'full';
747
+    }
748
+    else {
749
+      $context = $node->build_mode;
750
+    }
751
+    // The field may be missing info for $contexts added by modules
752
+    // enabled after the field was last edited.
753
+    $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
+    if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
+      $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756
+      $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757
+
758
+      $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759
+      // Do not include field labels when indexing content.
760
+      if ($context == NODE_BUILD_SEARCH_INDEX) {
761
+        $label_display = 'hidden';
762
+      }
732 763
 
733
-      // Previewed nodes bypass the 'presave' op, so we need to some massaging.
734
-      if ($node->build_mode == NODE_BUILD_PREVIEW && content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
735
-        if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
736
-          // Reorder items to account for drag-n-drop reordering.
737
-          $items = _content_sort_items($field, $items);
738
-        }
764
+      $element = array(
765
+        '#type' => 'content_field',
766
+        '#title' => check_plain(t($field['widget']['label'])),
767
+        '#field_name' => $field['field_name'],
768
+        '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
+        '#label_display' => $label_display,
770
+        '#node' => $node,
771
+        '#teaser' => $teaser,
772
+        '#page' => $page,
773
+        '#context' => $context,
774
+        '#single' => $single,
775
+        'items' => array(),
776
+      );
739 777
 
740
-        // Filter out empty values.
741
-        $items = content_set_empty($field, $items);
778
+      // Fill-in items.
779
+      foreach ($items as $delta => $item) {
780
+        $element['items'][$delta] = array(
781
+          '#item' => $item,
782
+          '#weight' => $delta,
783
+        );
742 784
       }
743 785
 
744
-      // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745
-      if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746
-        $context = $teaser ? 'teaser' : 'full';
786
+      // Append formatter information either on each item ('single-value' formatter)
787
+      // or at the upper 'items' level ('multiple-value' formatter)
788
+      $format_info = array(
789
+        '#theme' => $theme,
790
+        '#field_name' => $field['field_name'],
791
+        '#type_name' => $node->type,
792
+        '#formatter' => $formatter_name,
793
+        '#node' => $node,
794
+      );
795
+      if ($single) {
796
+        foreach ($items as $delta => $item) {
797
+          $element['items'][$delta] += $format_info;
798
+          $element['items'][$delta]['#item']['#delta'] = $delta;
799
+        }
747 800
       }
748 801
       else {
749
-        $context = $node->build_mode;
802
+        $element['items'] += $format_info;
750 803
       }
751
-      // The field may be missing info for $contexts added by modules
752
-      // enabled after the field was last edited.
753
-      $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754
-      if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
-        $theme = $formatter['module'] .'_formatter_'. $formatter_name;
756
-        $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757
-
758
-        $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
759
-        // Do not include field labels when indexing content.
760
-        if ($context == NODE_BUILD_SEARCH_INDEX) {
761
-          $label_display = 'hidden';
762
-        }
763 804
 
764
-        $element = array(
765
-          '#type' => 'content_field',
766
-          '#title' => check_plain(t($field['widget']['label'])),
767
-          '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
769
-          '#label_display' => $label_display,
770
-          '#node' => $node,
771
-          '#teaser' => $teaser,
772
-          '#page' => $page,
773
-          '#context' => $context,
774
-          '#single' => $single,
775
-          'items' => array(),
776
-        );
805
+      // The wrapper lets us get the themed output for the whole field
806
+      // to populate the $FIELD_NAME_rendered variable for node templates,
807
+      // and hide it from the $content variable if needed.
808
+      // See 'preprocess_node' op and theme_content_field_wrapper()?
809
+      $wrapper = array(
810
+        'field' => $element,
811
+        '#weight' => $field['widget']['weight'],
812
+        '#post_render' => array('content_field_wrapper_post_render'),
813
+        '#field_name' => $field['field_name'],
814
+        '#type_name' => $node->type,
815
+        '#context' => $context,
816
+      );
777 817
 
778
-        // Fill-in items.
779
-        foreach ($items as $delta => $item) {
780
-          $element['items'][$delta] = array(
781
-            '#item' => $item,
782
-            '#weight' => $delta,
783
-          );
784
-        }
818
+      $addition = array($field['field_name'] => $wrapper);
819
+    }
820
+    return $addition;
821
+
822
+  case 'alter':
823
+    // Add back the formatted values in the 'view' element,
824
+    // so that tokens and node templates can use it.
825
+    // Note: Doing this in 'preprocess_node' breaks token integration.
826
+
827
+    // The location of the field's rendered output depends on whether the
828
+    // field is in a fieldgroup or not.
829
+    $wrapper = NULL;
830
+    if (isset($node->content[$field['field_name']])) {
831
+      $wrapper = $node->content[$field['field_name']];
832
+    }
833
+    elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834
+      $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
+    }
785 836
 
786
-        // Append formatter information either on each item ('single-value' formatter)
787
-        // or at the upper 'items' level ('multiple-value' formatter)
788
-        $format_info = array(
789
-          '#theme' => $theme,
790
-          '#field_name' => $field['field_name'],
791
-          '#type_name' => $node->type,
792
-          '#formatter' => $formatter_name,
793
-          '#node' => $node,
794
-        );
795
-        if ($single) {
796
-          foreach ($items as $delta => $item) {
797
-            $element['items'][$delta] += $format_info;
798
-            $element['items'][$delta]['#item']['#delta'] = $delta;
837
+    if ($wrapper) {
838
+      $element = $wrapper['field'];
839
+      // '#single' is not set if the field is hidden or inaccessible.
840
+      if (isset($element['#single'])) {
841
+        if (!empty($element['#single'])) {
842
+          // Single value formatter.
843
+          foreach (element_children($element['items']) as $delta) {
844
+            // '#chilren' is not set if the field is empty.
845
+            $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
799 846
           }
800 847
         }
801
-        else {
802
-          $element['items'] += $format_info;
848
+        elseif (isset($element['items']['#children']))  {
849
+          // Multiple values formatter.
850
+          $items[0]['view'] = $element['items']['#children'];
803 851
         }
804
-
805
-        // The wrapper lets us get the themed output for the whole field
806
-        // to populate the $FIELD_NAME_rendered variable for node templates,
807
-        // and hide it from the $content variable if needed.
808
-        // See 'preprocess_node' op and theme_content_field_wrapper()?
809
-        $wrapper = array(
810
-          'field' => $element,
811
-          '#weight' => $field['widget']['weight'],
812
-          '#post_render' => array('content_field_wrapper_post_render'),
813
-          '#field_name' => $field['field_name'],
814
-          '#type_name' => $node->type,
815
-          '#context' => $context,
816
-        );
817
-
818
-        $addition = array($field['field_name'] => $wrapper);
819
-      }
820
-      return $addition;
821
-
822
-    case 'alter':
823
-      // Add back the formatted values in the 'view' element,
824
-      // so that tokens and node templates can use it.
825
-      // Note: Doing this in 'preprocess_node' breaks token integration.
826
-
827
-      // The location of the field's rendered output depends on whether the
828
-      // field is in a fieldgroup or not.
829
-      $wrapper = NULL;
830
-      if (isset($node->content[$field['field_name']])) {
831
-        $wrapper = $node->content[$field['field_name']];
832 852
       }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834
-        $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835
-      }
836
-
837
-      if ($wrapper) {
838
-        $element = $wrapper['field'];
839
-        // '#single' is not set if the field is hidden or inaccessible.
840
-        if (isset($element['#single'])) {
841
-          if (!empty($element['#single'])) {
842
-            // Single value formatter.
843
-            foreach (element_children($element['items']) as $delta) {
844
-              // '#chilren' is not set if the field is empty.
845
-              $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846
-            }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
849
-            // Multiple values formatter.
850
-            $items[0]['view'] = $element['items']['#children'];
851
-          }
852
-        }
853
-        else {
854
-          // Hidden or inaccessible field.
855
-          $items[0]['view'] = '';
856
-        }
853
+      else {
854
+        // Hidden or inaccessible field.
855
+        $items[0]['view'] = '';
857 856
       }
858
-      break;
857
+    }
858
+    break;
859 859
 
860
-    case 'preprocess_node':
861
-      // Add $FIELD_NAME_rendered variables.
862
-      $addition = array();
860
+  case 'preprocess_node':
861
+    // Add $FIELD_NAME_rendered variables.
862
+    $addition = array();
863 863
 
864
-      // The location of the field's rendered output depends on whether the
865
-      // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
867
-      if (isset($node->content[$field['field_name']])) {
868
-        $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871
-        $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
-      }
864
+    // The location of the field's rendered output depends on whether the
865
+    // field is in a fieldgroup or not.
866
+    $wrapper = NULL;
867
+    if (isset($node->content[$field['field_name']])) {
868
+      $wrapper = $node->content[$field['field_name']];
869
+    }
870
+    elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871
+      $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872
+    }
873 873
 
874
-      if ($wrapper) {
875
-        // '#chilren' is not set if the field is empty.
876
-        $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
-      }
874
+    if ($wrapper) {
875
+      // '#chilren' is not set if the field is empty.
876
+      $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877
+    }
878 878
 
879
-      return $addition;
879
+    return $addition;
880 880
 
881
-    case 'prepare translation':
882
-      $addition = array();
883
-      if (isset($node->translation_source->$field['field_name'])) {
884
-        $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
-      }
886
-      return $addition;
881
+  case 'prepare translation':
882
+    $addition = array();
883
+    if (isset($node->translation_source->$field['field_name'])) {
884
+      $addition[$field['field_name']] = $node->translation_source->$field['field_name'];
885
+    }
886
+    return $addition;
887 887
   }
888 888
 }
889 889
 
@@ -974,122 +974,122 @@  discard block
 block discarded – undo
974 974
   $type = content_types($type_name);
975 975
 
976 976
   switch ($op) {
977
-    case 'load':
978
-      // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979
-      // warning: 61-join limit in MySQL ?
980
-      $additions = array();
981
-      // For each table used by this content type,
982
-      foreach ($type['tables'] as $table) {
983
-        $schema = drupal_get_schema($table);
984
-        // The per-type table might not have any fields actually stored in it.
985
-        if (!$schema['content fields']) {
986
-          continue;
987
-        }
988
-        $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989
-
990
-        // If we're loading a table for a multiple field,
991
-        // we fetch all rows (values) ordered by delta,
992
-        // else we only fetch one row.
993
-        $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
994
-
995
-        // For each table row, populate the fields.
996
-        while ($row = db_fetch_array($result)) {
997
-          // For each field stored in the table, add the field item.
998
-          foreach ($schema['content fields'] as $field_name) {
999
-            $item = array();
1000
-            $field = content_fields($field_name, $type_name);
1001
-            $db_info = content_database_info($field);
1002
-            // For each column declared by the field, populate the item.
1003
-            foreach ($db_info['columns'] as $column => $attributes) {
1004
-              $item[$column] = $row[$attributes['column']];
1005
-            }
1006
-
1007
-            // Add the item to the field values for the node.
1008
-            if (!isset($additions[$field_name])) {
1009
-              $additions[$field_name] = array();
1010
-            }
1011
-            $additions[$field_name][] = $item;
1012
-          }
1013
-        }
977
+  case 'load':
978
+    // OPTIMIZE: load all non multiple fields in a single JOIN query ?
979
+    // warning: 61-join limit in MySQL ?
980
+    $additions = array();
981
+    // For each table used by this content type,
982
+    foreach ($type['tables'] as $table) {
983
+      $schema = drupal_get_schema($table);
984
+      // The per-type table might not have any fields actually stored in it.
985
+      if (!$schema['content fields']) {
986
+        continue;
1014 987
       }
1015
-      return $additions;
988
+      $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
989
+
990
+      // If we're loading a table for a multiple field,
991
+      // we fetch all rows (values) ordered by delta,
992
+      // else we only fetch one row.
993
+      $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
1016 994
 
1017
-    case 'insert':
1018
-    case 'update':
1019
-      foreach ($type['tables'] as $table) {
1020
-        $schema = drupal_get_schema($table);
1021
-        $record = array();
995
+      // For each table row, populate the fields.
996
+      while ($row = db_fetch_array($result)) {
997
+        // For each field stored in the table, add the field item.
1022 998
         foreach ($schema['content fields'] as $field_name) {
1023
-          if (isset($node->$field_name)) {
1024
-            $field = content_fields($field_name, $type_name);
1025
-            // Multiple fields need specific handling, we'll deal with them later on.
1026
-            if ($field['multiple']) {
1027
-              continue;
1028
-            }
1029
-            $db_info = content_database_info($field);
1030
-            foreach ($db_info['columns'] as $column => $attributes) {
1031
-              $record[$attributes['column']] = $node->{$field_name}[0][$column];
1032
-            }
999
+          $item = array();
1000
+          $field = content_fields($field_name, $type_name);
1001
+          $db_info = content_database_info($field);
1002
+          // For each column declared by the field, populate the item.
1003
+          foreach ($db_info['columns'] as $column => $attributes) {
1004
+            $item[$column] = $row[$attributes['column']];
1033 1005
           }
1006
+
1007
+          // Add the item to the field values for the node.
1008
+          if (!isset($additions[$field_name])) {
1009
+            $additions[$field_name] = array();
1010
+          }
1011
+          $additions[$field_name][] = $item;
1034 1012
         }
1035
-        // $record might be empty because
1036
-        // - the table stores a multiple field :
1037
-        //   we do nothing, this is handled later on
1038
-        // - this is the per-type table and no field is actually stored in it :
1039
-        //   we still store the nid and vid
1040
-        if (count($record) || empty($schema['content fields'])) {
1041
-          $record['nid'] = $node->nid;
1042
-          $record['vid'] = $node->vid;
1043
-          // Can't rely on the insert/update op of the node to decide if this
1044
-          // is an insert or an update, a node or revision may have existed
1045
-          // before any fields were created, so there may not be an entry here.
1046
-
1047
-          // TODO - should we auto create an entry for all existing nodes when
1048
-          // fields are added to content types -- either a NULL value
1049
-          // or the default value? May need to offer the user an option of
1050
-          // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052
-            content_write_record($table, $record, array('vid'));
1013
+      }
1014
+    }
1015
+    return $additions;
1016
+
1017
+  case 'insert':
1018
+  case 'update':
1019
+    foreach ($type['tables'] as $table) {
1020
+      $schema = drupal_get_schema($table);
1021
+      $record = array();
1022
+      foreach ($schema['content fields'] as $field_name) {
1023
+        if (isset($node->$field_name)) {
1024
+          $field = content_fields($field_name, $type_name);
1025
+          // Multiple fields need specific handling, we'll deal with them later on.
1026
+          if ($field['multiple']) {
1027
+            continue;
1053 1028
           }
1054
-          else {
1055
-            content_write_record($table, $record);
1029
+          $db_info = content_database_info($field);
1030
+          foreach ($db_info['columns'] as $column => $attributes) {
1031
+            $record[$attributes['column']] = $node->{$field_name}[0][$column];
1056 1032
           }
1057 1033
         }
1058 1034
       }
1035
+      // $record might be empty because
1036
+      // - the table stores a multiple field :
1037
+      //   we do nothing, this is handled later on
1038
+      // - this is the per-type table and no field is actually stored in it :
1039
+      //   we still store the nid and vid
1040
+      if (count($record) || empty($schema['content fields'])) {
1041
+        $record['nid'] = $node->nid;
1042
+        $record['vid'] = $node->vid;
1043
+        // Can't rely on the insert/update op of the node to decide if this
1044
+        // is an insert or an update, a node or revision may have existed
1045
+        // before any fields were created, so there may not be an entry here.
1046
+
1047
+        // TODO - should we auto create an entry for all existing nodes when
1048
+        // fields are added to content types -- either a NULL value
1049
+        // or the default value? May need to offer the user an option of
1050
+        // how to handle that.
1051
+        if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052
+          content_write_record($table, $record, array('vid'));
1053
+        }
1054
+        else {
1055
+          content_write_record($table, $record);
1056
+        }
1057
+      }
1058
+    }
1059 1059
 
1060
-      // Handle multiple fields.
1061
-      foreach ($type['fields'] as $field) {
1062
-        if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
-          $db_info = content_database_info($field);
1064
-          // Delete and insert, rather than update, in case a value was added.
1065
-          if ($op == 'update') {
1066
-            db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
-          }
1068
-          foreach ($node->$field['field_name'] as $delta => $item) {
1069
-            $record = array();
1070
-            foreach ($db_info['columns'] as $column => $attributes) {
1071
-              $record[$attributes['column']] = $item[$column];
1072
-            }
1073
-            $record['nid'] = $node->nid;
1074
-            $record['vid'] = $node->vid;
1075
-            $record['delta'] = $delta;
1076
-            content_write_record($db_info['table'], $record);
1060
+    // Handle multiple fields.
1061
+    foreach ($type['fields'] as $field) {
1062
+      if ($field['multiple'] && isset($node->$field['field_name'])) {
1063
+        $db_info = content_database_info($field);
1064
+        // Delete and insert, rather than update, in case a value was added.
1065
+        if ($op == 'update') {
1066
+          db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1067
+        }
1068
+        foreach ($node->$field['field_name'] as $delta => $item) {
1069
+          $record = array();
1070
+          foreach ($db_info['columns'] as $column => $attributes) {
1071
+            $record[$attributes['column']] = $item[$column];
1077 1072
           }
1073
+          $record['nid'] = $node->nid;
1074
+          $record['vid'] = $node->vid;
1075
+          $record['delta'] = $delta;
1076
+          content_write_record($db_info['table'], $record);
1078 1077
         }
1079 1078
       }
1080
-      break;
1079
+    }
1080
+    break;
1081 1081
 
1082
-    case 'delete':
1083
-      foreach ($type['tables'] as $table) {
1084
-        db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
-      }
1086
-      break;
1082
+  case 'delete':
1083
+    foreach ($type['tables'] as $table) {
1084
+      db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1085
+    }
1086
+    break;
1087 1087
 
1088
-    case 'delete revision':
1089
-      foreach ($type['tables'] as $table) {
1090
-        db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
-      }
1092
-      break;
1088
+  case 'delete revision':
1089
+    foreach ($type['tables'] as $table) {
1090
+      db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1091
+    }
1092
+    break;
1093 1093
   }
1094 1094
 }
1095 1095
 
@@ -1526,18 +1526,18 @@  discard block
 block discarded – undo
1526 1526
  */
1527 1527
 function content_node_type($op, $info) {
1528 1528
   switch ($op) {
1529
-    case 'insert':
1530
-      module_load_include('inc', 'content', 'includes/content.crud');
1531
-      content_type_create($info);
1532
-      break;
1533
-    case 'update':
1534
-      module_load_include('inc', 'content', 'includes/content.crud');
1535
-      content_type_update($info);
1536
-      break;
1537
-    case 'delete':
1538
-      module_load_include('inc', 'content', 'includes/content.crud');
1539
-      content_type_delete($info);
1540
-      break;
1529
+  case 'insert':
1530
+    module_load_include('inc', 'content', 'includes/content.crud');
1531
+    content_type_create($info);
1532
+    break;
1533
+  case 'update':
1534
+    module_load_include('inc', 'content', 'includes/content.crud');
1535
+    content_type_update($info);
1536
+    break;
1537
+  case 'delete':
1538
+    module_load_include('inc', 'content', 'includes/content.crud');
1539
+    content_type_delete($info);
1540
+    break;
1541 1541
   }
1542 1542
 }
1543 1543
 
@@ -1994,14 +1994,14 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
   $name = str_replace('-', '_', $name);
1996 1996
   switch ("$version-$storage") {
1997
-    case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998
-      return "node_$name";
1999
-    case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
2000
-      return "node_data_$name";
2001
-    case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002
-      return "content_type_$name";
2003
-    case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004
-      return "content_$name";
1997
+  case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998
+    return "node_$name";
1999
+  case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
2000
+    return "node_data_$name";
2001
+  case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002
+    return "content_type_$name";
2003
+  case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2004
+    return "content_$name";
2005 2005
   }
2006 2006
 }
2007 2007
 
@@ -2153,13 +2153,13 @@  discard block
 block discarded – undo
2153 2153
  */
2154 2154
 function content_callback($entity, $op, $field) {
2155 2155
   switch ($entity) {
2156
-    case 'field':
2157
-      $info = module_invoke($field['module'], "field_info");
2158
-      return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2156
+  case 'field':
2157
+    $info = module_invoke($field['module'], "field_info");
2158
+    return isset($info[$field['type']]['callbacks'][$op]) ? $info[$field['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2159 2159
 
2160
-    case 'widget':
2161
-      $info = module_invoke($field['widget']['module'], "widget_info");
2162
-      return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2160
+  case 'widget':
2161
+    $info = module_invoke($field['widget']['module'], "widget_info");
2162
+    return isset($info[$field['widget']['type']]['callbacks'][$op]) ? $info[$field['widget']['type']]['callbacks'][$op] : CONTENT_CALLBACK_DEFAULT;
2163 2163
   }
2164 2164
 }
2165 2165
 
@@ -2183,18 +2183,18 @@  discard block
 block discarded – undo
2183 2183
  */
2184 2184
 function content_handle($entity, $op, $object) {
2185 2185
   switch ($entity) {
2186
-    case 'field':
2187
-      $info = module_invoke($object['module'], "field_info");
2188
-      return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189
-
2190
-    case 'widget':
2191
-      $info = module_invoke($object['widget']['module'], "widget_info");
2192
-      return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193
-
2194
-    case 'formatter':
2195
-      // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196
-      // We let content_handle deal with them only for code consistency.
2197
-      return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2186
+  case 'field':
2187
+    $info = module_invoke($object['module'], "field_info");
2188
+    return isset($info[$object['type']][$op]) ? $info[$object['type']][$op] : CONTENT_HANDLE_CORE;
2189
+
2190
+  case 'widget':
2191
+    $info = module_invoke($object['widget']['module'], "widget_info");
2192
+    return isset($info[$object['widget']['type']][$op]) ? $info[$object['widget']['type']][$op] : CONTENT_HANDLE_CORE;
2193
+
2194
+  case 'formatter':
2195
+    // Much simpler, formatters arrays *are* the 'formatter_info' itself.
2196
+    // We let content_handle deal with them only for code consistency.
2197
+    return isset($object[$op]) ? $object[$op] : CONTENT_HANDLE_CORE;
2198 2198
   }
2199 2199
 }
2200 2200
 
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 function content_help($path, $arg) {
19 19
   switch ($path) {
20 20
     case 'admin/help#content':
21
-      $output = '<p>'. t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))) .'</p>';
22
-      $output .= '<p>'. t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.') .'</p>';
23
-      $output .= '<p>'. t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))) .'</p>';
21
+      $output = '<p>'.t('The content module, a required component of the Content Construction Kit (CCK), allows administrators to associate custom fields with content types. In Drupal, content types are used to define the characteristics of a post, including the title and description of the fields displayed on its add and edit pages. Using the content module (and the other helper modules included in CCK), custom fields beyond the default "Title" and "Body" may be added. CCK features are accessible through tabs on the <a href="@content-types">content types administration page</a>. (See the <a href="@node-help">node module help page</a> for more information about content types.)', array('@content-types' => url('admin/content/types'), '@node-help' => url('admin/help/node'))).'</p>';
22
+      $output .= '<p>'.t('When adding a custom field to a content type, you determine its type (whether it will contain text, numbers, or references to other objects) and how it will be displayed (either as a text field or area, a select box, checkbox, radio button, or autocompleting field). A field may have multiple values (i.e., a "person" may have multiple e-mail addresses) or a single value (i.e., an "employee" has a single employee identification number). As you add and edit fields, CCK automatically adjusts the structure of the database as necessary. CCK also provides a number of other features, including intelligent caching for your custom data, an import and export facility for content type definitions, and integration with other contributed modules.').'</p>';
23
+      $output .= '<p>'.t('Custom field types are provided by a set of optional modules included with CCK (each module provides a different type). The <a href="@modules">modules page</a> allows you to enable or disable CCK components. A default installation of CCK includes:', array('@modules' => url('admin/build/modules'))).'</p>';
24 24
       $output .= '<ul>';
25
-      $output .= '<li>'. t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.') .'</li>';
26
-      $output .= '<li>'. t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.") .'</li>';
27
-      $output .= '<li>'. t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).') .'</li>';
28
-      $output .= '<li>'. t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.') .'</li>';
29
-      $output .= '<li>'. t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.') .'</li>';
25
+      $output .= '<li>'.t('<em>number</em>, which adds numeric field types, in integer, decimal or floating point form. You may define a set of allowed inputs, or specify an allowable range of values. A variety of common formats for displaying numeric data are available.').'</li>';
26
+      $output .= '<li>'.t("<em>text</em>, which adds text field types. A text field may contain plain text only, or optionally, may use Drupal's input format filters to securely manage rich text input. Text input fields may be either a single line (text field), multiple lines (text area), or for greater input control, a select box, checkbox, or radio buttons. If desired, CCK can validate the input to a set of allowed values.").'</li>';
27
+      $output .= '<li>'.t('<em>nodereference</em>, which creates custom references between Drupal nodes. By adding a <em>nodereference</em> field and two different content types, for instance, you can easily create complex parent/child relationships between data (multiple "employee" nodes may contain a <em>nodereference</em> field linking to an "employer" node).').'</li>';
28
+      $output .= '<li>'.t('<em>userreference</em>, which creates custom references to your sites\' user accounts. By adding a <em>userreference</em> field, you can create complex relationships between your site\'s users and posts. To track user involvement in a post beyond Drupal\'s standard <em>Authored by</em> field, for instance, add a <em>userreference</em> field named "Edited by" to a content type to store a link to an editor\'s user account page.').'</li>';
29
+      $output .= '<li>'.t('<em>fieldgroup</em>, which creates collapsible fieldsets to hold a group of related fields. A fieldset may either be open or closed by default. The order of your fieldsets, and the order of fields within a fieldset, is managed via a drag-and-drop interface provided by content module.').'</li>';
30 30
       $output .= '</ul>';
31
-      $output .= '<p>'. t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')) .'</p>';
31
+      $output .= '<p>'.t('For more information, see the online handbook entry for <a href="@handbook-cck">CCK</a> or the <a href="@project-cck">CCK project page</a>.', array('@handbook-cck' => 'http://drupal.org/handbook/modules/cck', '@project-cck' => 'http://drupal.org/project/cck')).'</p>';
32 32
       return $output;
33 33
   }
34 34
 }
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
  * Implementation of hook_init().
45 45
  */
46 46
 function content_init() {
47
-  drupal_add_css(drupal_get_path('module', 'content') .'/theme/content-module.css');
47
+  drupal_add_css(drupal_get_path('module', 'content').'/theme/content-module.css');
48 48
   if (module_exists('token') && !function_exists('content_token_values')) {
49 49
     module_load_include('inc', 'content', 'includes/content.token');
50 50
   }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
   // Customize the content types page with our own callback
68 68
   $items['admin/content/types']['page callback'] = 'content_types_overview';
69 69
   $items['admin/content/types']['file'] = 'content.admin.inc';
70
-  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content') .'/includes';
70
+  $items['admin/content/types']['file path'] = drupal_get_path('module', 'content').'/includes';
71 71
 }
72 72
 
73 73
 /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
       $type_name = $type->type;
98 98
       $content_type = content_types($type_name);
99 99
       $type_url_str = $content_type['url_str'];
100
-      $items['admin/content/node-type/'. $type_url_str .'/fields'] = array(
100
+      $items['admin/content/node-type/'.$type_url_str.'/fields'] = array(
101 101
         'title' => 'Manage fields',
102 102
         'page callback' => 'drupal_get_form',
103 103
         'page arguments' => array('content_field_overview_form', $type_name),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
         'type' => MENU_LOCAL_TASK,
107 107
         'weight' => 1,
108 108
       );
109
-      $items['admin/content/node-type/'. $type_url_str .'/display'] = array(
109
+      $items['admin/content/node-type/'.$type_url_str.'/display'] = array(
110 110
         'title' => 'Display fields',
111 111
         'page callback' => 'drupal_get_form',
112 112
         'page arguments' => array('content_display_overview_form', $type_name),
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
       );
118 118
       $contexts = content_build_modes('_tabs');
119 119
       foreach ($contexts as $key => $tab) {
120
-        $items['admin/content/node-type/'. $type_url_str .'/display/'. $key] = array(
120
+        $items['admin/content/node-type/'.$type_url_str.'/display/'.$key] = array(
121 121
           'title' => $tab['title'],
122 122
           'page arguments' => array('content_display_overview_form', $type_name, $key),
123 123
           'access arguments' => array('administer content types'),
@@ -127,9 +127,9 @@  discard block
 block discarded – undo
127 127
       }
128 128
       // Cast as an array in case this is called before any fields have
129 129
       // been added, like when a new content type is created.
130
-      foreach ((array) $content_type['fields'] as $field) {
130
+      foreach ((array)$content_type['fields'] as $field) {
131 131
         $field_name = $field['field_name'];
132
-        $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name] = array(
132
+        $items['admin/content/node-type/'.$type_url_str.'/fields/'.$field_name] = array(
133 133
           'title' => $field['widget']['label'],
134 134
           'page callback' => 'drupal_get_form',
135 135
           'page arguments' => array('content_field_edit_form', $type_name, $field_name),
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
           'file' => 'includes/content.admin.inc',
138 138
           'type' => MENU_LOCAL_TASK,
139 139
         );
140
-        $items['admin/content/node-type/'. $type_url_str .'/fields/'. $field_name .'/remove'] = array(
140
+        $items['admin/content/node-type/'.$type_url_str.'/fields/'.$field_name.'/remove'] = array(
141 141
           'title' => 'Remove field',
142 142
           'page callback' => 'drupal_get_form',
143 143
           'page arguments' => array('content_field_remove_form', $type_name, $field_name),
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
  * Implementation of hook_theme().
174 174
  */
175 175
 function content_theme() {
176
-  $path = drupal_get_path('module', 'content') .'/theme';
176
+  $path = drupal_get_path('module', 'content').'/theme';
177 177
   require_once "./$path/theme.inc";
178 178
 
179 179
   return array(
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 function content_views_api() {
216 216
   return array(
217 217
     'api' => 2,
218
-    'path' => drupal_get_path('module', 'content') . '/includes/views',
218
+    'path' => drupal_get_path('module', 'content').'/includes/views',
219 219
   );
220 220
 }
221 221
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
  */
225 225
 function content_ctools_plugin_directory($module, $plugin) {
226 226
   if ($module == 'ctools' && $plugin == 'content_types') {
227
-    return 'includes/panels/' . $plugin;
227
+    return 'includes/panels/'.$plugin;
228 228
   }
229 229
 }
230 230
 
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
  * cache the loaded object structure and invalidate it during the update process.
238 238
  */
239 239
 function content_load(&$node) {
240
-  $cid = 'content:'. $node->nid .':'. $node->vid;
240
+  $cid = 'content:'.$node->nid.':'.$node->vid;
241 241
   if ($cached = cache_get($cid, content_cache_tablename())) {
242 242
     foreach ($cached->data as $key => $value) {
243 243
       $node->$key = $value;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 function content_update(&$node) {
298 298
   _content_field_invoke('update', $node);
299 299
   _content_field_invoke_default('update', $node);
300
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
300
+  cache_clear_all('content:'.$node->nid.':'.$node->vid, content_cache_tablename());
301 301
 }
302 302
 
303 303
 /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 function content_delete(&$node) {
309 309
   _content_field_invoke('delete', $node);
310 310
   _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
311
+  cache_clear_all('content:'.$node->nid.':', content_cache_tablename(), TRUE);
312 312
 }
313 313
 
314 314
 /**
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 function content_delete_revision(&$node) {
320 320
   _content_field_invoke('delete revision', $node);
321 321
   _content_field_invoke_default('delete revision', $node);
322
-  cache_clear_all('content:'. $node->nid .':'. $node->vid, content_cache_tablename());
322
+  cache_clear_all('content:'.$node->nid.':'.$node->vid, content_cache_tablename());
323 323
 }
324 324
 
325 325
 /**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 
334 334
   // Merge fields.
335 335
   $additions = _content_field_invoke_default('view', $node, $teaser, $page);
336
-  $node->content = array_merge((array) $node->content, $additions);
336
+  $node->content = array_merge((array)$node->content, $additions);
337 337
 }
338 338
 
339 339
 /**
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
     // One-field equivalent to _content_field_invoke('sanitize').
372 372
     $field_types = _content_field_types();
373 373
     $module = $field_types[$field['type']]['module'];
374
-    $function = $module .'_field';
374
+    $function = $module.'_field';
375 375
     if (function_exists($function)) {
376 376
       $function('sanitize', $node, $field, $items, $teaser, $page);
377 377
       $node->$field['field_name'] = $items;
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
   $additions = _content_field_invoke('prepare translation', $node);
406 406
   // Merge module additions after the default ones to enable overriding
407 407
   // of field values.
408
-  $node = (object) array_merge((array) $node, $default_additions, $additions);
408
+  $node = (object)array_merge((array)$node, $default_additions, $additions);
409 409
 }
410 410
 
411 411
 /**
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
     $type = content_types($node->type);
418 418
     // Save cycles if the type has no CCK fields.
419 419
     if (!empty($type['fields'])) {
420
-      $callback = 'content_'. str_replace(' ', '_', $op);
420
+      $callback = 'content_'.str_replace(' ', '_', $op);
421 421
       if (function_exists($callback)) {
422 422
         $callback($node, $a3, $a4);
423 423
       }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
  *  Implementation of hook_form_alter().
437 437
  */
438 438
 function content_form_alter(&$form, $form_state, $form_id) {
439
-  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'] .'_node_form' == $form_id) {
439
+  if (isset($form['type']) && isset($form['#node']) && $form['type']['#value'].'_node_form' == $form_id) {
440 440
     $type = content_types($form['#node']->type);
441 441
     if (!empty($type['fields'])) {
442 442
       module_load_include('inc', 'content', 'includes/content.node_form');
@@ -487,9 +487,9 @@  discard block
 block discarded – undo
487 487
   $output = '';
488 488
 
489 489
   if ($field['multiple'] >= 1) {
490
-    $table_id = $element['#field_name'] .'_values';
491
-    $order_class = $element['#field_name'] .'-delta-order';
492
-    $required = !empty($element['#required']) ? '<span class="form-required" title="'. t('This field is required.') .'">*</span>' : '';
490
+    $table_id = $element['#field_name'].'_values';
491
+    $order_class = $element['#field_name'].'-delta-order';
492
+    $required = !empty($element['#required']) ? '<span class="form-required" title="'.t('This field is required.').'">*</span>' : '';
493 493
 
494 494
     $header = array(
495 495
       array(
@@ -504,7 +504,7 @@  discard block
 block discarded – undo
504 504
     // preview or failed validation)
505 505
     $items = array();
506 506
     foreach (element_children($element) as $key) {
507
-      if ($key !== $element['#field_name'] .'_add_more') {
507
+      if ($key !== $element['#field_name'].'_add_more') {
508 508
         $items[] = &$element[$key];
509 509
       }
510 510
     }
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
     }
527 527
 
528 528
     $output .= theme('table', $header, $rows, array('id' => $table_id, 'class' => 'content-multiple-table'));
529
-    $output .= $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '';
530
-    $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
529
+    $output .= $element['#description'] ? '<div class="description">'.$element['#description'].'</div>' : '';
530
+    $output .= drupal_render($element[$element['#field_name'].'_add_more']);
531 531
 
532 532
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533 533
   }
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571 571
         return FALSE;
572 572
       }
573
-      db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
573
+      db_query("UPDATE {".content_field_tablename()."} SET active=0 WHERE module='%s'", $module);
574
+      db_query("UPDATE {".content_instance_tablename()."} SET widget_active=0 WHERE widget_module='%s'", $module);
575 575
       content_clear_type_cache(TRUE);
576 576
       break;
577 577
   }
@@ -593,14 +593,14 @@  discard block
 block discarded – undo
593 593
   if ($module_fields) {
594 594
     foreach ($module_fields as $name => $field_info) {
595 595
       watchdog('content', 'Updating field type %type with module %module.', array('%type' => $name, '%module' => $module));
596
-      db_query("UPDATE {". content_field_tablename() ."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
596
+      db_query("UPDATE {".content_field_tablename()."} SET module = '%s', active = %d WHERE type = '%s'", $module, 1, $name);
597 597
     }
598 598
   }
599 599
   $module_widgets = module_invoke($module, 'widget_info');
600 600
   if ($module_widgets) {
601 601
     foreach ($module_widgets as $name => $widget_info) {
602 602
       watchdog('content', 'Updating widget type %type with module %module.', array('%type' => $name, '%module' => $module));
603
-      db_query("UPDATE {". content_instance_tablename() ."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
603
+      db_query("UPDATE {".content_instance_tablename()."} SET widget_module = '%s', widget_active = %d WHERE widget_type = '%s'", $module, 1, $name);
604 604
     }
605 605
   }
606 606
   // This is called from updates and installs, so get the install-safe
@@ -611,8 +611,8 @@  discard block
 block discarded – undo
611 611
   foreach ($types as $type_name => $fields) {
612 612
     foreach ($fields as $field) {
613 613
       if ($field['module'] == $module && !in_array($field['field_name'], $fields_set)) {
614
-        $columns = (array) module_invoke($field['module'], 'field_settings', 'database columns', $field);
615
-        db_query("UPDATE {". content_field_tablename() ."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
614
+        $columns = (array)module_invoke($field['module'], 'field_settings', 'database columns', $field);
615
+        db_query("UPDATE {".content_field_tablename()."} SET db_columns = '%s' WHERE field_name = '%s'", serialize($columns), $field['field_name']);
616 616
         $fields_set[] = $field['field_name'];
617 617
       }
618 618
     }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 
697 697
     case 'presave':
698 698
       if (!empty($node->devel_generate)) {
699
-        include_once('./'. drupal_get_path('module', 'content') .'/includes/content.devel.inc');
699
+        include_once('./'.drupal_get_path('module', 'content').'/includes/content.devel.inc');
700 700
         content_generate_fields($node, $field);
701 701
         $items = $node->{$field['field_name']};
702 702
       }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 
716 716
       // If there was an AHAH add more button in this field, don't save it.
717 717
       // TODO: is it still needed ?
718
-      unset($items[$field['field_name'] .'_add_more']);
718
+      unset($items[$field['field_name'].'_add_more']);
719 719
 
720 720
       if (content_handle('widget', 'multiple values', $field) == CONTENT_HANDLE_CORE) {
721 721
         // Reorder items to account for drag-n-drop reordering.
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
       // enabled after the field was last edited.
753 753
       $formatter_name = isset($field['display_settings'][$context]) && isset($field['display_settings'][$context]['format']) ? $field['display_settings'][$context]['format'] : 'default';
754 754
       if ($formatter = _content_get_formatter($formatter_name, $field['type'])) {
755
-        $theme = $formatter['module'] .'_formatter_'. $formatter_name;
755
+        $theme = $formatter['module'].'_formatter_'.$formatter_name;
756 756
         $single = (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE);
757 757
 
758 758
         $label_display = isset($field['display_settings']['label']['format']) ? $field['display_settings']['label']['format'] : 'above';
@@ -845,7 +845,7 @@  discard block
 block discarded – undo
845 845
               $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846 846
             }
847 847
           }
848
-          elseif (isset($element['items']['#children']))  {
848
+          elseif (isset($element['items']['#children'])) {
849 849
             // Multiple values formatter.
850 850
             $items[0]['view'] = $element['items']['#children'];
851 851
           }
@@ -873,7 +873,7 @@  discard block
 block discarded – undo
873 873
 
874 874
       if ($wrapper) {
875 875
         // '#chilren' is not set if the field is empty.
876
-        $addition[$field['field_name'] .'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
876
+        $addition[$field['field_name'].'_rendered'] = isset($wrapper['#children']) ? $wrapper['#children'] : '';
877 877
       }
878 878
 
879 879
       return $addition;
@@ -901,8 +901,8 @@  discard block
 block discarded – undo
901 901
 function content_set_empty($field, $items) {
902 902
   // Filter out empty values.
903 903
   $filtered = array();
904
-  $function = $field['module'] .'_content_is_empty';
905
-  foreach ((array) $items as $delta => $item) {
904
+  $function = $field['module'].'_content_is_empty';
905
+  foreach ((array)$items as $delta => $item) {
906 906
     if (!$function($item, $field)) {
907 907
       $filtered[] = $item;
908 908
     }
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
         if (!$schema['content fields']) {
986 986
           continue;
987 987
         }
988
-        $query = 'SELECT * FROM {'. $table .'} WHERE vid = %d';
988
+        $query = 'SELECT * FROM {'.$table.'} WHERE vid = %d';
989 989
 
990 990
         // If we're loading a table for a multiple field,
991 991
         // we fetch all rows (values) ordered by delta,
992 992
         // else we only fetch one row.
993
-        $result = isset($schema['fields']['delta']) ? db_query($query .' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
993
+        $result = isset($schema['fields']['delta']) ? db_query($query.' ORDER BY delta', $node->vid) : db_query_range($query, $node->vid, 0, 1);
994 994
 
995 995
         // For each table row, populate the fields.
996 996
         while ($row = db_fetch_array($result)) {
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
           // fields are added to content types -- either a NULL value
1049 1049
           // or the default value? May need to offer the user an option of
1050 1050
           // how to handle that.
1051
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1051
+          if (db_result(db_query("SELECT COUNT(*) FROM {".$table."} WHERE vid = %d", $node->vid))) {
1052 1052
             content_write_record($table, $record, array('vid'));
1053 1053
           }
1054 1054
           else {
@@ -1063,7 +1063,7 @@  discard block
 block discarded – undo
1063 1063
           $db_info = content_database_info($field);
1064 1064
           // Delete and insert, rather than update, in case a value was added.
1065 1065
           if ($op == 'update') {
1066
-            db_query('DELETE FROM {'. $db_info['table'] .'} WHERE vid = %d', $node->vid);
1066
+            db_query('DELETE FROM {'.$db_info['table'].'} WHERE vid = %d', $node->vid);
1067 1067
           }
1068 1068
           foreach ($node->$field['field_name'] as $delta => $item) {
1069 1069
             $record = array();
@@ -1081,13 +1081,13 @@  discard block
 block discarded – undo
1081 1081
 
1082 1082
     case 'delete':
1083 1083
       foreach ($type['tables'] as $table) {
1084
-        db_query('DELETE FROM {'. $table .'} WHERE nid = %d', $node->nid);
1084
+        db_query('DELETE FROM {'.$table.'} WHERE nid = %d', $node->nid);
1085 1085
       }
1086 1086
       break;
1087 1087
 
1088 1088
     case 'delete revision':
1089 1089
       foreach ($type['tables'] as $table) {
1090
-        db_query('DELETE FROM {'. $table .'} WHERE vid = %d', $node->vid);
1090
+        db_query('DELETE FROM {'.$table.'} WHERE vid = %d', $node->vid);
1091 1091
       }
1092 1092
       break;
1093 1093
   }
@@ -1132,7 +1132,7 @@  discard block
 block discarded – undo
1132 1132
 
1133 1133
   // Convert to an object if needed.
1134 1134
   if (is_array($object)) {
1135
-    $object = (object) $object;
1135
+    $object = (object)$object;
1136 1136
     $array = TRUE;
1137 1137
   }
1138 1138
   else {
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
   // Build the SQL.
1189 1189
   $query = '';
1190 1190
   if (!count($update)) {
1191
-    $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1191
+    $query = "INSERT INTO {".$table."} (".implode(', ', $fields).') VALUES ('.implode(', ', $placeholders).')';
1192 1192
     $return = SAVED_NEW;
1193 1193
   }
1194 1194
   else {
@@ -1197,15 +1197,15 @@  discard block
 block discarded – undo
1197 1197
       if ($query) {
1198 1198
         $query .= ', ';
1199 1199
       }
1200
-      $query .= $field .' = '. $placeholders[$id];
1200
+      $query .= $field.' = '.$placeholders[$id];
1201 1201
     }
1202 1202
 
1203 1203
     foreach ($update as $key) {
1204
-      $conditions[] = "$key = ". db_type_placeholder($schema['fields'][$key]['type']);
1204
+      $conditions[] = "$key = ".db_type_placeholder($schema['fields'][$key]['type']);
1205 1205
       $values[] = $object->$key;
1206 1206
     }
1207 1207
 
1208
-    $query = "UPDATE {". $table ."} SET $query WHERE ". implode(' AND ', $conditions);
1208
+    $query = "UPDATE {".$table."} SET $query WHERE ".implode(' AND ', $conditions);
1209 1209
     $return = SAVED_UPDATED;
1210 1210
   }
1211 1211
 
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
 
1221 1221
     // If we began with an array, convert back so we don't surprise the caller.
1222 1222
     if ($array) {
1223
-      $object = (array) $object;
1223
+      $object = (array)$object;
1224 1224
     }
1225 1225
 
1226 1226
     return $return;
@@ -1245,10 +1245,10 @@  discard block
 block discarded – undo
1245 1245
     $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1246 1246
 
1247 1247
     // Make sure AHAH 'add more' button isn't sent to the fields for processing.
1248
-    unset($items[$field['field_name'] .'_add_more']);
1248
+    unset($items[$field['field_name'].'_add_more']);
1249 1249
 
1250 1250
     $module = $field_types[$field['type']]['module'];
1251
-    $function = $module .'_field';
1251
+    $function = $module.'_field';
1252 1252
     if (function_exists($function)) {
1253 1253
       $result = $function($op, $node, $field, $items, $teaser, $page);
1254 1254
       if (is_array($result)) {
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
       return array();
1409 1409
     }
1410 1410
 
1411
-    if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1411
+    if (!$reset && $cached = cache_get('content_type_info:'.$language->language, content_cache_tablename())) {
1412 1412
       $info = $cached->data;
1413 1413
     }
1414 1414
     else {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
       // Populate actual field instances.
1470 1470
       module_load_include('inc', 'content', 'includes/content.crud');
1471 1471
       foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1472
-        $type = (array) $data;
1472
+        $type = (array)$data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
1475 1475
         $type['tables'] = array();
@@ -1502,7 +1502,7 @@  discard block
 block discarded – undo
1502 1502
         $extra = module_invoke_all('content_extra_fields', $type_name);
1503 1503
         drupal_alter('content_extra_fields', $extra, $type_name);
1504 1504
         // Add saved weights.
1505
-        foreach (variable_get('content_extra_weights_'. $type_name, array()) as $key => $value) {
1505
+        foreach (variable_get('content_extra_weights_'.$type_name, array()) as $key => $value) {
1506 1506
           // Some stored entries might not exist anymore, for instance if uploads
1507 1507
           // have been disabled, or vocabularies removed...
1508 1508
           if (isset($extra[$key])) {
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
         $info['content types'][$type_name] = $type;
1515 1515
       }
1516 1516
 
1517
-      cache_set('content_type_info:'. $language->language, $info, content_cache_tablename());
1517
+      cache_set('content_type_info:'.$language->language, $info, content_cache_tablename());
1518 1518
     }
1519 1519
   }
1520 1520
   return $info;
@@ -1585,10 +1585,10 @@  discard block
 block discarded – undo
1585 1585
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586 1586
   }
1587 1587
 
1588
-  $db_info['columns'] = (array) $field['columns'];
1588
+  $db_info['columns'] = (array)$field['columns'];
1589 1589
   // Generate column names for this field from generic column names.
1590 1590
   foreach ($db_info['columns'] as $column_name => $attributes) {
1591
-    $db_info['columns'][$column_name]['column'] = $field['field_name'] .'_'. $column_name;
1591
+    $db_info['columns'][$column_name]['column'] = $field['field_name'].'_'.$column_name;
1592 1592
   }
1593 1593
 
1594 1594
   return $db_info;
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
 function content_allowed_values($field, $flatten = TRUE) {
1683 1683
   static $allowed_values;
1684 1684
 
1685
-  $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
1685
+  $cid = $field['field_name'].':'.($flatten ? '1' : '0');
1686 1686
   if (isset($allowed_values[$cid])) {
1687 1687
     return $allowed_values[$cid];
1688 1688
   }
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
       $opt = content_filter_xss($opt);
1711 1711
       if (strpos($opt, '|') !== FALSE) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713
-        $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1713
+        $allowed_values[$cid][$key] = (isset($value) && $value !== '') ? $value : $key;
1714 1714
       }
1715 1715
       else {
1716 1716
         $allowed_values[$cid][$opt] = $opt;
@@ -1755,14 +1755,14 @@  discard block
 block discarded – undo
1755 1755
  * List of tags allowed by content_filter_xss().
1756 1756
  */
1757 1757
 function _content_filter_xss_allowed_tags() {
1758
-  return array('a', 'b', 'big',  'code', 'del', 'em', 'i', 'ins',  'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1758
+  return array('a', 'b', 'big', 'code', 'del', 'em', 'i', 'ins', 'pre', 'q', 'small', 'span', 'strong', 'sub', 'sup', 'tt', 'ol', 'ul', 'li', 'p', 'br', 'img');
1759 1759
 }
1760 1760
 
1761 1761
 /**
1762 1762
  * Human-readable list of allowed tags, for display in help texts.
1763 1763
  */
1764 1764
 function _content_filter_xss_display_allowed_tags() {
1765
-  return '<'. implode('> <', _content_filter_xss_allowed_tags()) .'>';
1765
+  return '<'.implode('> <', _content_filter_xss_allowed_tags()).'>';
1766 1766
 }
1767 1767
 
1768 1768
 /**
@@ -1795,12 +1795,12 @@  discard block
 block discarded – undo
1795 1795
   }
1796 1796
 
1797 1797
   if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798
-    $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1798
+    $theme = $formatter['module'].'_formatter_'.$formatter_name;
1799 1799
 
1800 1800
     $element = array(
1801 1801
       '#theme' => $theme,
1802 1802
       '#field_name' => $field['field_name'],
1803
-      '#type_name' => isset($node->type) ? $node->type :'',
1803
+      '#type_name' => isset($node->type) ? $node->type : '',
1804 1804
       '#formatter' => $formatter_name,
1805 1805
       '#node' => $node,
1806 1806
       '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
@@ -1811,7 +1811,7 @@  discard block
 block discarded – undo
1811 1811
 
1812 1812
       // hook_field('sanitize') expects an array of items, so we build one.
1813 1813
       $items = array($item);
1814
-      $function = $field['module'] .'_field';
1814
+      $function = $field['module'].'_field';
1815 1815
       if (function_exists($function)) {
1816 1816
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1817 1817
       }
@@ -1821,7 +1821,7 @@  discard block
 block discarded – undo
1821 1821
     else {
1822 1822
       // Multiple values formatter.
1823 1823
       $items = $item;
1824
-      $function = $field['module'] .'_field';
1824
+      $function = $field['module'].'_field';
1825 1825
       if (function_exists($function)) {
1826 1826
         $function('sanitize', $node, $field, $items, FALSE, FALSE);
1827 1827
       }
@@ -1856,13 +1856,13 @@  discard block
 block discarded – undo
1856 1856
   if (!isset($info)) {
1857 1857
     $data = array();
1858 1858
     foreach (module_implements('content_build_modes') as $module) {
1859
-      $function = $module .'_content_build_modes';
1860
-      $data = array_merge($data, (array) $function());
1859
+      $function = $module.'_content_build_modes';
1860
+      $data = array_merge($data, (array)$function());
1861 1861
     }
1862 1862
     $flat = array();
1863 1863
     foreach ($data as $tab) {
1864 1864
       // Use the + operator to preserve numeric indexes (core build modes).
1865
-      $flat += (array) $tab['build modes'];
1865
+      $flat += (array)$tab['build modes'];
1866 1866
     }
1867 1867
     $info = array('tabs' => $data, 'build modes' => $flat);
1868 1868
   }
@@ -1994,13 +1994,13 @@  discard block
 block discarded – undo
1994 1994
 
1995 1995
   $name = str_replace('-', '_', $name);
1996 1996
   switch ("$version-$storage") {
1997
-    case '0-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1997
+    case '0-'.CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
1998 1998
       return "node_$name";
1999
-    case '0-'. CONTENT_DB_STORAGE_PER_FIELD :
1999
+    case '0-'.CONTENT_DB_STORAGE_PER_FIELD :
2000 2000
       return "node_data_$name";
2001
-    case '1003-'. CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2001
+    case '1003-'.CONTENT_DB_STORAGE_PER_CONTENT_TYPE :
2002 2002
       return "content_type_$name";
2003
-    case '1003-'. CONTENT_DB_STORAGE_PER_FIELD :
2003
+    case '1003-'.CONTENT_DB_STORAGE_PER_FIELD :
2004 2004
       return "content_$name";
2005 2005
   }
2006 2006
 }
@@ -2083,7 +2083,7 @@  discard block
 block discarded – undo
2083 2083
 
2084 2084
   if (!empty($field['columns'])) {
2085 2085
     foreach ($field['columns'] as $column => $attributes) {
2086
-      $column_name =  $field['field_name'] .'_'. $column;
2086
+      $column_name = $field['field_name'].'_'.$column;
2087 2087
       if (isset($attributes['index']) && $attributes['index']) {
2088 2088
         $schema['indexes'][$column_name] = array($column_name);
2089 2089
         unset($attributes['index']);
@@ -2116,7 +2116,7 @@  discard block
 block discarded – undo
2116 2116
   if ($db_type == 'mysql' || $db_type == 'mysqli') {
2117 2117
     if (version_compare(db_version(), '5.0.3') < 0) {
2118 2118
       // Earlier versions of MySQL don't support a WHERE clause for SHOW.
2119
-      $result = db_query('SHOW INDEX FROM {'. $table .'}');
2119
+      $result = db_query('SHOW INDEX FROM {'.$table.'}');
2120 2120
       while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122 2122
           return TRUE;
@@ -2124,12 +2124,12 @@  discard block
 block discarded – undo
2124 2124
       }
2125 2125
       return FALSE;
2126 2126
     }
2127
-    return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2127
+    return (bool)db_result(db_query("SHOW INDEX FROM {".$table."} WHERE key_name = '$name'"));
2128 2128
   }
2129 2129
   elseif ($db_type == 'pgsql') {
2130 2130
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2131
     // the table name and suffixed by '_idx'.
2132
-    return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2132
+    return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{".$table."}_{$name}_idx'"));
2133 2133
   }
2134 2134
   return FALSE;
2135 2135
 }
@@ -2226,7 +2226,7 @@  discard block
 block discarded – undo
2226 2226
   elseif (!empty($field['widget']['default_value'])) {
2227 2227
     $default_value = $field['widget']['default_value'];
2228 2228
   }
2229
-  return (array) $default_value;
2229
+  return (array)$default_value;
2230 2230
 }
2231 2231
 
2232 2232
 /**
@@ -2373,7 +2373,7 @@  discard block
 block discarded – undo
2373 2373
       $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2374
     }
2375 2375
   }
2376
-  else  {
2376
+  else {
2377 2377
     // Multiple values formatter.
2378 2378
     // We display the 'all items' output as $items[0], as if it was the
2379 2379
     // output of a single valued field.
@@ -2409,9 +2409,9 @@  discard block
 block discarded – undo
2409 2409
     'field_empty' => $field_empty,
2410 2410
     'template_files' => array(
2411 2411
       'content-field',
2412
-      'content-field-'. $element['#field_name'],
2413
-      'content-field-'. $element['#node']->type,
2414
-      'content-field-'. $element['#field_name'] .'-'. $element['#node']->type,
2412
+      'content-field-'.$element['#field_name'],
2413
+      'content-field-'.$element['#node']->type,
2414
+      'content-field-'.$element['#field_name'].'-'.$element['#node']->type,
2415 2415
     ),
2416 2416
   );
2417 2417
   $variables = array_merge($variables, $additions);
@@ -2629,7 +2629,7 @@  discard block
 block discarded – undo
2629 2629
       if (empty($type_name) || $content_type['type'] == $type_name) {
2630 2630
         foreach ($content_type['fields'] as $field) {
2631 2631
           $db_info = content_database_info($field);
2632
-          if (db_result(db_query("SELECT COUNT(*) FROM {". $db_info['table'] ."}")) >= 1) {
2632
+          if (db_result(db_query("SELECT COUNT(*) FROM {".$db_info['table']."}")) >= 1) {
2633 2633
             return 0;
2634 2634
           }
2635 2635
         }
@@ -2642,10 +2642,10 @@  discard block
 block discarded – undo
2642 2642
   else {
2643 2643
     $db_info = content_database_info($field);
2644 2644
     if (!empty($type_name)) {
2645
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2645
+      $delta = db_result(db_query("SELECT MAX(delta) FROM {".$db_info['table']."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646 2646
     }
2647 2647
     else {
2648
-      $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2648
+      $delta = db_result(db_query("SELECT MAX(delta) FROM {".$db_info['table']."}"));
2649 2649
     }
2650 2650
     if ($delta >= 0) {
2651 2651
       return $delta;
Please login to merge, or discard this patch.
Braces   +36 added lines, -72 removed lines patch added patch discarded remove patch
@@ -242,8 +242,7 @@  discard block
 block discarded – undo
242 242
     foreach ($cached->data as $key => $value) {
243 243
       $node->$key = $value;
244 244
     }
245
-  }
246
-  else {
245
+  } else {
247 246
     $default_additions = _content_field_invoke_default('load', $node);
248 247
     if ($default_additions) {
249 248
       foreach ($default_additions as $key => $value) {
@@ -458,8 +457,7 @@  discard block
 block discarded – undo
458 457
       // render arrays. Check we're not on a form first.
459 458
       if (!isset($elements['#build_id']) && isset($value['view']) && isset($elements[$value['view']])) {
460 459
         $elements[$value['view']]['#weight'] = $value['weight'];
461
-      }
462
-      elseif (isset($elements[$key])) {
460
+      } elseif (isset($elements[$key])) {
463 461
         $elements[$key]['#weight'] = $value['weight'];
464 462
       }
465 463
     }
@@ -530,8 +528,7 @@  discard block
 block discarded – undo
530 528
     $output .= drupal_render($element[$element['#field_name'] .'_add_more']);
531 529
 
532 530
     drupal_add_tabledrag($table_id, 'order', 'sibling', $order_class);
533
-  }
534
-  else {
531
+  } else {
535 532
     foreach (element_children($element) as $key) {
536 533
       $output .= drupal_render($element[$key]);
537 534
     }
@@ -744,8 +741,7 @@  discard block
 block discarded – undo
744 741
       // NODE_BUILD_NORMAL is 0, and ('whatever' == 0) is TRUE, so we need a ===.
745 742
       if ($node->build_mode === NODE_BUILD_NORMAL || $node->build_mode == NODE_BUILD_PREVIEW) {
746 743
         $context = $teaser ? 'teaser' : 'full';
747
-      }
748
-      else {
744
+      } else {
749 745
         $context = $node->build_mode;
750 746
       }
751 747
       // The field may be missing info for $contexts added by modules
@@ -797,8 +793,7 @@  discard block
 block discarded – undo
797 793
             $element['items'][$delta] += $format_info;
798 794
             $element['items'][$delta]['#item']['#delta'] = $delta;
799 795
           }
800
-        }
801
-        else {
796
+        } else {
802 797
           $element['items'] += $format_info;
803 798
         }
804 799
 
@@ -829,8 +824,7 @@  discard block
 block discarded – undo
829 824
       $wrapper = NULL;
830 825
       if (isset($node->content[$field['field_name']])) {
831 826
         $wrapper = $node->content[$field['field_name']];
832
-      }
833
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
827
+      } elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
834 828
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
835 829
       }
836 830
 
@@ -844,13 +838,11 @@  discard block
 block discarded – undo
844 838
               // '#chilren' is not set if the field is empty.
845 839
               $items[$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
846 840
             }
847
-          }
848
-          elseif (isset($element['items']['#children']))  {
841
+          } elseif (isset($element['items']['#children'])) {
849 842
             // Multiple values formatter.
850 843
             $items[0]['view'] = $element['items']['#children'];
851 844
           }
852
-        }
853
-        else {
845
+        } else {
854 846
           // Hidden or inaccessible field.
855 847
           $items[0]['view'] = '';
856 848
         }
@@ -866,8 +858,7 @@  discard block
 block discarded – undo
866 858
       $wrapper = NULL;
867 859
       if (isset($node->content[$field['field_name']])) {
868 860
         $wrapper = $node->content[$field['field_name']];
869
-      }
870
-      elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
861
+      } elseif (module_exists('fieldgroup') && ($group_name = fieldgroup_get_group($node->type, $field['field_name'])) && isset($node->content[$group_name]['group'][$field['field_name']])) {
871 862
         $wrapper = $node->content[$group_name]['group'][$field['field_name']];
872 863
       }
873 864
 
@@ -1050,8 +1041,7 @@  discard block
 block discarded – undo
1050 1041
           // how to handle that.
1051 1042
           if (db_result(db_query("SELECT COUNT(*) FROM {". $table ."} WHERE vid = %d", $node->vid))) {
1052 1043
             content_write_record($table, $record, array('vid'));
1053
-          }
1054
-          else {
1044
+          } else {
1055 1045
             content_write_record($table, $record);
1056 1046
           }
1057 1047
         }
@@ -1134,8 +1124,7 @@  discard block
 block discarded – undo
1134 1124
   if (is_array($object)) {
1135 1125
     $object = (object) $object;
1136 1126
     $array = TRUE;
1137
-  }
1138
-  else {
1127
+  } else {
1139 1128
     $array = FALSE;
1140 1129
   }
1141 1130
 
@@ -1174,12 +1163,10 @@  discard block
 block discarded – undo
1174 1163
 
1175 1164
         if (empty($info['serialize'])) {
1176 1165
           $values[] = $object->$field;
1177
-        }
1178
-        else {
1166
+        } else {
1179 1167
           $values[] = serialize($object->$field);
1180 1168
         }
1181
-      }
1182
-      else {
1169
+      } else {
1183 1170
         $placeholders[] = 'NULL';
1184 1171
       }
1185 1172
     }
@@ -1190,8 +1177,7 @@  discard block
 block discarded – undo
1190 1177
   if (!count($update)) {
1191 1178
     $query = "INSERT INTO {". $table ."} (". implode(', ', $fields) .') VALUES ('. implode(', ', $placeholders) .')';
1192 1179
     $return = SAVED_NEW;
1193
-  }
1194
-  else {
1180
+  } else {
1195 1181
     $query = '';
1196 1182
     foreach ($fields as $id => $field) {
1197 1183
       if ($query) {
@@ -1253,8 +1239,7 @@  discard block
 block discarded – undo
1253 1239
       $result = $function($op, $node, $field, $items, $teaser, $page);
1254 1240
       if (is_array($result)) {
1255 1241
         $return = array_merge($return, $result);
1256
-      }
1257
-      else if (isset($result)) {
1242
+      } else if (isset($result)) {
1258 1243
         $return[] = $result;
1259 1244
       }
1260 1245
     }
@@ -1279,15 +1264,13 @@  discard block
 block discarded – undo
1279 1264
   // rather than by field.
1280 1265
   if (in_array($op, array('load', 'insert', 'update', 'delete', 'delete revision'))) {
1281 1266
     return content_storage($op, $node);
1282
-  }
1283
-  else {
1267
+  } else {
1284 1268
     foreach ($type['fields'] as $field) {
1285 1269
       $items = isset($node->$field['field_name']) ? $node->$field['field_name'] : array();
1286 1270
       $result = content_field($op, $node, $field, $items, $teaser, $page);
1287 1271
       if (is_array($result)) {
1288 1272
         $return = array_merge($return, $result);
1289
-      }
1290
-      else if (isset($result)) {
1273
+      } else if (isset($result)) {
1291 1274
         $return[] = $result;
1292 1275
       }
1293 1276
       if (isset($node->$field['field_name'])) {
@@ -1410,8 +1393,7 @@  discard block
 block discarded – undo
1410 1393
 
1411 1394
     if (!$reset && $cached = cache_get('content_type_info:'. $language->language, content_cache_tablename())) {
1412 1395
       $info = $cached->data;
1413
-    }
1414
-    else {
1396
+    } else {
1415 1397
       $info = array(
1416 1398
         'field types' => array(),
1417 1399
         'widget types' => array(),
@@ -1580,8 +1562,7 @@  discard block
 block discarded – undo
1580 1562
   $db_info = array();
1581 1563
   if ($field['db_storage'] == CONTENT_DB_STORAGE_PER_FIELD) {
1582 1564
     $db_info['table'] = _content_tablename($field['field_name'], CONTENT_DB_STORAGE_PER_FIELD);
1583
-  }
1584
-  else {
1565
+  } else {
1585 1566
     $db_info['table'] = _content_tablename($field['type_name'], CONTENT_DB_STORAGE_PER_CONTENT_TYPE);
1586 1567
   }
1587 1568
 
@@ -1600,8 +1581,7 @@  discard block
 block discarded – undo
1600 1581
 function content_storage_type($field) {
1601 1582
   if ($field['multiple'] > 0) {
1602 1583
     return CONTENT_DB_STORAGE_PER_FIELD;
1603
-  }
1604
-  else {
1584
+  } else {
1605 1585
     module_load_include('inc', 'content', 'includes/content.crud');
1606 1586
     $instances = content_field_instance_read(array('field_name' => $field['field_name']));
1607 1587
     if (count($instances) > 1) {
@@ -1655,8 +1635,7 @@  discard block
 block discarded – undo
1655 1635
     foreach ($array as $key => $value) {
1656 1636
       if (is_array($value)) {
1657 1637
         $result += content_array_flatten($value);
1658
-      }
1659
-      else {
1638
+      } else {
1660 1639
         $result[$key] = $value;
1661 1640
       }
1662 1641
     }
@@ -1711,8 +1690,7 @@  discard block
 block discarded – undo
1711 1690
       if (strpos($opt, '|') !== FALSE) {
1712 1691
         list($key, $value) = explode('|', $opt);
1713 1692
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714
-      }
1715
-      else {
1693
+      } else {
1716 1694
         $allowed_values[$cid][$opt] = $opt;
1717 1695
       }
1718 1696
     }
@@ -1733,8 +1711,7 @@  discard block
 block discarded – undo
1733 1711
   foreach ($options as $key => $opt) {
1734 1712
     if (is_array($opt)) {
1735 1713
       content_allowed_values_filter_html($options[$key]);
1736
-    }
1737
-    else {
1714
+    } else {
1738 1715
       $options[$key] = html_entity_decode(strip_tags($opt), ENT_QUOTES);
1739 1716
     }
1740 1717
   }
@@ -1817,8 +1794,7 @@  discard block
 block discarded – undo
1817 1794
       }
1818 1795
 
1819 1796
       $element['#item'] = $items[0];
1820
-    }
1821
-    else {
1797
+    } else {
1822 1798
       // Multiple values formatter.
1823 1799
       $items = $item;
1824 1800
       $function = $field['module'] .'_field';
@@ -1869,11 +1845,9 @@  discard block
 block discarded – undo
1869 1845
 
1870 1846
   if ($selector === '_tabs') {
1871 1847
     return $info['tabs'];
1872
-  }
1873
-  elseif (isset($selector) && isset($info['tabs'][$selector])) {
1848
+  } elseif (isset($selector) && isset($info['tabs'][$selector])) {
1874 1849
     return isset($info['tabs'][$selector]) ? $info['tabs'][$selector]['build modes'] : array();
1875
-  }
1876
-  else {
1850
+  } else {
1877 1851
     return $info['build modes'];
1878 1852
   }
1879 1853
 }
@@ -1987,8 +1961,7 @@  discard block
 block discarded – undo
1987 1961
 
1988 1962
   if ($version < 1003) {
1989 1963
     $version = 0;
1990
-  }
1991
-  else {
1964
+  } else {
1992 1965
     $version = 1003;
1993 1966
   }
1994 1967
 
@@ -2042,8 +2015,7 @@  discard block
 block discarded – undo
2042 2015
 function content_cache_tablename() {
2043 2016
   if (variable_get('content_schema_version', -1) < 6000) {
2044 2017
     return 'cache';
2045
-  }
2046
-  else {
2018
+  } else {
2047 2019
     return 'cache_content';
2048 2020
   }
2049 2021
 }
@@ -2125,8 +2097,7 @@  discard block
 block discarded – undo
2125 2097
       return FALSE;
2126 2098
     }
2127 2099
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128
-  }
2129
-  elseif ($db_type == 'pgsql') {
2100
+  } elseif ($db_type == 'pgsql') {
2130 2101
     // Note that the index names in Schema API for PostgreSQL are prefixed by
2131 2102
     // the table name and suffixed by '_idx'.
2132 2103
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
@@ -2222,8 +2193,7 @@  discard block
 block discarded – undo
2222 2193
     if (is_array($result)) {
2223 2194
       $default_value = $result;
2224 2195
     }
2225
-  }
2226
-  elseif (!empty($field['widget']['default_value'])) {
2196
+  } elseif (!empty($field['widget']['default_value'])) {
2227 2197
     $default_value = $field['widget']['default_value'];
2228 2198
   }
2229 2199
   return (array) $default_value;
@@ -2336,8 +2306,7 @@  discard block
 block discarded – undo
2336 2306
     || !is_array($object['display_settings'][$context])
2337 2307
     || empty($object['display_settings'][$context]['exclude'])) {
2338 2308
     return FALSE;
2339
-  }
2340
-  else {
2309
+  } else {
2341 2310
     return TRUE;
2342 2311
   }
2343 2312
 }
@@ -2372,8 +2341,7 @@  discard block
 block discarded – undo
2372 2341
       // Use isset() to avoid undefined index message on #children when field values are empty.
2373 2342
       $variables['items'][$delta]['view'] = isset($element['items'][$delta]['#children']) ? $element['items'][$delta]['#children'] : '';
2374 2343
     }
2375
-  }
2376
-  else  {
2344
+  } else {
2377 2345
     // Multiple values formatter.
2378 2346
     // We display the 'all items' output as $items[0], as if it was the
2379 2347
     // output of a single valued field.
@@ -2392,8 +2360,7 @@  discard block
 block discarded – undo
2392 2360
   foreach ($variables['items'] as $delta => $item) {
2393 2361
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394 2362
       $variables['items'][$delta]['empty'] = TRUE;
2395
-    }
2396
-    else {
2363
+    } else {
2397 2364
       $field_empty = FALSE;
2398 2365
       $variables['items'][$delta]['empty'] = FALSE;
2399 2366
     }
@@ -2643,8 +2610,7 @@  discard block
 block discarded – undo
2643 2610
     $db_info = content_database_info($field);
2644 2611
     if (!empty($type_name)) {
2645 2612
       $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."} f LEFT JOIN {node} n ON f.vid = n.vid WHERE n.type = '%s'", $type_name));
2646
-    }
2647
-    else {
2613
+    } else {
2648 2614
       $delta = db_result(db_query("SELECT MAX(delta) FROM {". $db_info['table'] ."}"));
2649 2615
     }
2650 2616
     if ($delta >= 0) {
@@ -2663,8 +2629,7 @@  discard block
 block discarded – undo
2663 2629
   if (!empty($type_name)) {
2664 2630
     $param = array('type_name' => $type_name);
2665 2631
     $inactive = array($type_name => array());
2666
-  }
2667
-  else {
2632
+  } else {
2668 2633
     $param = array();
2669 2634
     $inactive = array();
2670 2635
   }
@@ -2693,8 +2658,7 @@  discard block
 block discarded – undo
2693 2658
   if (!empty($type_name)) {
2694 2659
     $param = array('type_name' => $type_name);
2695 2660
     $inactive = array($type_name => array());
2696
-  }
2697
-  else {
2661
+  } else {
2698 2662
     $param = array();
2699 2663
     $inactive = array();
2700 2664
   }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
   return array(
180 180
     'content_field' => array(
181 181
       'template' => 'content-field',
182
-      'arguments' => array('element' => NULL),
182
+      'arguments' => array('element' => null),
183 183
       'path' => $path,
184 184
     ),
185 185
     'content_overview_links' => array(
@@ -189,22 +189,22 @@  discard block
 block discarded – undo
189 189
       'template' => 'content-admin-field-overview-form',
190 190
       'file' => 'theme.inc',
191 191
       'path' => $path,
192
-      'arguments' => array('form' => NULL),
192
+      'arguments' => array('form' => null),
193 193
     ),
194 194
     'content_display_overview_form' => array(
195 195
       'template' => 'content-admin-display-overview-form',
196 196
       'file' => 'theme.inc',
197 197
       'path' => $path,
198
-      'arguments' => array('form' => NULL),
198
+      'arguments' => array('form' => null),
199 199
     ),
200 200
     'content_exclude' => array(
201
-      'arguments' => array('content' => NULL, 'object' => array(), 'context' => NULL),
201
+      'arguments' => array('content' => null, 'object' => array(), 'context' => null),
202 202
     ),
203 203
     'content_view_multiple_field' => array(
204
-      'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL),
204
+      'arguments' => array('items' => null, 'field' => null, 'data' => null),
205 205
     ),
206 206
     'content_multiple_values' => array(
207
-      'arguments' => array('element' => NULL),
207
+      'arguments' => array('element' => null),
208 208
     ),
209 209
   );
210 210
 }
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
  * Implementation of hook_nodeapi 'validate' op.
266 266
  *
267 267
  */
268
-function content_validate(&$node, $form = NULL) {
268
+function content_validate(&$node, $form = null) {
269 269
   _content_field_invoke('validate', $node, $form);
270 270
   _content_field_invoke_default('validate', $node, $form);
271 271
 }
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 function content_delete(&$node) {
309 309
   _content_field_invoke('delete', $node);
310 310
   _content_field_invoke_default('delete', $node);
311
-  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), TRUE);
311
+  cache_clear_all('content:'. $node->nid .':', content_cache_tablename(), true);
312 312
 }
313 313
 
314 314
 /**
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
  *
328 328
  * Generate field render arrays.
329 329
  */
330
-function content_view(&$node, $teaser = FALSE, $page = FALSE) {
330
+function content_view(&$node, $teaser = false, $page = false) {
331 331
   // Let field modules sanitize their data for output.
332 332
   _content_field_invoke('sanitize', $node, $teaser, $page);
333 333
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
  * @return
361 361
  *   The themed output for the field.
362 362
  */
363
-function content_view_field($field, $node, $teaser = FALSE, $page = FALSE) {
363
+function content_view_field($field, $node, $teaser = false, $page = false) {
364 364
   $output = '';
365 365
   if (isset($node->$field['field_name'])) {
366 366
     $items = $node->$field['field_name'];
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
  * Add back the formatted values in the 'view' element for all fields,
392 392
  * so that node templates can use it.
393 393
  */
394
-function content_alter(&$node, $teaser = FALSE, $page = FALSE) {
394
+function content_alter(&$node, $teaser = false, $page = false) {
395 395
   _content_field_invoke_default('alter', $node, $teaser, $page);
396 396
 }
397 397
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 /**
412 412
  * Implementation of hook_nodeapi().
413 413
  */
414
-function content_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
414
+function content_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
415 415
   // Prevent against invalid 'nodes' built by broken 3rd party code.
416 416
   if (isset($node->type)) {
417 417
     $type = content_types($node->type);
@@ -568,11 +568,11 @@  discard block
 block discarded – undo
568 568
       // When CCK modules are disabled before content module's update is run
569 569
       // to add the active column, we can't do this.
570 570
       if (variable_get('content_schema_version', -1) < 6007) {
571
-        return FALSE;
571
+        return false;
572 572
       }
573 573
       db_query("UPDATE {". content_field_tablename() ."} SET active=0 WHERE module='%s'", $module);
574 574
       db_query("UPDATE {". content_instance_tablename() ."} SET widget_active=0 WHERE widget_module='%s'", $module);
575
-      content_clear_type_cache(TRUE);
575
+      content_clear_type_cache(true);
576 576
       break;
577 577
   }
578 578
 }
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
   // When CCK modules are enabled before content module's update is run,
588 588
   // to add module and active columns, we can't do this.
589 589
   if (variable_get('content_schema_version', -1) < 6007) {
590
-    return FALSE;
590
+    return false;
591 591
   }
592 592
   $module_fields = module_invoke($module, 'field_info');
593 593
   if ($module_fields) {
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
       // Missing fields on node update are handled in content_storage().
709 709
       if (empty($items) && !isset($node->nid)) {
710 710
         foreach (array_keys($field['columns']) as $column) {
711
-          $items[0][$column] = NULL;
711
+          $items[0][$column] = null;
712 712
         }
713 713
         $node->$field['field_name'] = $items;
714 714
       }
@@ -765,7 +765,7 @@  discard block
 block discarded – undo
765 765
           '#type' => 'content_field',
766 766
           '#title' => check_plain(t($field['widget']['label'])),
767 767
           '#field_name' => $field['field_name'],
768
-          '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node),
768
+          '#access' => $formatter_name != 'hidden' && content_access('view', $field, null, $node),
769 769
           '#label_display' => $label_display,
770 770
           '#node' => $node,
771 771
           '#teaser' => $teaser,
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 
827 827
       // The location of the field's rendered output depends on whether the
828 828
       // field is in a fieldgroup or not.
829
-      $wrapper = NULL;
829
+      $wrapper = null;
830 830
       if (isset($node->content[$field['field_name']])) {
831 831
         $wrapper = $node->content[$field['field_name']];
832 832
       }
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
 
864 864
       // The location of the field's rendered output depends on whether the
865 865
       // field is in a fieldgroup or not.
866
-      $wrapper = NULL;
866
+      $wrapper = null;
867 867
       if (isset($node->content[$field['field_name']])) {
868 868
         $wrapper = $node->content[$field['field_name']];
869 869
       }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
   // Make sure we store the right number of 'empty' values.
912 912
   $empty = array();
913 913
   foreach (array_keys($field['columns']) as $column) {
914
-    $empty[$column] = NULL;
914
+    $empty[$column] = null;
915 915
   }
916 916
   $pad = $field['multiple'] > 1 ? $field['multiple'] : 1;
917 917
   $filtered = array_pad($filtered, $pad, $empty);
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
   // Don't try this before content module's update is run to add
968 968
   // the active and module columns.
969 969
   if (variable_get('content_schema_version', -1) < 6007) {
970
-    return FALSE;
970
+    return false;
971 971
   }
972 972
 
973 973
   $type_name = $node->type;
@@ -1133,15 +1133,15 @@  discard block
 block discarded – undo
1133 1133
   // Convert to an object if needed.
1134 1134
   if (is_array($object)) {
1135 1135
     $object = (object) $object;
1136
-    $array = TRUE;
1136
+    $array = true;
1137 1137
   }
1138 1138
   else {
1139
-    $array = FALSE;
1139
+    $array = false;
1140 1140
   }
1141 1141
 
1142 1142
   $schema = drupal_get_schema($table);
1143 1143
   if (empty($schema)) {
1144
-    return FALSE;
1144
+    return false;
1145 1145
   }
1146 1146
 
1147 1147
   $fields = $defs = $values = $serials = $placeholders = array();
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
     return $return;
1227 1227
   }
1228 1228
 
1229
-  return FALSE;
1229
+  return false;
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1235,7 +1235,7 @@  discard block
 block discarded – undo
1235 1235
  * For each operation, both this function and _content_field_invoke_default() are
1236 1236
  * called so that the default database handling can occur.
1237 1237
  */
1238
-function _content_field_invoke($op, &$node, $teaser = NULL, $page = NULL) {
1238
+function _content_field_invoke($op, &$node, $teaser = null, $page = null) {
1239 1239
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1240 1240
   $type = content_types($type_name);
1241 1241
   $field_types = _content_field_types();
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
 /**
1270 1270
  * Invoke content.module's version of a field hook.
1271 1271
  */
1272
-function _content_field_invoke_default($op, &$node, $teaser = NULL, $page = NULL) {
1272
+function _content_field_invoke_default($op, &$node, $teaser = null, $page = null) {
1273 1273
   $type_name = is_string($node) ? $node : (is_array($node) ? $node['type'] : $node->type);
1274 1274
   $type = content_types($type_name);
1275 1275
   $field_types = _content_field_types();
@@ -1307,9 +1307,9 @@  discard block
 block discarded – undo
1307 1307
  * Do some type checking and set up empty arrays for missing
1308 1308
  * info to avoid foreach errors elsewhere in the code.
1309 1309
  */
1310
-function content_types($type_name = NULL) {
1310
+function content_types($type_name = null) {
1311 1311
   // handle type name with either an underscore or a dash
1312
-  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : NULL;
1312
+  $type_name = !empty($type_name) ? str_replace('-', '_', $type_name) : null;
1313 1313
 
1314 1314
   $info = _content_type_info();
1315 1315
   if (isset($info['content types'])) {
@@ -1336,7 +1336,7 @@  discard block
 block discarded – undo
1336 1336
  * content_type_name to avoid bad results when the value is set
1337 1337
  * but empty, as sometimes happens in the formatter.
1338 1338
  */
1339
-function content_fields($field_name = NULL, $content_type_name = NULL) {
1339
+function content_fields($field_name = null, $content_type_name = null) {
1340 1340
   $info = _content_type_info();
1341 1341
   if (isset($info['fields'])) {
1342 1342
     if (empty($field_name)) {
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
     $formatter_name = 'default';
1384 1384
   }
1385 1385
 
1386
-  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : FALSE;
1386
+  return isset($formatters[$formatter_name]) ? $formatters[$formatter_name] : false;
1387 1387
 }
1388 1388
 
1389 1389
 /**
@@ -1392,7 +1392,7 @@  discard block
 block discarded – undo
1392 1392
  * @param $reset
1393 1393
  *   If TRUE, clear the cache and fetch the information from the database again.
1394 1394
  */
1395
-function _content_type_info($reset = FALSE) {
1395
+function _content_type_info($reset = false) {
1396 1396
   global $language;
1397 1397
   static $info;
1398 1398
 
@@ -1468,7 +1468,7 @@  discard block
 block discarded – undo
1468 1468
 
1469 1469
       // Populate actual field instances.
1470 1470
       module_load_include('inc', 'content', 'includes/content.crud');
1471
-      foreach (node_get_types('types', NULL, TRUE) as $type_name => $data) {
1471
+      foreach (node_get_types('types', null, true) as $type_name => $data) {
1472 1472
         $type = (array) $data;
1473 1473
         $type['url_str'] = str_replace('_', '-', $type['type']);
1474 1474
         $type['fields'] = array();
@@ -1545,13 +1545,13 @@  discard block
 block discarded – undo
1545 1545
  * Clear the cache of content_types; called in several places when content
1546 1546
  * information is changed.
1547 1547
  */
1548
-function content_clear_type_cache($rebuild_schema = FALSE) {
1549
-  cache_clear_all('*', content_cache_tablename(), TRUE);
1550
-  _content_type_info(TRUE);
1548
+function content_clear_type_cache($rebuild_schema = false) {
1549
+  cache_clear_all('*', content_cache_tablename(), true);
1550
+  _content_type_info(true);
1551 1551
 
1552 1552
   // Refresh the schema to pick up new information.
1553 1553
   if ($rebuild_schema) {
1554
-    $schema = drupal_get_schema(NULL, TRUE);
1554
+    $schema = drupal_get_schema(null, true);
1555 1555
   }
1556 1556
 
1557 1557
   if (module_exists('views')) {
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
  *   FALSE can be used to support optgroups for select widgets
1680 1680
  *   when allowed values list is generated using PHP code.
1681 1681
  */
1682
-function content_allowed_values($field, $flatten = TRUE) {
1682
+function content_allowed_values($field, $flatten = true) {
1683 1683
   static $allowed_values;
1684 1684
 
1685 1685
   $cid = $field['field_name'] .':'. ($flatten ? '1' : '0');
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
     foreach ($list as $opt) {
1709 1709
       // Sanitize the user input with a permissive filter.
1710 1710
       $opt = content_filter_xss($opt);
1711
-      if (strpos($opt, '|') !== FALSE) {
1711
+      if (strpos($opt, '|') !== false) {
1712 1712
         list($key, $value) = explode('|', $opt);
1713 1713
         $allowed_values[$cid][$key] = (isset($value) && $value !=='') ? $value : $key;
1714 1714
       }
@@ -1789,12 +1789,12 @@  discard block
 block discarded – undo
1789 1789
  *   It will have been passed through the necessary check_plain() or check_markup()
1790 1790
  *   functions as necessary.
1791 1791
  */
1792
-function content_format($field, $item, $formatter_name = 'default', $node = NULL) {
1792
+function content_format($field, $item, $formatter_name = 'default', $node = null) {
1793 1793
   if (!is_array($field)) {
1794 1794
     $field = content_fields($field);
1795 1795
   }
1796 1796
 
1797
-  if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1797
+  if (content_access('view', $field, null, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) {
1798 1798
     $theme = $formatter['module'] .'_formatter_'. $formatter_name;
1799 1799
 
1800 1800
     $element = array(
@@ -1803,7 +1803,7 @@  discard block
 block discarded – undo
1803 1803
       '#type_name' => isset($node->type) ? $node->type :'',
1804 1804
       '#formatter' => $formatter_name,
1805 1805
       '#node' => $node,
1806
-      '#delta' => isset($item['#delta']) ? $item['#delta'] : NULL,
1806
+      '#delta' => isset($item['#delta']) ? $item['#delta'] : null,
1807 1807
     );
1808 1808
 
1809 1809
     if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) {
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
       $items = array($item);
1814 1814
       $function = $field['module'] .'_field';
1815 1815
       if (function_exists($function)) {
1816
-        $function('sanitize', $node, $field, $items, FALSE, FALSE);
1816
+        $function('sanitize', $node, $field, $items, false, false);
1817 1817
       }
1818 1818
 
1819 1819
       $element['#item'] = $items[0];
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
       $items = $item;
1824 1824
       $function = $field['module'] .'_field';
1825 1825
       if (function_exists($function)) {
1826
-        $function('sanitize', $node, $field, $items, FALSE, FALSE);
1826
+        $function('sanitize', $node, $field, $items, false, false);
1827 1827
       }
1828 1828
 
1829 1829
       foreach ($items as $delta => $item) {
@@ -1850,7 +1850,7 @@  discard block
 block discarded – undo
1850 1850
  *   - '_tabs': the list of tabs to be shown on the 'Display fields' screens.
1851 1851
  *   - a string tab id: the build modes in this tab.
1852 1852
  */
1853
-function content_build_modes($selector = NULL) {
1853
+function content_build_modes($selector = null) {
1854 1854
   static $info;
1855 1855
 
1856 1856
   if (!isset($info)) {
@@ -1920,11 +1920,11 @@  discard block
 block discarded – undo
1920 1920
       'build modes' => array(
1921 1921
         'teaser' => array(
1922 1922
           'title' => t('Teaser'),
1923
-          'views style' => TRUE,
1923
+          'views style' => true,
1924 1924
         ),
1925 1925
         'full' => array(
1926 1926
           'title' => t('Full node'),
1927
-          'views style' => TRUE,
1927
+          'views style' => true,
1928 1928
         ),
1929 1929
       ),
1930 1930
     ),
@@ -1933,7 +1933,7 @@  discard block
 block discarded – undo
1933 1933
       'build modes' => array(
1934 1934
         NODE_BUILD_RSS => array(
1935 1935
           'title' => t('RSS'),
1936
-          'views style' => FALSE,
1936
+          'views style' => false,
1937 1937
         ),
1938 1938
       ),
1939 1939
     ),
@@ -1946,11 +1946,11 @@  discard block
 block discarded – undo
1946 1946
       'build modes' => array(
1947 1947
         NODE_BUILD_SEARCH_INDEX => array(
1948 1948
           'title' => t('Search Index'),
1949
-          'views style' => FALSE,
1949
+          'views style' => false,
1950 1950
         ),
1951 1951
         NODE_BUILD_SEARCH_RESULT => array(
1952 1952
           'title' => t('Search Result'),
1953
-          'views style' => FALSE,
1953
+          'views style' => false,
1954 1954
         ),
1955 1955
       ),
1956 1956
     ),
@@ -1963,7 +1963,7 @@  discard block
 block discarded – undo
1963 1963
       'build modes' => array(
1964 1964
         NODE_BUILD_PRINT => array(
1965 1965
           'title' => t('Print'),
1966
-          'views style' => TRUE,
1966
+          'views style' => true,
1967 1967
         ),
1968 1968
       ),
1969 1969
     ),
@@ -1980,7 +1980,7 @@  discard block
 block discarded – undo
1980 1980
  * @return
1981 1981
  *   A string containing the generated name for the database table
1982 1982
  */
1983
-function _content_tablename($name, $storage, $version = NULL) {
1983
+function _content_tablename($name, $storage, $version = null) {
1984 1984
   if (is_null($version)) {
1985 1985
     $version = variable_get('content_schema_version', 0);
1986 1986
   }
@@ -2013,7 +2013,7 @@  discard block
 block discarded – undo
2013 2013
  * to avoid conflicts with field tables that will be prefixed
2014 2014
  * with 'content_field'.
2015 2015
  */
2016
-function content_field_tablename($version = NULL) {
2016
+function content_field_tablename($version = null) {
2017 2017
   if (is_null($version)) {
2018 2018
     $version = variable_get('content_schema_version', 0);
2019 2019
   }
@@ -2025,7 +2025,7 @@  discard block
 block discarded – undo
2025 2025
  *
2026 2026
  * Needed because the table name changes depending on version.
2027 2027
  */
2028
-function content_instance_tablename($version = NULL) {
2028
+function content_instance_tablename($version = null) {
2029 2029
   if (is_null($version)) {
2030 2030
     $version = variable_get('content_schema_version', 0);
2031 2031
   }
@@ -2055,11 +2055,11 @@  discard block
 block discarded – undo
2055 2055
  * Leave $field['columns'] empty to get only the base schema,
2056 2056
  * otherwise the function will return the whole thing.
2057 2057
  */
2058
-function content_table_schema($field = NULL) {
2058
+function content_table_schema($field = null) {
2059 2059
   $schema = array(
2060 2060
     'fields' => array(
2061
-      'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
2062
-      'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0)
2061
+      'vid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0),
2062
+      'nid' => array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0)
2063 2063
     ),
2064 2064
     'primary key' => array('vid'),
2065 2065
     'indexes' => array(
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 
2070 2070
   // Add delta column if needed.
2071 2071
   if (!empty($field['multiple'])) {
2072
-    $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0);
2072
+    $schema['fields']['delta'] = array('type' => 'int', 'unsigned' => true, 'not null' => true, 'default' => 0);
2073 2073
     $schema['primary key'][] = 'delta';
2074 2074
   }
2075 2075
   $schema['content fields'] = array();
@@ -2119,10 +2119,10 @@  discard block
 block discarded – undo
2119 2119
       $result = db_query('SHOW INDEX FROM {'. $table .'}');
2120 2120
       while ($row = db_fetch_array($result)) {
2121 2121
         if ($row['Key_name'] == $name) {
2122
-          return TRUE;
2122
+          return true;
2123 2123
         }
2124 2124
       }
2125
-      return FALSE;
2125
+      return false;
2126 2126
     }
2127 2127
     return (bool)db_result(db_query("SHOW INDEX FROM {". $table ."} WHERE key_name = '$name'"));
2128 2128
   }
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
     // the table name and suffixed by '_idx'.
2132 2132
     return (bool)db_result(db_query("SELECT COUNT(indexname) FROM pg_indexes WHERE indexname = '{". $table ."}_{$name}_idx'"));
2133 2133
   }
2134
-  return FALSE;
2134
+  return false;
2135 2135
 }
2136 2136
 
2137 2137
 /**
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
  *   TRUE if the operation is allowed;
2247 2247
  *   FALSE if the operation is denied.
2248 2248
  */
2249
-function content_access($op, $field, $account = NULL, $node = NULL) {
2249
+function content_access($op, $field, $account = null, $node = null) {
2250 2250
   global $user;
2251 2251
 
2252 2252
   if (is_null($account)) {
@@ -2254,15 +2254,15 @@  discard block
 block discarded – undo
2254 2254
   }
2255 2255
   // Check for valid field data.
2256 2256
   if (!isset($field['field_name'])) {
2257
-    return FALSE;
2257
+    return false;
2258 2258
   }
2259 2259
   $access = module_invoke_all('field_access', $op, $field, $account, $node);
2260 2260
   foreach ($access as $value) {
2261
-    if ($value === FALSE) {
2262
-      return FALSE;
2261
+    if ($value === false) {
2262
+      return false;
2263 2263
     }
2264 2264
   }
2265
-  return TRUE;
2265
+  return true;
2266 2266
 }
2267 2267
 
2268 2268
  /**
@@ -2335,10 +2335,10 @@  discard block
 block discarded – undo
2335 2335
     || empty($object['display_settings'][$context])
2336 2336
     || !is_array($object['display_settings'][$context])
2337 2337
     || empty($object['display_settings'][$context]['exclude'])) {
2338
-    return FALSE;
2338
+    return false;
2339 2339
   }
2340 2340
   else {
2341
-    return TRUE;
2341
+    return true;
2342 2342
   }
2343 2343
 }
2344 2344
 
@@ -2387,15 +2387,15 @@  discard block
 block discarded – undo
2387 2387
   $variables['teaser'] = $element['#teaser'];
2388 2388
   $variables['page'] = $element['#page'];
2389 2389
 
2390
-  $field_empty = TRUE;
2390
+  $field_empty = true;
2391 2391
 
2392 2392
   foreach ($variables['items'] as $delta => $item) {
2393 2393
     if (!isset($item['view']) || (empty($item['view']) && (string)$item['view'] !== '0')) {
2394
-      $variables['items'][$delta]['empty'] = TRUE;
2394
+      $variables['items'][$delta]['empty'] = true;
2395 2395
     }
2396 2396
     else {
2397
-      $field_empty = FALSE;
2398
-      $variables['items'][$delta]['empty'] = FALSE;
2397
+      $field_empty = false;
2398
+      $variables['items'][$delta]['empty'] = false;
2399 2399
     }
2400 2400
   }
2401 2401
 
@@ -2549,7 +2549,7 @@  discard block
 block discarded – undo
2549 2549
       'weight' => -3
2550 2550
     );
2551 2551
   }
2552
-  if (module_exists('upload') && variable_get("upload_$type_name", TRUE)) {
2552
+  if (module_exists('upload') && variable_get("upload_$type_name", true)) {
2553 2553
     $extra['attachments'] = array(
2554 2554
       'label' => t('File attachments'),
2555 2555
       'description' => t('Upload module form.'),
@@ -2616,7 +2616,7 @@  discard block
 block discarded – undo
2616 2616
  * Fields with only NULL data will show up as being in use.
2617 2617
  * Do we want to eliminate them from the results?
2618 2618
  */
2619
-function content_max_delta($field_name, $type_name = NULL) {
2619
+function content_max_delta($field_name, $type_name = null) {
2620 2620
   $fields = content_fields();
2621 2621
   $field = $fields[$field_name];
2622 2622
 
@@ -2652,13 +2652,13 @@  discard block
 block discarded – undo
2652 2652
     }
2653 2653
   }
2654 2654
   // If we got this far, there is no data for this field.
2655
-  return NULL;
2655
+  return null;
2656 2656
 }
2657 2657
 
2658 2658
 /**
2659 2659
  * Helper function to identify inactive fields.
2660 2660
  */
2661
-function content_inactive_fields($type_name = NULL) {
2661
+function content_inactive_fields($type_name = null) {
2662 2662
   module_load_include('inc', 'content', 'includes/content.crud');
2663 2663
   if (!empty($type_name)) {
2664 2664
     $param = array('type_name' => $type_name);
@@ -2668,7 +2668,7 @@  discard block
 block discarded – undo
2668 2668
     $param = array();
2669 2669
     $inactive = array();
2670 2670
   }
2671
-  $all = content_field_instance_read($param, TRUE);
2671
+  $all = content_field_instance_read($param, true);
2672 2672
   $active = array_keys(content_fields());
2673 2673
   foreach ($all as $field) {
2674 2674
     if (!in_array($field['field_name'], $active)) {
@@ -2688,7 +2688,7 @@  discard block
 block discarded – undo
2688 2688
  * EXCEPT that his function will return inactive instances even 
2689 2689
  * if the fields have other (shared) instances that are still active.
2690 2690
  */
2691
-function content_inactive_instances($type_name = NULL) {
2691
+function content_inactive_instances($type_name = null) {
2692 2692
   module_load_include('inc', 'content', 'includes/content.crud');
2693 2693
   if (!empty($type_name)) {
2694 2694
     $param = array('type_name' => $type_name);
@@ -2698,7 +2698,7 @@  discard block
 block discarded – undo
2698 2698
     $param = array();
2699 2699
     $inactive = array();
2700 2700
   }
2701
-  $all = content_field_instance_read($param, TRUE);
2701
+  $all = content_field_instance_read($param, true);
2702 2702
   foreach ($all as $field) {
2703 2703
     $inactive[$field['type_name']][$field['field_name']] = content_field_instance_expand($field);
2704 2704
   }
Please login to merge, or discard this patch.
modules/contrib/content_profile/modules/content_profile_registration.module 4 patches
Indentation   +107 added lines, -107 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_form_alter().
11 11
  */
12 12
 function content_profile_registration_form_alter(&$form, &$form_state, $form_id) {
13
-  if ($form_id == 'user_register') {
13
+    if ($form_id == 'user_register') {
14 14
     require_once drupal_get_path('module', 'node') .'/node.pages.inc';
15 15
 
16 16
     // Allow other modules to customize the used profile types, so modules
@@ -19,44 +19,44 @@  discard block
 block discarded – undo
19 19
     $form += array('#content_profile_registration_use_types' => $default_types);
20 20
 
21 21
     foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
22
-      content_profile_registration_add_profile_form($type, $form, $form_state);
22
+        content_profile_registration_add_profile_form($type, $form, $form_state);
23 23
     }
24
-  }
25
-  elseif ($form_id == 'content_profile_admin_settings') {
24
+    }
25
+    elseif ($form_id == 'content_profile_admin_settings') {
26 26
     $type = $form_state['type'];
27 27
     // Let other modules add registration child elements before us!
28 28
     $form += array('registration' => array());
29 29
     $form['registration'] += array(
30
-      '#type' => 'fieldset',
31
-      '#title' => t('User Registration'),
32
-      '#description' => t('Customize how this content profile shows up on the user registration page.'),
33
-      '#collapsible' => TRUE,
30
+        '#type' => 'fieldset',
31
+        '#title' => t('User Registration'),
32
+        '#description' => t('Customize how this content profile shows up on the user registration page.'),
33
+        '#collapsible' => TRUE,
34 34
     );
35 35
     $form['registration']['registration_use'] = array(
36
-      '#type' => 'checkbox',
37
-      '#title' => t('Use on Registration'),
38
-      '#description' => t('Use this content type on the user registration page'),
39
-      '#default_value' => content_profile_get_settings($type, 'registration_use'),
36
+        '#type' => 'checkbox',
37
+        '#title' => t('Use on Registration'),
38
+        '#description' => t('Use this content type on the user registration page'),
39
+        '#default_value' => content_profile_get_settings($type, 'registration_use'),
40 40
     );
41 41
     $form['registration']['admin_user_create_use'] = array(
42
-      '#type' => 'checkbox',
43
-      '#title' => t('Use on administrative user creation form'),
44
-      '#description' => t('Use this content type when an administrative user creates a new user'),
45
-      '#default_value' => content_profile_get_settings($type, 'admin_user_create_use'),
42
+        '#type' => 'checkbox',
43
+        '#title' => t('Use on administrative user creation form'),
44
+        '#description' => t('Use this content type when an administrative user creates a new user'),
45
+        '#default_value' => content_profile_get_settings($type, 'admin_user_create_use'),
46 46
     );
47 47
     $form['registration']['registration_hide'] = array(
48
-      '#type' => 'checkboxes',
49
-      '#title' => t('Hide form fields'),
50
-      '#description' => t('Hide fields from the user registration form. Required fields cannot be hidden and are not shown here.'),
51
-      '#options' => _content_profile_registration_get_field_select($type),
52
-      '#default_value' => content_profile_get_settings($type, 'registration_hide'),
48
+        '#type' => 'checkboxes',
49
+        '#title' => t('Hide form fields'),
50
+        '#description' => t('Hide fields from the user registration form. Required fields cannot be hidden and are not shown here.'),
51
+        '#options' => _content_profile_registration_get_field_select($type),
52
+        '#default_value' => content_profile_get_settings($type, 'registration_hide'),
53 53
     );
54 54
     array_unshift($form['#submit'], 'content_profile_registration_admin_form_submit');
55
-  }
55
+    }
56 56
 }
57 57
 
58 58
 function content_profile_registration_admin_form_submit($form, &$form_state) {
59
-  $form_state['values']['registration_hide'] = array_keys(array_filter($form_state['values']['registration_hide']));
59
+    $form_state['values']['registration_hide'] = array_keys(array_filter($form_state['values']['registration_hide']));
60 60
 }
61 61
 
62 62
 /**
@@ -68,8 +68,8 @@  discard block
 block discarded – undo
68 68
  *   Associated fields for the given content type.
69 69
  */
70 70
 function _content_profile_registration_get_fields($type) {
71
-  $typeinfo = content_types($type);
72
-  return $typeinfo['fields'];
71
+    $typeinfo = content_types($type);
72
+    return $typeinfo['fields'];
73 73
 }
74 74
 
75 75
 /**
@@ -81,19 +81,19 @@  discard block
 block discarded – undo
81 81
  *   An array of fields suitable for use in a select field.
82 82
 */
83 83
 function _content_profile_registration_get_field_select($type) {
84
-  $fields = module_exists('content') ? _content_profile_registration_get_fields($type) : array();
85
-  $return = array();
86
-  if (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_ENABLED) {
84
+    $fields = module_exists('content') ? _content_profile_registration_get_fields($type) : array();
85
+    $return = array();
86
+    if (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_ENABLED) {
87 87
     $return['title'] = t('Title');
88
-  }
89
-  foreach ($fields as $fieldname => $info) {
88
+    }
89
+    foreach ($fields as $fieldname => $info) {
90 90
     if (!$info['required']) {
91
-      $return[$fieldname] = drupal_ucfirst($info['widget']['label']);
91
+        $return[$fieldname] = drupal_ucfirst($info['widget']['label']);
92 92
     }
93
-  }
94
-  $return['other'] = t('Other form elements (except for required CCK fields)');
93
+    }
94
+    $return['other'] = t('Other form elements (except for required CCK fields)');
95 95
   
96
-  return $return;
96
+    return $return;
97 97
 }
98 98
 
99 99
 /**
@@ -104,28 +104,28 @@  discard block
 block discarded – undo
104 104
  * @see content_profile_registration_user_register_submit()
105 105
  */
106 106
 function content_profile_registration_add_profile_form($type, &$form, &$form_state) {
107
-  // Initialize new node and add in its form.
108
-  $node = array('uid' => 0, 'name' => '', 'type' => $type);
109
-  // Get the original node form.
110
-  $node_form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
111
-  drupal_prepare_form($type .'_node_form', $node_form, $form_state);
107
+    // Initialize new node and add in its form.
108
+    $node = array('uid' => 0, 'name' => '', 'type' => $type);
109
+    // Get the original node form.
110
+    $node_form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
111
+    drupal_prepare_form($type .'_node_form', $node_form, $form_state);
112 112
 
113
-  $node_form += array('#field_info' => array());
114
-  $form_add = array();
113
+    $node_form += array('#field_info' => array());
114
+    $form_add = array();
115 115
 
116
-  // If non-CCK form elements are hidden, only copy over the CCK stuff
117
-  if (in_array('other', content_profile_get_settings($type, 'registration_hide'))) {
116
+    // If non-CCK form elements are hidden, only copy over the CCK stuff
117
+    if (in_array('other', content_profile_get_settings($type, 'registration_hide'))) {
118 118
     foreach ($node_form['#field_info'] as $field_name => $info) {
119
-      if (isset($node_form[$field_name])) {
119
+        if (isset($node_form[$field_name])) {
120 120
         $form_add[$field_name] = $node_form[$field_name];
121
-      }
121
+        }
122 122
     }
123 123
     // Copy over any fieldgroups
124 124
     $keys = array_keys($node_form);
125 125
     foreach ($keys as $key) {
126
-      if (stristr($key, 'group_')) {
126
+        if (stristr($key, 'group_')) {
127 127
         $form_add[$key] = $node_form[$key];
128
-      }
128
+        }
129 129
     }
130 130
     // Add the title
131 131
     $form_add['title'] = $node_form['title'];
@@ -133,51 +133,51 @@  discard block
 block discarded – undo
133 133
     // Set this to the values of one node, as it might be need by some #ahah callbacks
134 134
     $form_add['#node'] = $node_form['#node'];
135 135
     $form_add['type'] = $node_form['type'];
136
-  }
137
-  else {
136
+    }
137
+    else {
138 138
     foreach (array('uid', 'name', 'author', 'buttons', 'language', '#theme', 'options') as $key) {
139
-      unset($node_form[$key]);
139
+        unset($node_form[$key]);
140 140
     }
141 141
     $form_add = $node_form;
142
-  }
142
+    }
143 143
 
144
-  // Hide fields as configured
145
-  foreach (content_profile_get_settings($type, 'registration_hide') as $field_name) {
144
+    // Hide fields as configured
145
+    foreach (content_profile_get_settings($type, 'registration_hide') as $field_name) {
146 146
     if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type, $field_name))) {
147
-      unset($form_add[$group_name][$field_name]);
148
-      if (count(element_children($form_add[$group_name])) == 0) {
147
+        unset($form_add[$group_name][$field_name]);
148
+        if (count(element_children($form_add[$group_name])) == 0) {
149 149
         unset($form_add[$group_name]);
150
-      }
150
+        }
151 151
     }
152 152
     else {
153
-      unset($form_add[$field_name]);
153
+        unset($form_add[$field_name]);
154
+    }
154 155
     }
155
-  }
156 156
   
157
-  // Add in the new form elements into $form.
158
-  $form += array('#field_info' => array());
159
-  $form['#field_info'] += $node_form['#field_info'];
160
-  $form += $form_add;
157
+    // Add in the new form elements into $form.
158
+    $form += array('#field_info' => array());
159
+    $form['#field_info'] += $node_form['#field_info'];
160
+    $form += $form_add;
161 161
   
162
-  // Add in further callbacks needed, if not yet done.
163
-  if (!isset($form['#content_profile_weights'])) {
162
+    // Add in further callbacks needed, if not yet done.
163
+    if (!isset($form['#content_profile_weights'])) {
164 164
     $form['#submit'][] = 'content_profile_registration_user_register_submit';
165 165
     $form['#validate'][] = 'content_profile_registration_user_register_validate';
166 166
     $form['#pre_render'][] = 'content_profile_registration_alter_weights';
167
-  }
167
+    }
168 168
 
169
-  // Care for the weights: Make use of the content types weight and sort the fields in behalf
170
-  // The weights will be applied by the pre_render callback.
171
-  $form += array('#content_profile_weights' => array());
172
-  $weight = content_profile_get_settings($type, 'weight') + 1;
173
-  foreach (element_children($form_add) as $key) {
169
+    // Care for the weights: Make use of the content types weight and sort the fields in behalf
170
+    // The weights will be applied by the pre_render callback.
171
+    $form += array('#content_profile_weights' => array());
172
+    $weight = content_profile_get_settings($type, 'weight') + 1;
173
+    foreach (element_children($form_add) as $key) {
174 174
     $form['#content_profile_weights'] += array($key => $weight);
175
-  }
175
+    }
176 176
 
177
-  // Set the enctype, if necessary.
178
-  if (isset($node_form['#attributes']['enctype'])){
177
+    // Set the enctype, if necessary.
178
+    if (isset($node_form['#attributes']['enctype'])){
179 179
     $form['#attributes']['enctype'] = $node_form['#attributes']['enctype'];
180
-  }
180
+    }
181 181
 }
182 182
 
183 183
 /**
@@ -187,13 +187,13 @@  discard block
 block discarded – undo
187 187
  * @see content_profile_registration_add_profile_form().
188 188
  */
189 189
 function content_profile_registration_alter_weights($elements) {
190
-  foreach ($elements['#content_profile_weights'] as $key => $weight) {
190
+    foreach ($elements['#content_profile_weights'] as $key => $weight) {
191 191
     if (isset($elements[$key]) && is_array($elements[$key])) {
192
-      $elements[$key] += array('#weight' => 0);
193
-      $elements[$key]['#weight'] = $weight + $elements[$key]['#weight'] / 1000;
192
+        $elements[$key] += array('#weight' => 0);
193
+        $elements[$key]['#weight'] = $weight + $elements[$key]['#weight'] / 1000;
194 194
     }
195
-  }
196
-  return $elements;
195
+    }
196
+    return $elements;
197 197
 }
198 198
 
199 199
 
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
  * Validates the user registration form
202 202
  */
203 203
 function content_profile_registration_user_register_validate($form, &$form_state) {
204
-  require_once drupal_get_path('module', 'node') .'/node.pages.inc';
204
+    require_once drupal_get_path('module', 'node') .'/node.pages.inc';
205 205
 
206
-  foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
206
+    foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
207 207
     $node = (object)$form_state['values'];
208 208
     $node->type = $type;
209 209
     node_object_prepare($node);
@@ -212,32 +212,32 @@  discard block
 block discarded – undo
212 212
     unset($node->name);
213 213
 
214 214
     if (!in_array('other', content_profile_get_settings($type, 'registration_hide'))) {
215
-      node_validate($node, $form);
215
+        node_validate($node, $form);
216 216
     }
217 217
     elseif (module_exists('content')) {
218
-      content_validate($node);
218
+        content_validate($node);
219 219
     }
220 220
 
221 221
     $form_state['content_profile_registration'][$type]['node'] = $node;
222
-  }
223
-  // Remove our added values
224
-  foreach ($form['#content_profile_weights'] as $key => $weight) {
222
+    }
223
+    // Remove our added values
224
+    foreach ($form['#content_profile_weights'] as $key => $weight) {
225 225
     _content_profile_registration_remove_values($key, $form[$key], $form_state);
226
-  }
226
+    }
227 227
 }
228 228
 
229 229
 /**
230 230
  * Recursivly removes all form values created by this element or its children.
231 231
  */
232 232
 function _content_profile_registration_remove_values($key, $element, &$form_state) {
233
-  if ((isset($element['#input']) || !empty($element['#tree'])) && isset($form_state['values'][$key])) {
233
+    if ((isset($element['#input']) || !empty($element['#tree'])) && isset($form_state['values'][$key])) {
234 234
     unset($form_state['values'][$key]);
235
-  }
236
-  elseif (empty($element['#input']) && empty($element['#tree'])) {
235
+    }
236
+    elseif (empty($element['#input']) && empty($element['#tree'])) {
237 237
     foreach (element_children($element) as $key) {
238
-      _content_profile_registration_remove_values($key, $element[$key], $form_state);
238
+        _content_profile_registration_remove_values($key, $element[$key], $form_state);
239
+    }
239 240
     }
240
-  }
241 241
 }
242 242
 
243 243
 
@@ -245,33 +245,33 @@  discard block
 block discarded – undo
245 245
  * Submits the user registration form
246 246
  */
247 247
 function content_profile_registration_user_register_submit($form, &$form_state) {
248
-  foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
248
+    foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
249 249
     if ($node = &$form_state['content_profile_registration'][$type]['node']) {
250
-      // Set user's information for the node.
251
-      if (empty($node->title) && (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_OPTIONAL)) {
250
+        // Set user's information for the node.
251
+        if (empty($node->title) && (!module_exists('auto_nodetitle') || auto_nodetitle_get_setting($type) != AUTO_NODETITLE_OPTIONAL)) {
252 252
         $node->title = $form_state['user']->name;
253
-      }
254
-      $node->uid = $form_state['user']->uid;
255
-      $node->name = $form_state['user']->name;
253
+        }
254
+        $node->uid = $form_state['user']->uid;
255
+        $node->name = $form_state['user']->name;
256 256
 
257
-      // Create the node.
258
-      $node = node_submit($node);
259
-      node_save($node);
260
-      // Give us a nice log message.
261
-      if ($node->nid) {
257
+        // Create the node.
258
+        $node = node_submit($node);
259
+        node_save($node);
260
+        // Give us a nice log message.
261
+        if ($node->nid) {
262 262
         watchdog('content', 'Content Profile: added %user %type upon registration.', array('%user' => $node->name, '%type' => $type), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
263
-      }
263
+        }
264
+    }
264 265
     }
265
-  }
266 266
 }
267 267
 
268 268
 /**
269 269
  * Implementation of hook_content_profile_settings().
270 270
  */
271 271
 function content_profile_registration_content_profile_settings() {
272
-  return array(
272
+    return array(
273 273
     'registration_use' => FALSE,
274 274
     'admin_user_create_use' => FALSE,
275 275
     'registration_hide' => array(),
276
-  );
276
+    );
277 277
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  */
12 12
 function content_profile_registration_form_alter(&$form, &$form_state, $form_id) {
13 13
   if ($form_id == 'user_register') {
14
-    require_once drupal_get_path('module', 'node') .'/node.pages.inc';
14
+    require_once drupal_get_path('module', 'node').'/node.pages.inc';
15 15
 
16 16
     // Allow other modules to customize the used profile types, so modules
17 17
     // can easily customize the registration form.
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
   // Initialize new node and add in its form.
108 108
   $node = array('uid' => 0, 'name' => '', 'type' => $type);
109 109
   // Get the original node form.
110
-  $node_form = drupal_retrieve_form($type .'_node_form', $form_state, $node);
111
-  drupal_prepare_form($type .'_node_form', $node_form, $form_state);
110
+  $node_form = drupal_retrieve_form($type.'_node_form', $form_state, $node);
111
+  drupal_prepare_form($type.'_node_form', $node_form, $form_state);
112 112
 
113 113
   $node_form += array('#field_info' => array());
114 114
   $form_add = array();
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
   }
176 176
 
177 177
   // Set the enctype, if necessary.
178
-  if (isset($node_form['#attributes']['enctype'])){
178
+  if (isset($node_form['#attributes']['enctype'])) {
179 179
     $form['#attributes']['enctype'] = $node_form['#attributes']['enctype'];
180 180
   }
181 181
 }
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
   foreach ($elements['#content_profile_weights'] as $key => $weight) {
191 191
     if (isset($elements[$key]) && is_array($elements[$key])) {
192 192
       $elements[$key] += array('#weight' => 0);
193
-      $elements[$key]['#weight'] = $weight + $elements[$key]['#weight'] / 1000;
193
+      $elements[$key]['#weight'] = $weight + $elements[$key]['#weight']/1000;
194 194
     }
195 195
   }
196 196
   return $elements;
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  * Validates the user registration form
202 202
  */
203 203
 function content_profile_registration_user_register_validate($form, &$form_state) {
204
-  require_once drupal_get_path('module', 'node') .'/node.pages.inc';
204
+  require_once drupal_get_path('module', 'node').'/node.pages.inc';
205 205
 
206 206
   foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
207 207
     $node = (object)$form_state['values'];
Please login to merge, or discard this patch.
Braces   +6 added lines, -11 removed lines patch added patch discarded remove patch
@@ -21,8 +21,7 @@  discard block
 block discarded – undo
21 21
     foreach ($form['#content_profile_registration_use_types'] as $type => $typename) {
22 22
       content_profile_registration_add_profile_form($type, $form, $form_state);
23 23
     }
24
-  }
25
-  elseif ($form_id == 'content_profile_admin_settings') {
24
+  } elseif ($form_id == 'content_profile_admin_settings') {
26 25
     $type = $form_state['type'];
27 26
     // Let other modules add registration child elements before us!
28 27
     $form += array('registration' => array());
@@ -133,8 +132,7 @@  discard block
 block discarded – undo
133 132
     // Set this to the values of one node, as it might be need by some #ahah callbacks
134 133
     $form_add['#node'] = $node_form['#node'];
135 134
     $form_add['type'] = $node_form['type'];
136
-  }
137
-  else {
135
+  } else {
138 136
     foreach (array('uid', 'name', 'author', 'buttons', 'language', '#theme', 'options') as $key) {
139 137
       unset($node_form[$key]);
140 138
     }
@@ -148,8 +146,7 @@  discard block
 block discarded – undo
148 146
       if (count(element_children($form_add[$group_name])) == 0) {
149 147
         unset($form_add[$group_name]);
150 148
       }
151
-    }
152
-    else {
149
+    } else {
153 150
       unset($form_add[$field_name]);
154 151
     }
155 152
   }
@@ -175,7 +172,7 @@  discard block
 block discarded – undo
175 172
   }
176 173
 
177 174
   // Set the enctype, if necessary.
178
-  if (isset($node_form['#attributes']['enctype'])){
175
+  if (isset($node_form['#attributes']['enctype'])) {
179 176
     $form['#attributes']['enctype'] = $node_form['#attributes']['enctype'];
180 177
   }
181 178
 }
@@ -213,8 +210,7 @@  discard block
 block discarded – undo
213 210
 
214 211
     if (!in_array('other', content_profile_get_settings($type, 'registration_hide'))) {
215 212
       node_validate($node, $form);
216
-    }
217
-    elseif (module_exists('content')) {
213
+    } elseif (module_exists('content')) {
218 214
       content_validate($node);
219 215
     }
220 216
 
@@ -232,8 +228,7 @@  discard block
 block discarded – undo
232 228
 function _content_profile_registration_remove_values($key, $element, &$form_state) {
233 229
   if ((isset($element['#input']) || !empty($element['#tree'])) && isset($form_state['values'][$key])) {
234 230
     unset($form_state['values'][$key]);
235
-  }
236
-  elseif (empty($element['#input']) && empty($element['#tree'])) {
231
+  } elseif (empty($element['#input']) && empty($element['#tree'])) {
237 232
     foreach (element_children($element) as $key) {
238 233
       _content_profile_registration_remove_values($key, $element[$key], $form_state);
239 234
     }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
       '#type' => 'fieldset',
31 31
       '#title' => t('User Registration'),
32 32
       '#description' => t('Customize how this content profile shows up on the user registration page.'),
33
-      '#collapsible' => TRUE,
33
+      '#collapsible' => true,
34 34
     );
35 35
     $form['registration']['registration_use'] = array(
36 36
       '#type' => 'checkbox',
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
  */
271 271
 function content_profile_registration_content_profile_settings() {
272 272
   return array(
273
-    'registration_use' => FALSE,
274
-    'admin_user_create_use' => FALSE,
273
+    'registration_use' => false,
274
+    'admin_user_create_use' => false,
275 275
     'registration_hide' => array(),
276 276
   );
277 277
 }
Please login to merge, or discard this patch.
boinc/modules/contrib/content_profile/modules/content_profile_tokens.module 5 patches
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -12,83 +12,83 @@
 block discarded – undo
12 12
  * Implementation of hook_token_values().
13 13
  */
14 14
 function content_profile_tokens_token_values($type, $object = NULL, $options = array()) {
15
-  $values = array();
16
-  $types = content_profile_get_types('types');
17
-  switch ($type) {
15
+    $values = array();
16
+    $types = content_profile_get_types('types');
17
+    switch ($type) {
18 18
     case 'user':
19 19
       foreach($types as $type_name => $type) {
20 20
         if (isset($object)) {
21
-          $profile = content_profile_load($type_name, $object->uid);
21
+            $profile = content_profile_load($type_name, $object->uid);
22 22
         }
23 23
         else {
24
-          global $user;
25
-          $profile = content_profile_load($type_name, $user->uid);
24
+            global $user;
25
+            $profile = content_profile_load($type_name, $user->uid);
26 26
         }
27 27
         $fields = content_types($type_name);
28 28
         foreach ($fields['fields'] as $field_name => $field) {
29
-          if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
30
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
32
-          }
29
+            if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
30
+                $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
+                $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
32
+            }
33
+        }
33 34
         }
34
-      }
35
-      break;
35
+        break;
36 36
 
37 37
     case 'flag_friend':
38 38
       if(!empty($object)) {
39 39
         foreach($types as $type_name => $type) {
40
-          $profile_requestor = content_profile_load($type_name, $object->friend->uid);
41
-          $profile_requestee = content_profile_load($type_name, $object->uid);
40
+            $profile_requestor = content_profile_load($type_name, $object->friend->uid);
41
+            $profile_requestee = content_profile_load($type_name, $object->uid);
42 42
           
43
-          $fields = content_types($type_name);
44
-          foreach ($fields['fields'] as $field_name => $field) {
43
+            $fields = content_types($type_name);
44
+            foreach ($fields['fields'] as $field_name => $field) {
45 45
             if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
46
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value'];
46
+                $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
+                $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value'];
48 48
               
49
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value'];
49
+                $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
+                $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value'];
51 51
             }
52
-          }
52
+            }
53
+        }
53 54
         }
54
-      }
55
-      break;
56
-  }
57
-  return $values;
55
+        break;
56
+    }
57
+    return $values;
58 58
 }
59 59
 
60 60
 /**
61 61
  * Implementation of hook_token_list().
62 62
  */
63 63
 function content_profile_tokens_token_list($type = 'all') {
64
-  $tokens = array();
65
-  if ($type == 'user' || $type == 'all') {
64
+    $tokens = array();
65
+    if ($type == 'user' || $type == 'all') {
66 66
     $types = content_profile_get_types('types');
67 67
     foreach ($types as $type_name => $type) {
68 68
     
69
-      $fields = content_types($type_name);
70
-      foreach ($fields['fields'] as $field_name => $field) {
69
+        $fields = content_types($type_name);
70
+        foreach ($fields['fields'] as $field_name => $field) {
71 71
         if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
72
-          $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']);
73
-          $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
72
+            $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']);
73
+            $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
74
+        }
74 75
         }
75
-      }
76 76
     }
77
-  }
77
+    }
78 78
   
79
-  if ($type == 'flag_friend' && module_exists('flag_friend')) {
79
+    if ($type == 'flag_friend' && module_exists('flag_friend')) {
80 80
     foreach($types as $type_name => $type) {
81
-      $fields = content_types($type_name);
82
-      foreach ($fields['fields'] as $field_name => $field) {
81
+        $fields = content_types($type_name);
82
+        foreach ($fields['fields'] as $field_name => $field) {
83 83
         if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
84
-          $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']);
85
-          $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
84
+            $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']);
85
+            $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
86 86
 
87
-          $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']);
88
-          $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
87
+            $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']);
88
+            $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
89
+        }
89 90
         }
90
-      }
91 91
     }
92
-  }
93
-  return $tokens;
92
+    }
93
+    return $tokens;
94 94
 }
Please login to merge, or discard this patch.
Switch Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -15,44 +15,44 @@
 block discarded – undo
15 15
   $values = array();
16 16
   $types = content_profile_get_types('types');
17 17
   switch ($type) {
18
-    case 'user':
19
-      foreach($types as $type_name => $type) {
20
-        if (isset($object)) {
21
-          $profile = content_profile_load($type_name, $object->uid);
22
-        }
23
-        else {
24
-          global $user;
25
-          $profile = content_profile_load($type_name, $user->uid);
26
-        }
27
-        $fields = content_types($type_name);
28
-        foreach ($fields['fields'] as $field_name => $field) {
29
-          if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
30
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
32
-          }
18
+  case 'user':
19
+    foreach($types as $type_name => $type) {
20
+      if (isset($object)) {
21
+        $profile = content_profile_load($type_name, $object->uid);
22
+      }
23
+      else {
24
+        global $user;
25
+        $profile = content_profile_load($type_name, $user->uid);
26
+      }
27
+      $fields = content_types($type_name);
28
+      foreach ($fields['fields'] as $field_name => $field) {
29
+        if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
30
+            $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
+            $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
33 32
         }
34 33
       }
35
-      break;
34
+    }
35
+    break;
36 36
 
37
-    case 'flag_friend':
38
-      if(!empty($object)) {
39
-        foreach($types as $type_name => $type) {
40
-          $profile_requestor = content_profile_load($type_name, $object->friend->uid);
41
-          $profile_requestee = content_profile_load($type_name, $object->uid);
37
+  case 'flag_friend':
38
+    if(!empty($object)) {
39
+      foreach($types as $type_name => $type) {
40
+        $profile_requestor = content_profile_load($type_name, $object->friend->uid);
41
+        $profile_requestee = content_profile_load($type_name, $object->uid);
42 42
           
43
-          $fields = content_types($type_name);
44
-          foreach ($fields['fields'] as $field_name => $field) {
45
-            if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
46
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value'];
43
+        $fields = content_types($type_name);
44
+        foreach ($fields['fields'] as $field_name => $field) {
45
+          if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
46
+            $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
+            $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value'];
48 48
               
49
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value'];
51
-            }
49
+            $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
+            $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value'];
52 51
           }
53 52
         }
54 53
       }
55
-      break;
54
+    }
55
+    break;
56 56
   }
57 57
   return $values;
58 58
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
   $types = content_profile_get_types('types');
17 17
   switch ($type) {
18 18
     case 'user':
19
-      foreach($types as $type_name => $type) {
19
+      foreach ($types as $type_name => $type) {
20 20
         if (isset($object)) {
21 21
           $profile = content_profile_load($type_name, $object->uid);
22 22
         }
@@ -27,27 +27,27 @@  discard block
 block discarded – undo
27 27
         $fields = content_types($type_name);
28 28
         foreach ($fields['fields'] as $field_name => $field) {
29 29
           if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
30
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
-              $values['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile->{$field_name}[0]['value'];
30
+              $values['content-profile-'.$type_name.'-'.substr($field_name, 6)] = check_plain($profile->{$field_name}[0]['value']);
31
+              $values['content-profile-'.$type_name.'-'.substr($field_name, 6).'-raw'] = $profile->{$field_name}[0]['value'];
32 32
           }
33 33
         }
34 34
       }
35 35
       break;
36 36
 
37 37
     case 'flag_friend':
38
-      if(!empty($object)) {
39
-        foreach($types as $type_name => $type) {
38
+      if (!empty($object)) {
39
+        foreach ($types as $type_name => $type) {
40 40
           $profile_requestor = content_profile_load($type_name, $object->friend->uid);
41 41
           $profile_requestee = content_profile_load($type_name, $object->uid);
42 42
           
43 43
           $fields = content_types($type_name);
44 44
           foreach ($fields['fields'] as $field_name => $field) {
45 45
             if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
46
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
-              $values['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestor->{$field_name}[0]['value'];
46
+              $values['requestor-'.$type_name.'-'.substr($field_name, 6)] = check_plain($profile_requestor->{$field_name}[0]['value']);
47
+              $values['requestor-'.$type_name.'-'.substr($field_name, 6).'-raw'] = $profile_requestor->{$field_name}[0]['value'];
48 48
               
49
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
-              $values['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = $profile_requestee->{$field_name}[0]['value'];
49
+              $values['requestee-'.$type_name.'-'.substr($field_name, 6)] = check_plain($profile_requestee->{$field_name}[0]['value']);
50
+              $values['requestee-'.$type_name.'-'.substr($field_name, 6).'-raw'] = $profile_requestee->{$field_name}[0]['value'];
51 51
             }
52 52
           }
53 53
         }
@@ -69,23 +69,23 @@  discard block
 block discarded – undo
69 69
       $fields = content_types($type_name);
70 70
       foreach ($fields['fields'] as $field_name => $field) {
71 71
         if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
72
-          $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6)] = t($fields['description']) .'-'. t($field['widget']['label']);
73
-          $tokens['user']['content-profile-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
72
+          $tokens['user']['content-profile-'.$type_name.'-'.substr($field_name, 6)] = t($fields['description']).'-'.t($field['widget']['label']);
73
+          $tokens['user']['content-profile-'.$type_name.'-'.substr($field_name, 6).'-raw'] = t($fields['description']).'-'.t($field['widget']['label']).' '.t('WARNING - raw user input');
74 74
         }
75 75
       }
76 76
     }
77 77
   }
78 78
   
79 79
   if ($type == 'flag_friend' && module_exists('flag_friend')) {
80
-    foreach($types as $type_name => $type) {
80
+    foreach ($types as $type_name => $type) {
81 81
       $fields = content_types($type_name);
82 82
       foreach ($fields['fields'] as $field_name => $field) {
83 83
         if (!$field['multiple'] && ($field['widget']['type'] == 'text_textfield' || $field['widget']['type'] == 'number')) {
84
-          $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6)] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']);
85
-          $tokens['content_profile_flag_friend']['requestor-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestor:') . t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
84
+          $tokens['content_profile_flag_friend']['requestor-'.$type_name.'-'.substr($field_name, 6)] = t('Requestor:').t($fields['description']).'-'.t($field['widget']['label']);
85
+          $tokens['content_profile_flag_friend']['requestor-'.$type_name.'-'.substr($field_name, 6).'-raw'] = t('Requestor:').t($fields['description']).'-'.t($field['widget']['label']).' '.t('WARNING - raw user input');
86 86
 
87
-          $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6)] = t('Requestee:') . t($fields['description']) .'-'. t($field['widget']['label']);
88
-          $tokens['content_profile_flag_friend']['requestee-'. $type_name .'-'. substr($field_name, 6) .'-raw'] = t('Requestee:') .t($fields['description']) .'-'. t($field['widget']['label']) .' '. t('WARNING - raw user input');
87
+          $tokens['content_profile_flag_friend']['requestee-'.$type_name.'-'.substr($field_name, 6)] = t('Requestee:').t($fields['description']).'-'.t($field['widget']['label']);
88
+          $tokens['content_profile_flag_friend']['requestee-'.$type_name.'-'.substr($field_name, 6).'-raw'] = t('Requestee:').t($fields['description']).'-'.t($field['widget']['label']).' '.t('WARNING - raw user input');
89 89
         }
90 90
       }
91 91
     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,8 +19,7 @@
 block discarded – undo
19 19
       foreach($types as $type_name => $type) {
20 20
         if (isset($object)) {
21 21
           $profile = content_profile_load($type_name, $object->uid);
22
-        }
23
-        else {
22
+        } else {
24 23
           global $user;
25 24
           $profile = content_profile_load($type_name, $user->uid);
26 25
         }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 /**
12 12
  * Implementation of hook_token_values().
13 13
  */
14
-function content_profile_tokens_token_values($type, $object = NULL, $options = array()) {
14
+function content_profile_tokens_token_values($type, $object = null, $options = array()) {
15 15
   $values = array();
16 16
   $types = content_profile_get_types('types');
17 17
   switch ($type) {
Please login to merge, or discard this patch.
sites/default/boinc/modules/contrib/content_profile/content_profile.module 5 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -11,56 +11,56 @@  discard block
 block discarded – undo
11 11
  * Implementation of hook_init().
12 12
  */
13 13
 function content_profile_init() {
14
-  module_load_include('inc', 'content_profile', 'content_profile.theme_vars');
14
+    module_load_include('inc', 'content_profile', 'content_profile.theme_vars');
15 15
 }
16 16
 
17 17
 /**
18 18
  * Implementation of hook_ctools_plugin_directory().
19 19
  */
20 20
 function content_profile_ctools_plugin_directory($module, $plugin) {
21
-  if ($module == 'ctools' && $plugin == 'relationships') {
21
+    if ($module == 'ctools' && $plugin == 'relationships') {
22 22
     return 'panels/' . $plugin;
23
-  }
23
+    }
24 24
 }
25 25
 
26 26
 /**
27 27
  * Implementation of hook_menu().
28 28
  */
29 29
 function content_profile_menu() {
30
-  $items = array();
30
+    $items = array();
31 31
 
32
-  //Register a path for each content profile type
33
-  foreach (content_profile_get_types('names') as $type => $typename) {
32
+    //Register a path for each content profile type
33
+    foreach (content_profile_get_types('names') as $type => $typename) {
34 34
     $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/edit'] = array(
35
-      'title' => 'Edit',
36
-      'type' => MENU_DEFAULT_LOCAL_TASK,
35
+        'title' => 'Edit',
36
+        'type' => MENU_DEFAULT_LOCAL_TASK,
37 37
     );
38 38
     $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/profile'] = array(
39
-      'title' => 'Content profile',
40
-      'description' => 'Configure the display and management of this content profile.',
41
-      'page callback' => 'drupal_get_form',
42
-      'page arguments' => array('content_profile_admin_settings', $type),
43
-      'access callback' => 'user_access',
44
-      'access arguments' => array('administer nodes'),
45
-      'type' => MENU_LOCAL_TASK,
46
-      'weight' => 1,
39
+        'title' => 'Content profile',
40
+        'description' => 'Configure the display and management of this content profile.',
41
+        'page callback' => 'drupal_get_form',
42
+        'page arguments' => array('content_profile_admin_settings', $type),
43
+        'access callback' => 'user_access',
44
+        'access arguments' => array('administer nodes'),
45
+        'type' => MENU_LOCAL_TASK,
46
+        'weight' => 1,
47 47
     );
48
-  }
49
-  foreach (content_profile_get_types('names') as $type => $type_name) {
48
+    }
49
+    foreach (content_profile_get_types('names') as $type => $type_name) {
50 50
     $items['user/%user/profile/'. $type] = array(
51
-      'title callback' => 'check_plain',
52
-      'title' => drupal_ucfirst($type_name),
53
-      'page callback' => 'content_profile_page_edit',
54
-      'page arguments' => array($type, 1),
55
-      'access callback' => 'content_profile_page_access',
56
-      'access arguments' => array($type, 1),
57
-      'weight' => content_profile_get_settings($type, 'weight'),
58
-      'file' => 'node.pages.inc',
59
-      'file path' => drupal_get_path('module', 'node'),
60
-      'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK,
51
+        'title callback' => 'check_plain',
52
+        'title' => drupal_ucfirst($type_name),
53
+        'page callback' => 'content_profile_page_edit',
54
+        'page arguments' => array($type, 1),
55
+        'access callback' => 'content_profile_page_access',
56
+        'access arguments' => array($type, 1),
57
+        'weight' => content_profile_get_settings($type, 'weight'),
58
+        'file' => 'node.pages.inc',
59
+        'file path' => drupal_get_path('module', 'node'),
60
+        'type' => content_profile_get_settings($type, 'edit_tab') == 'top' ? MENU_LOCAL_TASK : MENU_CALLBACK,
61 61
     );
62
-  }
63
-  return $items;
62
+    }
63
+    return $items;
64 64
 }
65 65
 
66 66
 /**
@@ -68,45 +68,45 @@  discard block
 block discarded – undo
68 68
  * Take over menu items generated by the user module for our categories.
69 69
  */
70 70
 function content_profile_menu_alter(&$items) {
71
-  foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
71
+    foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
72 72
     if (!empty($items['user/%user_category/edit/'. $type])) {
73
-      $item = &$items['user/%user_category/edit/'. $type];
74
-      $item = array(
73
+        $item = &$items['user/%user_category/edit/'. $type];
74
+        $item = array(
75 75
         'page callback' => 'content_profile_page_edit',
76 76
         'page arguments' => array($type, 1),
77 77
         'access callback' => 'content_profile_page_access',
78 78
         'access arguments' => array($type, 1),
79 79
         'file' => 'node.pages.inc',
80 80
         'file path' => drupal_get_path('module', 'node'),
81
-      ) + $item;
81
+        ) + $item;
82
+    }
82 83
     }
83
-  }
84 84
 }
85 85
 
86 86
 
87 87
 function content_profile_page_access($type, $account) {
88
-  if ($node = content_profile_load($type, $account->uid)) {
88
+    if ($node = content_profile_load($type, $account->uid)) {
89 89
     return node_access('update', $node);
90
-  }
91
-  // Else user may view the page when they are going to create their own profile
92
-  // or have permission to create it for others.
93
-  global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
90
+    }
91
+    // Else user may view the page when they are going to create their own profile
92
+    // or have permission to create it for others.
93
+    global $user;
94
+    if ($user->uid == $account->uid || user_access('administer nodes') ){
95 95
     return node_access('create', $type);
96
-  }
97
-  return FALSE;
96
+    }
97
+    return FALSE;
98 98
 }
99 99
 
100 100
 /**
101 101
  * Presents a node editing or adding form for the given content profile.
102 102
  */
103 103
 function content_profile_page_edit($type, $account) {
104
-  drupal_set_title(check_plain($account->name));
105
-  $node = content_profile_load($type, $account->uid);
106
-  if (!$node) {
104
+    drupal_set_title(check_plain($account->name));
105
+    $node = content_profile_load($type, $account->uid);
106
+    if (!$node) {
107 107
     $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
108
-  }
109
-  return drupal_get_form($type .'_node_form', $node);
108
+    }
109
+    return drupal_get_form($type .'_node_form', $node);
110 110
 }
111 111
 
112 112
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
  * Implementation of hook_views_api().
115 115
  */
116 116
 function content_profile_views_api() {
117
-  return array(
117
+    return array(
118 118
     'api' => 2,
119 119
     'path' => drupal_get_path('module', 'content_profile') .'/views',
120
-  );
120
+    );
121 121
 }
122 122
 
123 123
 
@@ -125,71 +125,71 @@  discard block
 block discarded – undo
125 125
  * Menu callback; content profile settings.
126 126
  */
127 127
 function content_profile_admin_settings(&$form_state, $type) {
128
-  $form_state['type'] = $type;
128
+    $form_state['type'] = $type;
129 129
 
130
-  $form['weight'] = array(
130
+    $form['weight'] = array(
131 131
     '#type' => 'weight',
132 132
     '#title' => t("Weight"),
133 133
     '#default_value' => content_profile_get_settings($type, 'weight'),
134 134
     '#description' => t('The weight of content of this content type where ever they appear - this applies to the input form integration as well to the display integration.'),
135 135
     '#weight' => 5,
136
-  );
137
-  $form['display'] = array(
136
+    );
137
+    $form['display'] = array(
138 138
     '#type' => 'fieldset',
139 139
     '#title' => t('Display settings'),
140 140
     '#description' => t('Customize the display of this content profile.'),
141 141
     '#collapsible' => TRUE,
142
-  );
143
-  $form['display']['user_display'] = array(
142
+    );
143
+    $form['display']['user_display'] = array(
144 144
     '#type' => 'radios',
145 145
     '#title' => t("User page display style"),
146 146
     '#default_value' => content_profile_get_settings($type, 'user_display'),
147 147
     '#options' => array(
148
-      0 => t("Don't display this content profile on the user account page"),
149
-      'link' => t('Display it as link to the profile content'),
150
-      'full' => t('Display the full content'),
151
-      'teaser' => t("Display the content's teaser"),
148
+        0 => t("Don't display this content profile on the user account page"),
149
+        'link' => t('Display it as link to the profile content'),
150
+        'full' => t('Display the full content'),
151
+        'teaser' => t("Display the content's teaser"),
152 152
     ),
153
-  );
154
-  $form['display']['edit_link'] = array(
153
+    );
154
+    $form['display']['edit_link'] = array(
155 155
     '#type' => 'checkbox',
156 156
     '#title' => t("Include an edit link to the display"),
157 157
     '#default_value' => content_profile_get_settings($type, 'edit_link'),
158
-  );
159
-  $form['display']['add_link'] = array(
158
+    );
159
+    $form['display']['add_link'] = array(
160 160
     '#type' => 'checkbox',
161 161
     '#title' => t("Show a link to the content profile creation page, if there is no profile."),
162 162
     '#default_value' => content_profile_get_settings($type, 'add_link'),
163 163
     '#description' => t("If selected and the user has no profile of this type yet, a link to add one is shown on the user page."),
164
-  );
165
-  $form['display']['edit_tab'] = array(
164
+    );
165
+    $form['display']['edit_tab'] = array(
166 166
     '#type' => 'radios',
167 167
     '#title' => t("Profile edit tab"),
168 168
     '#default_value' => content_profile_get_settings($type, 'edit_tab'),
169 169
     '#options' => array(
170
-      0 => t('None'),
171
-      'top' => t("Show a tab at the user's page"),
172
-      'sub' => t("Show a secondary tab below the user's edit tab"),
170
+        0 => t('None'),
171
+        'top' => t("Show a tab at the user's page"),
172
+        'sub' => t("Show a secondary tab below the user's edit tab"),
173 173
     ),
174
-  );
175
-  $form['submit'] = array(
174
+    );
175
+    $form['submit'] = array(
176 176
     '#type' => 'submit',
177 177
     '#value' => t('Submit'),
178 178
     '#weight' => 10,
179
-  );
180
-  return $form;
179
+    );
180
+    return $form;
181 181
 }
182 182
 
183 183
 function content_profile_admin_settings_submit($form, &$form_state) {
184
-  $settings = content_profile_get_settings($form_state['type']);
185
-  foreach (content_profile_settings_info() as $setting => $default) {
184
+    $settings = content_profile_get_settings($form_state['type']);
185
+    foreach (content_profile_settings_info() as $setting => $default) {
186 186
     if (isset($form_state['values'][$setting])) {
187
-      $settings[$setting] = $form_state['values'][$setting];
187
+        $settings[$setting] = $form_state['values'][$setting];
188
+    }
188 189
     }
189
-  }
190
-  content_profile_set_settings($form_state['type'], $settings);
191
-  drupal_set_message('Your changes have been saved.');
192
-  menu_rebuild();
190
+    content_profile_set_settings($form_state['type'], $settings);
191
+    drupal_set_message('Your changes have been saved.');
192
+    menu_rebuild();
193 193
 }
194 194
 
195 195
 /**
@@ -198,10 +198,10 @@  discard block
 block discarded – undo
198 198
  *   The node object or the node's type
199 199
  */
200 200
 function is_content_profile($type) {
201
-  if (is_object($type)) {
201
+    if (is_object($type)) {
202 202
     $type = $type->type;
203
-  }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
203
+    }
204
+    return variable_get('content_profile_use_'. $type, FALSE);
205 205
 }
206 206
 
207 207
 /**
@@ -218,14 +218,14 @@  discard block
 block discarded – undo
218 218
  *   The value to compare the given setting too.
219 219
  */
220 220
 function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
221
-  $types = array();
221
+    $types = array();
222 222
 
223
-  foreach (node_get_types($op) as $type => $info) {
223
+    foreach (node_get_types($op) as $type => $info) {
224 224
     if (is_content_profile($type) && (!isset($setting) || content_profile_get_settings($type, $setting) == $value)) {
225
-      $types[$type] = $info;
225
+        $types[$type] = $info;
226 226
     }
227
-  }
228
-  return $types;
227
+    }
228
+    return $types;
229 229
 }
230 230
 
231 231
 /**
@@ -233,79 +233,79 @@  discard block
 block discarded – undo
233 233
  * Rename or delete the settings variable if a type changes.
234 234
  */
235 235
 function content_profile_node_type($op, $info) {
236
-  switch ($op) {
236
+    switch ($op) {
237 237
     case 'delete':
238 238
       variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
240
-      break;
239
+        variable_del('content_profile_'. $info->type);
240
+        break;
241 241
     case 'update':
242 242
       if (!empty($info->old_type) && $info->old_type != $info->type) {
243 243
         if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
244
+            $settings = variable_get('content_profile_'. $info->old_type, array());
245
+            variable_del('content_profile_use_'. $info->old_type);
246
+            variable_del('content_profile_'. $info->old_type);
247
+            variable_set('content_profile_use_'. $info->type, 1);
248
+            variable_set('content_profile_'. $info->type, $settings);
249
+        }
249 250
         }
250
-      }
251
-      break;
252
-  }
251
+        break;
252
+    }
253 253
 }
254 254
 
255 255
 /**
256 256
  * Implementation of hook_form_alter().
257 257
  */
258 258
 function content_profile_form_alter(&$form, $form_state, $form_id) {
259
-  if ($form_id == 'node_type_form') {
259
+    if ($form_id == 'node_type_form') {
260 260
     $form['content_profile'] = array(
261
-      '#type' => 'fieldset',
262
-      '#title' => t('Content Profile'),
263
-      '#group' => 'additional_settings',
264
-      '#collapsible' => TRUE,
265
-      '#collapsed' => TRUE,
266
-      '#weight' => 32,
261
+        '#type' => 'fieldset',
262
+        '#title' => t('Content Profile'),
263
+        '#group' => 'additional_settings',
264
+        '#collapsible' => TRUE,
265
+        '#collapsed' => TRUE,
266
+        '#weight' => 32,
267 267
     );
268 268
     $form['content_profile']['content_profile_use'] = array(
269
-      '#type' => 'checkbox',
270
-      '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
269
+        '#type' => 'checkbox',
270
+        '#title' => t('Use this content type as a content profile for users'),
271
+        '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
272 272
     );
273
-  }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
273
+    }
274
+    elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277
-      $form['buttons']['preview']['#access'] = FALSE;
278
-      $form['buttons']['delete']['#access'] = FALSE;
279
-      $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
277
+        $form['buttons']['preview']['#access'] = FALSE;
278
+        $form['buttons']['delete']['#access'] = FALSE;
279
+        $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
282 282
     if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) {
283
-      $form['author']['name']['#default_value'] = $user->name;
283
+        $form['author']['name']['#default_value'] = $user->name;
284
+    }
284 285
     }
285
-  }
286 286
 }
287 287
 
288 288
 /**
289 289
  * Implementation of hook_user().
290 290
  */
291 291
 function content_profile_user($op, &$edit, &$account, $category = NULL) {
292
-  global $user;
292
+    global $user;
293 293
 
294
-  switch ($op) {
294
+    switch ($op) {
295 295
     case 'categories':
296 296
       $data = array();
297
-      foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
297
+        foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298 298
         $data[] = array(
299
-          'name' => $type,
300
-          'title' => drupal_ucfirst($type_name),
301
-          'weight' => content_profile_get_settings($type, 'weight') + 1,
299
+            'name' => $type,
300
+            'title' => drupal_ucfirst($type_name),
301
+            'weight' => content_profile_get_settings($type, 'weight') + 1,
302 302
         );
303
-      }
304
-      return $data;
303
+        }
304
+        return $data;
305 305
 
306 306
     case 'view':
307 307
       $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
-      break;
308
+        break;
309 309
 
310 310
     case 'delete':
311 311
       // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 
316 316
         $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317 317
         while ($node = db_fetch_object($result)) {
318
-          _content_profile_node_delete($node);
318
+            _content_profile_node_delete($node);
319
+        }
319 320
         }
320
-      }
321
-      break;
322
-  }
321
+        break;
322
+    }
323 323
 }
324 324
 
325 325
 /**
@@ -333,42 +333,42 @@  discard block
 block discarded – undo
333 333
  * "SELECT * FROM {node}" query) instead of just the $nid.
334 334
  */
335 335
 function _content_profile_node_delete($node) {
336
-  // Copied over from node_load(), so that node_invoke('delete') gets
337
-  // the fully extended node object, like modules would expect:
336
+    // Copied over from node_load(), so that node_invoke('delete') gets
337
+    // the fully extended node object, like modules would expect:
338 338
 
339
-  if ($node->nid) {
339
+    if ($node->nid) {
340 340
     // Call the node specific callback (if any) and piggy-back the
341 341
     // results to the node or overwrite some values.
342 342
     if ($extra = node_invoke($node, 'load')) {
343
-      foreach ($extra as $key => $value) {
343
+        foreach ($extra as $key => $value) {
344 344
         $node->$key = $value;
345
-      }
345
+        }
346 346
     }
347 347
     if ($extra = node_invoke_nodeapi($node, 'load')) {
348
-      foreach ($extra as $key => $value) {
348
+        foreach ($extra as $key => $value) {
349 349
         $node->$key = $value;
350
-      }
350
+        }
351
+    }
351 352
     }
352
-  }
353 353
 
354
-  // Copied over from node_delete():
354
+    // Copied over from node_delete():
355 355
 
356
-  db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
357
-  db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
356
+    db_query('DELETE FROM {node} WHERE nid = %d', $node->nid);
357
+    db_query('DELETE FROM {node_revisions} WHERE nid = %d', $node->nid);
358 358
 
359
-  // Call the node-specific callback (if any):
360
-  node_invoke($node, 'delete');
361
-  node_invoke_nodeapi($node, 'delete');
359
+    // Call the node-specific callback (if any):
360
+    node_invoke($node, 'delete');
361
+    node_invoke_nodeapi($node, 'delete');
362 362
 
363
-  // Clear the cache so an anonymous poster can see the node being deleted.
364
-  cache_clear_all();
363
+    // Clear the cache so an anonymous poster can see the node being deleted.
364
+    cache_clear_all();
365 365
 
366
-  // Remove this node from the search index if needed.
367
-  if (function_exists('search_wipe')) {
366
+    // Remove this node from the search index if needed.
367
+    if (function_exists('search_wipe')) {
368 368
     search_wipe($node->nid, 'node');
369
-  }
370
-  watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
371
-  drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
369
+    }
370
+    watchdog('content', '@type: deleted %title.', array('@type' => $node->type, '%title' => $node->title));
371
+    drupal_set_message(t('@type %title has been deleted.', array('@type' => node_get_types('name', $node), '%title' => $node->title)));
372 372
 }
373 373
 
374 374
 /**
@@ -376,30 +376,30 @@  discard block
 block discarded – undo
376 376
  */
377 377
 function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
378 378
 
379
-  if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
379
+    if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
380 380
     // Check if this nodetype already exists
381 381
     if ($nid = content_profile_profile_exists($node, $node->uid)) {
382
-      // This node already exists, redirect to edit page
383
-      drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
382
+        // This node already exists, redirect to edit page
383
+        drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
384 384
     }
385
-  }
386
-  elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
385
+    }
386
+    elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
387 387
     $form = $a3;
388 388
     // Only validate if the user-name changed or we add a new node
389 389
     if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {
390
-      return;
390
+        return;
391 391
     }
392 392
     //check whether the selected user has already a profile
393 393
     $uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $node->name));
394 394
     if ($uid && content_profile_profile_exists($node, $uid)) {
395
-      form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
395
+        form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
396
+    }
396 397
     }
397
-  }
398
-  elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
398
+    elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
399 399
     // Make sure the translated profile belongs to the same user.
400 400
     $node->uid = $node->translation_source->uid;
401 401
     $node->name = $node->translation_source->name;
402
-  }
402
+    }
403 403
 }
404 404
 
405 405
 /**
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
  * @return If a node exists, the node id, FALSE else.
413 413
  */
414 414
 function content_profile_profile_exists($node, $uid) {
415
-  $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d ";
416
-  if (module_exists('translation') && translation_supported_type($node->type)) {
415
+    $query = "SELECT n.nid AS nid FROM {node} n WHERE n.type = '%s' AND n.uid = %d ";
416
+    if (module_exists('translation') && translation_supported_type($node->type)) {
417 417
     $query .= "AND n.language = '%s'";
418
-  }
419
-  return db_result(db_query($query, $node->type, $uid, $node->language));
418
+    }
419
+    return db_result(db_query($query, $node->type, $uid, $node->language));
420 420
 }
421 421
 
422 422
 /**
@@ -428,19 +428,19 @@  discard block
 block discarded – undo
428 428
  *   e.g. user_edit, register or weight.
429 429
  */
430 430
 function content_profile_get_settings($type, $return = 'all') {
431
-  $settings = variable_get('content_profile_'. $type, array());
432
-  $settings += content_profile_settings_info();
433
-  if ($return == 'all') {
431
+    $settings = variable_get('content_profile_'. $type, array());
432
+    $settings += content_profile_settings_info();
433
+    if ($return == 'all') {
434 434
     return $settings;
435
-  }
436
-  return $settings[$return];
435
+    }
436
+    return $settings[$return];
437 437
 }
438 438
 
439 439
 /**
440 440
  * Saves the content_profile settings of a content type.
441 441
  */
442 442
 function content_profile_set_settings($type, $settings) {
443
-  variable_set('content_profile_'. $type, $settings);
443
+    variable_set('content_profile_'. $type, $settings);
444 444
 }
445 445
 
446 446
 /**
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
  * and their default value.
449 449
  */
450 450
 function content_profile_settings_info() {
451
-  return module_invoke_all('content_profile_settings');
451
+    return module_invoke_all('content_profile_settings');
452 452
 }
453 453
 
454 454
 /**
@@ -457,13 +457,13 @@  discard block
 block discarded – undo
457 457
  * Defines content profile settings and their default value.
458 458
  */
459 459
 function content_profile_content_profile_settings() {
460
-  return array(
460
+    return array(
461 461
     'weight' => 0,
462 462
     'user_display' => 'full',
463 463
     'edit_link' => 0,
464 464
     'edit_tab' => 'sub',
465 465
     'add_link' => 1,
466
-  );
466
+    );
467 467
 }
468 468
 
469 469
 /**
@@ -479,17 +479,17 @@  discard block
 block discarded – undo
479 479
  *   Optional. If set, the cache is reset.
480 480
  */
481 481
 function content_profile_load($type, $uid, $lang = '', $reset = NULL) {
482
-  static $cache = array();
482
+    static $cache = array();
483 483
 
484
-  if (!isset($cache[$type][$uid][$lang]) || $reset) {
484
+    if (!isset($cache[$type][$uid][$lang]) || $reset) {
485 485
     $cache[$type][$uid][$lang] = FALSE;
486 486
     $params = array('type' => $type, 'uid' => $uid);
487 487
     if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) {
488
-      $cache[$type][$uid][$lang] = $node->nid;
488
+        $cache[$type][$uid][$lang] = $node->nid;
489 489
     }
490 490
     return $node;
491
-  }
492
-  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
491
+    }
492
+    return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
493 493
 }
494 494
 
495 495
 /**
@@ -498,19 +498,19 @@  discard block
 block discarded – undo
498 498
  * Show node submission guidelines for content profile node forms.
499 499
  */
500 500
 function content_profile_help($path, $arg) {
501
-  if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) {
501
+    if (preg_match('/user\/\%\/(profile|edit)\/(.*)/', $path, $matches)) {
502 502
     foreach (content_profile_get_types('names') as $type => $typename) {
503
-      if ($type == $matches[2]) {
503
+        if ($type == $matches[2]) {
504 504
         $node = content_profile_load($type, $arg[1]);
505 505
         if ($node) {
506
-          return node_help('node/%/edit', array(1 => $node->nid));
506
+            return node_help('node/%/edit', array(1 => $node->nid));
507 507
         }
508 508
         else {
509
-          return node_help('node/add/'. $type, array('node', 'add', $type));
509
+            return node_help('node/add/'. $type, array('node', 'add', $type));
510 510
         }
511
-      }
511
+        }
512
+    }
512 513
     }
513
-  }
514 514
 }
515 515
 
516 516
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * that shows all content_profiles as configured by the admin.
519 519
  */
520 520
 function content_profile_show_profiles($uid) {
521
-  global $user;
521
+    global $user;
522 522
 
523
-  $content = array();
524
-  foreach (content_profile_get_types('names') as $type => $type_name) {
523
+    $content = array();
524
+    foreach (content_profile_get_types('names') as $type => $type_name) {
525 525
     $node = content_profile_load($type, $uid);
526 526
 
527 527
     if (($style = content_profile_get_settings($type, 'user_display')) && $node && node_access('view', $node)) {
528
-      $content['content_profile_'. $type] = array(
528
+        $content['content_profile_'. $type] = array(
529 529
         '#theme' => ($style == 'link') ? 'content_profile_display_link' : 'content_profile_display_view',
530 530
         '#edit_link' => content_profile_get_settings($type, 'edit_link'),
531 531
         '#uid' => $uid,
@@ -533,59 +533,59 @@  discard block
 block discarded – undo
533 533
         '#content_type' => $type,
534 534
         '#weight' => content_profile_get_settings($type, 'weight'),
535 535
         '#suffix' => '<br />',
536
-      );
536
+        );
537 537
 
538
-      // Working around the bug described at http://drupal.org/node/302873
539
-      module_load_include('inc', 'content_profile', 'content_profile.theme');
538
+        // Working around the bug described at http://drupal.org/node/302873
539
+        module_load_include('inc', 'content_profile', 'content_profile.theme');
540 540
     }
541 541
     elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
-      $content['content_profile_'. $type] = array(
542
+        $content['content_profile_'. $type] = array(
543 543
         '#admin' => $uid != $user->uid,
544 544
         '#theme' => 'content_profile_display_add_link',
545 545
         '#uid' => $uid,
546 546
         '#content_type' => $type,
547 547
         '#weight' => content_profile_get_settings($type, 'weight'),
548 548
         '#suffix' => '<br />',
549
-      );
549
+        );
550
+    }
550 551
     }
551
-  }
552
-  if ($content) {
552
+    if ($content) {
553 553
     $content['#prefix'] = '<p id="content-profile-view">';
554 554
     $content['#suffix'] = '</p>';
555
-  }
556
-  return $content;
555
+    }
556
+    return $content;
557 557
 }
558 558
 
559 559
 /**
560 560
  * Implementation of hook_theme().
561 561
  */
562 562
 function content_profile_theme() {
563
-  $return = array(
563
+    $return = array(
564 564
     'content_profile_display_view' => array(
565
-      'template'  => 'content_profile-display-view',
566
-      'arguments' => array('element' => NULL),
567
-      'file' => 'content_profile.theme.inc',
565
+        'template'  => 'content_profile-display-view',
566
+        'arguments' => array('element' => NULL),
567
+        'file' => 'content_profile.theme.inc',
568 568
     ),
569 569
     'content_profile_display_add_link' => array(
570
-      'file' => 'content_profile.theme.inc',
570
+        'file' => 'content_profile.theme.inc',
571 571
     ),
572 572
     'content_profile_display_link' => array(
573
-      'file' => 'content_profile.theme.inc',
573
+        'file' => 'content_profile.theme.inc',
574 574
     ),
575 575
     'content_profile_display_tab_view' => array(
576
-      'file' => 'content_profile.theme.inc',
576
+        'file' => 'content_profile.theme.inc',
577 577
     ),
578 578
     'content_profile_display_tab_edit' => array(
579
-      'file' => 'content_profile.theme.inc',
579
+        'file' => 'content_profile.theme.inc',
580 580
     ),
581
-  );
582
-  if (module_exists('pageroute')) {
581
+    );
582
+    if (module_exists('pageroute')) {
583 583
     $return['content_profile_pageroute_empty']  = array(
584
-      'arguments' => array('type_name' => NULL),
585
-    	'file' => 'content_profile.pageroute.inc',
584
+        'arguments' => array('type_name' => NULL),
585
+        'file' => 'content_profile.pageroute.inc',
586 586
     );
587
-  }
588
-  return $return;
587
+    }
588
+    return $return;
589 589
 }
590 590
 
591 591
 /**
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
  * $conf['content_profile_extra_templates'] in settings.php.
595 595
  */
596 596
 function content_profile_theme_registry_alter(&$items) {
597
-  $templates = array_merge(array(
597
+    $templates = array_merge(array(
598 598
     'author_pane',
599 599
     'comment',
600 600
     'node',
@@ -603,47 +603,47 @@  discard block
 block discarded – undo
603 603
     'username',
604 604
     'user_profile',
605 605
     'user_signature',
606
-  ), variable_get('content_profile_extra_templates', array()));
606
+    ), variable_get('content_profile_extra_templates', array()));
607 607
 
608
-  foreach ($templates as $key) {
608
+    foreach ($templates as $key) {
609 609
     if (isset($items[$key])) {
610
-      $items[$key] += array('preprocess functions' => array());
611
-      $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess';
610
+        $items[$key] += array('preprocess functions' => array());
611
+        $items[$key]['preprocess functions'][] = 'content_profile_template_preprocess';
612
+    }
612 613
     }
613
-  }
614 614
 }
615 615
 
616 616
 /**
617 617
  * Adds $content_profile variable if we can find a $uid.
618 618
  */
619 619
 function content_profile_template_preprocess(&$variables, $hook) {
620
-  // Search the uid
621
-  foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) {
620
+    // Search the uid
621
+    foreach (array('account_id', 'uid', 'account', 'node', 'comment', 'user') as $name) {
622 622
     if (isset($variables[$name])) {
623
-      $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name];
624
-      $variables['content_profile'] = new content_profile_theme_variables($uid);
625
-      break;
623
+        $uid = is_object($variables[$name]) ? $variables[$name]->uid : $variables[$name];
624
+        $variables['content_profile'] = new content_profile_theme_variables($uid);
625
+        break;
626
+    }
626 627
     }
627
-  }
628 628
 }
629 629
 
630 630
 /**
631 631
  * Implementation of hook_simpletest().
632 632
  */
633 633
 function content_profile_simpletest() {
634
-  // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
-  $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
636
-  return array_keys($tests);
634
+    // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
+    $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
636
+    return array_keys($tests);
637 637
 }
638 638
 
639 639
 /**
640 640
  * Implementation of hook_pageroute_info() for Pageroute integration.
641 641
  */
642 642
 function content_profile_pageroute_info() {
643
-  return array(
643
+    return array(
644 644
     'content_profile' => array(
645
-      'viewprofile' => 'content_profile.pageroute',
646
-      'editprofile' => 'content_profile.pageroute',
645
+        'viewprofile' => 'content_profile.pageroute',
646
+        'editprofile' => 'content_profile.pageroute',
647 647
     )
648
-  );
648
+    );
649 649
 }
Please login to merge, or discard this patch.
Switch Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -234,21 +234,21 @@  discard block
 block discarded – undo
234 234
  */
235 235
 function content_profile_node_type($op, $info) {
236 236
   switch ($op) {
237
-    case 'delete':
238
-      variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
240
-      break;
241
-    case 'update':
242
-      if (!empty($info->old_type) && $info->old_type != $info->type) {
243
-        if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
249
-        }
237
+  case 'delete':
238
+    variable_del('content_profile_use_'. $info->type);
239
+    variable_del('content_profile_'. $info->type);
240
+    break;
241
+  case 'update':
242
+    if (!empty($info->old_type) && $info->old_type != $info->type) {
243
+      if (is_content_profile($info->old_type)) {
244
+        $settings = variable_get('content_profile_'. $info->old_type, array());
245
+        variable_del('content_profile_use_'. $info->old_type);
246
+        variable_del('content_profile_'. $info->old_type);
247
+        variable_set('content_profile_use_'. $info->type, 1);
248
+        variable_set('content_profile_'. $info->type, $settings);
250 249
       }
251
-      break;
250
+    }
251
+    break;
252 252
   }
253 253
 }
254 254
 
@@ -292,33 +292,33 @@  discard block
 block discarded – undo
292 292
   global $user;
293 293
 
294 294
   switch ($op) {
295
-    case 'categories':
296
-      $data = array();
297
-      foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298
-        $data[] = array(
299
-          'name' => $type,
300
-          'title' => drupal_ucfirst($type_name),
301
-          'weight' => content_profile_get_settings($type, 'weight') + 1,
302
-        );
303
-      }
304
-      return $data;
295
+  case 'categories':
296
+    $data = array();
297
+    foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
298
+      $data[] = array(
299
+        'name' => $type,
300
+        'title' => drupal_ucfirst($type_name),
301
+        'weight' => content_profile_get_settings($type, 'weight') + 1,
302
+      );
303
+    }
304
+    return $data;
305 305
 
306
-    case 'view':
307
-      $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
-      break;
306
+  case 'view':
307
+    $account->content['content_profile'] = content_profile_show_profiles($account->uid);
308
+    break;
309 309
 
310
-    case 'delete':
311
-      // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
312
-      if ($types = content_profile_get_types()) {
313
-        $condition = array_fill(0, count($types), "type = '%s'");
314
-        $arguments = array_merge(array_keys($types), array($account->uid));
310
+  case 'delete':
311
+    // Retrieve all profile nodes (in any language) for this user by issueing an SQL query.
312
+    if ($types = content_profile_get_types()) {
313
+      $condition = array_fill(0, count($types), "type = '%s'");
314
+      $arguments = array_merge(array_keys($types), array($account->uid));
315 315
 
316
-        $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317
-        while ($node = db_fetch_object($result)) {
318
-          _content_profile_node_delete($node);
319
-        }
316
+      $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
317
+      while ($node = db_fetch_object($result)) {
318
+        _content_profile_node_delete($node);
320 319
       }
321
-      break;
320
+    }
321
+    break;
322 322
   }
323 323
 }
324 324
 
Please login to merge, or discard this patch.
Spacing   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function content_profile_ctools_plugin_directory($module, $plugin) {
21 21
   if ($module == 'ctools' && $plugin == 'relationships') {
22
-    return 'panels/' . $plugin;
22
+    return 'panels/'.$plugin;
23 23
   }
24 24
 }
25 25
 
@@ -31,11 +31,11 @@  discard block
 block discarded – undo
31 31
 
32 32
   //Register a path for each content profile type
33 33
   foreach (content_profile_get_types('names') as $type => $typename) {
34
-    $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/edit'] = array(
34
+    $items['admin/content/node-type/'.str_replace('_', '-', $type).'/edit'] = array(
35 35
       'title' => 'Edit',
36 36
       'type' => MENU_DEFAULT_LOCAL_TASK,
37 37
     );
38
-    $items['admin/content/node-type/'. str_replace('_', '-', $type) .'/profile'] = array(
38
+    $items['admin/content/node-type/'.str_replace('_', '-', $type).'/profile'] = array(
39 39
       'title' => 'Content profile',
40 40
       'description' => 'Configure the display and management of this content profile.',
41 41
       'page callback' => 'drupal_get_form',
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     );
48 48
   }
49 49
   foreach (content_profile_get_types('names') as $type => $type_name) {
50
-    $items['user/%user/profile/'. $type] = array(
50
+    $items['user/%user/profile/'.$type] = array(
51 51
       'title callback' => 'check_plain',
52 52
       'title' => drupal_ucfirst($type_name),
53 53
       'page callback' => 'content_profile_page_edit',
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function content_profile_menu_alter(&$items) {
71 71
   foreach (content_profile_get_types('names', 'edit_tab', 'sub') as $type => $type_name) {
72
-    if (!empty($items['user/%user_category/edit/'. $type])) {
73
-      $item = &$items['user/%user_category/edit/'. $type];
72
+    if (!empty($items['user/%user_category/edit/'.$type])) {
73
+      $item = &$items['user/%user_category/edit/'.$type];
74 74
       $item = array(
75 75
         'page callback' => 'content_profile_page_edit',
76 76
         'page arguments' => array($type, 1),
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   // Else user may view the page when they are going to create their own profile
92 92
   // or have permission to create it for others.
93 93
   global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
94
+  if ($user->uid == $account->uid || user_access('administer nodes')) {
95 95
     return node_access('create', $type);
96 96
   }
97 97
   return FALSE;
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
   if (!$node) {
107 107
     $node = array('uid' => $account->uid, 'name' => (isset($account->name) ? $account->name : ''), 'type' => $type, 'language' => '');
108 108
   }
109
-  return drupal_get_form($type .'_node_form', $node);
109
+  return drupal_get_form($type.'_node_form', $node);
110 110
 }
111 111
 
112 112
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 function content_profile_views_api() {
117 117
   return array(
118 118
     'api' => 2,
119
-    'path' => drupal_get_path('module', 'content_profile') .'/views',
119
+    'path' => drupal_get_path('module', 'content_profile').'/views',
120 120
   );
121 121
 }
122 122
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   if (is_object($type)) {
202 202
     $type = $type->type;
203 203
   }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
204
+  return variable_get('content_profile_use_'.$type, FALSE);
205 205
 }
206 206
 
207 207
 /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
  * @param $value
218 218
  *   The value to compare the given setting too.
219 219
  */
220
-function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
220
+function content_profile_get_types($op = 'types', $setting = NULL, $value = TRUE) {
221 221
   $types = array();
222 222
 
223 223
   foreach (node_get_types($op) as $type => $info) {
@@ -235,17 +235,17 @@  discard block
 block discarded – undo
235 235
 function content_profile_node_type($op, $info) {
236 236
   switch ($op) {
237 237
     case 'delete':
238
-      variable_del('content_profile_use_'. $info->type);
239
-      variable_del('content_profile_'. $info->type);
238
+      variable_del('content_profile_use_'.$info->type);
239
+      variable_del('content_profile_'.$info->type);
240 240
       break;
241 241
     case 'update':
242 242
       if (!empty($info->old_type) && $info->old_type != $info->type) {
243 243
         if (is_content_profile($info->old_type)) {
244
-          $settings = variable_get('content_profile_'. $info->old_type, array());
245
-          variable_del('content_profile_use_'. $info->old_type);
246
-          variable_del('content_profile_'. $info->old_type);
247
-          variable_set('content_profile_use_'. $info->type, 1);
248
-          variable_set('content_profile_'. $info->type, $settings);
244
+          $settings = variable_get('content_profile_'.$info->old_type, array());
245
+          variable_del('content_profile_use_'.$info->old_type);
246
+          variable_del('content_profile_'.$info->old_type);
247
+          variable_set('content_profile_use_'.$info->type, 1);
248
+          variable_set('content_profile_'.$info->type, $settings);
249 249
         }
250 250
       }
251 251
       break;
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
     $form['content_profile']['content_profile_use'] = array(
269 269
       '#type' => 'checkbox',
270 270
       '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
271
+      '#default_value' => variable_get('content_profile_use_'.$form['#node_type']->type, FALSE),
272 272
     );
273 273
   }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
274
+  elseif (isset($form['#node']) && $form['#node']->type.'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277 277
       $form['buttons']['preview']['#access'] = FALSE;
278 278
       $form['buttons']['delete']['#access'] = FALSE;
279
-      $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
279
+      $form['#redirect'] = arg(2) == 'profile' ? 'user/'.$form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
282 282
     if (!empty($_GET['uid']) && ($uid = intval($_GET['uid'])) && ($user = user_load($uid))) {
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
         $condition = array_fill(0, count($types), "type = '%s'");
314 314
         $arguments = array_merge(array_keys($types), array($account->uid));
315 315
 
316
-        $result = db_query("SELECT * FROM {node} WHERE (". implode(' OR ', $condition) .") AND uid = %d", $arguments);
316
+        $result = db_query("SELECT * FROM {node} WHERE (".implode(' OR ', $condition).") AND uid = %d", $arguments);
317 317
         while ($node = db_fetch_object($result)) {
318 318
           _content_profile_node_delete($node);
319 319
         }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     // Check if this nodetype already exists
381 381
     if ($nid = content_profile_profile_exists($node, $node->uid)) {
382 382
       // This node already exists, redirect to edit page
383
-      drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
383
+      drupal_goto('node/'.$nid.'/edit', 'destination=user/'.$node->uid);
384 384
     }
385 385
   }
386 386
   elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
  *   e.g. user_edit, register or weight.
429 429
  */
430 430
 function content_profile_get_settings($type, $return = 'all') {
431
-  $settings = variable_get('content_profile_'. $type, array());
431
+  $settings = variable_get('content_profile_'.$type, array());
432 432
   $settings += content_profile_settings_info();
433 433
   if ($return == 'all') {
434 434
     return $settings;
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
  * Saves the content_profile settings of a content type.
441 441
  */
442 442
 function content_profile_set_settings($type, $settings) {
443
-  variable_set('content_profile_'. $type, $settings);
443
+  variable_set('content_profile_'.$type, $settings);
444 444
 }
445 445
 
446 446
 /**
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
           return node_help('node/%/edit', array(1 => $node->nid));
507 507
         }
508 508
         else {
509
-          return node_help('node/add/'. $type, array('node', 'add', $type));
509
+          return node_help('node/add/'.$type, array('node', 'add', $type));
510 510
         }
511 511
       }
512 512
     }
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     $node = content_profile_load($type, $uid);
526 526
 
527 527
     if (($style = content_profile_get_settings($type, 'user_display')) && $node && node_access('view', $node)) {
528
-      $content['content_profile_'. $type] = array(
528
+      $content['content_profile_'.$type] = array(
529 529
         '#theme' => ($style == 'link') ? 'content_profile_display_link' : 'content_profile_display_view',
530 530
         '#edit_link' => content_profile_get_settings($type, 'edit_link'),
531 531
         '#uid' => $uid,
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
       // Working around the bug described at http://drupal.org/node/302873
539 539
       module_load_include('inc', 'content_profile', 'content_profile.theme');
540 540
     }
541
-    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
-      $content['content_profile_'. $type] = array(
541
+    elseif (user_access('create '.$type.' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542
+      $content['content_profile_'.$type] = array(
543 543
         '#admin' => $uid != $user->uid,
544 544
         '#theme' => 'content_profile_display_add_link',
545 545
         '#uid' => $uid,
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
     ),
581 581
   );
582 582
   if (module_exists('pageroute')) {
583
-    $return['content_profile_pageroute_empty']  = array(
583
+    $return['content_profile_pageroute_empty'] = array(
584 584
       'arguments' => array('type_name' => NULL),
585 585
     	'file' => 'content_profile.pageroute.inc',
586 586
     );
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
  */
633 633
 function content_profile_simpletest() {
634 634
   // Scan through content_profile/tests directory for any .test files to tell SimpleTest module.
635
-  $tests = file_scan_directory(drupal_get_path('module', 'content_profile') .'/tests', '\.test');
635
+  $tests = file_scan_directory(drupal_get_path('module', 'content_profile').'/tests', '\.test');
636 636
   return array_keys($tests);
637 637
 }
638 638
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -11 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
   // Else user may view the page when they are going to create their own profile
92 92
   // or have permission to create it for others.
93 93
   global $user;
94
-  if ($user->uid == $account->uid || user_access('administer nodes') ){
94
+  if ($user->uid == $account->uid || user_access('administer nodes') ) {
95 95
     return node_access('create', $type);
96 96
   }
97 97
   return FALSE;
@@ -270,8 +270,7 @@  discard block
 block discarded – undo
270 270
       '#title' => t('Use this content type as a content profile for users'),
271 271
       '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
272 272
     );
273
-  }
274
-  elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
273
+  } elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 274
     // Customize the redirect target and buttons of our own node forms.
276 275
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277 276
       $form['buttons']['preview']['#access'] = FALSE;
@@ -382,8 +381,7 @@  discard block
 block discarded – undo
382 381
       // This node already exists, redirect to edit page
383 382
       drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid);
384 383
     }
385
-  }
386
-  elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
384
+  } elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) {
387 385
     $form = $a3;
388 386
     // Only validate if the user-name changed or we add a new node
389 387
     if (!empty($node->nid) && $form['author']['name']['#default_value'] == $node->name) {
@@ -394,8 +392,7 @@  discard block
 block discarded – undo
394 392
     if ($uid && content_profile_profile_exists($node, $uid)) {
395 393
       form_set_error('name', t('This user already has a content profile of this type. You can only create one profile per user.'));
396 394
     }
397
-  }
398
-  elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
395
+  } elseif ($op == 'prepare translation' && is_content_profile($node->translation_source)) {
399 396
     // Make sure the translated profile belongs to the same user.
400 397
     $node->uid = $node->translation_source->uid;
401 398
     $node->name = $node->translation_source->name;
@@ -504,8 +501,7 @@  discard block
 block discarded – undo
504 501
         $node = content_profile_load($type, $arg[1]);
505 502
         if ($node) {
506 503
           return node_help('node/%/edit', array(1 => $node->nid));
507
-        }
508
-        else {
504
+        } else {
509 505
           return node_help('node/add/'. $type, array('node', 'add', $type));
510 506
         }
511 507
       }
@@ -537,8 +533,7 @@  discard block
 block discarded – undo
537 533
 
538 534
       // Working around the bug described at http://drupal.org/node/302873
539 535
       module_load_include('inc', 'content_profile', 'content_profile.theme');
540
-    }
541
-    elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
536
+    } elseif (user_access('create '. $type .' content') && content_profile_get_settings($type, 'add_link') && !$node && ($uid == $user->uid || user_access('administer nodes'))) {
542 537
       $content['content_profile_'. $type] = array(
543 538
         '#admin' => $uid != $user->uid,
544 539
         '#theme' => 'content_profile_display_add_link',
Please login to merge, or discard this patch.
Upper-Lower-Casing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
   if ($user->uid == $account->uid || user_access('administer nodes') ){
95 95
     return node_access('create', $type);
96 96
   }
97
-  return FALSE;
97
+  return false;
98 98
 }
99 99
 
100 100
 /**
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
     '#type' => 'fieldset',
139 139
     '#title' => t('Display settings'),
140 140
     '#description' => t('Customize the display of this content profile.'),
141
-    '#collapsible' => TRUE,
141
+    '#collapsible' => true,
142 142
   );
143 143
   $form['display']['user_display'] = array(
144 144
     '#type' => 'radios',
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
   if (is_object($type)) {
202 202
     $type = $type->type;
203 203
   }
204
-  return variable_get('content_profile_use_'. $type, FALSE);
204
+  return variable_get('content_profile_use_'. $type, false);
205 205
 }
206 206
 
207 207
 /**
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
  * @param $value
218 218
  *   The value to compare the given setting too.
219 219
  */
220
-function content_profile_get_types($op = 'types', $setting = NULL , $value = TRUE) {
220
+function content_profile_get_types($op = 'types', $setting = null , $value = true) {
221 221
   $types = array();
222 222
 
223 223
   foreach (node_get_types($op) as $type => $info) {
@@ -261,21 +261,21 @@  discard block
 block discarded – undo
261 261
       '#type' => 'fieldset',
262 262
       '#title' => t('Content Profile'),
263 263
       '#group' => 'additional_settings',
264
-      '#collapsible' => TRUE,
265
-      '#collapsed' => TRUE,
264
+      '#collapsible' => true,
265
+      '#collapsed' => true,
266 266
       '#weight' => 32,
267 267
     );
268 268
     $form['content_profile']['content_profile_use'] = array(
269 269
       '#type' => 'checkbox',
270 270
       '#title' => t('Use this content type as a content profile for users'),
271
-      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, FALSE),
271
+      '#default_value' => variable_get('content_profile_use_'. $form['#node_type']->type, false),
272 272
     );
273 273
   }
274 274
   elseif (isset($form['#node']) && $form['#node']->type .'_node_form' == $form_id && is_content_profile($form['#node'])) {
275 275
     // Customize the redirect target and buttons of our own node forms.
276 276
     if (arg(0) == 'user' && is_numeric(arg(1)) && arg(2) == 'edit' || arg(2) == 'profile') {
277
-      $form['buttons']['preview']['#access'] = FALSE;
278
-      $form['buttons']['delete']['#access'] = FALSE;
277
+      $form['buttons']['preview']['#access'] = false;
278
+      $form['buttons']['delete']['#access'] = false;
279 279
       $form['#redirect'] = arg(2) == 'profile' ? 'user/'. $form['#node']->uid : $_GET['q'];
280 280
     }
281 281
     // Set the author value - note that this works only for admins.
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 /**
289 289
  * Implementation of hook_user().
290 290
  */
291
-function content_profile_user($op, &$edit, &$account, $category = NULL) {
291
+function content_profile_user($op, &$edit, &$account, $category = null) {
292 292
   global $user;
293 293
 
294 294
   switch ($op) {
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 /**
375 375
  * Implementation of hook_nodeapi().
376 376
  */
377
-function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
377
+function content_profile_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
378 378
 
379 379
   if ($op == 'prepare' && is_content_profile($node) && !isset($node->nid) && $node->uid && !user_access('administer nodes') && arg(0) != 'admin') {
380 380
     // Check if this nodetype already exists
@@ -478,18 +478,18 @@  discard block
 block discarded – undo
478 478
  * @param $reset
479 479
  *   Optional. If set, the cache is reset.
480 480
  */
481
-function content_profile_load($type, $uid, $lang = '', $reset = NULL) {
481
+function content_profile_load($type, $uid, $lang = '', $reset = null) {
482 482
   static $cache = array();
483 483
 
484 484
   if (!isset($cache[$type][$uid][$lang]) || $reset) {
485
-    $cache[$type][$uid][$lang] = FALSE;
485
+    $cache[$type][$uid][$lang] = false;
486 486
     $params = array('type' => $type, 'uid' => $uid);
487
-    if ($node = node_load($lang ? $params + array('language' => $lang) : $params, NULL, $reset)) {
487
+    if ($node = node_load($lang ? $params + array('language' => $lang) : $params, null, $reset)) {
488 488
       $cache[$type][$uid][$lang] = $node->nid;
489 489
     }
490 490
     return $node;
491 491
   }
492
-  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : FALSE;
492
+  return !empty($cache[$type][$uid][$lang]) ? node_load($cache[$type][$uid][$lang]) : false;
493 493
 }
494 494
 
495 495
 /**
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
   $return = array(
564 564
     'content_profile_display_view' => array(
565 565
       'template'  => 'content_profile-display-view',
566
-      'arguments' => array('element' => NULL),
566
+      'arguments' => array('element' => null),
567 567
       'file' => 'content_profile.theme.inc',
568 568
     ),
569 569
     'content_profile_display_add_link' => array(
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
   );
582 582
   if (module_exists('pageroute')) {
583 583
     $return['content_profile_pageroute_empty']  = array(
584
-      'arguments' => array('type_name' => NULL),
584
+      'arguments' => array('type_name' => null),
585 585
     	'file' => 'content_profile.pageroute.inc',
586 586
     );
587 587
   }
Please login to merge, or discard this patch.
default/boinc/modules/contrib/content_profile/content_profile.rules.inc 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -10,79 +10,79 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_rules_condition_info().
11 11
  */
12 12
 function content_profile_rules_condition_info() {
13
-  return array(
13
+    return array(
14 14
     'content_profile_user_has_profile_condition' => array(
15
-      'label' => t('User has content profile'),
16
-      'arguments' => array(
15
+        'label' => t('User has content profile'),
16
+        'arguments' => array(
17 17
         'user' => array('type' => 'user', 'label' => t('User')),
18
-      ),
19
-      'module' => 'Content Profile',
18
+        ),
19
+        'module' => 'Content Profile',
20 20
     ),
21
-  );
21
+    );
22 22
 }
23 23
 
24 24
 function content_profile_user_has_profile_condition($user, $settings) {
25
-  $node = content_profile_load($settings['type'], $user->uid);
26
-  return (bool)$node;
25
+    $node = content_profile_load($settings['type'], $user->uid);
26
+    return (bool)$node;
27 27
 }
28 28
 
29 29
 function content_profile_user_has_profile_condition_form($settings, &$form) {
30
-  $settings += array('type' => array());
31
-  $form['settings']['type'] = array(
30
+    $settings += array('type' => array());
31
+    $form['settings']['type'] = array(
32 32
     '#type' => 'select',
33 33
     '#title' => t('Content Profile Content Type'),
34 34
     '#options' => content_profile_get_types('names'),
35 35
     '#default_value' => $settings['type'],
36 36
     '#description' => t('Select the Content Profile content type to check for.'),
37 37
     '#required' => TRUE,
38
-  );
38
+    );
39 39
 }
40 40
 
41 41
 function content_profile_user_has_profile_condition_label($settings, $argument_labels) {
42
-  return t('@user has his @type created', $argument_labels + array('@type' => node_get_types('name', $settings['type'])));
42
+    return t('@user has his @type created', $argument_labels + array('@type' => node_get_types('name', $settings['type'])));
43 43
 }
44 44
 
45 45
 /**
46 46
  * Implementation of hook_rules_action_info().
47 47
  */
48 48
 function content_profile_rules_action_info() {
49
-  return array(
49
+    return array(
50 50
     'content_profile_action_load' => array(
51
-      'label' => t('Load Content Profile'),
52
-      'arguments' => array(
51
+        'label' => t('Load Content Profile'),
52
+        'arguments' => array(
53 53
         'user' => array('type' => 'user', 'label' => t('User, whose profile should be loaded')),
54
-      ),
55
-      'new variables' => array(
54
+        ),
55
+        'new variables' => array(
56 56
         'profile_node' => array('type' => 'node', 'label' => t('Content Profile')),
57
-      ),
58
-      'module' => 'Content Profile',
57
+        ),
58
+        'module' => 'Content Profile',
59 59
     ),
60
-  );
60
+    );
61 61
 }
62 62
 
63 63
 /**
64 64
  * Loads a Content Profile
65 65
  */
66 66
 function content_profile_action_load($user, $settings) {
67
-  if ($node = content_profile_load($settings['type'], $user->uid)) {
67
+    if ($node = content_profile_load($settings['type'], $user->uid)) {
68 68
     return array('profile_node' => $node);
69
-  }
69
+    }
70 70
 }
71 71
 
72 72
 function content_profile_action_load_form($settings, &$form) {
73
-  $settings += array('type' => array());
74
-  $form['settings']['type'] = array(
73
+    $settings += array('type' => array());
74
+    $form['settings']['type'] = array(
75 75
     '#type' => 'select',
76 76
     '#title' => t('Content Profile Content Type'),
77 77
     '#options' => content_profile_get_types('names'),
78 78
     '#default_value' => $settings['type'],
79 79
     '#description' => t('Select the Content Profile content type to load.'),
80 80
     '#required' => TRUE,
81
-  );
81
+    );
82 82
 }
83 83
 
84 84
 function content_profile_action_load_label($settings, $argument_labels) {
85
-  return t("Load @user's @type", $argument_labels + array('@type' => node_get_types('name', $settings['type'])));
85
+    return t("Load @user's @type", $argument_labels + array('@type' => node_get_types('name', $settings['type'])));
86 86
 }
87 87
 
88 88
 
@@ -90,8 +90,8 @@  discard block
 block discarded – undo
90 90
  * Support upgrading from nodeprofile-workflow-ng integration.
91 91
  */
92 92
 function nodeprofile_user_has_profile_condition_upgrade(&$element) {
93
-  $element['#name'] = 'content_profile_user_has_profile_condition';
93
+    $element['#name'] = 'content_profile_user_has_profile_condition';
94 94
 }
95 95
 function nodeprofile_action_load_upgrade(&$element) {
96
-  $element['#name'] = 'content_profile_action_load';
96
+    $element['#name'] = 'content_profile_action_load';
97 97
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
     '#options' => content_profile_get_types('names'),
35 35
     '#default_value' => $settings['type'],
36 36
     '#description' => t('Select the Content Profile content type to check for.'),
37
-    '#required' => TRUE,
37
+    '#required' => true,
38 38
   );
39 39
 }
40 40
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
     '#options' => content_profile_get_types('names'),
78 78
     '#default_value' => $settings['type'],
79 79
     '#description' => t('Select the Content Profile content type to load.'),
80
-    '#required' => TRUE,
80
+    '#required' => true,
81 81
   );
82 82
 }
83 83
 
Please login to merge, or discard this patch.
content_profile/views/content_profile_views_handler_relationship.inc 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -6,46 +6,46 @@  discard block
 block discarded – undo
6 6
  * Specialized relationship handler to adding content profiles.
7 7
  */
8 8
 class content_profile_views_handler_relationship extends views_handler_relationship {
9
-  function option_definition() {
9
+    function option_definition() {
10 10
     $options = parent::option_definition();
11 11
 
12 12
     $options['type'] = array('default' => '');
13 13
     return $options;
14
-  }
14
+    }
15 15
 
16
-  /**
17
-   * Adds a form element for choosing the right content type.
18
-   */
19
-  function options_form(&$form, &$form_state) {
16
+    /**
17
+     * Adds a form element for choosing the right content type.
18
+     */
19
+    function options_form(&$form, &$form_state) {
20 20
     parent::options_form($form, $form_state);
21 21
 
22 22
     $form['type'] = array(
23
-      '#type' => 'radios',
24
-      '#title' => t('Content type'),
25
-      '#default_value' => $this->options['type'],
26
-      '#options' => content_profile_get_types('names'),
27
-      '#required' => TRUE,
23
+        '#type' => 'radios',
24
+        '#title' => t('Content type'),
25
+        '#default_value' => $this->options['type'],
26
+        '#options' => content_profile_get_types('names'),
27
+        '#required' => TRUE,
28 28
     );
29
-  }
29
+    }
30 30
 
31
-  /**
32
-   * Called to implement a relationship in a query.
33
-   */
34
-  function query() {
31
+    /**
32
+     * Called to implement a relationship in a query.
33
+     */
34
+    function query() {
35 35
     // Figure out what base table this relationship brings to the party.
36 36
     $join = new views_join();
37 37
     $join->definition = array(
38
-      'table' => 'node',
39
-      'field' => 'uid',
40
-      'left_table' => !empty($this->relationship) ? $this->relationship : 'users',
41
-      'left_field' => 'uid',
42
-      'extra' => array(
38
+        'table' => 'node',
39
+        'field' => 'uid',
40
+        'left_table' => !empty($this->relationship) ? $this->relationship : 'users',
41
+        'left_field' => 'uid',
42
+        'extra' => array(
43 43
         array('field' => 'type', 'value' => $this->options['type']),
44
-      ),
44
+        ),
45 45
     );
46 46
 
47 47
     if (!empty($this->options['required'])) {
48
-      $join->definition['type'] = 'INNER';
48
+        $join->definition['type'] = 'INNER';
49 49
     }
50 50
 
51 51
     $join->construct();
@@ -53,5 +53,5 @@  discard block
 block discarded – undo
53 53
 
54 54
     $alias = $join->definition['table'] .'_'. $join->definition['left_table'];
55 55
     $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
56
-  }
56
+    }
57 57
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
     $join->construct();
52 52
     $this->ensure_my_table();
53 53
 
54
-    $alias = $join->definition['table'] .'_'. $join->definition['left_table'];
54
+    $alias = $join->definition['table'].'_'.$join->definition['left_table'];
55 55
     $this->alias = $this->query->add_relationship($alias, $join, $this->definition['base'], $this->relationship);
56 56
   }
57 57
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
       '#title' => t('Content type'),
25 25
       '#default_value' => $this->options['type'],
26 26
       '#options' => content_profile_get_types('names'),
27
-      '#required' => TRUE,
27
+      '#required' => true,
28 28
     );
29 29
   }
30 30
 
Please login to merge, or discard this patch.
boinc/modules/contrib/content_profile/views/content_profile.views.inc 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -10,18 +10,18 @@  discard block
 block discarded – undo
10 10
  * Implementation of hook_views_data_alter().
11 11
  */
12 12
 function content_profile_views_data_alter(&$data) {
13
-  // node relationship for profiles
14
-  $data['users']['content_profile_rel'] = array(
13
+    // node relationship for profiles
14
+    $data['users']['content_profile_rel'] = array(
15 15
     'group' => t('Node'),
16 16
     'title' => t('Content Profile'),
17 17
     'help' => t('Create a relationship to a content profile of the user.'),
18 18
     'relationship' => array(
19
-      'handler' => 'content_profile_views_handler_relationship',
20
-      'base' => 'node',
21
-      'base field' => 'uid',
22
-      'label' => t('Content Profile'),
19
+        'handler' => 'content_profile_views_handler_relationship',
20
+        'base' => 'node',
21
+        'base field' => 'uid',
22
+        'label' => t('Content Profile'),
23 23
     ),
24
-  );
24
+    );
25 25
 }
26 26
 
27 27
 
@@ -29,14 +29,14 @@  discard block
 block discarded – undo
29 29
  * Implementation of hook_views_handlers().
30 30
  */
31 31
 function content_profile_views_handlers() {
32
-  return array(
33
-  'info' => array(
32
+    return array(
33
+    'info' => array(
34 34
     'path' => drupal_get_path('module', 'content_profile') .'/views',
35 35
     ),
36
-  'handlers' => array(
36
+    'handlers' => array(
37 37
     'content_profile_views_handler_relationship' => array(
38
-     'parent' => 'views_handler_relationship',
39
-     ),
38
+        'parent' => 'views_handler_relationship',
39
+        ),
40 40
     ),
41
-  );
41
+    );
42 42
 }
43 43
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 function content_profile_views_handlers() {
32 32
   return array(
33 33
   'info' => array(
34
-    'path' => drupal_get_path('module', 'content_profile') .'/views',
34
+    'path' => drupal_get_path('module', 'content_profile').'/views',
35 35
     ),
36 36
   'handlers' => array(
37 37
     'content_profile_views_handler_relationship' => array(
Please login to merge, or discard this patch.
modules/contrib/content_profile/panels/relationships/node_from_user.inc 3 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * Implementation of specially named hook_ctools_relationships().
12 12
  */
13 13
 function content_profile_node_from_user_ctools_relationships() {
14
-  $args['node_from_user'] = array(
14
+    $args['node_from_user'] = array(
15 15
     'title' => t("Profile Node"),
16 16
     'keyword' => 'content_profile',
17 17
     'description' => t('Adds a Content Profile from user context'),
@@ -19,49 +19,49 @@  discard block
 block discarded – undo
19 19
     'context' => 'content_profile_node_from_user_ctools_context',
20 20
     'settings form' => 'content_profile_node_from_user_ctools_settings_form',
21 21
     'settings form validate' => 'content_profile_node_from_user_ctools_settings_form_validate',
22
-  );
22
+    );
23 23
   
24
-  return $args;
24
+    return $args;
25 25
 }
26 26
 
27 27
 /**
28 28
  * Return a new context based on an existing context.
29 29
  */
30 30
 function content_profile_node_from_user_ctools_context($context, $conf) {
31
-  // If unset it wants a generic, unfilled context, which is just NULL.
32
-  if (empty($context->data) || !isset($context->data->uid)) {
31
+    // If unset it wants a generic, unfilled context, which is just NULL.
32
+    if (empty($context->data) || !isset($context->data->uid)) {
33 33
     $new_context = ctools_context_create_empty('node', NULL);
34
-  }
35
-  else {
34
+    }
35
+    else {
36 36
     // Load the node for the requested type
37 37
     $uid = $context->data->uid;
38 38
     $content_profile_node = content_profile_load($conf['type'], $uid);
39 39
 
40 40
     // Send it to ctools.
41 41
     $new_context = ctools_context_create('node', $content_profile_node);
42
-  }
42
+    }
43 43
 
44
-  // Have content profile relationships limit CCK field availability.
45
-  if (isset($new_context->restrictions['type'])) {
44
+    // Have content profile relationships limit CCK field availability.
45
+    if (isset($new_context->restrictions['type'])) {
46 46
     $new_context->restrictions['type'][] = $conf['type'];
47
-  }
48
-  else {
47
+    }
48
+    else {
49 49
     $new_context->restrictions['type'] = array($conf['type']);
50
-  }
51
-  return $new_context;
50
+    }
51
+    return $new_context;
52 52
 }
53 53
 
54 54
 /**
55 55
  * Settings form for the relationship
56 56
  */
57 57
 function content_profile_node_from_user_ctools_settings_form($conf) {
58
-  $options = content_profile_get_types('names');
59
-  $form['type'] = array(
58
+    $options = content_profile_get_types('names');
59
+    $form['type'] = array(
60 60
     '#type' => 'select',
61 61
     '#title' => t('Relationship type'),
62 62
     '#options' => $options,
63 63
     '#default_value' => $conf['type']
64
-  );
64
+    );
65 65
 
66
-  return $form;
66
+    return $form;
67 67
 }
68 68
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -31,8 +31,7 @@  discard block
 block discarded – undo
31 31
   // If unset it wants a generic, unfilled context, which is just NULL.
32 32
   if (empty($context->data) || !isset($context->data->uid)) {
33 33
     $new_context = ctools_context_create_empty('node', NULL);
34
-  }
35
-  else {
34
+  } else {
36 35
     // Load the node for the requested type
37 36
     $uid = $context->data->uid;
38 37
     $content_profile_node = content_profile_load($conf['type'], $uid);
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
   // Have content profile relationships limit CCK field availability.
45 44
   if (isset($new_context->restrictions['type'])) {
46 45
     $new_context->restrictions['type'][] = $conf['type'];
47
-  }
48
-  else {
46
+  } else {
49 47
     $new_context->restrictions['type'] = array($conf['type']);
50 48
   }
51 49
   return $new_context;
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@
 block discarded – undo
30 30
 function content_profile_node_from_user_ctools_context($context, $conf) {
31 31
   // If unset it wants a generic, unfilled context, which is just NULL.
32 32
   if (empty($context->data) || !isset($context->data->uid)) {
33
-    $new_context = ctools_context_create_empty('node', NULL);
33
+    $new_context = ctools_context_create_empty('node', null);
34 34
   }
35 35
   else {
36 36
     // Load the node for the requested type
Please login to merge, or discard this patch.
boinc/modules/contrib/content_profile/content_profile.theme_vars.inc 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -11,109 +11,109 @@
 block discarded – undo
11 11
  */
12 12
 class content_profile_theme_variables {
13 13
 
14
-  var $uid;
15
-  var $_cache = array();
14
+    var $uid;
15
+    var $_cache = array();
16 16
 
17
-  function content_profile_theme_variables($uid) {
17
+    function content_profile_theme_variables($uid) {
18 18
     $this->uid = $uid;
19
-  }
19
+    }
20 20
 
21
-  /**
22
-   * Gets the user id of the profiles owner.
23
-   */
24
-  function get_uid() {
21
+    /**
22
+     * Gets the user id of the profiles owner.
23
+     */
24
+    function get_uid() {
25 25
     return $uid;
26
-  }
26
+    }
27 27
 
28
-  /**
29
-   * Gets all type names keyed with their machine readable names.
30
-   */
31
-  function get_profile_types() {
28
+    /**
29
+     * Gets all type names keyed with their machine readable names.
30
+     */
31
+    function get_profile_types() {
32 32
     return content_profile_get_types('names');
33
-  }
33
+    }
34 34
 
35
-  /**
36
-   * Gets all template variables for the content profile of this type.
37
-   *
38
-   * @param $type
39
-   *   The type of the user's content profile
40
-   * @param $teaser
41
-   *   Whether the value is to be generated for the teaser.
42
-   * @param $page
43
-   *   Whether the value is to be generated for the page view.
44
-   *
45
-   * @return
46
-   *   An array of variables available for the profile node
47
-   *   or FALSE if there has been no profile created yet.
48
-   */
49
-  function get_variables($type, $teaser = FALSE, $page = FALSE) {
35
+    /**
36
+     * Gets all template variables for the content profile of this type.
37
+     *
38
+     * @param $type
39
+     *   The type of the user's content profile
40
+     * @param $teaser
41
+     *   Whether the value is to be generated for the teaser.
42
+     * @param $page
43
+     *   Whether the value is to be generated for the page view.
44
+     *
45
+     * @return
46
+     *   An array of variables available for the profile node
47
+     *   or FALSE if there has been no profile created yet.
48
+     */
49
+    function get_variables($type, $teaser = FALSE, $page = FALSE) {
50 50
     if (!isset($this->_cache[$type][$teaser][$page])) {
51
-      $this->_cache[$type][$teaser][$page] = FALSE;
51
+        $this->_cache[$type][$teaser][$page] = FALSE;
52 52
 
53
-      if ($node = content_profile_load($type, $this->uid)) {
53
+        if ($node = content_profile_load($type, $this->uid)) {
54 54
         // Make sure the node is prepared for viewing
55 55
         $node = node_build_content($node, $teaser, $page);
56 56
         $vars = array('node' => $node, 'teaser' => $teaser, 'page' => $page);
57 57
 
58 58
         // Apply all node template preprocessors
59 59
         foreach ($this->_get_node_preprocessors() as $function) {
60
-          if (function_exists($function)) {
60
+            if (function_exists($function)) {
61 61
             $function($vars, 'node');
62
-          }
62
+            }
63 63
         }
64 64
         $this->_cache[$type][$teaser][$page] = $vars;
65
-      }
65
+        }
66 66
     }
67 67
     return $this->_cache[$type][$teaser][$page];
68
-  }
68
+    }
69 69
 
70
-  /**
71
-   * Gets a single template variable for the content profile of this type.
72
-   *
73
-   * @param $type
74
-   *   The type of the user's content profile
75
-   * @param $name
76
-   *   The name of the variable to get.
77
-   *
78
-   * @return
79
-   *   The variable or FALSE if there has been no profile created yet.
80
-   */
81
-  function get_variable($type, $name) {
70
+    /**
71
+     * Gets a single template variable for the content profile of this type.
72
+     *
73
+     * @param $type
74
+     *   The type of the user's content profile
75
+     * @param $name
76
+     *   The name of the variable to get.
77
+     *
78
+     * @return
79
+     *   The variable or FALSE if there has been no profile created yet.
80
+     */
81
+    function get_variable($type, $name) {
82 82
     if ($vars = $this->get_variables($type)) {
83
-      return $vars[$name];
83
+        return $vars[$name];
84 84
     }
85 85
     return FALSE;
86
-  }
86
+    }
87 87
 
88 88
 
89
-  /**
90
-   * Generate a display of the given node.
91
-   *
92
-   * @param $type
93
-   *   The type of the user's content profile
94
-   * @param $teaser
95
-   *   Whether to display the teaser only or the full form.
96
-   * @param $page
97
-   *   Whether the node is being displayed by itself as a page.
98
-   * @param $links
99
-   *   Whether or not to display node links. Links are omitted for node previews.
100
-   *
101
-   * @return
102
-   *   An HTML representation of the themed node or FALSE if there has been no profile created yet.
103
-   */
104
-  function get_view($type, $teaser = FALSE, $page = FALSE, $links = TRUE) {
89
+    /**
90
+     * Generate a display of the given node.
91
+     *
92
+     * @param $type
93
+     *   The type of the user's content profile
94
+     * @param $teaser
95
+     *   Whether to display the teaser only or the full form.
96
+     * @param $page
97
+     *   Whether the node is being displayed by itself as a page.
98
+     * @param $links
99
+     *   Whether or not to display node links. Links are omitted for node previews.
100
+     *
101
+     * @return
102
+     *   An HTML representation of the themed node or FALSE if there has been no profile created yet.
103
+     */
104
+    function get_view($type, $teaser = FALSE, $page = FALSE, $links = TRUE) {
105 105
     if ($node = content_profile_load($type, $this->uid)) {
106
-      return node_view($node, $teaser, $page, $links);
106
+        return node_view($node, $teaser, $page, $links);
107 107
     }
108 108
     return FALSE;
109
-  }
109
+    }
110 110
 
111 111
 
112
-  function _get_node_preprocessors() {
112
+    function _get_node_preprocessors() {
113 113
     $hooks = theme_get_registry();
114 114
     $functions = $hooks['node']['preprocess functions'];
115 115
     // We don't need 'template_preprocess'
116 116
     unset($functions[0]);
117 117
     return $functions;
118
-  }
118
+    }
119 119
 }
Please login to merge, or discard this patch.
Upper-Lower-Casing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
    *   An array of variables available for the profile node
47 47
    *   or FALSE if there has been no profile created yet.
48 48
    */
49
-  function get_variables($type, $teaser = FALSE, $page = FALSE) {
49
+  function get_variables($type, $teaser = false, $page = false) {
50 50
     if (!isset($this->_cache[$type][$teaser][$page])) {
51
-      $this->_cache[$type][$teaser][$page] = FALSE;
51
+      $this->_cache[$type][$teaser][$page] = false;
52 52
 
53 53
       if ($node = content_profile_load($type, $this->uid)) {
54 54
         // Make sure the node is prepared for viewing
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
     if ($vars = $this->get_variables($type)) {
83 83
       return $vars[$name];
84 84
     }
85
-    return FALSE;
85
+    return false;
86 86
   }
87 87
 
88 88
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
    * @return
102 102
    *   An HTML representation of the themed node or FALSE if there has been no profile created yet.
103 103
    */
104
-  function get_view($type, $teaser = FALSE, $page = FALSE, $links = TRUE) {
104
+  function get_view($type, $teaser = false, $page = false, $links = true) {
105 105
     if ($node = content_profile_load($type, $this->uid)) {
106 106
       return node_view($node, $teaser, $page, $links);
107 107
     }
108
-    return FALSE;
108
+    return false;
109 109
   }
110 110
 
111 111
 
Please login to merge, or discard this patch.