You are here

function facebook_boxes_block_view in Facebook Boxes 7

Implements hook_block_view().

File

./facebook_boxes.module, line 249

Code

function facebook_boxes_block_view($delta = '') {
  $block = array();
  global $base_root;
  if ($delta == 'fb_like') {
    $url = urlencode(variable_get('fb_like_url', 'http://www.facebook.com/platform'));
    $width = variable_get('fb_like_width', 292);
    $height = variable_get('fb_like_height', 300);
    $colorscheme = urlencode(variable_get('fb_like_colorscheme', 'light'));
    $border = urlencode(variable_get('fb_like_border', ''));
    $opts = variable_get('fb_like_toggles', array(
      'fb_faces',
      'fb_header',
    ));
    $block['subject'] = "On Facebook";
    $block['content'] = array(
      '#markup' => sprintf('<iframe src="//www.facebook.com/plugins/likebox.php?href=%s&amp;width=%u&amp;height=%u&amp;colorscheme=%s&amp;show_faces=%s&amp;border_color=%s&amp;stream=%s&amp;header=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%spx; height:%spx;" allowTransparency="true"></iframe>', $url, $width, $height, $colorscheme, in_array('fb_faces', $opts) ? 'true' : 'false', $border, in_array('fb_stream', $opts) ? 'true' : 'false', in_array('fb_header', $opts) ? 'true' : 'false', $width, $height),
    );
  }
  elseif ($delta == 'fb_rec') {
    $opts = variable_get('fb_rec_toggles', array(
      'fb_blank',
      'fb_header',
    ));
    $block['subject'] = "Facebook Recommendations";
    $block['content'] = array(
      '#markup' => sprintf('<iframe src="//www.facebook.com/plugins/recommendations.php?site=%s&amp;action&amp;width=%u&amp;height=%u&amp;colorscheme=%s&amp;&amp;border_color=%s&amp;header=%s&amp;font&amp;linktarget=%s" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:%upx; height:%upx;" allowTransparency="true"></iframe>', urlencode(variable_get('fb_rec_domain', parse_url($base_root, PHP_URL_HOST))), variable_get('fb_rec_width', 292), variable_get('fb_rec_height', 300), urlencode(variable_get('fb_rec_colorscheme', 'light')), urlencode(variable_get('fb_rec_border', '')), in_array('fb_header', $opts) ? 'true' : 'false', in_array('fb_target', $opts) ? '_blank' : '_top', variable_get('fb_rec_width', 292), variable_get('fb_rec_height', 300)),
    );
  }
  elseif ($delta == 'fb_follow') {
    $block['subject'] = 'Follow';
    $out = array();
    $url = variable_get('fb_follow_url', 'http://www.facebook.com/newsignature');
    $out[] = '<iframe src="http://www.facebook.com/plugins/follow.php?href=' . $url;
    $layout = variable_get('fb_follow_layout', 'standard');
    $out[] = '&amp;layout=' . $layout;
    if ($layout == 'standard') {
      $showfaces = variable_get('fb_follow_showface', 'TRUE');
      if (!$showfaces) {
        $showfaces = 'FALSE';
      }
      $out[] = '&amp;show_faces=' . $showfaces;
    }
    $out[] = '&amp;colorscheme=' . variable_get('fb_follow_colorscheme', 'light');
    $out[] = '&amp;font=' . variable_get('fb_follow_font', 'arial');
    $width = preg_replace('/[^\\d\\s]/', '', variable_get('fb_follow_width', '450'));
    $out[] = '&amp;width=' . $width;
    $out[] = '&amp;height=80" scrolling="no" frameborder="0" ';
    $out[] = 'style="border:none; overflow:hidden; width:' . $width;
    $out[] = ';height:80px; "allowTransparency="true"></iframe>';
    $block['content'] = array(
      '#markup' => implode('', $out),
    );
  }
  return $block;
}