Projet

Général

Profil

Paste
Télécharger (23 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panels / includes / common.inc @ 5a7e6170

1
<?php
2

    
3

    
4
/**
5
 * @file
6
 * Functions used by more than one panels client module.
7
 */
8

    
9
/**
10
 * Class definition for the allowed layouts governing structure.
11
 *
12
 * @ingroup mainapi
13
 *
14
 * This class is designed to handle panels allowed layouts data from start to finish, and sees
15
 * action at two times:\n
16
 *    - When a client module wants to generate a form allowing an admin to create or edit a set
17
 *      of allowed layouts. In this case, either a new panels_allowed_layouts object is created
18
 *      or one is retrieved from storage and panels_allowed_layouts::set_allowed() is called to
19
 *      generate the allowed layouts form. \n
20
 *    - When a client module is calling panels_edit_layout(), a saved instantiation of this object
21
 *      can be called up and passed in to the fourth parameter, and only the allowed layouts saved
22
 *      in that object will be displayed on the form. \n
23
 * Because the panels API does not impose a data structure on the allowed_layouts data, client
24
 * modules can create as many of these objects as they want, and organize them around any concept:
25
 * node types, date published, author roles...anything.
26
 *
27
 * To call the settings form, instantiate this class - or, if your client module's needs are
28
 * heavy-duty, extend this class and instantiate your subclass - assign values to any relevant
29
 * desired members, and call panels_allowed_layouts::set_allowed(). See the documentation on
30
 * that method for a sample implementation.
31
 *
32
 * Note that when unserializing saved tokens of this class, you must
33
 * run panels_load_include('common') before unserializing in order to ensure
34
 * that the object is properly loaded.
35
 *
36
 * Client modules extending this class should implement a save() method and use it for
37
 * their custom data storage routine. You'll need to rewrite other class methods if
38
 * you choose to go another route.
39
 *
40
 * @see panels_edit_layout()
41
 * @see _panels_edit_layout()
42
 *
43
 */
44
class panels_allowed_layouts {
45

    
46
  /**
47
   *  Specifies whether newly-added layouts (as in, new .inc files) should be automatically
48
   *  allowed (TRUE) or disallowed (FALSE) for $this. Defaults to TRUE, which is more
49
   *  permissive but less of an administrative hassle if/when you add new layouts. Note
50
   *  that this parameter will be derived from $allowed_layouts if a value is passed in.
51
   */
52
  var $allow_new = TRUE;
53

    
54
  /**
55
   *  Optional member. If provided, the Panels API will generate a drupal variable using
56
   *  variable_set($module_name . 'allowed_layouts', serialize($this)), thereby handling the
57
   *  storage of this object entirely within the Panels API. This object will be
58
   *  called and rebuilt by panels_edit_layout() if the same $module_name string is passed in
59
   *  for the $allowed_types parameter. \n
60
   *  This is primarily intended for convenience - client modules doing heavy-duty implementations
61
   *  of the Panels API will probably want to create their own storage method.
62
   * @see panels_edit_layout()
63
   */
64
  var $module_name = NULL;
65

    
66
  /**
67
   *  An associative array of all available layouts, keyed by layout name (as defined
68
   *  in the corresponding layout plugin definition), with value = 1 if the layout is
69
   *  allowed, and value = 0 if the layout is not allowed.
70
   *  Calling array_filter(panels_allowed_layouts::$allowed_layout_settings) will return an associative array
71
   *  containing only the allowed layouts, and wrapping that in array_keys() will
72
   *  return an indexed version of that array.
73
   */
74
  var $allowed_layout_settings = array();
75

    
76
  /**
77
   * Hack-imitation of D6's $form_state. Used by the panels_common_set_allowed_types()
78
   * form to indicate whether the returned value is in its 'render', 'failed-validate',
79
   * or 'submit' stage.
80
   */
81
  var $form_state;
82

    
83
  /**
84
   * Constructor function; loads the $allowed_layout_settings array with initial values according
85
   * to $start_allowed
86
   *
87
   * @param bool $start_allowed
88
   *  $start_allowed determines whether all available layouts will be marked
89
   *  as allowed or not allowed on the initial call to panels_allowed_layouts::set_allowed()
90
   *
91
   */
92
  function panels_allowed_layouts($start_allowed = TRUE) {
93
    // TODO would be nice if there was a way to just fetch the names easily
94
    foreach ($this->list_layouts() as $layout_name) {
95
      $this->allowed_layout_settings[$layout_name] = $start_allowed ? 1 : 0;
96
    }
97
  }
98

    
99
  /**
100
   * Manage panels_common_set_allowed_layouts(), the FAPI code for selecting allowed layouts.
101
   *
102
   * MAKE SURE to set panels_allowed_layouts::allow_new before calling this method. If you want the panels API
103
   * to handle saving these allowed layout settings, panels_allowed_layouts::module_name must also be set.
104
   *
105
   * Below is a sample implementation; refer to the rest of the class documentation to understand all the
106
   * specific pieces. Values that are intended to be replaced are wrapped with <>.
107
   *
108
   * \n @code
109
   *  function docdemo_allowed_layouts() {
110
   *    ctools_include('common', 'panels');
111
   *    if (!is_a($allowed_layouts = unserialize(variable_get('panels_common_allowed_layouts', serialize(''))), 'panels_allowed_layouts')) {
112
   *     $allowed_layouts = new panels_allowed_layouts();
113
   *      $allowed_layouts->allow_new = TRUE;
114
   *      $allowed_layouts->module_name = '<client_module_name>';
115
   *    }
116
   *    $result = $allowed_layouts->set_allowed('<Desired client module form title>');
117
   *    if (in_array($allowed_layouts->form_state, array('failed-validate', 'render'))) {
118
   *     return $result;
119
   *    }
120
   *    elseif ($allowed_layouts->form_state == 'submit') {
121
   *      drupal_goto('</path/to/desired/redirect>');
122
   *    }
123
   *  }
124
   * @endcode \n
125
   *
126
   * If $allowed_layouts->form_state == 'failed-validate' || 'render', then you'll need to return
127
   * $result as it contains the structured form HTML generated by drupal_render_form() and is ready
128
   * to be passed through index.php's call to theme('page', ...).
129
   *
130
   * However, if $allowed_layouts->form_state == 'submit', then the form has been submitted and we should
131
   * react. It's really up to your client module how you handle the rest; panels_allowed_layouts::save() (or
132
   * panels_allowed_layouts::api_save(), if that's the route you're going) will have already been called,
133
   * so if those methods handle your save routine, then all there is left to do is handle redirects, if you
134
   * want. The current implementation of the allowed layouts form currently never redirects, so it's up to
135
   * you to control where the user ends up next.
136
   *
137
   * @param string $title
138
   *  Used to set the title of the allowed layouts form. If no value is given, defaults to
139
   *  'Panels: Allowed Layouts'.
140
   *
141
   * @return mixed $result
142
   *  - On the first passthrough when the form is being rendered, $result is the form's structured
143
   *    HTML, ready to be pushed to the screen with a call to theme('page', ...).
144
   *  - A successful second passthrough indicates a successful submit, and
145
   *    $result === panels_allowed_layouts::allowed_layout_settings. Returning it is simply for convenience.
146
   */
147
  function set_allowed($title = 'Panels: Allowed Layouts') {
148
    $this->sync_with_available();
149
    $form_id = 'panels_common_set_allowed_layouts';
150
    // TODO switch to drupal_build_form(); need to pass by ref
151
    $form = drupal_retrieve_form($form_id, $this, $title);
152

    
153
    if ($result = drupal_process_form($form_id, $form)) {
154
      // successful submit
155
      $this->form_state = 'submit';
156
      return $result;
157
    }
158
    $this->form_state = isset($_POST['op']) ? 'failed-validate' : 'render';
159
    $result = drupal_render_form($form_id, $form);
160
    return $result;
161
  }
162

    
163
  /**
164
   * Checks for newly-added layouts and deleted layouts. If any are found, updates panels_allowed_layouts::allowed_layout_settings;
165
   * new additions are made according to panels_allowed_layouts::allow_new, while deletions are unset().
166
   *
167
   * Note that any changes made by this function are not saved in any permanent location.
168
   */
169
  function sync_with_available() {
170
    $layouts = $this->list_layouts();
171
    foreach (array_diff($layouts, array_keys($this->allowed_layout_settings)) as $new_layout) {
172
      $this->allowed_layout_settings[$new_layout] = $this->allow_new ? 1 : 0;
173
    }
174
    foreach (array_diff(array_keys($this->allowed_layout_settings), $layouts) as $deleted_layout) {
175
      unset($this->allowed_layout_settings[$deleted_layout]);
176
    }
177
  }
178

    
179
  /**
180
   * Use panels_allowed_layouts::module_name to generate a variable for variable_set(), in which
181
   * a serialized version of $this will be stored.
182
   *
183
   * Does nothing if panels_allowed_layouts::module_name is not set.
184
   *
185
   * IMPORTANT NOTE: if you use variable_get() in a custom client module save() method, you MUST
186
   * wrap $this in serialize(), then unserialize() what you get from variable_get(). Failure to
187
   * do so will result in an incomplete object. The following code will work:
188
   * @code
189
   *  $allowed_layouts = unserialize(variable_get('your_variable_name', serialize(''));
190
   * @endcode
191
   *
192
   * If you don't serialize the second parameter of variable_get() and the variable name you provide
193
   * can't be found, an E_STRICT warning will be generated for trying to unserialize an entity
194
   * that has not been serialized.
195
   *
196
   */
197
  function save() {
198
    if (!is_null($this->module_name)) {
199
      variable_set($this->module_name . "_allowed_layouts", serialize($this));
200
    }
201
  }
202

    
203
  /**
204
   * Snag a list of the current layouts for internal use.
205
   *
206
   * Data is not saved in a class member in order to ensure that it's
207
   * fresh.
208
   *
209
   * @return array $layouts
210
   *  An indexed array of the system names for all currently available layouts.
211
   */
212
  function list_layouts() {
213
    static $layouts = array();
214
    if (empty($layouts)) {
215
      ctools_include('plugins', 'panels');
216
      $layouts = array_keys(panels_get_layouts());
217
    }
218
    return $layouts;
219
  }
220
}
221

    
222
/**
223
 * A common settings page for Panels modules, because this code is relevant to
224
 * any modules that don't already have special requirements.
225
 */
226
function panels_common_settings($form, &$form_state, $module_name = 'panels_common') {
227
  ctools_include('plugins', 'panels');
228
  ctools_include('content');
229
  $content_types = ctools_get_content_types();
230
  $skip = FALSE;
231

    
232
  $default_types = variable_get($module_name . '_default', NULL);
233
  if (!isset($default_types)) {
234
    $default_types = array('other' => TRUE);
235
    $skip = TRUE;
236
  }
237

    
238
  foreach ($content_types as $id => $info) {
239
    if (empty($info['single'])) {
240
      $default_options[$id] = t('New @s', array('@s' => $info['title']));
241
      if ($skip) {
242
        $default_types[$id] = TRUE;
243
      }
244
    }
245
  }
246

    
247
  $default_options['other'] = t('New content of other types');
248

    
249
  $form['additional_settings'] = array(
250
    '#type' => 'vertical_tabs',
251
  );
252

    
253
  $form['common'] = array(
254
    '#type' => 'fieldset',
255
    '#title' => t('New content behavior'),
256
    '#group' => 'additional_settings',
257
    '#weight' => -10,
258
  );
259
  $form['common']['panels_common_default'] = array(
260
    '#type' => 'checkboxes',
261
    '#description' => t('Select the default behavior of new content added to the system. If checked, new content will automatically be immediately available to be added to Panels pages. If not checked, new content will not be available until specifically allowed here.'),
262
    '#options' => $default_options,
263
    '#default_value' => array_keys(array_filter($default_types)),
264
  );
265

    
266
  $form_state['skip'] = $skip;
267
  if ($skip) {
268
    $form['markup'] = array('#value' => t('<p>Click Submit to be presented with a complete list of available content types set to the defaults you selected.</p>'));
269
  }
270
  else {
271
    // Rebuild the entire list, setting appropriately from defaults. Give
272
    // each type its own checkboxes set unless it's 'single' in which
273
    // case it can go into our fake other set.
274
    $available_content_types = ctools_content_get_all_types();
275
    $allowed_content_types = variable_get($module_name . '_allowed_types', array());
276

    
277
    foreach ($available_content_types as $id => $types) {
278
      foreach ($types as $type => $info) {
279
        $key = $id . '-' . $type;
280
        $checkboxes = empty($content_types[$id]['single']) ? $id : 'other';
281
        $options[$checkboxes][$key] = $info['title'];
282
        if (!isset($allowed_content_types[$key])) {
283
          $allowed[$checkboxes][$key] = isset($default_types[$id]) ? $default_types[$id] : $default_types['other'];
284
        }
285
        else {
286
          $allowed[$checkboxes][$key] = $allowed_content_types[$key];
287
        }
288
      }
289
    }
290

    
291
    $form['content_types'] = array(
292
      '#tree' => TRUE,
293
    );
294

    
295
    // cheat a bit
296
    $content_types['other'] = array('title' => t('Other'), 'weight' => 10);
297
    foreach ($content_types as $id => $info) {
298
      if (isset($allowed[$id])) {
299

    
300
        $form['content_types'][$id] = array(
301
          '#type' => 'fieldset',
302
          '#group' => 'additional_settings',
303
          '#title' => t('Allowed @s content', array('@s' => $info['title'])),
304
        );
305

    
306
        $form['content_types'][$id]['options'] = array(
307
          '#prefix' => '<div class="panels-page-type-container">',
308
          '#suffix' => '</div>',
309
          '#type' => 'checkboxes',
310
          '#options' => $options[$id],
311
          '#default_value' => array_keys(array_filter($allowed[$id])),
312
          '#checkall' => TRUE,
313
        );
314
      }
315
    }
316
  }
317

    
318
  // Layout selection.
319
  panels_common_allowed_layouts_form($form, $form_state, $module_name);
320

    
321
  $form['allowed'] = array(
322
    '#type' => 'value',
323
    '#value' => isset($allowed) ? array_keys($allowed) : array(),
324
  );
325

    
326
  $form['module_name'] = array(
327
    '#type' => 'value',
328
    '#value' => $module_name,
329
  );
330

    
331
  $form['submit'] = array(
332
    '#type' => 'submit',
333
    '#value' => t('Save'),
334
  );
335

    
336
  ctools_add_css('panels_page', 'panels');
337
  return $form;
338
}
339

    
340
/**
341
 * Submit hook for panels_common_settings
342
 */
343
function panels_common_settings_validate($form, &$form_state) {
344
  panels_common_allowed_layouts_form_validate($form, $form_state);
345
}
346

    
347
/**
348
 * Submit hook for panels_common_settings
349
 */
350
function panels_common_settings_submit($form, &$form_state) {
351
  panels_common_allowed_layouts_form_submit($form, $form_state);
352
  $module_name = $form_state['values']['module_name'];
353
  variable_set($module_name . '_default', $form_state['values']['panels_common_default']);
354
  if (!$form_state['skip']) {
355
    // merge the broken apart array neatly back together
356
    $allowed = $form_state['values']['allowed'];
357
    $allowed_content_types = array();
358
    foreach ($form_state['values']['allowed'] as $allowed) {
359
      $allowed_content_types = array_merge($allowed_content_types, $form_state['values']['content_types'][$allowed]['options']);
360
    }
361
    variable_set($module_name . '_allowed_types', $allowed_content_types);
362
  }
363
  drupal_set_message(t('Your changes have been saved.'));
364
}
365

    
366
/**
367
 * Based upon the settings, get the allowed types for this node.
368
 */
369
function panels_common_get_allowed_types($module, $contexts = array(), $has_content = FALSE, $default_defaults = array(), $default_allowed_types = array()) {
370
  // Get a list of all types that are available
371

    
372
  $default_types = variable_get($module . '_default', $default_defaults);
373
  $allowed_types = variable_get($module . '_allowed_types', $default_allowed_types);
374

    
375
  // By default, if they haven't gone and done the initial setup here,
376
  // let all 'other' types (which will be all types) be available.
377
  if (!isset($default_types['other'])) {
378
    $default_types['other'] = TRUE;
379
  }
380

    
381
  ctools_include('content');
382
  $content_types = ctools_content_get_available_types($contexts, $has_content, $allowed_types, $default_types);
383

    
384
  return $content_types;
385
}
386

    
387
/**
388
 * The FAPI code for generating an 'allowed layouts' selection form.
389
 *
390
 * NOTE: Because the Panels API does not guarantee a particular method of storing the data on allowed layouts,
391
 * it is not_possible for the Panels API to implement any checks that determine whether reductions in
392
 * the set of allowed layouts conflict with pre-existing layout selections. $displays in that category
393
 * will continue to function with their current layout as normal until the user/owner/admin attempts
394
 * to change layouts on that display, at which point they will have to select from the new set of
395
 * allowed layouts. If this is not the desired behavior for your client module, it's up to you to
396
 * write a validation routine that determines what should be done with conflicting layouts.
397
 *
398
 * Remember that changing layouts where panes have already been created can result in data loss;
399
 * consult panels_change_layout() to see how the Panels API handles that process. Running
400
 * drupal_execute('panels_change_layout', ...) is one possible starting point.
401
 *
402
 * @ingroup forms
403
 *
404
 * @param array $allowed_layouts
405
 *  The set of allowed layouts that should be used as the default values
406
 *  for this form. If none is provided, then by default no layouts will be restricted.
407
 */
408
function panels_common_allowed_layouts_form(&$form, &$form_state, $module_name) {
409
  // Fetch our allowed layouts from variables.
410
  $allowed_layouts = panels_common_get_allowed_layout_object($module_name);
411

    
412
  $layouts = panels_get_layouts();
413
  foreach ($layouts as $id => $layout) {
414
    $options[$id] = panels_print_layout_icon($id, $layout, check_plain($layout['title']));
415
  }
416

    
417
  $form_state['allowed_layouts'] = &$allowed_layouts;
418

    
419
  ctools_add_js('layout', 'panels');
420

    
421
  $form['layout_selection'] = array(
422
    '#type' => 'fieldset',
423
    '#title' => t('Select allowed layouts'),
424
    '#group' => 'additional_settings',
425
    '#weight' => 10,
426
  );
427
  $form['layout_selection']['layouts'] = array(
428
    '#type' => 'checkboxes',
429
    '#options' => $options,
430
    '#description' => t('Check the boxes for all layouts you want to allow users choose from when picking a layout. You must allow at least one layout.'),
431
    '#default_value' => array_keys(array_filter($allowed_layouts->allowed_layout_settings)),
432
    '#prefix' => '<div class="clearfix panels-layouts-checkboxes">',
433
    '#suffix' => '</div>',
434
    '#checkall' => TRUE,
435
  );
436

    
437
  return $form;
438
}
439

    
440
function panels_common_allowed_layouts_form_validate($form, &$form_state) {
441
  $selected = array_filter($form_state['values']['layouts']);
442
  if (empty($selected)) {
443
    form_set_error('layouts', 'You must choose at least one layout to allow.');
444
  }
445
}
446

    
447
function panels_common_allowed_layouts_form_submit($form, &$form_state) {
448
  foreach ($form_state['values']['layouts'] as $layout => $setting) {
449
    $form_state['allowed_layouts']->allowed_layout_settings[$layout] = (bool) $setting;
450
  }
451
  $form_state['allowed_layouts']->save();
452
}
453

    
454
/**
455
 * Get the allowed layout object for the given module.
456
 */
457
function panels_common_get_allowed_layout_object($module_name) {
458
  $allowed_layouts = unserialize(variable_get($module_name . "_allowed_layouts", serialize('')));
459

    
460
  // if no parameter was provided, or the variable_get failed
461
  if (!$allowed_layouts) {
462
    // still no dice. simply creates a dummy version where all layouts
463
    // are allowed.
464
    $allowed_layouts = new panels_allowed_layouts();
465
    $allowed_layouts->allow_new = TRUE;
466
    $allowed_layouts->module_name = $module_name;
467
  }
468

    
469
  // sanitize allowed layout listing; this is redundant if the
470
  // $allowed_layouts param was null, but the data is cached anyway
471
  $allowed_layouts->sync_with_available();
472

    
473
  return $allowed_layouts;
474
}
475

    
476
/**
477
 * Get the allowed layouts for the given module.
478
 */
479
function panels_common_get_allowed_layouts($module_name) {
480
  ctools_include('plugins', 'panels');
481
  $available_layouts = panels_get_layouts();
482
  if (empty($module_name)) {
483
    return $available_layouts;
484
  }
485
  else if (is_object($module_name)) {
486
    $allowed_layouts = $module_name;
487
  }
488
  else {
489
    $allowed_layouts = panels_common_get_allowed_layout_object($module_name);
490
  }
491

    
492
  $allowed = array_filter($allowed_layouts->allowed_layout_settings);
493
  $order = array();
494
  foreach ($available_layouts as $name => $plugin) {
495
    if (!empty($allowed[$name])) {
496
      $order[$name] = $plugin['category'] . ':' . $plugin['title'];
497
    }
498
  }
499

    
500
  // Sort
501
  $layouts = array();
502

    
503
  asort($order);
504
  foreach ($order as $name => $junk) {
505
    $layouts[$name] = $available_layouts[$name];
506
  }
507

    
508
  return $layouts;
509
}
510

    
511
/**
512
 * Create a visible list of content in a display.
513
 * Note that the contexts must be pre-loaded.
514
 */
515
function theme_panels_common_content_list($vars) {
516
  $display = $vars['display'];
517

    
518
  $layout = panels_get_layout($display->layout);
519
  $content = '<dl class="content-list">';
520
  foreach (panels_get_regions($layout, $display) as $panel_id => $title) {
521
    $content .= "<dt>$title</dt><dd>";
522
    if (!empty($display->panels[$panel_id])) {
523
      $content .= '<ol>';
524
      foreach ($display->panels[$panel_id] as $pid) {
525
        $content .= '<li>' . panels_get_pane_title($display->content[$pid], $display->context) . '</li>';
526
      }
527
      $content .= '</ol>';
528
    }
529
    else {
530
      $content .= t('Empty');
531
    }
532
    $content .= '</dd>';
533
  }
534
  $content .= '</dl>';
535
  return $content;
536
}
537

    
538
/**
539
 * Print a selector of layouts, each linked to the next step.
540
 *
541
 * Most operations use radio buttons for selecting layouts, but some will
542
 * give each layout as a link that goes to the next step. This function
543
 * makes it easy to simply provide a list of allowed layouts and the base
544
 * path.
545
 *
546
 * One limitation is that it will only append the layout name to the end, so
547
 * if the actual layout name is needed in the middle, that can't happen.
548
 *
549
 * @return
550
 *   The rendered output.
551
 */
552
function panels_common_print_layout_links($layouts, $base_path, $link_options = array(), $current_layout = NULL) {
553
  $output = '';
554

    
555
  $categories = array();
556
  ctools_include('cleanstring');
557
  $default_category = '';
558
  foreach ($layouts as $id => $layout) {
559
    $category = ctools_cleanstring($layout['category']);
560

    
561
    $categories[$category] = $layout['category'];
562
    if ($id == $current_layout) {
563
      $default_category = $category;
564
    }
565

    
566
    $options[$category][$id] = panels_print_layout_link($id, $layout, $base_path . '/' . $id, $link_options, $current_layout);
567
  }
568

    
569
  $form = array();
570
  $form['categories'] = array(
571
    '#title' => t('Category'),
572
    '#type' => 'select',
573
    '#options' => $categories,
574
    '#name' => 'categories',
575
    '#id' => 'edit-categories',
576
    '#value' => $default_category,
577
    '#parents' => array('categories'),
578
    '#access' => (count($categories) > 1) ? TRUE : FALSE,
579
  );
580

    
581
  $output .= drupal_render($form);
582

    
583
  $output .= '<div class="panels-choose-layout panels-layouts-checkboxes clearfix">';
584

    
585
  // We're doing these dependencies completely manualy, which is unusual, but
586
  // the process code only supports doing them in a form.
587
  // @todo modify dependent.inc to make this easier.
588

    
589
  $dependencies = array();
590
  foreach ($options as $category => $links) {
591
    $dependencies['panels-layout-category-' . $category] = array(
592
      'values' => array('edit-categories' => array($category)),
593
      'num' => 1,
594
      'type' => 'hide',
595
    );
596

    
597
    $output .= '<div id="panels-layout-category-' . $category . '-wrapper">';
598
    $output .= '<div id="panels-layout-category-' . $category . '" class="form-checkboxes clearfix">';
599
    $output .= (count($categories) > 1) ? '<div class="panels-layouts-category">' . $categories[$category] . '</div>' : '';
600

    
601
    foreach ($links as $key => $link) {
602
      $output .= $link;
603
    }
604
    $output .= '</div></div>';
605
  }
606

    
607
  $output .= '</div>';
608

    
609
  ctools_add_js('dependent');
610
  $js['CTools']['dependent'] = $dependencies;
611
  drupal_add_js($js, 'setting');
612

    
613
  return $output;
614
}