You are here

function fb_devel_page in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb_devel.module \fb_devel_page()
  2. 5 fb_devel.module \fb_devel_page()
  3. 6.3 fb_devel.module \fb_devel_page()
  4. 6.2 fb_devel.module \fb_devel_page()
  5. 7.4 fb_devel.module \fb_devel_page()

Provides a page with useful debug info.

@TODO - clean this up and rely less on drupal_set_message() and dpm().

1 string reference to 'fb_devel_page'
fb_devel_menu in ./fb_devel.module

File

./fb_devel.module, line 335
Makes development with Drupal for Facebook much easier. Keep this module enabled until you're confident your app works perfectly.

Code

function fb_devel_page() {
  global $_fb, $_fb_app;
  global $user;
  if (isset($_REQUEST['require_login']) && $_REQUEST['require_login']) {
    fb_require_authorization($_fb);
  }
  $items = array();
  $items['fb_settings'] = fb_settings();
  if ($_fb) {
    $items['$GLOBALS[_fb]'] = $_fb;

    // TODO: determine whether connect page or canvas.
    drupal_set_message(t("session name: " . session_name()));
    drupal_set_message(t("session id: " . session_id()));
    drupal_set_message(t("cookie domain: " . fb_settings(FB_SETTINGS_COOKIE_DOMAIN)));
    if (isset($_COOKIE['fbs_' . $_fb_app->apikey])) {
      drupal_set_message(t("fbs_" . $_fb_app->apikey . ": " . $_COOKIE["fbs_" . $_fb_app->apikey]));
    }
    drupal_set_message(t("<a href=\"!url\">processed link</a>, <a href=!url>unprocessed</a>", array(
      '!url' => url('fb/devel'),
    )));
    drupal_set_message(t("getUser() returns " . $_fb
      ->getUser()));
    drupal_set_message(t("getAccessToken() returns " . $_fb
      ->getAccessToken()));
    drupal_set_message(t("base_url: " . $GLOBALS['base_url']));
    drupal_set_message(t("base_path: " . $GLOBALS['base_path']));
    drupal_set_message(t("url() returns: " . url()));
  }
  if ($fbu = fb_get_fbu($user)) {
    $path = "fb/devel/fbu/{$fbu}";
    drupal_set_message(t("Learn more about the current user at !link", array(
      '!link' => l($path, $path),
    )));
  }
  dpm(fb_get_fbu($user), 'Facebook user via fb_get_fbu');

  //dpm($user, "Local user " . theme('username', $user));
  if (isset($GLOBALS['fb_connect_apikey'])) {
    drupal_set_message(t("fb_connect_apikey = " . $GLOBALS['fb_connect_apikey']));
  }
  dpm(fb_settings(), 'fb_settings()');
  dpm($_COOKIE, 'cookie');
  dpm($_REQUEST, "Request");

  //dpm($_fb_app, "fb_app");
  dpm($_SESSION, "session:");
  foreach ($items as $key => $val) {
    if (is_array($val) || is_object($val)) {
      $markup = print_r($val, 1);
    }
    else {
      $markup = $val;
    }
    $out[$key] = array(
      '#prefix' => "<dl><dt>{$key}</dt><dd><pre>",
      '#suffix' => "</pre></dd></dl>",
      '#markup' => $markup,
    );
  }
  return render($out);
}