function google_plusone_admin_settings in Google Plus One Button | Google+ Badge 6
Same name and namespace in other branches
- 7 google_plusone.admin.inc \google_plusone_admin_settings()
Menu callback: displays the Google Plus One module settings page.
1 string reference to 'google_plusone_admin_settings'
- google_plusone_menu in ./
google_plusone.module - Implements hook_menu().
File
- ./
google_plusone.admin.inc, line 13 - Administration page for the Google +1 Button.
Code
function google_plusone_admin_settings() {
// Custom javascript code to preview in real-time the button
drupal_add_js(drupal_get_path('module', 'google_plusone') . '/google_plusone.admin.js');
// not good performance in <head>, but anyway, it's only for the admin page and can help for debugging purposes.
$script = '<script type="text/javascript" src="http://apis.google.com/js/plusone.js">';
drupal_set_html_head('<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>');
$locations = array(
'full' => t('Full node'),
'teaser' => t('Teaser'),
'link' => t('Node links'),
);
$form['display'] = array(
'#type' => 'fieldset',
'#title' => t('Display Settings for nodes'),
'#description' => t('These settings will render a button <strong>for each node</strong>, using its URL. If you only need a block with a fixed URL like your homepage, or dynamic URL for generic pages, better go to the <a href="@blocks">blocks</a> page to enable and configure the <em>Google +1 Button</em> block.', array(
'@blocks' => url('admin/build/block'),
)),
);
$form['display']['google_plusone_node_types'] = array(
'#type' => 'checkboxes',
'#title' => t('Display the button on these content types:'),
'#options' => array_map('check_plain', node_get_types('names')),
'#default_value' => variable_get('google_plusone_node_types', array()),
);
$form['display']['google_plusone_node_location'] = array(
'#type' => 'checkboxes',
'#title' => t('Display the button in these view modes:'),
'#options' => $locations,
'#default_value' => variable_get('google_plusone_node_location', array(
'full',
)),
);
$form['display']['google_plusone_weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#delta' => 50,
'#default_value' => variable_get('google_plusone_weight', '-10'),
'#description' => t('Heavier items will sink. The default weight -10 will show the button at the top of the node content.'),
);
$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'),
);
$default = array(
'annotation' => 'bubble',
'width' => '250',
'size' => '',
// standard
'css' => 'margin: 0 1em 1em 1em;float:right',
'syntax' => 'HTML5',
'alias' => 'aliased',
);
$button_settings = array_merge($default, variable_get('google_plusone_button_settings', array()));
$form['google_plusone_button_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Button Settings for nodes'),
'#tree' => TRUE,
// All the options in this fieldset will be grouped in 1 single variable.
'#description' => google_plusone_build_preview_button($available_sizes),
);
$form['google_plusone_button_settings']['annotation'] = array(
'#type' => 'radios',
'#title' => t('Annotation: How to show the counting?'),
'#options' => $available_annotations,
'#default_value' => $button_settings['annotation'],
);
$form['google_plusone_button_settings']['width'] = array(
'#type' => 'textfield',
'#title' => t('Width (only affects to inline annotation)'),
'#default_value' => $button_settings['width'],
'#size' => 20,
'#description' => t('By default recommended 250 (pixels). Minimum 120'),
);
$form['google_plusone_button_settings']['size'] = array(
'#type' => 'radios',
'#title' => t('Size'),
'#options' => $available_sizes,
'#default_value' => $button_settings['size'],
);
$form['google_plusone_button_settings']['css'] = array(
'#type' => 'textfield',
'#title' => t('Optional wrapper with CSS'),
'#maxlength' => 256,
'#default_value' => $button_settings['css'],
'#description' => t('The button is wrapped in a div <div class="g-plusone-wrapper">[button]</div><br/>. Here you can enter CSS rules to style this wrapper. By default <em>margin: 0 1em 1em 1em;float:right</em><br />To disable totally the wrapper, input the word <em>nowrapper</em>'),
);
$form['google_plusone_button_settings']['syntax'] = array(
'#type' => 'radios',
'#title' => t('Tag syntax'),
'#options' => array(
'HTML5' => t('HTML5'),
'g:plusone' => t('g:plusone'),
),
'#default_value' => $button_settings['syntax'],
'#description' => t('Two different but equivalent formats are allowed for the +1 tag. By default: HTML5'),
);
$form['google_plusone_button_settings']['alias'] = array(
'#type' => 'radios',
'#title' => t('Aliased path'),
'#default_value' => $button_settings['alias'],
'#options' => array(
'not_aliased' => t('Not aliased'),
'aliased' => t('Aliased'),
),
'#description' => t('By default <em>Aliased</em>. 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.'),
);
$default_advanced = array(
'lang' => '',
'scope_location' => 'footer',
'parsetags' => 'onload',
'async' => 1,
);
$config = array_merge($default_advanced, variable_get('google_plusone_advanced_settings', $default_advanced));
$form['google_plusone_advanced_settings'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced Settings'),
'#collapsed' => TRUE,
'#tree' => TRUE,
// All the options in this fieldset will be grouped in 1 single variable.
'#collapsible' => TRUE,
'#description' => t('Get more information about these options from the documentation of the <a href="@api-doc">Google +1 API</a>.', array(
'@api-doc' => 'https://developers.google.com/+/plugins/+1button/',
)),
);
$form['google_plusone_advanced_settings']['lang'] = array(
'#type' => 'textfield',
'#title' => t('Language'),
'#default_value' => $config['lang'],
'#description' => t('Input the language code you want from <a href="@api-doc">this list</a>. Leave empty to use the default <em>en-Us</em> language.<br/>If, and only if, you have a multi-lingual site using Locale module, then you can input a list of <strong>Google +1 language codes</strong> separated by commas. For example: <em>pt-br,fr,ru</em>', array(
'@api-doc' => 'https://developers.google.com/+/plugins/+1button/#available-languages',
)),
);
$form['google_plusone_advanced_settings']['scope_location'] = array(
'#type' => 'radios',
'#title' => t('Scope'),
'#options' => array(
'footer' => t('Footer'),
'header' => t('Header'),
),
'#default_value' => $config['scope_location'],
'#description' => t('Location of the script file. By default: <em>Footer</em>, for performance reasons.'),
);
$form['google_plusone_advanced_settings']['async'] = array(
'#type' => 'checkbox',
'#title' => t('Load JavaScript asynchronously'),
'#default_value' => $config['async'],
'#description' => t('By default enabled. If enabled, the Google+1 JavaScript will be loaded asynchronously, preventing that the browser gets blocked (waiting for the JavaScript load) in the pages where Google+1 button is present.'),
);
$form['google_plusone_advanced_settings']['parsetags'] = array(
'#type' => 'radios',
'#title' => t('Parse tags'),
'#options' => array(
'explicit' => t('explicit'),
'onload' => t('onload'),
),
'#default_value' => $config['parsetags'],
'#description' => t('Buttons will be rendered immediately upon page load, or explicitly called. By default <em>onload</em>.'),
);
return system_settings_form($form);
}