\n" . $vars['admin'] . "\n"; } // Change 'Home' in breadcrumbs. $crumbs = drupal_get_breadcrumb(); if (count($crumbs) && strpos($crumbs[0], t('Home'))) { $crumbs[0] = l(t($_fb_app->title), ''); $vars['breadcrumb'] = theme('breadcrumb', $crumbs); } // Style page differently depending on which sidebars are present. // Approach copied from Zen theme. // allows styling based on context (home page, node of certain type, etc.) $body_classes = array(); $body_classes[] = ($vars['is_front']) ? 'front' : 'not-front'; $body_classes[] = ($user->uid > 0) ? 'logged-in' : 'not-logged-in'; if (isset($vars['left']) && isset($vars['right'])) { $body_classes[] = 'with-both-sidebars'; } elseif ($vars['right']) { $body_classes[] = 'with-sidebar-right'; } elseif ($vars['left']) { $body_classes[] = 'with-sidebar-left'; } // new facebook pages are wider if ($_REQUEST['fb_sig_in_new_facebook']) $body_classes[] = 'in-new-facebook'; // Regions $region_list = array( 'prefaces' => array('preface_first', 'preface_middle', 'preface_last'), //'postscripts' => array('postscript_first', 'postscript_middle', 'postscript_last') ); foreach ($region_list as $sub_region_key => $sub_region_list) { $active_regions = array(); foreach ($sub_region_list as $region_item) { if ($vars[$region_item]) { $active_regions[] = $region_item; } } $vars[$sub_region_key . '_class'] = $sub_region_key .'-'. strval(count($active_regions)); $vars[$sub_region_key . '_count'] = count($active_regions); } $vars['body_classes'] = implode(' ', $body_classes); } } function _fb_fbml_menu_hack() { // We have to go out of our way here to theme the tabs. // The code in menu.inc that themes them is complex, // incomprehensible, and tangles the theme layer with the logic // layer. It doesn't help that the same theme functions are called // for tabs as are called for all other menus. So we use a global // to keep track of what we're doing. global $_fb_canvas_state; $_fb_canvas_state = 'tabs'; // Why does a call to menu_tab_root_path theme the tabs? I have no // idea, but it does and caches the result. menu_tab_root_path(); $_fb_canvas_state = NULL; } function fb_fbml_preprocess_node(&$vars) { // Add node_bottom region content $vars['node_bottom'] = theme('blocks', 'node_bottom'); } //// override tabs at top of page. We rely on a hack in fb_canvas.module to detect when we are theming the tabs. function fb_fbml_menu_local_task($link, $active = FALSE) { global $_fb_canvas_state; if ($_fb_canvas_state == 'tabs') { if ($active) { $link = str_replace('selected="false"', 'selected="true"', $link); } return $link; } else return theme_menu_local_task($link, $active); } function fb_fbml_menu_item_link($link) { global $_fb_canvas_state; if ($_fb_canvas_state == 'tabs') { // Theme an FBML tab $output = "" . $link['title'] . "\n"; return $output; } else return theme_menu_item_link($link); } function fb_fbml_menu_local_tasks() { global $fb; // menu.inc generates the local task (tab) markup in a convoluted and inflexible way. Because of this we generate markup with for the secondary links. Here we use replacement to "fix" this. if ($fb && $fb->in_fb_canvas()) { $output = ''; if ($primary = menu_primary_local_tasks()) { $output .= "\n". $primary ."\n"; } if ($secondary = menu_secondary_local_tasks()) { // replace fb:tab-items with list items $pattern = '|]*)>([^<]*)|'; $replace = '
  • $4
  • '; $secondary = preg_replace($pattern, $replace, $secondary); $output .= "\n"; } } else { $output = theme_menu_local_tasks(); } return $output; } // collapsing fieldsets 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'] = '' . $element['#title'] . ''; } $output = '
    '; if ($element['#title']) { $output .= ''. $element['#title'] .''; } $output .= '
    '; if ($element['#description']) $output .= '
    '. $element['#description'] .'
    '; $output .= $element['#children']; if (isset($element['#value'])) $output .= $element['#value']; $output .= "
    \n"; } else $output = theme_fieldset($element); return $output; }