Projet

Général

Profil

Paste
Télécharger (14,5 ko) Statistiques
| Branche: | Révision:

root / htmltest / sites / all / modules / addthis / includes / addthis.admin.inc @ 4543c6c7

1
<?php
2
/**
3
 * @file
4
 * Administrative page callbacks for the AddThis-module.
5
 */
6

    
7
/**
8
 * Form handler for admin_settings_form.
9
 */
10
function addthis_admin_settings_form($form_state) {
11
  AddThis::getInstance()->addStylesheets();
12

    
13
  // Visual settings.
14
  $form['fieldset_compact_menu'] = array(
15
    '#type' => 'fieldset',
16
    '#title' => t('Compact menu'),
17
    '#collapsible' => FALSE,
18
    '#collapsed' => TRUE,
19
    '#description' => '<p>' . t('Configure the global behavior and style of the compact menu and some additional settings related to the interface.') . '</p>'
20
  );
21
  $form['fieldset_compact_menu']['fieldset_menu_style'] = array(
22
    '#type' => 'fieldset',
23
    '#title' => t('Style'),
24
    '#collapsible' => TRUE,
25
    '#collapsed' => TRUE,
26
  );
27
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::CO_BRAND_KEY] = array(
28
    '#type' => 'textfield',
29
    '#title' => t('Branding text'),
30
    '#description' => t('Additional branding message to be rendered in the upper-right-hand corner of the compact menus.<br />Should be less than 15 characters in most cases to render properly.'),
31
    '#default_value' => AddThis::getInstance()->getCoBrand(),
32
    '#required' => FALSE,
33
    '#maxlength' => 15,
34
  );
35
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::UI_HEADER_COLOR_KEY] = array(
36
    '#type' => 'textfield',
37
    '#title' => t('Header text color'),
38
    '#default_value' => AddThis::getInstance()->getUiHeaderColor(),
39
    '#description' => t('Something like #FFFFFF'),
40
    '#size' => 8,
41
    '#maxlength' => 7,
42
    '#required' => FALSE,
43
  );
44
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::UI_HEADER_BACKGROUND_COLOR_KEY] = array(
45
    '#type' => 'textfield',
46
    '#title' => t('Header background color'),
47
    '#default_value' => AddThis::getInstance()->getUiHeaderBackgroundColor(),
48
    '#description' => t('Something like #000000'),
49
    '#size' => 8,
50
    '#maxlength' => 7,
51
    '#required' => FALSE,
52
  );
53
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::CLICK_TO_OPEN_COMPACT_MENU_ENABLED_KEY] = array(
54
    '#type' => 'checkbox',
55
    '#title' => t('Open compact menu on click'),
56
    '#description' => t('Default behavior is to open compact menu on hover.'),
57
    '#default_value' => AddThis::getInstance()->isClickToOpenCompactMenuEnabled(),
58
    '#required' => FALSE,
59
  );
60
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::OPEN_WINDOWS_ENABLED_KEY] = array(
61
    '#type' => 'checkbox',
62
    '#title' => t('Use pop-up windows'),
63
    '#description' => t('If checked, all shares will open in a new pop-up window instead of a new tab or regular browser window.'),
64
    '#default_value' => AddThis::getInstance()->isOpenWindowsEnabled(),
65
    '#required' => FALSE,
66
  );
67
  $form['fieldset_compact_menu']['fieldset_menu_style'][AddThis::UI_DELAY_KEY] = array(
68
    '#type' => 'textfield',
69
    '#title' => t('Menu open delay'),
70
    '#description' => t('Delay, in milliseconds, before compact menu appears when mousing over a regular button. Capped at 500 ms.'),
71
    '#default_value' => AddThis::getInstance()->getUiDelay(),
72
    '#required' => FALSE,
73
    '#size' => 3,
74
    '#maxlength' => 3,
75
  );
76

    
77
  // Enabled services settings.
78
  $form['fieldset_compact_menu']['enabled_services_fieldset'] = array(
79
    '#type' => 'fieldset',
80
    '#title' => t('Compact menu enabled services'),
81
    '#description' => t('The sharing services you select here will be displayed in the compact menu. If you select no services, AddThis will provide a list of frequently used services. This list is updated regularly. <b>Notice that this setting does not define what services should be display in a toolbox.</b>'),
82
    '#collapsible' => TRUE,
83
    '#collapsed' => TRUE,
84
  );
