You are here

function google_plusone_block_configure in Google Plus One Button | Google+ Badge 7

Implements hook_block_configure().

File

./google_plusone.module, line 415

Code

function google_plusone_block_configure($delta = '') {
  $form = array();
  if ($delta == 'google_plusone_block') {
    module_load_include('inc', 'google_plusone', 'google_plusone.admin');

    // Custom javascript code to preview in real-time the button
    drupal_add_js('https://apis.google.com/js/plusone.js', 'external');
    drupal_add_js(drupal_get_path('module', 'google_plusone') . '/google_plusone.admin.js');
    $default = array(
      'url' => '',
      'annotation' => 'bubble',
      'width' => '250',
      'size' => '',
      // standard
      'css' => 'text-align:center',
      'alias' => 'aliased',
    );
    $settings = array_merge($default, variable_get('google_plusone_block_settings', array()));
    $available_sizes = array(
      'small' => t('Small (15px)'),
      'medium' => t('Medium (20px)'),
      '' => t('Standard (24px)'),
      'tall' => t('Tall (60px)'),
    );
    $available_annotations = array(
      'none' => t('None'),
      'bubble' => t('Bubble (by default)'),
      'inline' => t('Inline'),
    );
    $form['g1button'] = array(
      '#type' => 'fieldset',
      '#title' => t('Button Settings'),
      '#description' => t('Notice that these settings are exclusively for this block and they cover the basic options.<br /> The rest of settings will be taken from the <a href="@sett">general settings</a>.', array(
        '@sett' => url('admin/config/services/google-plusone'),
      )),
    );
    $form['g1button']['google_plusone_block_url'] = array(
      '#title' => t('URL address to use in the Google +1 button'),
      '#type' => 'textfield',
      '#default_value' => $settings['url'],
      '#description' => t('3 different options: <br/><ol><li>Type an fixed, absolute URL. Remember to type the <em>http://</em> part.</li><li>Type <em>&lt;front&gt;</em></front> to use always your frontpage ($base_url), that is language-aware. </li><li>Leave empty. Then it will be used the current URL address present in that moment in that page where the block is.</li></ol>'),
    );
    $form['g1button']['google_plusone_block_alias'] = array(
      '#type' => 'radios',
      '#title' => t('Aliased node path'),
      '#default_value' => $settings['alias'],
      '#options' => array(
        'not_aliased' => t('Not aliased'),
        'aliased' => t('Aliased'),
      ),
      '#description' => t('By default aliased. It only will be applied when the previous setting <em>URL</em> has been left empty and it\'s a node page. <br/> If you change this setting, <strong>be aware</strong> that Google+ will see them as different URLs, so the button will not keep the previous counting.'),
    );
    $form['g1button']['google_plusone_block_annotation'] = array(
      '#type' => 'radios',
      '#title' => t('Annotation: How to show the counting?'),
      '#options' => $available_annotations,
      '#default_value' => $settings['annotation'],
      '#description' => google_plusone_build_preview_button($available_sizes),
    );
    $form['g1button']['google_plusone_block_width'] = array(
      '#type' => 'textfield',
      '#title' => t('Width (only affects to inline annotation)'),
      '#default_value' => $settings['width'],
      '#size' => 20,
      '#description' => t('By default recommended 250 (pixels). Minimum 120'),
    );
    $form['g1button']['google_plusone_block_size'] = array(
      '#type' => 'radios',
      '#title' => t('Size'),
      '#options' => $available_sizes,
      '#default_value' => $settings['size'],
    );
    $form['g1button']['google_plusone_block_wrapper_css'] = array(
      '#type' => 'textfield',
      '#title' => t('Optional wrapper with CSS'),
      '#maxlength' => 256,
      '#default_value' => $settings['css'],
      '#description' => t('To help with the layout and placement of the button, it will be rendered by default inside a wrapper: 	&lt;div class="g-plusone-wrapper"&gt;	&lt;/div&gt;<br/>You can enter CSS rules to style this wrapper. By default <em>text-align:center</em><br />To disable totally the wrapper, input the word <em>nowrapper</em>'),
    );
  }
  elseif ($delta == 'google_plusone_badge_block') {
    drupal_add_js(array(
      'google_plusone_preview' => url('google_plusone_demo_badge_preview'),
    ), 'setting');
    drupal_add_js(drupal_get_path('module', 'google_plusone') . '/google_plusone_badge.admin.js');
    $preview_placeholder = '<div style="float:right;margin-right:5%;border-left:1px dotted #ccc;padding:10px 20px" id="badge_preview"><div id="demo"></div>';
    $preview_placeholder .= '<div style="margin:1em;width:280px;font-size:0.9em;"><p>' . t('In this sidebar you should see a real-time preview of the badge settings.') . '</p>';
    $preview_placeholder .= '<p>' . t('You can help reporting any bugs in the <a href="@module" target="_blank">issue queue</a> of the module.', array(
      '@module' => 'http://drupal.org/project/google_plusone',
    )) . '</p>';
    $preview_placeholder .= '<p>' . t('For debugging purposes, you may want to compare it with the code generated from the <a href="@preview" target="_blank">Google+ Badge Tool site</a>.', array(
      '@preview' => 'https://developers.google.com/+/plugins/badge/preview',
    )) . '</div>';
    $available_styles = array(
      'standardbadge' => t('Standard Badge'),
      'smallbadge' => t('Small Badge'),
      'smallicon' => t('Small Icon'),
      'mediumicon' => t('Medium Icon'),
      'largeicon' => t('Large Icon'),
      'page' => t('Page'),
    );
    $form['g1badge'] = array(
      '#type' => 'fieldset',
      '#title' => t('Badge Settings'),
      '#description' => t('Specific settings for the Badge.<br/>The rest of settings are shared with the <a href="@sett">general settings</a> of Google +1 button.', array(
        '@sett' => url('admin/config/services/google-plusone'),
      )) . $preview_placeholder,
    );
    $form['g1badge']['preview'] = array(
      '#value' => $preview_placeholder,
    );
    $form['g1badge']['google_plusone_badge_page_id'] = array(
      '#title' => t('URL address with Page ID'),
      '#type' => 'textfield',
      '#default_value' => variable_get('google_plusone_badge_page_id', 'https://'),
      '#description' => t('The <strong>whole URL</strong> of your Google+ page, not only the Page ID. <br />For example: https://plus.google.com/101560853443212199687'),
    );
    $form['g1badge']['google_plusone_badge_style'] = array(
      '#title' => t('Google+ Badge Style'),
      '#type' => 'radios',
      '#options' => $available_styles,
      '#default_value' => variable_get('google_plusone_badge_style', 'standardbadge'),
      '#description' => t('Icons of 16, 32 and 64 px.'),
    );
    $form['g1badge']['google_plusone_badge_width'] = array(
      '#title' => t('Width (for Badge)'),
      '#type' => 'textfield',
      '#default_value' => variable_get('google_plusone_badge_width', '300'),
      '#description' => t('Width of the badge in <em>px</em>. By default 300. Minimum of 100 (for Small Badge) and 170 (for Standard Badge).'),
    );
    $form['g1badge']['google_plusone_badge_theme'] = array(
      '#title' => t('Theme color (for Badge)'),
      '#type' => 'radios',
      '#options' => array(
        'light' => 'Light',
        'dark' => 'Dark',
      ),
      '#default_value' => variable_get('google_plusone_badge_theme', 'light'),
    );
    $form['g1badge']['google_plusone_badge_custom_name'] = array(
      '#title' => t('Custom name (only for Icon style)'),
      '#type' => 'textfield',
      '#default_value' => variable_get('google_plusone_badge_custom_name', ''),
      '#description' => t('Custom name of the Google+ page. It will appear only for the icon style.'),
    );
  }
  return $form;
}