You are here

function facebook_comments_display in Facebook Comments Social Plugin 7

Generate the output of a Facebook commenting plugin.

Parameters

int $width: The width of the plugin in pixels.

int $amount: The amount of comments to display.

int $fluid: Use fluid width.

int $fragment: Add the nid as a fragment.

2 calls to facebook_comments_display()
facebook_comments_block_view in ./facebook_comments.module
Implements hook_block_view().
facebook_comments_node_view in ./facebook_comments.module
Implements hook_node_view().

File

./facebook_comments.module, line 429
Facebook Comments Social Plugin module file.

Code

function facebook_comments_display($mode = 'node', $width, $amount, $fluid = 1, $fragment = 0) {

  // Add the Facebook App ID if it exists.
  if ($appid = variable_get('facebook_comments_appid', '')) {
    $element = array(
      '#tag' => 'meta',
      '#attributes' => array(
        'property' => 'fb:app_id',
        'content' => $appid,
      ),
    );
    drupal_add_html_head($element, 'facebook_comments');
  }
  elseif ($admins = variable_get('facebook_comments_admins', '')) {
    $admin = explode(",", $admins);
    foreach ($admin as $key => $value) {
      $element = array(
        '#tag' => 'meta',
        '#attributes' => array(
          'property' => 'fb:admins',
          'content' => $value,
        ),
      );
      drupal_add_html_head($element, 'facebook_comments_' . $key);
    }
  }
  if ($fluid) {
    $class = "fb-comments-fluid";
    drupal_add_css('#fbcomments, .fb-comments, .fb-comments iframe, .fb-comments span {width: 100% !important;}', array(
      'type' => 'inline',
    ));
  }
  else {
    $class = "";
  }

  // Generate the URL.
  $options = array(
    'absolute' => TRUE,
  );
  if ($fragment) {
    $options['fragment'] = $fragment;
  }
  $url = url(current_path(), $options);

  // If the path is non-SSL, rewrite it to SSL.
  if (variable_get('facebook_comments_ssl', 0) && strpos($url, "http://") !== FALSE) {
    $url = str_ireplace("http://", "https://", $url);
  }

  // Add user defined settings.
  if ($mode == 'block') {
    $style = variable_get('facebook_comments_block_style', 'light');
  }
  else {
    $style = variable_get('facebook_comments_style', 'light');
  }
  $lang = _facebook_comments_get_language_code();
  $output = theme('facebook_comments_display_' . $mode, array(
    'class' => $class,
    'url' => $url,
    'amount' => $amount,
    'width' => $width,
    'style' => $style,
    'lang' => $lang,
  ));
  return $output;
}