You are here

function _fb_likebox_block_view in Facebook Page Plugin 7.2

Builds the link needed to connect with facebook.

1 call to _fb_likebox_block_view()
fb_likebox_block_view in ./fb_likebox.module
Implements hook_block_view().

File

./fb_likebox.module, line 194
Simple module that provides a configurable block with Facebook Likebox's plugin.

Code

function _fb_likebox_block_view() {

  // Get the values given in the admin form.
  $fb_url = variable_get('fb_likebox_url', 'https://www.facebook.com/FacebookDevelopers');
  $fb_app_id = variable_get('fb_likebox_app_id', '');
  $fb_hide_header = variable_get('fb_likebox_hide_header', 'false');
  $fb_tabs = array();
  if (variable_get('fb_likebox_stream') == 1) {
    $fb_tabs[] = 'timeline';
  }
  if (variable_get('fb_likebox_events') == 1) {
    $fb_tabs[] = 'events';
  }
  if (variable_get('fb_likebox_messages') == 1) {
    $fb_tabs[] = 'messages';
  }
  $fb_show_faces = variable_get('fb_likebox_show_faces', 'true');
  $fb_width = variable_get('fb_likebox_width', '340');
  $fb_height = variable_get('fb_likebox_height', '500');
  $fb_iframe_title = variable_get('fb_likebox_title', 'Like us on Facebook');
  $fb_hide_cta = variable_get('fb_likebox_hide_cta', 'false');
  $fb_small_header = variable_get('fb_likebox_small_header', 'false');
  $fb_adapt_container_width = variable_get('fb_likebox_adapt_container_width', 'true');
  $fb_language = variable_get('fb_likebox_language', 'en_EN');
  $block['block'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'fb-page',
      ),
      'data-href' => array(
        $fb_url,
      ),
      'data-width' => array(
        $fb_width,
      ),
      'data-height' => array(
        $fb_height,
      ),
      'data-tabs' => array(
        implode(',', $fb_tabs),
      ),
      'data-hide-cover' => array(
        $fb_hide_header,
      ),
      'data-show-facepile' => array(
        $fb_show_faces,
      ),
      'data-hide-cta' => array(
        $fb_hide_cta,
      ),
      'data-small-header' => array(
        $fb_small_header,
      ),
      'data-adapt-container-width' => array(
        $fb_adapt_container_width,
      ),
    ),
  );
  $block['block']['child'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'fb-xfbml-parse-ignore',
      ),
    ),
  );
  $block['block']['child']['blockquote'] = array(
    '#type' => 'link',
    '#title' => $fb_iframe_title,
    '#href' => $fb_url,
    '#suffix' => '</blockquote>',
    '#prefix' => '<blockquote cite="' . $fb_url . '">',
  );
  $block['#attached']['js'] = array(
    drupal_get_path('module', 'fb_likebox') . '/fb_likebox.js',
    array(
      'data' => array(
        'fb_likebox_app_id' => $fb_app_id,
        'fb_likebox_language' => $fb_language,
      ),
      'type' => 'setting',
    ),
  );
  return $block;
}