85
  $form['fieldset_compact_menu']['enabled_services_fieldset'][AddThis::ENABLED_SERVICES_KEY] = array(
86
    '#type' => 'checkboxes',
87
    '#title' => t('Enabled services'),
88
    '#options' => AddThis::getInstance()->getServices(),
89
    '#default_value' => AddThis::getInstance()->getEnabledServices(),
90
    '#required' => FALSE,
91
    '#columns' => 3,
92
  );
93

    
94
  // Additional visual settings.
95
  $form['fieldset_compact_menu']['fieldset_additionals'] = array(
96
    '#type' => 'fieldset',
97
    '#title' => t('Additional configuration'),
98
    '#collapsible' => TRUE,
99
    '#collapsed' => TRUE,
100
  );
101
  $form['fieldset_compact_menu']['fieldset_additionals'][AddThis::STANDARD_CSS_ENABLED_KEY] = array(
102
    '#type' => 'checkbox',
103
    '#title' => t('Use standard AddThis stylesheet'),
104
    '#description' => t('If not checked, AddThis will not load standard CSS file, allowing you to style everything yourself without incurring the cost of an additional load.'),
105
    '#default_value' => AddThis::getInstance()->isStandardCssEnabled(),
106
    '#required' => FALSE,
107
  );
108
  $form['fieldset_compact_menu']['fieldset_additionals'][AddThis::COMPLIANT_508_KEY] = array(
109
    '#type' => 'checkbox',
110
    '#title' => t('508 compliant'),
111
    '#description' => 'If checked, clicking the AddThis button will open a new window to a page that is keyboard navigable.',
112
    '#default_value' => AddThis::getInstance()->get508Compliant(),
113
    '#required' => FALSE,
114
  );
115
  $form['fieldset_compact_menu']['fieldset_additionals'][AddThis::ADDRESSBOOK_ENABLED_KEY] = array(
116
    '#type' => 'checkbox',
117
    '#title' => t('Use addressbook'),
118
    '#description' => 'If checked, the user will be able import their contacts from popular webmail services when using AddThis\'s email sharing.',
119
    '#default_value' => AddThis::getInstance()->isAddressbookEnabled(),
120
    '#required' => FALSE,
121
  );
122

    
123
  // Analytics settings.
124
  $profile_id = AddThis::getInstance()->getProfileId();
125
  $can_track_clicks = empty($profile_id) ? FALSE : TRUE;
126
  $form['fieldset_analytics'] = array(
127
    '#type' => 'fieldset',
128
    '#title' => t('Analytics & Tracking'),
129
    '#collapsible' => TRUE,
130
    '#collapsed' => $can_track_clicks ? TRUE : FALSE,
131
  );
132

    
133
  if (!$can_track_clicks) {
134
    $form['fieldset_analytics']['can_track_notice'] = array(
135
      '#theme' => 'html_tag',
136
      '#tag' => 'div',
137
      '#value' => t('For click analytics and statistics you have to provide a ProfileID from <a href="http://www.addthis.com">AddThis.com</a>. Register <a href="https://www.addthis.com/register" targt="_blank">here</a>.'),
138
      '#attributes' => array('class' => array('messages', 'warning')),
139
    );
140
  }
141
  $form['fieldset_analytics'][AddThis::PROFILE_ID_KEY] = array(
142
    '#type' => 'textfield',
143
    '#title' => t('AddThis ProfileID'),
144
    '#default_value' => AddThis::getInstance()->getProfileId(),
145
    '#required' => FALSE,
146
    '#size' => 25,
147
    '#description' => t('ProfileID at <a href="http://addthis.com/" target="_blank">AddThis.com</a>. Required for statistics.'),
148
  );
149
  $form['fieldset_analytics'][AddThis::CLICKBACK_TRACKING_ENABLED_KEY] = array(
150
    '#type' => 'checkbox',
151
    '#title' => t('Track clickback'),
152
    '#description' => 'Check to allow AddThis to append a variable to your URLs upon sharing. AddThis will use this to track how many people come back to your content via links shared with AddThis. Highly recommended. Always global.',
153
    '#default_value' => AddThis::getInstance()->isClickbackTrackingEnabled(),
154
    '#required' => FALSE,
155
  );
156

    
157
  // Facebook Like tracking requires a namespace to be added.
158
  $rdf_enabled = module_exists('rdf');
159
  if (!$rdf_enabled) {
160
    $rdf_description = '<span class="admin-disabled">' . t('The RDF module needs to be enabled to support Facebook Like tracking support.<br />Enable the module on <a href="!modules">modules</a> page.',
161
      array('!modules' => base_path() . 'admin/modules')
162
    ) . '</span>';
163
  }
