You are here

function fb_fbml_fieldset in Drupal for Facebook 6.2

File

themes/fb_fbml/template.php, line 177
Logic needed for FBML theme.

Code

function fb_fbml_fieldset($element) {
  global $fb;
  if ($fb && $fb
    ->in_fb_canvas() || fb_is_fbml_canvas()) {
    static $count = 0;
    if (isset($element['#collapsible']) && $element['#collapsible']) {
      $id = 'fbml_fieldset_' . $count++;
      $linkattrs = array(
        'clicktotoggle' => $id,
        'href' => '#',
      );
      $contentattrs = array(
        'id' => $id,
      );
      if (!isset($element['#attributes']['class'])) {
        $element['#attributes']['class'] = '';
      }
      $element['#attributes']['class'] .= ' collapsible';
      if ($element['#collapsed']) {
        $element['#attributes']['class'] .= ' collapsed';
        $contentattrs['style'] = 'display:none';
      }
      $element['#title'] = '<a ' . drupal_attributes($linkattrs) . '>' . $element['#title'] . '</a>';
    }
    $output = '<fieldset ' . drupal_attributes($element['#attributes']) . '>';
    if ($element['#title']) {
      $output .= '<legend>' . $element['#title'] . '</legend>';
    }
    $output .= '<div class="fieldset-content" ' . (isset($contentattrs) ? drupal_attributes($contentattrs) : '') . '>';
    if ($element['#description']) {
      $output .= '<div class="description">' . $element['#description'] . '</div>';
    }
    $output .= $element['#children'];
    if (isset($element['#value'])) {
      $output .= $element['#value'];
    }
    $output .= "</div></fieldset>\n";
  }
  else {
    $output = theme_fieldset($element);
  }
  return $output;
}