You are here

function sharebar_bar_filter in ShareBar 7

Same name and namespace in other branches
  1. 8 sharebar.module \sharebar_bar_filter()
  2. 6 sharebar.module \sharebar_bar_filter()
  3. 7.2 sharebar.module \sharebar_bar_filter()

Replaces dynamic data with their values.

1 call to sharebar_bar_filter()
sharebar_onblock in ./sharebar.module
Custom function to assemble renderable array for block content.

File

./sharebar.module, line 257
Various module information.

Code

function sharebar_bar_filter($input, $title = '') {
  $name = '';
  $sitename = variable_get('site_name', '');
  global $base_url;
  global $language;
  if (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ($node != FALSE && $node->nid > 0) {
      $title = $node->title;
      $name = $node->name;
    }
  }
  else {
    $node = '';
  }
  $path = isset($_GET['q']) ? $_GET['q'] : '<front>';
  $currenturl = url($path, array(
    'absolute' => TRUE,
  ));
  $code = array(
    '[title]',
    '[url]',
    '[author]',
    '[twitter]',
  );
  $values = array(
    $title,
    $currenturl,
    $name,
    variable_get('sharebar_bar_twitter_username', $sitename),
  );
  $result = str_replace($code, $values, $input);

  // Now do some serious token replacement.
  if (module_exists('token')) {
    $variables = array();
    $variables['node'] = $node;
    $result = token_replace($result, $variables, array(
      'language' => $language,
      'sanitize' => FALSE,
      'clear' => TRUE,
    ));
  }
  return $result;
}