/[drupal]/contributions/modules/gravatar/gravatar.admin.inc
ViewVC logotype

Contents of /contributions/modules/gravatar/gravatar.admin.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (show annotations) (download) (as text)
Wed Jul 29 16:27:23 2009 UTC (3 months, 4 weeks ago) by davereid
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +88 -114 lines
File MIME type: text/x-php
by Dave Reid: Merged with 6.x and updated for 7.x.
1 <?php
2 // $Id: gravatar.admin.inc,v 1.1.2.34 2009/07/21 02:39:46 davereid Exp $
3
4 /**
5 * @file
6 * Administrative page callbacks for the gravatar module.
7 */
8
9 /**
10 * Administration settings form.
11 *
12 * @see system_settings_form()
13 */
14 function gravatar_admin_settings() {
15 $form = array();
16
17 // Display settings.
18 $form['display'] = array(
19 '#type' => 'fieldset',
20 '#title' => t('Display'),
21 );
22 $form['display']['gravatar_size'] = array(
23 '#type' => 'item',
24 '#title' => t('Image size'),
25 '#description' => t('The preferred image size (maximum 512 pixels). This setting can be adjusted in the <a href="@user-picture-link">user pictures settings</a>.', array('@user-picture-link' => url('admin/user/settings', array('fragment' => 'edit-user-picture-default')))),
26 '#value' => t('@sizex@size pixels', array('@size' => _gravatar_get_size())),
27 );
28 $form['display']['gravatar_rating'] = array(
29 '#type' => 'select',
30 '#title' => t('Image maturity filter'),
31 '#description' => theme('item_list', array(
32 t('G: Suitable for display on all websites with any audience type.'),
33 t('PG: May contain rude gestures, provocatively dressed individuals, the lesser swear words, or mild violence.'),
34 t('R: May contain such things as harsh profanity, intense violence, nudity, or hard drug use.'),
35 t('X: May contain hardcore sexual imagery or extremely disturbing violence.'),
36 )),
37 '#options' => drupal_map_assoc(array('G', 'PG', 'R', 'X')),
38 '#default_value' => gravatar_var('rating'),
39 );
40 $form['display']['gravatar_default'] = array(
41 '#type' => 'radios',
42 '#title' => t('Default image'),
43 '#description' => t('Specifies an image that should be returned if either the requested e-mail address has no associated gravatar, or that gravatar has a rating higher than is allowed by the maturity filter.'),
44 '#options' => array(
45 GRAVATAR_DEFAULT_GLOBAL => t('Global default user image'),
46 GRAVATAR_DEFAULT_MODULE => t('Module default image (white background)'),
47 GRAVATAR_DEFAULT_MODULE_CLEAR => t('Module default image (transparent background)'),
48 GRAVATAR_DEFAULT_IDENTICON => t('Gravatar.com identicon (generated)'),
49 GRAVATAR_DEFAULT_WAVATAR => t('Gravatar.com wavatar (generated)'),
50 GRAVATAR_DEFAULT_MONSTERID => t('Gravatar.com monsterid (generated)'),
51 GRAVATAR_DEFAULT_LOGO => t('Gravatar.com logo'),
52 ),
53 '#default_value' => gravatar_var('default'),
54 '#prefix' => '<div class="picture js-show">' . theme('image', '', t('Default picture example'), t('Default picture example'), array('id' => 'gravatar-imagepreview'), FALSE) . '</div>',
55 '#process' => array('form_process_radios', 'gravatar_process_default_setting'),
56 );
57
58 // Add JavaScript and CSS to swap the defalut image previews.
59 drupal_add_js(drupal_get_path('module', 'gravatar') . '/gravatar.js');
60 drupal_add_css(drupal_get_path('module', 'gravatar') . '/gravatar.css');
61
62 // Advanced settings.
63 $form['advanced'] = array(
64 '#type' => 'fieldset',
65 '#title' => t('Advanced'),
66 '#description' => t('Do not modify these options unless you know what you are doing!'),
67 '#collapsible' => TRUE,
68 '#collapsed' => TRUE,
69 );
70 $form['advanced']['gravatar_url'] = array(
71 '#type' => 'textfield',
72 '#title' => t('Gravatar URL'),
73 '#default_value' => gravatar_var('url'),
74 );
75
76 return system_settings_form($form);
77 }
78
79 function gravatar_process_default_setting($element) {
80 $element[GRAVATAR_DEFAULT_GLOBAL]['#description'] = t('This setting can be adjusted in the <a href="@user-picture-link">user pictures settings</a>.', array('@user-picture-link' => url('admin/user/settings', array('fragment' => 'edit-user-picture-default'))));
81 // If the global user picture is empty, disable the respective option.
82 if (!variable_get('user_picture_default', '')) {
83 $element[GRAVATAR_DEFAULT_GLOBAL]['#disabled'] = TRUE;
84 $element[GRAVATAR_DEFAULT_GLOBAL]['#description'] = t('There currently is not a global default user picture specified.') . ' ' . $element[GRAVATAR_DEFAULT_GLOBAL]['#description'];
85 }
86
87 foreach ($element['#options'] as $key => $choice) {
88 // Add an image to preview this default image option.
89 $attributes = array(
90 'id' => 'gravatar-imagepreview-'. $key,
91 // Hide the image if the respective option is disabled.
92 'class' => $choice['#disabled'] ? 'hide' : 'js-hide',
93 );
94 $element[$key]['#suffix'] = theme('image', gravatar_get_gravatar(mt_rand(), array('default' => _gravatar_get_default_image($key))), $choice, $choice, $attributes, FALSE);
95 }
96
97 return $element;
98 }

  ViewVC Help
Powered by ViewVC 1.1.2