You are here

function sharebar_onblock in ShareBar 7

Same name and namespace in other branches
  1. 7.2 sharebar.module \sharebar_onblock()

Custom function to assemble renderable array for block content.

Return value

array returns a renderable array of block content.

2 calls to sharebar_onblock()
sharebar_block_view in ./sharebar.module
Implements hook_block_view().
sharebar_preprocess_region in ./sharebar.module
Preprocess variables for region.tpl.php.

File

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

Code

function sharebar_onblock() {
  $strh = '';
  $sbg = variable_get('sharebar_bar_background', 'FFFFFF');
  if ($sbg != 'transparent') {
    $sbg = "#" . $sbg;
  }
  $sborder = variable_get('sharebar_bar_border', 'CCCCCC');
  if ($sborder != 'transparent') {
    $sborder = "#" . $sborder;
  }
  $credit = variable_get('sharebar_bar_credit', TRUE);
  $margin_top = variable_get('sharebar_bar_toptoffset', 0);
  if (variable_get('sharebar_bar_oncontent', TRUE)) {
    if (variable_get('sharebar_bar_position', 'left') == 'left') {
      $mar = ' margin-right:' . variable_get('sharebar_bar_rightoffset', 10) . 'px;';
    }
    else {
      $mar = ' margin-left:' . variable_get('sharebar_bar_leftoffset', 10) . 'px;';
    }

    // $cls = 'sharebarp';
    $cls = variable_get('sharebar_bar_idcontent', 'sharebarp');
    $settings['cls'] = "#" . $cls;
    drupal_add_js(array(
      'sharebar' => $settings,
    ), 'setting');
    $sty = 'width: ' . variable_get('sharebar_bar_swidth', 75) . 'px; float: ' . variable_get('sharebar_bar_position', 'left') . ';' . $mar;
  }
  else {

    // $cls = 'sharebar';
    $cls = variable_get('sharebar_bar_id', 'sharebar');
    $settings['cls'] = "#" . $cls;
    drupal_add_js(array(
      'sharebar' => $settings,
    ), 'setting');
    $sty = '';
  }
  $str = '<ul id="' . $cls . '" style="background:' . $sbg . ';border-style:' . variable_get('sharebar_bar_border_style', 'solid') . ';border-color:' . $sborder . ';border-width:' . variable_get('sharebar_bar_border_width', '1px') . ';margin-top:' . $margin_top . 'px;' . $sty . '">';
  $buttons = unserialize(variable_get('sharebar_buttons', sharebar_buttons_def()));
  if (is_array($buttons) && count($buttons)) {
    usort($buttons, "sharebar_cmp_up");
    foreach ($buttons as $key => $value) {
      if ($value->enabled) {
        $str .= '<li>' . sharebar_bar_filter($value->big_button, drupal_get_title()) . '</li>';
      }
      if ($value->enabled && variable_get('sharebar_bar_horizontal', TRUE)) {
        $strh .= '<li>' . sharebar_bar_filter($value->small_button, drupal_get_title()) . '</li>';
      }
    }
  }
  if ($credit) {
    $str .= '<li class="credit"><a href="' . SHAREBAR_CREDIT_URL . '" target="_blank">Sharebar</a></li>';
  }
  $str .= '</ul>';
  if (variable_get('sharebar_bar_horizontal', TRUE)) {
    $hrcls = variable_get('sharebar_bar_idhorizontal', 'sharebarx');
    $settings['hrcls'] = "#" . $hrcls;
    drupal_add_js(array(
      'sharebar' => $settings,
    ), 'setting');
    $str .= '<ul id="' . $hrcls . '">' . $strh . '</ul>';
  }
  return $str;
}