164
  else {
165
    $rdf_description = t('Check to enable Facebook Like tracking support. Always global.');
166
  }
167
  $form['fieldset_analytics']['title_facebook'] = array(
168
    '#theme' => 'html_tag',
169
    '#tag' => 'div',
170
    '#value' => '<b>' . t('Facebook') . '</b>',
171
  );
172
  $form['fieldset_analytics']['facebook_notice'] = array(
173
    '#theme' => 'html_tag',
174
    '#tag' => 'p',
175
    '#value' => $rdf_description,
176
    '#access' => !$rdf_enabled,
177
  );
178

    
179
  $form['fieldset_analytics'][AddThis::FACEBOOK_LIKE_COUNT_SUPPORT_ENABLED] = array(
180
    '#type' => 'checkbox',
181
    '#title' => t('Enable Facebook Like tracking'),
182
    '#description' => filter_xss($rdf_description, array('span')),
183
    '#default_value' => AddThis::getInstance()->isFacebookLikeCountSupportEnabled(),
184
    '#required' => FALSE,
185
    '#disabled' => !$rdf_enabled,
186
  );
187

    
188
  // Google Analytics and Google Social Tracking support.
189
  $can_do_google_social_tracking = module_exists('googleanalytics');
190
  $is_google_analytics_setup = $can_do_google_social_tracking && variable_get('googleanalytics_account', '');
191
  $form['fieldset_analytics']['google_analytics'] = array(
192
    '#theme' => 'html_tag',
193
    '#tag' => 'div',
194
    '#value' => '<b>' . t('Google Analytics') . '</b>',
195
  );
196
  if (!$can_do_google_social_tracking) {
197
    $form['fieldset_analytics']['can_do_google_analytics'] = array(
198
      '#theme' => 'html_tag',
199
      '#tag' => 'p',
200
      '#value' => '<span class="admin-disabled">' . t('Install/enable the <a href="http://drupal.org/project/google_analytics" target="_blank">Google Analytics</a> module for Social Tracking support.') . '</span>',
201
    );
202
  }
203
  elseif ($can_do_google_social_tracking && !$is_google_analytics_setup) {
204
    $form['fieldset_analytics']['can_do_google_analytics'] = array(
205
      '#theme' => 'html_tag',
206
      '#tag' => 'p',
207
      '#value' => '<span class="admin-disabled">' . t('Configure the Google Analytics module correctly with the account code to use this feature.') . '</span>',
208
    );
209
  }
210
  $form['fieldset_analytics'][AddThis::GOOGLE_ANALYTICS_TRACKING_ENABLED_KEY] = array(
211
    '#type' => 'checkbox',
212
    '#title' => t('Track with Google Analytics'),
213
    '#description' => t('Check to track shares in your Google Analytics account reports (<a href="http://www.addthis.com/help/google-analytics-integration">more info</a>). Always global.'),
214
    '#default_value' => AddThis::getInstance()->isGoogleAnalyticsTrackingEnabled(),
215
    '#required' => FALSE,
216
    '#disabled' => !$is_google_analytics_setup,
217
  );
218
  $form['fieldset_analytics'][AddThis::GOOGLE_ANALYTICS_SOCIAL_TRACKING_ENABLED_KEY] = array(
219
    '#type' => 'checkbox',
220
    '#title' => t('Track with Google Analytics social'),
221
    '#description' => t('Check to track shares in the new Google Analytics social interaction reports (<a href="http://www.addthis.com/help/google-analytics-integration#social">more info</a>). Always global.'),
222
    '#default_value' => AddThis::getInstance()->isGoogleAnalyticsSocialTrackingEnabled(),
223
    '#required' => FALSE,
224
    '#disabled' => !$is_google_analytics_setup,
225
  );
226

    
227
  // Third party settings.
228
  $form['third_party_fieldset'] = array(
229
    '#type' => 'fieldset',
230
    '#title' => t('Third party settings'),
231
    '#collapsible' => TRUE,
232
    '#collapsed' => TRUE,
233
  );
234
  $form['third_party_fieldset']['twitter_service'] = array(
235
    '#type' => 'fieldset',
236
    '#title' => t('Twitter'),
237
    '#collapsible' => TRUE,
238
    '#collapsed' => TRUE,
239
  );
240
  $form['third_party_fieldset']['twitter_service'][AddThis::TWITTER_VIA_KEY] = array(
241
    '#type' => 'textfield',
242
    '#title' => t('Send via'),
243
    '#description' => t('When sending a tweet this is the screen name of the user to attribute the Tweet to. (Relates to Tweet Button)'),
244
    '#default_value' => AddThis::getInstance()->getTwitterVia(),
245
    '#size' => 15,
246
  );
