You are here

function sharebar_settings in ShareBar 6

Same name and namespace in other branches
  1. 7.2 sharebar.admin.inc \sharebar_settings()
  2. 7 sharebar.admin.inc \sharebar_settings()

Form builder: Configure the sharebar system.

1 string reference to 'sharebar_settings'
sharebar_menu in ./sharebar.module
Implements hook_menu().

File

./sharebar.admin.inc, line 193
Admin page callbacks for the block module.

Code

function sharebar_settings() {
  drupal_add_css(drupal_get_path('module', 'sharebar') . '/css/colorpicker.css');
  drupal_add_js(drupal_get_path('module', 'sharebar') . '/js/colorpicker.js');
  drupal_add_js('jQuery(document).ready(function($) {
			var ids = ["edit-sharebar-bar-background","edit-sharebar-bar-border"];
			$.each(ids, function() {
				var id = this;
				$("#"+this).ColorPicker({
					onSubmit: function(hsb, hex, rgb, el) {
						$(el).val(hex);
						$(el).ColorPickerHide();
					},
					onBeforeShow: function () {
						$(this).ColorPickerSetColor(this.value);
					},
					onChange: function(hsb, hex, rgb, el) {
						$("#"+id).val(hex);
					}
				});
			});
		});
  ', 'inline');
  $form['buttonsset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Buttons'),
    '#description' => t(''),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['buttonsset']['buttons'] = array(
    '#theme' => 'sharebar_buttons_table',
    '#weight' => 0,
  );

  // Add sharebar.
  $form['addsharebar'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add Sharebar'),
    '#description' => t('The following settings allow you to automatically add the Sharebar to your pages.'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $node_types = node_get_types();
  if (is_array($node_types) && count($node_types)) {
    foreach ($node_types as $key => $value) {
      $form['addsharebar']['sharebar_bar_posts_' . $value->type . '_enabled'] = array(
        '#type' => 'checkbox',
        '#title' => t('Automatically add Sharebar to content type ' . $value->name . '? (only affects content type ' . $value->name . ')'),
        '#default_value' => variable_get('sharebar_bar_posts_' . $value->type . '_enabled', TRUE),
      );
    }
  }
  $form['addsharebar']['sharebar_bar_pages_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Automatically add Sharebar to Basic page? (only affects basic pages)'),
    '#default_value' => variable_get('sharebar_bar_pages_enabled', TRUE),
  );

  // Display options.
  $form['displayoptions'] = array(
    '#type' => 'fieldset',
    '#title' => t('Display options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['displayoptions']['sharebar_bar_horizontal'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display horizontal Sharebar if the page is resized to less than 1000px?'),
    '#default_value' => variable_get('sharebar_bar_horizontal', TRUE),
  );
  $form['displayoptions']['sharebar_bar_oncontent'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display sharebar in content'),
    '#default_value' => variable_get('sharebar_bar_oncontent', TRUE),
    '#ahah' => array(
      'path' => 'sharebar/ahah/csscontainer/callback',
      //'path' => 'examples/ahah_example/autotextfields/callback',
      'wrapper' => 'csscontainer-wrapper',
      'effect' => 'fade',
    ),
  );
  $form['displayoptions']['sharebar_bar_credit'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display credit link back to the Sharebar plugin? If disabled, please consider donating.'),
    '#default_value' => variable_get('sharebar_bar_credit', TRUE),
  );
  $form['displayoptions']['csscontainer'] = array(
    '#title' => t("Custom Css Container"),
    '#prefix' => '<div id="csscontainer-wrapper">',
    '#suffix' => '</div>',
    '#type' => 'fieldset',
  );
  if (variable_get('sharebar_bar_oncontent', TRUE)) {
    $form['displayoptions']['csscontainer']['sharebar_bar_idcontent'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom CSS Container when displayed in content region(only id selector is supported)'),
      '#size' => 10,
      '#default_value' => variable_get('sharebar_bar_idcontent', 'sharebarp'),
    );
  }
  else {
    $form['displayoptions']['csscontainer']['sharebar_bar_id'] = array(
      '#type' => 'textfield',
      '#title' => t('Custom CSS Container when not displayed in content region (only id selector is supported)'),
      '#size' => 10,
      '#default_value' => variable_get('sharebar_bar_id', 'sharebar'),
    );
  }
  $form['displayoptions']['sharebar_bar_toptoffset'] = array(
    '#type' => 'textfield',
    '#title' => t('Top offset'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_toptoffset', 0),
  );
  $form['displayoptions']['sharebar_bar_position'] = array(
    '#type' => 'select',
    '#title' => t('Sharebar position'),
    '#default_value' => variable_get('sharebar_bar_position', 'left'),
    '#options' => array(
      'left' => 'Left',
      'right' => 'Right',
    ),
  );
  $form['displayoptions']['sharebar_bar_leftoffset'] = array(
    '#type' => 'textfield',
    '#title' => t('Left Offset (used when positioned to left)'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_leftoffset', 10),
  );
  $form['displayoptions']['sharebar_bar_rightoffset'] = array(
    '#type' => 'textfield',
    '#title' => t('Right Offset (used when positioned to right)'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_rightoffset', 10),
  );
  $form['displayoptions']['sharebar_bar_width'] = array(
    '#type' => 'textfield',
    '#title' => t('Minimum width in pixels required to show vertical Sharebar to the left of post (cannot be blank)'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_width', 1000),
  );

  // Customize.
  $form['customize'] = array(
    '#type' => 'fieldset',
    '#title' => t('Customize'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['customize']['sharebar_bar_swidth'] = array(
    '#type' => 'textfield',
    '#title' => t('Sharebar width'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_swidth', 75),
  );
  $form['customize']['sharebar_bar_twitter_username'] = array(
    '#type' => 'textfield',
    '#title' => t('Twitter username'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_twitter_username', 'themesnap'),
  );
  $form['customize']['sharebar_bar_background'] = array(
    '#type' => 'textfield',
    '#title' => t('Sharebar background color'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_background', 'FFFFFF'),
  );
  $form['customize']['sharebar_bar_border'] = array(
    '#type' => 'textfield',
    '#title' => t('Sharebar border color'),
    '#size' => 10,
    '#default_value' => variable_get('sharebar_bar_border', 'CCCCCC'),
  );
  $form['#attributes'] = array(
    'enctype' => 'multipart/form-data',
  );
  return system_settings_form($form);
}