You are here

function sexybookmarks_get_config in Share Buttons, Related Posts, Content Analytics - Shareaholic 7

Same name and namespace in other branches
  1. 7.2 sexybookmarks.module \sexybookmarks_get_config()

Prepare configuration for SexyBookmarks theme callback.

1 call to sexybookmarks_get_config()
theme_sexybookmarks in ./sexybookmarks.module
Theme callback for SexyBookmarks.

File

./sexybookmarks.module, line 170
Contains core functions for the SexyBookmarks module.

Code

function sexybookmarks_get_config(&$variables) {
  $config = NULL;
  if (!empty($variables['profile'])) {
    ctools_include('export');
    if ($profile = ctools_export_crud_load('sexybookmarks_profiles', $variables['profile'])) {
      if (empty($profile->disabled)) {
        $config = $profile->config;
        if (isset($variables['config'])) {
          $config = array_merge($config, $variables['config']);
        }
      }
      else {
        watchdog('sexybookmarks', 'Provided profile disabled (!profile).', array(
          '!profile' => $variables['profile'],
        ), WATCHDOG_ERROR);
      }
    }
    else {
      watchdog('sexybookmarks', 'Invalid profile provided (!profile).', array(
        '!profile' => $variables['profile'],
      ), WATCHDOG_ERROR);
    }
  }
  elseif (isset($variables['config'])) {
    $config = $variables['config'];
  }
  else {
    watchdog('sexybookmarks', 'No profile or configuration provided.', array(), WATCHDOG_ERROR);
  }

  // Convert certain strings to boolean values.
  $string_to_bool = array(
    'fbLikeButton',
    'dontShowShareCount',
    'designer_toolTips',
    'shrlink',
    'expand',
  );
  foreach ($string_to_bool as $key) {
    if (isset($config[$key])) {
      $config[$key] = (bool) $config[$key];
    }
  }
  if ($config['perfOptionSetting'] == '1') {
    drupal_add_js('SHRSB_Globals.perfoption=1', 'inline');
    drupal_add_js('SHRCB_Globals.perfoption=1', 'inline');
  }

  // Allow other modules to alter configuration.
  drupal_alter('sexybookmarks_config', $config, $variables);
  return $config;
}