247
  $form['third_party_fieldset']['twitter_service'][AddThis::TWITTER_TEMPLATE_KEY] = array(
248
    '#type' => 'textfield',
249
    '#title' => t('Template text'),
250
    '#description' => t('The {{title}} and {{url}} are replaced from the Twitter Button.'),
251
    '#default_value' => AddThis::getInstance()->getTwitterTemplate(),
252
  );
253

    
254
  return system_settings_form($form);
255
}
256

    
257
/**
258
 * Form handler for admin_settings_advanced_form.
259
 */
260
function addthis_admin_settings_advanced_form($form_state) {
261

    
262
  // Service URL's settings.
263
  $form['service_urls_fieldset'] = array(
264
    '#type' => 'fieldset',
265
    '#title' => t('Service URLs'),
266
    '#collapsible' => TRUE,
267
    '#collapsed' => TRUE,
268
  );
269
  $form['service_urls_fieldset'][AddThis::BOOKMARK_URL_KEY] = array(
270
    '#type' => 'textfield',
271
    '#title' => t('AddThis bookmark URL'),
272
    '#default_value' => AddThis::getInstance()->getBaseBookmarkUrl(),
273
    '#required' => TRUE,
274
  );
275
  $form['service_urls_fieldset'][AddThis::SERVICES_CSS_URL_KEY] = array(
276
    '#type' => 'textfield',
277
    '#title' => t('AddThis services stylesheet URL'),
278
    '#default_value' => AddThis::getInstance()->getServicesCssUrl(),
279
    '#required' => TRUE,
280
  );
281
  $form['service_urls_fieldset'][AddThis::SERVICES_JSON_URL_KEY] = array(
282
    '#type' => 'textfield',
283
    '#title' => t('AddThis services json URL'),
284
    '#default_value' => AddThis::getInstance()->getServicesJsonUrl(),
285
    '#required' => TRUE,
286
  );
287
  $form['service_urls_fieldset'][AddThis::WIDGET_JS_URL_KEY] = array(
288
    '#type' => 'textfield',
289
    '#title' => t('AddThis javascript widget URL'),
290
    '#default_value' => AddThis::getInstance()->getBaseWidgetJsUrl(),
291
    '#required' => TRUE,
292
  );
293

    
294
  // Advanced settings.
295
  $form['advanced_settings_fieldset'] = array(
296
    '#type' => 'fieldset',
297
    '#title' => t('Advanced settings'),
298
    '#access' => user_access(AddThis::PERMISSION_ADMINISTER_ADVANCED_ADDTHIS),
299
    '#collapsible' => TRUE,
300
    '#collapsed' => TRUE,
301
  );
302
  $form['advanced_settings_fieldset'][AddThis::CUSTOM_CONFIGURATION_CODE_ENABLED_KEY] = array(
303
    '#type' => 'checkbox',
304
    '#title' => t('Use custom AddThis configuration code'),
305
    '#default_value' => AddThis::getInstance()->isCustomConfigurationCodeEnabled(),
306
    '#required' => FALSE,
307
    '#description' => t('Use custom AddThis configuration code. If checked, custom configuration will be used instead of other configuration settings provided in AddThis administration user interface.'),
308
  );
309
  $form['advanced_settings_fieldset'][AddThis::CUSTOM_CONFIGURATION_CODE_KEY] = array(
310
    '#type' => 'textarea',
311
    '#title' => t('AddThis custom configuration code'),
312
    '#default_value' => AddThis::getInstance()->getCustomConfigurationCode(),
313
    '#required' => FALSE,
314
    '#description' => t('AddThis custom configuration code. See format at <a href="http://addthis.com/" target="_blank">AddThis.com</a>'),
315
  );
316
  $form['advanced_settings_fieldset'][AddThis::WIDGET_JS_LOAD_TYPE] = array(
317
    '#type' => 'select',
318
    '#title' => t('When to load the widget js.'),
319
    '#options' => array(
320
      'async' => t('When the page loads, but load assets asynchronously. (default)'),
321
      'include' => t('When the page loads.'),
322
      'domready' => t('When the DOM is ready at the script dynamicly.'),
323
    ),
324
    '#default_value' => AddThis::getInstance()->getWidgetJsLoadType(),
325
    '#required' => FALSE,
326
  );
327
  return system_settings_form($form);
328
}