? facebook-platform
Index: fb.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb.module,v
retrieving revision 1.56
diff -u -r1.56 fb.module
--- fb.module	27 Oct 2009 21:24:06 -0000	1.56
+++ fb.module	9 Nov 2009 23:13:43 -0000
@@ -835,7 +835,7 @@
   $pre = '';
   
   // Prefix each known value to the URL
-  foreach (array_reverse(_fb_settings_url_rewrite_prefixes()) as $prefix) {
+  foreach (_fb_settings_url_rewrite_prefixes() as $prefix) {
     if ($value = fb_settings($prefix))
       $pre .= $prefix . '/'. $value . '/';
   }
Index: fb_connect.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_connect.js,v
retrieving revision 1.11
diff -u -r1.11 fb_connect.js
--- fb_connect.js	27 Oct 2009 20:19:27 -0000	1.11
+++ fb_connect.js	9 Nov 2009 23:13:43 -0000
@@ -76,7 +76,8 @@
 FB_Connect.on_connected = function(fbu) {
   //alert("FB_Connect.on_connected " + fbu + " settings fbu is " + Drupal.settings.fb_connect.fbu + " FB_Connect.fbu is " + FB_Connect.fbu);
   var status = {'changed': false, 'fbu': fbu};
-  if (FB_Connect.fbu === 0 || Drupal.settings.fb_connect.fbu != fbu) {
+  if ((FB_Connect.fbu === 0 || Drupal.settings.fb_connect.fbu != fbu) &&
+      Drupal.settings.fb_connect.in_iframe != 1) {
     status.changed = true;
   }
   FB_Connect.fbu = fbu;
@@ -86,7 +87,8 @@
 FB_Connect.on_not_connected = function() {
   //alert("FB_Connect.on_not_connected, settings fbu is " + Drupal.settings.fb_connect.fbu);
   var status = {'changed': false, 'fbu': 0};
-  if (FB_Connect.fbu > 0 || Drupal.settings.fb_connect.fbu > 0) {
+  if ((FB_Connect.fbu > 0 || Drupal.settings.fb_connect.fbu > 0) &&
+      Drupal.setings.fb_connect.in_iframe != 1){
     // This code will not be reached if fb_connect_logout_onclick (below) calls logoutAndRedirect.
     // We've gone from connected to not connected.
     status.changed = true;
Index: fb_connect.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_connect.module,v
retrieving revision 1.31
diff -u -r1.31 fb_connect.module
--- fb_connect.module	27 Oct 2009 21:03:10 -0000	1.31
+++ fb_connect.module	9 Nov 2009 23:13:43 -0000
@@ -169,6 +169,10 @@
 
 }
 
+/**
+ * This wrapper function around drupal_add_js() ensures that our
+ * settings are added once and only once when needed.
+ */
 function _fb_connect_add_js() {
   static $just_once;
   if (!isset($just_once)) {
@@ -180,6 +184,8 @@
     drupal_add_js(array('fb_connect' => array(
                           'front_url' => url('<front>'),
                           'fbu' => $fbu,
+                          // Is there a better way to keep track of iframe?
+                          'in_iframe' => $_REQUEST['fb_sig_in_iframe'],
                         ),
                   ), 'setting');
     drupal_add_js($base . '/fb_connect.js');
Index: fb_devel.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/fb_devel.module,v
retrieving revision 1.24
diff -u -r1.24 fb_devel.module
--- fb_devel.module	22 Oct 2009 23:22:55 -0000	1.24
+++ fb_devel.module	9 Nov 2009 23:13:43 -0000
@@ -10,9 +10,16 @@
   $items['fb/devel/fbu'] = array(
     'page callback' => 'fb_devel_fbu_page',
     'type' => MENU_CALLBACK,
-    'access' => TRUE,
+    'access callback' => TRUE,
   );
-  
+
+  // Return some info for debugging AHAH problems
+  $items['fb/devel/js'] = array(
+    'page callback' => 'fb_devel_js',
+    'type' => MENU_CALLBACK,
+    'access callback' => TRUE,
+  );
+
   return $items;
 }
 
@@ -114,7 +121,7 @@
     $message .= dprint_r($data, 1);
     $message .= dprint_r($_REQUEST,1);
     watchdog('fb_devel', $message);
-  }
+ }
   
   else if ($op == FB_OP_CANVAS_EXIT && $data['fb'] && $return) {
     watchdog('fb_devel', 'Drupal is redirecting a canvas page, destination is %destination.', array('%destination' => $return));
@@ -204,9 +211,59 @@
   return $output;
 }
 
+
+/**
+ * Provide some information for testing AHAH and AJAX scenarios.
+ */
+function fb_devel_js() {
+  $data = '<pre>';
+
+  $data .= "session_name() = " . session_name() . "\n";
+  $data .= "session_id() = " . session_id() . "\n";
+  $data .= "REQUEST: " . dprint_r($_REQUEST, 1) . "\n";
+  $data .= "SESSION: " . dprint_r($_SESSION, 1) . "\n";
+  $data .= '</pre>';
+
+  print drupal_json(array('status' => TRUE, 'data' => $data));
+  exit();
+}
+
+function fb_devel_form_alter(&$form, $form_state, $form_id) {
+  static $count;
+  $count++;
+
+  if (fb_verbose() == 'extreme') { // most people will not want this...
+    $form['fb_devel'] = array(
+      '#type' => 'fieldset',
+      '#title' => t('Drupal for Facebook Devel'),
+      '#description' => t('For debugging ahah problems......'),
+      '#collapsible' => TRUE,
+      '#collapsed' => FALSE,
+    );
+    $form['fb_devel']['submit'] = array(
+      '#type' => 'submit',
+      '#value' => t('fb_devel'),
+      '#ahah' => array(
+        'event' => 'click',
+        'path' => 'fb/devel/js',
+        'wrapper' => "fb_devel_wrapper$count",
+        'method' => 'replace',
+        'effect' => 'fade',
+        'progress' => array('type' => 'bar', 'message' => 'XXX'),
+      ),
+    );
+    $form['fb_devel']['wrap'] = array(
+      '#type' => 'markup',
+      '#value' => "<div id=fb_devel_wrapper$count>This is the wrapper.</div>",
+    );
+  }
+}
+
 function fb_devel_block($op = 'list', $delta = 0, $edit = array()) {
   if ($op == 'list') {
+    // Provide two copies of same block, for iframe scenarios.
     $items[0]['info'] = t('Facebook Devel Page Info');
+    $items[1]['info'] = t('Facebook Devel Page Info 2');
     return $items;
   }
   else if ($op == 'view') {
Index: themes/fb_fbml/fb_fbml.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/themes/fb_fbml/fb_fbml.info,v
retrieving revision 1.1
diff -u -r1.1 fb_fbml.info
--- themes/fb_fbml/fb_fbml.info	5 Mar 2009 17:07:36 -0000	1.1
+++ themes/fb_fbml/fb_fbml.info	9 Nov 2009 23:13:43 -0000
@@ -8,4 +8,5 @@
 regions[right] = Canvas Right
 regions[content_footer] = Content Footer
 regions[canvas_footer] = Canvas Footer
+regions[iframe_footer] = Iframe Footer
 
Index: themes/fb_fbml/iframe.tpl.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/themes/fb_fbml/iframe.tpl.php,v
retrieving revision 1.2
diff -u -r1.2 iframe.tpl.php
--- themes/fb_fbml/iframe.tpl.php	19 Sep 2008 20:45:24 -0000	1.2
+++ themes/fb_fbml/iframe.tpl.php	9 Nov 2009 23:13:43 -0000
@@ -1,5 +1,5 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language; ?>" xml:lang="<?php print $language; ?>" xmlns:fb="http://www.facebook.com/2008/fbml">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php print $language->language; ?>" xml:lang="<?php print $language->language; ?>" xmlns:fb="http://www.facebook.com/2008/fbml">
   <head>
 	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 	<title><?php print $head_title; ?></title>
Index: themes/fb_fbml/template.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/fb/themes/fb_fbml/template.php,v
retrieving revision 1.16
diff -u -r1.16 template.php
--- themes/fb_fbml/template.php	27 Oct 2009 20:39:52 -0000	1.16
+++ themes/fb_fbml/template.php	9 Nov 2009 23:13:43 -0000
@@ -1,9 +1,16 @@
 <?php
 
-function fb_fbml_preprocess_pageXXX() {
-  //dpm(func_get_args(), 'fb_fbml_preprocess_page');
-}
-
+/**
+ * Ideally, we would not have to implement fb_fbml_page() to override
+ * theme('page', ...), but we do because Drupal's menu (tab) theme
+ * functions are impossible to override effectively on their own.
+ * 
+ * This function is a bit of a hack.  And has the bad drawback (in D6)
+ * that our fb_fbml_preprocess() is not called by theme(), so that we
+ * have to do more hacking to support iframe pages.  In short, with
+ * each new version of Drupal, check to see whether we can get rid of
+ * this function.
+ */
 function fb_fbml_page($content, $show_blocks = TRUE, $show_messages = TRUE) {
   $variables = array('template_files' => array(),
 		     'content' => $content,
@@ -33,7 +40,12 @@
   // Now our own preprocessing
   fb_fbml_preprocess($variables, $hook);
   
-  $template_file = path_to_theme() . '/page.tpl.php';
+  if (function_exists('fb_canvas_is_iframe') && fb_canvas_is_iframe()) {
+    $template_file = path_to_theme() . '/iframe.tpl.php';
+  }
+  else {
+    $template_file = path_to_theme() . '/page.tpl.php';
+  }
   $output = theme_render_template($template_file, $variables);
   
   if (function_exists('fb_canvas_process')) {
