5 * Administrative page callbacks for the AddThis-module.
9 * Implements hook_admin_settings_form().
11 function addthis_admin_settings_form($form_state) {
12 AddThis
::getInstance()->addStylesheets();
14 // Part with compact menu settings.
15 $form['fieldset_profile'] = array(
16 '#type' => 'fieldset',
17 '#title' => t('Profile'),
18 '#collapsible' => FALSE
,
21 $form['fieldset_profile'][AddThis
::PROFILE_ID_KEY
] = array(
22 '#type' => 'textfield',
23 '#title' => t('AddThis ProfileID'),
24 '#default_value' => AddThis
::getInstance()->getProfileId(),
27 '#description' => t('ProfileID at <a href="http://addthis.com/" target="_blank">AddThis.com</a>. Required for statistics.'),
30 // The first fieldset to set the user interface settings.
31 $form['visual_settings_fieldset'] = array(
32 '#type' => 'fieldset',
33 '#title' => t('User interface'),
34 '#collapsible' => FALSE
,
36 '#description' => '<p>' .
t('Configure the global behavior and style of the compact menu and some additional settings related to the interface.') .
'</p>'
39 // Part with compact menu settings.
40 $form['visual_settings_fieldset']['fieldset_compact_menu'] = array(
41 '#type' => 'fieldset',
42 '#title' => t('Compact menu'),
43 '#collapsible' => TRUE
,
46 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::CO_BRAND_KEY
] = array(
47 '#type' => 'textfield',
48 '#title' => t('Branding text'),
49 '#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.'),
50 '#default_value' => AddThis
::getInstance()->getCoBrand(),
54 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::UI_HEADER_COLOR_KEY
] = array(
55 '#type' => 'textfield',
56 '#title' => t('Header text color'),
57 '#default_value' => AddThis
::getInstance()->getUiHeaderColor(),
58 '#description' => t('Something like #FFFFFF'),
63 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::UI_HEADER_BACKGROUND_COLOR_KEY
] = array(
64 '#type' => 'textfield',
65 '#title' => t('Header background color'),
66 '#default_value' => AddThis
::getInstance()->getUiHeaderBackgroundColor(),
67 '#description' => t('Something like #000000'),
72 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::CLICK_TO_OPEN_COMPACT_MENU_ENABLED_KEY
] = array(
73 '#type' => 'checkbox',
74 '#title' => t('Open compact menu on click'),
75 '#description' => t('Default behavior is open compact menu on hover.'),
76 '#default_value' => AddThis
::getInstance()->isClickToOpenCompactMenuEnabled(),
79 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::OPEN_WINDOWS_ENABLED_KEY
] = array(
80 '#type' => 'checkbox',
81 '#title' => t('Use pop-up windows'),
82 '#description' => t('If checked, all shares will open in a new pop-up window instead of a new tab or regular browser window.'),
83 '#default_value' => AddThis
::getInstance()->isOpenWindowsEnabled(),
86 $form['visual_settings_fieldset']['fieldset_compact_menu'][AddThis
::UI_DELAY_KEY
] = array(
87 '#type' => 'textfield',
88 '#title' => t('Menu open delay'),
89 '#description' => t('Delay, in milliseconds, before compact menu appears when mousing over a regular button. Capped at 500 ms.'),
90 '#default_value' => AddThis
::getInstance()->getUiDelay(),
96 // Additional settings
97 $form['visual_settings_fieldset']['fieldset_additionals'] = array(
98 '#type' => 'fieldset',
99 '#title' => t('Additional configuration'),
100 '#collapsible' => TRUE
,
101 '#collapsed' => TRUE
,
103 $form['visual_settings_fieldset']['fieldset_additionals'][AddThis
::STANDARD_CSS_ENABLED_KEY
] = array(
104 '#type' => 'checkbox',
105 '#title' => t('Use standard AddThis stylesheet'),
106 '#description' => t('If not checked, AddThis will not load standard CSS file, allowing you to style everything yourself without incurring the cost of an additonal load.'),
107 '#default_value' => AddThis
::getInstance()->isStandardCssEnabled(),
108 '#required' => FALSE
,
110 $form['visual_settings_fieldset']['fieldset_additionals'][AddThis
::COMPLIANT_508_KEY
] = array(
111 '#type' => 'checkbox',
112 '#title' => t('508 compliant'),
113 '#description' => 'If checked, clicking the AddThis button will open a new window to a page that is keyboard navigable.',
114 '#default_value' => AddThis
::getInstance()->get508Compliant(),
115 '#required' => FALSE
,
117 $form['visual_settings_fieldset']['fieldset_additionals'][AddThis
::ADDRESSBOOK_ENABLED_KEY
] = array(
118 '#type' => 'checkbox',
119 '#title' => t('Use addressbook'),
120 '#description' => 'If checked, the user will be able import their contacts from popular webmail services when using AddThis\'s email sharing.',
121 '#default_value' => AddThis
::getInstance()->isAddressbookEnabled(),
122 '#required' => FALSE
,
126 $form['fieldset_analytics'] = array(
127 '#type' => 'fieldset',
128 '#title' => t('Analytics'),
129 '#collapsible' => TRUE
,
130 '#collapsed' => TRUE
,
133 $profile_id = AddThis
::getInstance()->getProfileId();
134 $can_track_clicks = empty($profile_id) ? FALSE
: TRUE
;
135 if (!$can_track_clicks) {
136 $form['fieldset_analytics']['can_track_notice'] = array(
137 '#theme' => 'html_tag',
139 '#value' => t('For click analytics/statistics you have to provide a ProfileID at top of this configuration page from <a href="http://www.addthis.com">AddThis.com</a>.'),
140 '#attributes' => array('class' => array('messages', 'warning')),
143 $form['fieldset_analytics'][AddThis
::CLICKBACK_TRACKING_ENABLED_KEY
] = array(
144 '#type' => 'checkbox',
145 '#title' => t('Track clickback'),
146 '#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.',
147 '#default_value' => AddThis
::getInstance()->isClickbackTrackingEnabled(),
148 '#required' => FALSE
,
152 if (module_exists('googleanalytics') && variable_get('googleanalytics_account', '') !== '') {
153 // Google Analytics support
154 $form['fieldset_analytics'][AddThis
::GOOGLE_ANALYTICS_TRACKING_ENABLED_KEY
] = array(
155 '#type' => 'checkbox',
156 '#title' => t('Track with Google Analytics'),
157 '#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.'),
158 '#default_value' => AddThis
::getInstance()->isGoogleAnalyticsTrackingEnabled(),
159 '#required' => FALSE
,
161 // Google Social Tracking support
162 $form['fieldset_analytics'][AddThis
::GOOGLE_ANALYTICS_SOCIAL_TRACKING_ENABLED_KEY
] = array(
163 '#type' => 'checkbox',
164 '#title' => t('Track with Google Analytics social'),
165 '#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.'),
166 '#default_value' => AddThis
::getInstance()->isGoogleAnalyticsSocialTrackingEnabled(),
167 '#required' => FALSE
,
171 $rdf_enabled = module_exists('rdf');
173 $rdf_description = t('<span class="admin-disabled">The RDF module needs to be enabled to support Facebook Like tracking support.<br>Enabled the module here on the <a href="!modules">modules</a> page.</span>',
174 array('!modules' => base_path() .
'admin/modules')
178 $rdf_description = t('Check to track Facebook Like tracking support. Always global.');
180 // Trackinhg of Facebook Like needs a namespace added.
181 $form['fieldset_analytics'][AddThis
::FACEBOOK_LIKE_COUNT_SUPPORT_ENABLED
] = array(
182 '#type' => 'checkbox',
183 '#title' => t('Enable Facebook Like tracking'),
184 '#description' => $rdf_description,
185 '#default_value' => AddThis
::getInstance()->isFacebookLikeCountSupportEnabled(),
186 '#required' => FALSE
,
187 '#disabled' => !$rdf_enabled,
190 // Servicees enabled for compact menu.
191 $form['enabled_services_fieldset'] = array(
192 '#type' => 'fieldset',
193 '#title' => t('Enabled services'),
194 '#description' => t('The sharing services you select here will be in the compact menu. If you select nothing AddThis will provide a list of frequently used services. This list is updated regularily.'),
195 '#collapsible' => TRUE
,
196 '#collapsed' => TRUE
,
198 $form['enabled_services_fieldset'][AddThis
::ENABLED_SERVICES_KEY
] = array(
199 '#type' => 'checkboxes',
200 '#title' => t('Enabled services'),
201 '#options' => AddThis
::getInstance()->getServices(),
202 '#default_value' => AddThis
::getInstance()->getEnabledServices(),
203 '#required' => FALSE
,
204 '#theme' => 'addthis_checkboxes_columns',
207 $form['service_urls_fieldset'] = array(
208 '#type' => 'fieldset',
209 '#title' => t('Service URLs'),
210 '#collapsible' => TRUE
,
211 '#collapsed' => TRUE
,
213 $form['service_urls_fieldset'][AddThis
::BOOKMARK_URL_KEY
] = array(
214 '#type' => 'textfield',
215 '#title' => t('AddThis bookmark URL'),
216 '#default_value' => AddThis
::getInstance()->getBaseBookmarkUrl(),
219 $form['service_urls_fieldset'][AddThis
::SERVICES_CSS_URL_KEY
] = array(
220 '#type' => 'textfield',
221 '#title' => t('AddThis services stylesheet URL'),
222 '#default_value' => AddThis
::getInstance()->getServicesCssUrl(),
225 $form['service_urls_fieldset'][AddThis
::SERVICES_JSON_URL_KEY
] = array(
226 '#type' => 'textfield',
227 '#title' => t('AddThis services json URL'),
228 '#default_value' => AddThis
::getInstance()->getServicesJsonUrl(),
231 $form['service_urls_fieldset'][AddThis
::WIDGET_JS_URL_KEY
] = array(
232 '#type' => 'textfield',
233 '#title' => t('AddThis javascript widget URL'),
234 '#default_value' => AddThis
::getInstance()->getBaseWidgetJsUrl(),
237 // @todo Move to advanced tab.
238 $form['advanced_settings_fieldset'] = array(
239 '#type' => 'fieldset',
240 '#title' => t('Advanced settings'),
241 '#access' => user_access(AddThis
::PERMISSION_ADMINISTER_ADVANCED_ADDTHIS
),
242 '#collapsible' => TRUE
,
243 '#collapsed' => TRUE
,
245 $form['advanced_settings_fieldset'][AddThis
::CUSTOM_CONFIGURATION_CODE_ENABLED_KEY
] = array(
246 '#type' => 'checkbox',
247 '#title' => t('Use custom AddThis configuration code'),
248 '#default_value' => AddThis
::getInstance()->isCustomConfigurationCodeEnabled(),
249 '#required' => FALSE
,
250 '#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.'),
252 $form['advanced_settings_fieldset'][AddThis
::CUSTOM_CONFIGURATION_CODE_KEY
] = array(
253 '#type' => 'textarea',
254 '#title' => t('AddThis custom configuration code'),
255 '#default_value' => AddThis
::getInstance()->getCustomConfigurationCode(),
256 '#required' => FALSE
,
257 '#description' => t('AddThis custom configuration code. See format at <a href="http://addthis.com/" target="_blank">AddThis.com</a>'),
259 return system_settings_form($form);