You are here

function phptemplate_fieldset in Drupal for Facebook 5.2

Same name and namespace in other branches
  1. 5 themes/fb_fbml/template.php \phptemplate_fieldset()

File

themes/fb_fbml/template.php, line 165

Code

function phptemplate_fieldset($element) {
  global $fb;
  if ($fb && $fb
    ->in_fb_canvas() || function_exists('fb_canvas_is_fbml') && fb_canvas_is_fbml()) {
    static $count = 0;
    if ($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" ' . drupal_attributes($contentattrs) . '>';
    if ($element['#description']) {
      $output .= '<div class="description">' . $element['#description'] . '</div>';
    }
    $output .= $element['#children'] . $element['#value'];
    $output .= "</div></fieldset>\n";
  }
  else {
    $output = theme_fieldset($element);
  }
  return $output;
}