You are here

function _janrain_capture_share_button in Janrain Registration 7.4

Same name and namespace in other branches
  1. 7.2 janrain_capture.module \_janrain_capture_share_button()
  2. 7.3 janrain_capture.module \_janrain_capture_share_button()

Returns HTML markup for the social share button.

1 call to _janrain_capture_share_button()
janrain_capture_node_view in ./janrain_capture.module
Implements hook_node_view().

File

./janrain_capture.module, line 1030
This module implements authentication endpoints for Janrain Capture.

Code

function _janrain_capture_share_button($node) {
  global $user;
  $janrain_share_settings = variable_get('janrain_capture_share', array());

  // Prepare arguments for the share widget.
  $args = array();
  foreach (array(
    'message',
    'title',
    'summary',
  ) as $arg) {
    $args[$arg] = $janrain_share_settings['nodes']['default_' . $arg];

    // We disable sanitize for token_replace() to prevent it from encoding
    // apostrophes and such.
    $args[$arg] = filter_xss(token_replace($args[$arg], array(
      'node' => $node,
      'user' => $user,
    ), array(
      'clear' => TRUE,
      'sanitize' => FALSE,
    )));
  }
  $args['summary'] = addslashes(text_summary(strip_tags($args['summary']), NULL, 128) . '...');
  $args['title'] = addslashes($args['title']);
  $args['message'] = addslashes($args['message']);
  $args['url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . request_uri();
  janrain_capture_share_js();
  return theme('janrain_capture_share_button', array(
    'args' => $args,
    'node' => $node,
  ));
}