You are here

function sharebar_preprocess_page in ShareBar 8

Same name and namespace in other branches
  1. 6 sharebar.module \sharebar_preprocess_page()

Implements hook_preprocess_page().

File

./sharebar.module, line 27
Allows site owner to add share buttons on their website

Code

function sharebar_preprocess_page(&$variables) {
  $args = explode('/', current_path());
  if ($args[0] != 'admin') {
    if ($args[0] == 'node' && is_numeric($args[1]) && $args[2] == '' || !($args[0] == 'node' && is_numeric($args[1])) && $args[1] != 'add' && $args[2] != 'edit' && $args[3] != 'edit' && \Drupal::config('sharebar.settings')
      ->get('sharebar_bar_pages_enabled')) {
      _drupal_add_css(drupal_get_path('module', 'sharebar') . '/css/sharebar.css');
      if (!\Drupal::config('sharebar.settings')
        ->get('sharebar_bar_oncontent')) {
        if (\Drupal::config('sharebar.settings')
          ->get('sharebar_bar_horizontal')) {
          $hori = 'TRUE';
        }
        else {
          $hori = 'FALSE';
        }
        $width = \Drupal::config('sharebar.settings')
          ->get('sharebar_bar_width');
        $swidth = \Drupal::config('sharebar.settings')
          ->get('sharebar_bar_swidth');
        $position = \Drupal::config('sharebar.settings')
          ->get('sharebar_bar_position');
        $leftoffset = \Drupal::config('sharebar.settings')
          ->get('sharebar_bar_leftoffset');
        $rightoffset = \Drupal::config('sharebar.settings')
          ->get('sharebar_bar_rightoffset');
        _drupal_add_js(drupal_get_path('module', 'sharebar') . '/js/sharebar.js');
        _drupal_add_js('jQuery(document).ready(function($) { $(\'.sharebar\').sharebar({horizontal:\'' . $hori . '\',swidth:\'' . $swidth . '\',minwidth:' . $width . ',position:\'' . $position . '\',leftOffset:' . $leftoffset . ',rightOffset:' . $rightoffset . '}); });', 'inline');
      }
    }
  }
}