Index: themes/fb_fbml/fb_fbml.info
===================================================================
--- themes/fb_fbml/fb_fbml.info
+++ themes/fb_fbml/fb_fbml.info	(6.x working copy)
@@ -1,4 +0,0 @@
+name = fb_fbml
+description = for fb module.
+core = 6.x
+engine = phptemplate
Index: themes/fb_fbml/template.php
===================================================================
--- themes/fb_fbml/template.php	(revision 1.8)
+++ themes/fb_fbml/template.php	(6.x working copy)
@@ -1,23 +1,21 @@
 <?php
 
-/**
- * borrowed from 5.x _phptemplate_callback() source
- * TODO: is there a better/more 6.x modern way of doing this?
- * can't use fb_fbml.info to add stylesheet, Facebook removes it.
- * must be included inline so that it's rendered on the canvas
- */
-function fb_fbml_styles() {
-   ob_start();                      // Start output buffering
-   include "styles.tpl.php";        // Include the file
-   $contents = ob_get_contents();   // Get the contents of the buffer
-   ob_end_clean();                  // End buffering and discard
-   return $contents;                // Return the contents
+
+function fb_fbml_page($content, $show_blocks = TRUE) {
+  $output = phptemplate_page($content, $show_blocks);
+  
+  if (function_exists('fb_canvas_process')) {
+	$output = fb_canvas_process($output);
+  }
+  return $output;
+  
 }
 
-function fb_fbml_preprocess_page(&$vars) {
+function _phptemplate_variables($hook, $vars = array()) {
   global $fb_app, $user;
 
-  $vars['styles'] = fb_fbml_styles(); //TODO: prolly a better way to do this in 6.x themeing?
+  if ($hook == 'page') {
+    $vars['styles'] = _phptemplate_callback('styles', $vars);
 
     // Enforce that only admins see admin block.  This can be done (more
     // cleanly?) elsewhere.  But we're doing it here to make sure.
@@ -28,6 +26,13 @@
         "\n</div><!-- end admin sidebar-->";
 	}
 
+	// 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 advanced theming based on context (home page, node of certain type, etc.)
@@ -45,31 +50,12 @@
 	}
 
 	$vars['body_classes'] = implode(' ', $body_classes);
-    
-  //var_dump($vars);
-  if (function_exists('fb_canvas_process')) {
-    fb_canvas_process($vars);
-  }
-  //var_dump($fb_app,$vars);
-}
-
-function fb_fbml_breadcrumb($breadcrumb) {
-  // Change 'Home' in breadcrumbs
-  if (!empty($breadcrumb)) {
-    global $fb_app;
-    if (count($breadcrumb) && strpos($breadcrumb[0], t('Home'))) {
-      $breadcrumb[0] = l(t($fb_app->title), '');
-      $breadcrumb = theme('breadcrumb', $breadcrumb);
-    }
-  }
-}  
 
-function fb_fbml_preprocess_node(&$vars) {
-  global $fb_app, $user;
-  
-  if ($vars['teaser']) {
-    $vars['template_file'] = 'node-teaser';
   }
+  else if ($hook == 'node') {
+    if ($vars['teaser']) {
+      $vars['template_file'] = 'node-teaser';
+    }
 
     // TODO: could move this to phptemplate engine.
     if (count($vars['about']))
@@ -88,54 +74,52 @@
 	  $vars['picture'] = '<div class="picture"><fb:profile-pic uid="'.$fbu.'" linked="yes" size="'.$size.'" /></div>';
     
     //drupal_set_message("node vars: " . dprint_r($vars, 1));
+  }
+  return $vars;
 }
 
-function fb_fbml_preprocess_regions(&$vars) {
-  $vars['regions'] = array('admin' => t('Admin sidebar'),
+function fb_fbml_regions() {
+  $regions = array('admin' => t('Admin sidebar'),
 				   'header' => t('Canvas Header'),
 				   'right' => t('Canvas Right'),
 				   'content_footer' => t('Content Footer'),
 				   'canvas_footer' => t('Canvas Footer'),
 				   );
+  return $regions;
 }
 
 //// tabs
-//TODO: port this function to 6.x.  I don't get the changes to the menu_ functions yet.
-function fb_fbml_menu_local_tasks() {
-/*  global $fb;
-  if ($fb && $fb->in_canvas()) {
-  $local_tasks = menu_local_tasks();
-  //$output = theme('menu_local_task', $local_tasks); //TODO: total guess - would this give the same result?
-  $pid = menu_get_active_nontask_item();
-  $output = '';
-  
-  if (count($local_tasks[$pid]['children'])) {
-    $output .= "<fb:tabs>\n";
-    foreach ($local_tasks[$pid]['children'] as $mid) {
-    $item = menu_get_item($mid);
-    $selected = menu_in_active_trail($mid) ? "true" : "false";
-    $output .= "<fb:tab-item href=\"".url($item['path'], NULL, NULL, FALSE)."\" title=\"".$item['title']."\" selected=\"$selected\">".$item['title']."</fb:tab-item>\n";
-    }
-    $output .= "</fb:tabs>\n";
-  }
-  // TODO secondary local tasks
+
+function phptemplate_menu_local_tasks() {
+  global $fb;
+  if ($fb && $fb->in_fb_canvas()) {
+	$local_tasks = menu_get_local_tasks();
+	$pid = menu_get_active_nontask_item();
+	$output = '';
+	
+	if (count($local_tasks[$pid]['children'])) {
+	  $output .= "<fb:tabs>\n";
+	  foreach ($local_tasks[$pid]['children'] as $mid) {
+		$item = menu_get_item($mid);
+		$selected = menu_in_active_trail($mid) ? "true" : "false";
+		$output .= "<fb:tab-item href=\"".url($item['path'], NULL, NULL, FALSE)."\" title=\"".$item['title']."\" selected=\"$selected\">".$item['title']."</fb:tab-item>\n";
+	  }
+	  $output .= "</fb:tabs>\n";
+	}
+	// TODO secondary local tasks
   }
   else 
-  $output = theme_menu_local_tasks();*/
-  
-//TEMP DEBUG PATCH
-//TODO: FIX _menu_local_tasks
-$output = "<fb:tabs>\n<fb:tab-item href=\"\">item</fb:tab-item></fb:tabs>";
+	$output = theme_menu_local_tasks();
+
   return $output;
   
 }
 
 // collapsing fieldsets
-function fb_fbml_fieldset($element) {
+function phptemplate_fieldset($element) {
   global $fb;
   if ($fb && $fb->in_fb_canvas()) {
 	
-	//drupal_set_message("fb_fbml_fieldset" . dpr($element, 1));
 	static $count = 0;
 	
 	if ($element['#collapsible']) {
@@ -160,9 +144,9 @@
 	if ($element['#title']) {
 	  $output .= '<legend>'. $element['#title'] .'</legend>';
 	}
-	$output .= '<div ' . drupal_attributes($contentattrs) . '>';
+	$output .= '<div class="fieldset-content" ' . drupal_attributes($contentattrs) . '>';
 	if ($element['#description'])
-	  $output .= '<div class="fieldset-content" ' . drupal_attributes($contentattrs) . '>';
+	  $output .= '<div class="description">'. $element['#description'] .'</div>';
 	$output .= $element['#children'] . $element['#value'];
 	$output .= "</div></fieldset>\n";
 	
@@ -173,3 +157,4 @@
 	return $output;
 }
 
+?>
\ No newline at end of file
