b4096262fa246077f64b03df66616e3df95005f7
[project/addthis.git] / includes / addthis.admin.inc
1 <?php
2
3 /**
4 * @file
5 * Administrative page callbacks for the AddThis-module.
6 */
7
8 /**
9 * Implements hook_admin_settings_form().
10 */
11 function addthis_admin_settings_form($form_state) {
12 AddThis::getInstance()->addStylesheets();
13 $form[AddThis::PROFILE_ID_KEY] = array(
14 '#type' => 'textfield',
15 '#title' => t('AddThis Profile ID'),
16 '#default_value' => AddThis::getInstance()->getProfileId(),
17 '#required' => FALSE,
18 '#description' => t('Profile ID at <a href="http://addthis.com/" target="_blank">AddThis.com</a>. Required for statistics.'),
19 );
20 $form['visual_settings_fieldset'] = array(
21 '#type' => 'fieldset',
22 '#title' => t('Visual settings'),
23 '#collapsible' => TRUE,
24 '#collapsed' => TRUE,
25 );
26 $form['visual_settings_fieldset'][AddThis::LARGE_ICONS_ENABLED_KEY] = array(
27 '#type' => 'checkbox',
28 '#title' => t('Use large 32x32 pixel toolbox icons instead of smaller 16x16 pixel icons'),
29 '#default_value' => AddThis::getInstance()->areLargeIconsEnabled(),
30 '#required' => FALSE,
31 );
32 $form['visual_settings_fieldset'][AddThis::CLICK_TO_OPEN_COMPACT_MENU_ENABLED_KEY] = array(
33 '#type' => 'checkbox',
34 '#title' => t('Click to open compact menu'),
35 '#description' => t('If checked, the compact menu will never appear upon mousing over the regular button. Instead, it will be revealed upon clicking the button.'),
36 '#default_value' => AddThis::getInstance()->isClickToOpenCompactMenuEnabled(),
37 '#required' => FALSE,
38 );
39 $form['visual_settings_fieldset'][AddThis::OPEN_WINDOWS_ENABLED_KEY] = array(
40 '#type' => 'checkbox',
41 '#title' => t('Use pop-up windows'),
42 '#description' => t('If true, all shares will open in a new pop-up window instead of a new tab or regular browser window.'),
43 '#default_value' => AddThis::getInstance()->isOpenWindowsEnabled(),
44 '#required' => FALSE,
45 );
46 $form['visual_settings_fieldset'][AddThis::STANDARD_CSS_ENABLED_KEY] = array(
47 '#type' => 'checkbox',
48 '#title' => t('Use standard AddThis stylesheet'),
49 '#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. Always global; must be defined in a page-level global variable.'),
50 '#default_value' => AddThis::getInstance()->isStandardCssEnabled(),
51 '#required' => FALSE,
52 );
53 $form['visual_settings_fieldset'][AddThis::NUMBER_OF_PREFERRED_SERVICES_KEY] = array(
54 '#type' => 'textfield',
55 '#title' => t('Number of preferred service icons displayed when using the toolbox widget'),
56 '#default_value' => AddThis::getInstance()->getNumberOfPreferredServices(),
57 '#required' => FALSE,
58 '#size' => 1,
59 '#maxlength' => 1,
60 );
61 $form['visual_settings_fieldset'][AddThis::UI_DELAY_KEY] = array(
62 '#type' => 'textfield',
63 '#title' => t('UI delay'),
64 '#description' => t('Delay, in milliseconds, before compact menu appears when mousing over a regular button. Capped at 500 ms.'),
65 '#default_value' => AddThis::getInstance()->getUiDelay(),
66 '#required' => FALSE,
67 '#size' => 3,
68 '#maxlength' => 3,
69 );
70 $form['visual_settings_fieldset'][AddThis::UI_HEADER_COLOR_KEY] = array(
71 '#type' => 'textfield',
72 '#title' => t('AddThis user interface header text color (like #ffffff)'),
73 '#default_value' => AddThis::getInstance()->getUiHeaderColor(),
74 '#required' => FALSE,
75 );
76 $form['visual_settings_fieldset'][AddThis::UI_HEADER_BACKGROUND_COLOR_KEY] = array(
77 '#type' => 'textfield',
78 '#title' => t('AddThis user interface header background color (like #000000)'),
79 '#default_value' => AddThis::getInstance()->getUiHeaderBackgroundColor(),
80 '#required' => FALSE,
81 );
82 $form['visual_settings_fieldset'][AddThis::CO_BRAND_KEY] = array(
83 '#type' => 'textfield',
84 '#title' => t('Additional branding message to be rendered in the upper-right-hand corner of the menus'),
85 '#description' => t('Should be less than 15 characters in most cases to render properly.'),
86 '#default_value' => AddThis::getInstance()->getCoBrand(),
87 '#required' => FALSE,
88 '#maxlength' => 15,
89 );
90 $form['accessibility_fieldset'] = array(
91 '#type' => 'fieldset',
92 '#title' => t('Accessibility'),
93 '#collapsible' => TRUE,
94 '#collapsed' => TRUE,
95 );
96 $form['accessibility_fieldset'][AddThis::COMPLIANT_508_KEY] = array(
97 '#type' => 'checkbox',
98 '#title' => t('508 compliant'),
99 '#description' => 'If checked, clicking the AddThis button will open a new window to a page that is keyboard navigable.',
100 '#default_value' => AddThis::getInstance()->get508Compliant(),
101 '#required' => FALSE,
102 );
103 $form['data_tracking_fieldset'] = array(
104 '#type' => 'fieldset',
105 '#title' => t('Data tracking'),
106 '#collapsible' => TRUE,
107 '#collapsed' => TRUE,
108 );
109 $form['data_tracking_fieldset'][AddThis::CLICKBACK_TRACKING_ENABLED_KEY] = array(
110 '#type' => 'checkbox',
111 '#title' => t('Track clickback'),
112 '#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.',
113 '#default_value' => AddThis::getInstance()->isClickbackTrackingEnabled(),
114 '#required' => FALSE,
115 );
116 $form['email_settings_fieldset'] = array(
117 '#type' => 'fieldset',
118 '#title' => t('Email settings'),
119 '#collapsible' => TRUE,
120 '#collapsed' => TRUE,
121 );
122 $form['email_settings_fieldset'][AddThis::ADDRESSBOOK_ENABLED_KEY] = array(
123 '#type' => 'checkbox',
124 '#title' => t('Use addressbook'),
125 '#description' => 'If checked, the user will be able import their contacts from popular webmail services when using AddThis\'s email sharing.',
126 '#default_value' => AddThis::getInstance()->isAddressbookEnabled(),
127 '#required' => FALSE,
128 );
129 $form['facebook_settings_fieldset'] = array(
130 '#type' => 'fieldset',
131 '#title' => t('Facebook settings'),
132 '#description' => t('Facebook functionality requires some meta-tags to be added to your pages (<a href="http://developers.facebook.com/docs/opengraph/" target="_blank">Open Graph protocol</a>). You can use the <a href="http://drupal.org/project/opengraph_meta">Open Graph meta tags module</a> or add the tags some other way.'),
133 '#collapsible' => TRUE,
134 '#collapsed' => TRUE,
135 );
136 $form['facebook_settings_fieldset'][AddThis::FACEBOOK_LIKE_ENABLED_KEY] = array(
137 '#type' => 'checkbox',
138 '#title' => t('Add Facebook Like to toolbox'),
139 '#default_value' => AddThis::getInstance()->isFacebookLikeEnabled(),
140 '#required' => FALSE,
141 );
142 $form['twitter_settings_fieldset'] = array(
143 '#type' => 'fieldset',
144 '#title' => t('Twitter settings'),
145 '#collapsible' => TRUE,
146 '#collapsed' => TRUE,
147 );
148 $form['twitter_settings_fieldset'][AddThis::TWITTER_ENABLED_KEY] = array(
149 '#type' => 'checkbox',
150 '#title' => t('Add Twitter to toolbox'),
151 '#default_value' => AddThis::getInstance()->isTwitterEnabled(),
152 '#required' => FALSE,
153 );
154 $form['google_plus_one_settings_fieldset'] = array(
155 '#type' => 'fieldset',
156 '#title' => t('Google +1 settings'),
157 '#collapsible' => TRUE,
158 '#collapsed' => TRUE,
159 );
160 $form['google_plus_one_settings_fieldset'][AddThis::GOOGLE_PLUS_ONE_ENABLED_KEY] = array(
161 '#type' => 'checkbox',
162 '#title' => t('Add Google +1 to toolbox'),
163 '#default_value' => AddThis::getInstance()->isGooglePlusOneEnabled(),
164 '#required' => FALSE,
165 );
166 $form['service_urls_fieldset'] = array(
167 '#type' => 'fieldset',
168 '#title' => t('Service URLs'),
169 '#collapsible' => TRUE,
170 '#collapsed' => TRUE,
171 );
172 $form['service_urls_fieldset'][AddThis::BOOKMARK_URL_KEY] = array(
173 '#type' => 'textfield',
174 '#title' => t('AddThis bookmark URL'),
175 '#default_value' => AddThis::getInstance()->getBaseBookmarkUrl(),
176 '#required' => TRUE,
177 );
178 $form['service_urls_fieldset'][AddThis::SERVICES_CSS_URL_KEY] = array(
179 '#type' => 'textfield',
180 '#title' => t('AddThis services stylesheet URL'),
181 '#default_value' => AddThis::getInstance()->getServicesCssUrl(),
182 '#required' => TRUE,
183 );
184 $form['service_urls_fieldset'][AddThis::SERVICES_JSON_URL_KEY] = array(
185 '#type' => 'textfield',
186 '#title' => t('AddThis services json URL'),
187 '#default_value' => AddThis::getInstance()->getServicesJsonUrl(),
188 '#required' => TRUE,
189 );
190 $form['service_urls_fieldset'][AddThis::WIDGET_JS_URL_KEY] = array(
191 '#type' => 'textfield',
192 '#title' => t('AddThis javascript widget URL'),
193 '#default_value' => AddThis::getInstance()->getBaseWidgetJsUrl(),
194 '#required' => TRUE,
195 );
196 $form['enabled_services_fieldset'] = array(
197 '#type' => 'fieldset',
198 '#title' => t('Enabled services'),
199 '#collapsible' => TRUE,
200 '#collapsed' => TRUE,
201 );
202 $form['enabled_services_fieldset'][AddThis::ENABLED_SERVICES_KEY] = array(
203 '#type' => 'checkboxes',
204 '#title' => t('Enabled services'),
205 '#options' => AddThis::getInstance()->getServices(),
206 '#default_value' => AddThis::getInstance()->getEnabledServices(),
207 '#required' => FALSE,
208 );
209 $form['advanced_settings_fieldset'] = array(
210 '#type' => 'fieldset',
211 '#title' => t('Advanced settings'),
212 '#access' => user_access(AddThis::PERMISSION_ADMINISTER_ADVANCED_ADDTHIS),
213 '#collapsible' => TRUE,
214 '#collapsed' => TRUE,
215 );
216 $form['advanced_settings_fieldset'][AddThis::CUSTOM_CONFIGURATION_CODE_ENABLED_KEY] = array(
217 '#type' => 'checkbox',
218 '#title' => t('Use custom AddThis configuration code'),
219 '#default_value' => AddThis::getInstance()->isCustomConfigurationCodeEnabled(),
220 '#required' => FALSE,
221 '#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.'),
222 );
223 $form['advanced_settings_fieldset'][AddThis::CUSTOM_CONFIGURATION_CODE_KEY] = array(
224 '#type' => 'textarea',
225 '#title' => t('AddThis custom configuration code'),
226 '#default_value' => AddThis::getInstance()->getCustomConfigurationCode(),
227 '#required' => FALSE,
228 '#description' => t('AddThis custom configuration code. See format at <a href="http://addthis.com/" target="_blank">AddThis.com</a>'),
229 );
230 return system_settings_form($form);
231 }