You are here

function fb_admin_page in Drupal for Facebook 6.2

Same name and namespace in other branches
  1. 6.3 fb.admin.inc \fb_admin_page()
  2. 7.3 fb.admin.inc \fb_admin_page()

Drupal page callback.

1 string reference to 'fb_admin_page'
fb_menu in ./fb.module
Implementation of hook_menu().

File

./fb.admin.inc, line 21
Admin pages and forms for Drupal for Facebook.

Code

function fb_admin_page() {
  $apps = fb_get_all_apps();
  if (count($apps)) {
    $header = array(
      t('Label'),
      t('About'),
      t('Canvas'),
      t('Local Settings'),
      t('Remote Settings'),
    );
    foreach ($apps as $fb_app) {

      // Get properties from facebook.
      fb_admin_get_app_properties($fb_app);
      $row = array();

      // Title.
      $row[] = $fb_app->label . ($fb_app->status ? '' : ' ' . t('(<em>not enabled</em>)'));

      // About.
      $row[] = l($fb_app->application_name, 'http://www.facebook.com/apps/application.php?id=' . $fb_app->id);

      // Canvas Page.
      if ($fb_app->canvas_name != $fb_app->canvas) {
        drupal_set_message(t('Canvas page for %label is out of sync!  Facebook believes it is %fbcanvas, while our database believes %canvas.  Edit and save the application to remedy this.', array(
          '%label' => $fb_app->label,
          '%fbcanvas' => $fb_app->canvas_name,
          '%canvas' => $fb_app->canvas,
        )), 'error');
      }
      if ($fb_app->canvas) {
        $row[] = l($fb_app->canvas, 'http://apps.facebook.com/' . $fb_app->canvas);
      }
      else {
        $row[] = t('n/a');
      }

      // Local Settings
      $local_links = fb_invoke(FB_ADMIN_OP_LOCAL_LINKS, array(
        'fb_app' => $fb_app,
      ), array(
        t('view') => FB_PATH_ADMIN_APPS . '/' . $fb_app->label,
      ), FB_ADMIN_HOOK);
      $links = array();
      foreach ($local_links as $title => $href) {
        $links[] = array(
          'title' => $title,
          'href' => $href,
        );
      }
      $row[] = theme('links', $links);

      // Remote Settings
      $row[] = l($fb_app->id, 'http://www.facebook.com/developers/editapp.php?app_id=' . $fb_app->id);
      $rows[] = $row;
    }
    $output .= theme('table', $header, $rows);
  }
  else {
    $output = t('Start by creating an application.');
    if (!module_exists('fb_app')) {
      $output .= t('Ensure the Facebook Application module is enabled.');
    }
    else {
      $output .= t('Click <a href="!url">Add Application</a> to continue.', array(
        '!url' => url('admin/build/fb/fb_app_create'),
      ));
    }
  }
  return $output;
}