|
1 <?php |
|
2 |
|
3 /** |
|
4 * @file |
|
5 * Configuration system that lets administrators modify the workings of the site. |
|
6 */ |
|
7 |
|
8 /** |
|
9 * Maximum age of temporary files in seconds. |
|
10 */ |
|
11 define('DRUPAL_MAXIMUM_TEMP_FILE_AGE', 21600); |
|
12 |
|
13 /** |
|
14 * Default interval for automatic cron executions in seconds. |
|
15 */ |
|
16 define('DRUPAL_CRON_DEFAULT_THRESHOLD', 10800); |
|
17 |
|
18 /** |
|
19 * New users will be set to the default time zone at registration. |
|
20 */ |
|
21 define('DRUPAL_USER_TIMEZONE_DEFAULT', 0); |
|
22 |
|
23 /** |
|
24 * New users will get an empty time zone at registration. |
|
25 */ |
|
26 define('DRUPAL_USER_TIMEZONE_EMPTY', 1); |
|
27 |
|
28 /** |
|
29 * New users will select their own timezone at registration. |
|
30 */ |
|
31 define('DRUPAL_USER_TIMEZONE_SELECT', 2); |
|
32 |
|
33 /** |
|
34 * Disabled option on forms and settings |
|
35 */ |
|
36 define('DRUPAL_DISABLED', 0); |
|
37 |
|
38 /** |
|
39 * Optional option on forms and settings |
|
40 */ |
|
41 define('DRUPAL_OPTIONAL', 1); |
|
42 |
|
43 /** |
|
44 * Required option on forms and settings |
|
45 */ |
|
46 define('DRUPAL_REQUIRED', 2); |
|
47 |
|
48 /** |
|
49 * Maximum number of values in a weight select element. |
|
50 * |
|
51 * If the number of values is over the maximum, a text field is used instead. |
|
52 */ |
|
53 define('DRUPAL_WEIGHT_SELECT_MAX', 100); |
|
54 |
|
55 /** |
|
56 * Return only visible regions. |
|
57 * |
|
58 * @see system_region_list() |
|
59 */ |
|
60 define('REGIONS_VISIBLE', 'visible'); |
|
61 |
|
62 /** |
|
63 * Return all regions. |
|
64 * |
|
65 * @see system_region_list() |
|
66 */ |
|
67 define('REGIONS_ALL', 'all'); |
|
68 |
|
69 /** |
|
70 * Implements hook_help(). |
|
71 */ |
|
72 function system_help($path, $arg) { |
|
73 global $base_url; |
|
74 |
|
75 switch ($path) { |
|
76 case 'admin/help#system': |
|
77 $output = ''; |
|
78 $output .= '<h3>' . t('About') . '</h3>'; |
|
79 $output .= '<p>' . t('The System module is integral to the site, and provides basic but extensible functionality for use by other modules and themes. Some integral elements of Drupal are contained in and managed by the System module, including caching, enabling and disabling modules and themes, preparing and displaying the administrative page, and configuring fundamental site settings. A number of key system maintenance operations are also part of the System module. For more information, see the online handbook entry for <a href="@system">System module</a>.', array('@system' => 'http://drupal.org/documentation/modules/system')) . '</p>'; |
|
80 $output .= '<h3>' . t('Uses') . '</h3>'; |
|
81 $output .= '<dl>'; |
|
82 $output .= '<dt>' . t('Managing modules') . '</dt>'; |
|
83 $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable modules on the <a href="@modules">Modules administration page</a>. Drupal comes with a number of core modules, and each module provides a discrete set of features and may be enabled or disabled depending on the needs of the site. Many additional modules contributed by members of the Drupal community are available for download at the <a href="@drupal-modules">Drupal.org module page</a>.', array('@modules' => url('admin/modules'), '@drupal-modules' => 'http://drupal.org/project/modules')) . '</dd>'; |
|
84 $output .= '<dt>' . t('Managing themes') . '</dt>'; |
|
85 $output .= '<dd>' . t('The System module allows users with the appropriate permissions to enable and disable themes on the <a href="@themes">Appearance administration page</a>. Themes determine the design and presentation of your site. Drupal comes packaged with several core themes, and additional contributed themes are available at the <a href="@drupal-themes">Drupal.org theme page</a>.', array('@themes' => url('admin/appearance'), '@drupal-themes' => 'http://drupal.org/project/themes')) . '</dd>'; |
|
86 $output .= '<dt>' . t('Managing caching') . '</dt>'; |
|
87 $output .= '<dd>' . t("The System module allows users with the appropriate permissions to manage caching on the <a href='@cache-settings'>Performance settings page</a>. Drupal has a robust caching system that allows the efficient re-use of previously-constructed web pages and web page components. Pages requested by anonymous users are stored in a compressed format; depending on your site configuration and the amount of your web traffic tied to anonymous visitors, the caching system may significantly increase the speed of your site.", array('@cache-settings' => url('admin/config/development/performance'))) . '</dd>'; |
|
88 $output .= '<dt>' . t('Performing system maintenance') . '</dt>'; |
|
89 $output .= '<dd>' . t('In order for the site and its modules to continue to operate well, a set of routine administrative operations must run on a regular basis. The System module manages this task by making use of a system cron job. You can verify the status of cron tasks by visiting the <a href="@status">Status report page</a>. For more information, see the online handbook entry for <a href="@handbook">configuring cron jobs</a>. You can set up cron job by visiting <a href="@cron">Cron configuration</a> page', array('@status' => url('admin/reports/status'), '@handbook' => 'http://drupal.org/cron', '@cron' => url('admin/config/system/cron'))) . '</dd>'; |
|
90 $output .= '<dt>' . t('Configuring basic site settings') . '</dt>'; |
|
91 $output .= '<dd>' . t('The System module also handles basic configuration options for your site, including <a href="@date-time-settings">Date and time settings</a>, <a href="@file-system">File system settings</a>, <a href="@clean-url">Clean URL support</a>, <a href="@site-info">Site name and other information</a>, and a <a href="@maintenance-mode">Maintenance mode</a> for taking your site temporarily offline.', array('@date-time-settings' => url('admin/config/regional/date-time'), '@file-system' => url('admin/config/media/file-system'), '@clean-url' => url('admin/config/search/clean-urls'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>'; |
|
92 $output .= '<dt>' . t('Configuring actions') . '</dt>'; |
|
93 $output .= '<dd>' . t('Actions are individual tasks that the system can do, such as unpublishing a piece of content or banning a user. Modules, such as the <a href="@trigger-help">Trigger module</a>, can fire these actions when certain system events happen; for example, when a new post is added or when a user logs in. Modules may also provide additional actions. Visit the <a href="@actions">Actions page</a> to configure actions.', array('@trigger-help' => url('admin/help/trigger'), '@actions' => url('admin/config/system/actions'))) . '</dd>'; |
|
94 $output .= '</dl>'; |
|
95 return $output; |
|
96 case 'admin/index': |
|
97 return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>'; |
|
98 case 'admin/appearance': |
|
99 $output = '<p>' . t('Set and configure the default theme for your website. Alternative <a href="@themes">themes</a> are available.', array('@themes' => 'http://drupal.org/project/themes')) . '</p>'; |
|
100 return $output; |
|
101 case 'admin/appearance/settings/' . $arg[3]: |
|
102 $theme_list = list_themes(); |
|
103 $theme = $theme_list[$arg[3]]; |
|
104 return '<p>' . t('These options control the display settings for the %name theme. When your site is displayed using this theme, these settings will be used.', array('%name' => $theme->info['name'])) . '</p>'; |
|
105 case 'admin/appearance/settings': |
|
106 return '<p>' . t('These options control the default display settings for your entire site, across all themes. Unless they have been overridden by a specific theme, these settings will be used.') . '</p>'; |
|
107 case 'admin/modules': |
|
108 $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>'; |
|
109 if (module_exists('update')) { |
|
110 if (update_manager_access()) { |
|
111 $output .= '<p>' . t('Regularly review and install <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>'; |
|
112 } |
|
113 else { |
|
114 $output .= '<p>' . t('Regularly review <a href="@updates">available updates</a> to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated.', array('@update-php' => $base_url . '/update.php', '@updates' => url('admin/reports/updates'))) . '</p>'; |
|
115 } |
|
116 } |
|
117 else { |
|
118 $output .= '<p>' . t('Regularly review available updates to maintain a secure and current site. Always run the <a href="@update-php">update script</a> each time a module is updated. Enable the Update manager module to update and install modules and themes.', array('@update-php' => $base_url . '/update.php')) . '</p>'; |
|
119 } |
|
120 return $output; |
|
121 case 'admin/modules/uninstall': |
|
122 return '<p>' . t('The uninstall process removes all data related to a module. To uninstall a module, you must first disable it on the main <a href="@modules">Modules page</a>.', array('@modules' => url('admin/modules'))) . '</p>'; |
|
123 case 'admin/structure/block/manage': |
|
124 if ($arg[4] == 'system' && $arg[5] == 'powered-by') { |
|
125 return '<p>' . t('The <em>Powered by Drupal</em> block is an optional link to the home page of the Drupal project. While there is absolutely no requirement that sites feature this link, it may be used to show support for Drupal.') . '</p>'; |
|
126 } |
|
127 break; |
|
128 case 'admin/config/development/maintenance': |
|
129 global $user; |
|
130 if ($user->uid == 1) { |
|
131 return '<p>' . t('If you are upgrading to a newer version of Drupal or upgrading contributed modules or themes, you may need to run the <a href="@update-php">update script</a>.', array('@update-php' => $base_url . '/update.php')) . '</p>'; |
|
132 } |
|
133 break; |
|
134 case 'admin/config/system/actions': |
|
135 case 'admin/config/system/actions/manage': |
|
136 $output = ''; |
|
137 $output .= '<p>' . t('There are two types of actions: simple and advanced. Simple actions do not require any additional configuration, and are listed here automatically. Advanced actions need to be created and configured before they can be used, because they have options that need to be specified; for example, sending an e-mail to a specified address, or unpublishing content containing certain words. To create an advanced action, select the action from the drop-down list in the advanced action section below and click the <em>Create</em> button.') . '</p>'; |
|
138 if (module_exists('trigger')) { |
|
139 $output .= '<p>' . t('You may proceed to the <a href="@url">Triggers</a> page to assign these actions to system events.', array('@url' => url('admin/structure/trigger'))) . '</p>'; |
|
140 } |
|
141 return $output; |
|
142 case 'admin/config/system/actions/configure': |
|
143 return t('An advanced action offers additional configuration options which may be filled out below. Changing the <em>Description</em> field is recommended, in order to better identify the precise action taking place. This description will be displayed in modules such as the Trigger module when assigning actions to system events, so it is best if it is as descriptive as possible (for example, "Send e-mail to Moderation Team" rather than simply "Send e-mail").'); |
|
144 case 'admin/config/people/ip-blocking': |
|
145 return '<p>' . t('IP addresses listed here are blocked from your site. Blocked addresses are completely forbidden from accessing the site and instead see a brief message explaining the situation.') . '</p>'; |
|
146 case 'admin/reports/status': |
|
147 return '<p>' . t("Here you can find a short overview of your site's parameters as well as any problems detected with your installation. It may be useful to copy and paste this information into support requests filed on drupal.org's support forums and project issue queues.") . '</p>'; |
|
148 } |
|
149 } |
|
150 |
|
151 /** |
|
152 * Implements hook_theme(). |
|
153 */ |
|
154 function system_theme() { |
|
155 return array_merge(drupal_common_theme(), array( |
|
156 'system_themes_page' => array( |
|
157 'variables' => array('theme_groups' => NULL), |
|
158 'file' => 'system.admin.inc', |
|
159 ), |
|
160 'system_settings_form' => array( |
|
161 'render element' => 'form', |
|
162 ), |
|
163 'confirm_form' => array( |
|
164 'render element' => 'form', |
|
165 ), |
|
166 'system_modules_fieldset' => array( |
|
167 'render element' => 'form', |
|
168 'file' => 'system.admin.inc', |
|
169 ), |
|
170 'system_modules_incompatible' => array( |
|
171 'variables' => array('message' => NULL), |
|
172 'file' => 'system.admin.inc', |
|
173 ), |
|
174 'system_modules_uninstall' => array( |
|
175 'render element' => 'form', |
|
176 'file' => 'system.admin.inc', |
|
177 ), |
|
178 'status_report' => array( |
|
179 'render element' => 'requirements', |
|
180 'file' => 'system.admin.inc', |
|
181 ), |
|
182 'admin_page' => array( |
|
183 'variables' => array('blocks' => NULL), |
|
184 'file' => 'system.admin.inc', |
|
185 ), |
|
186 'admin_block' => array( |
|
187 'variables' => array('block' => NULL), |
|
188 'file' => 'system.admin.inc', |
|
189 ), |
|
190 'admin_block_content' => array( |
|
191 'variables' => array('content' => NULL), |
|
192 'file' => 'system.admin.inc', |
|
193 ), |
|
194 'system_admin_index' => array( |
|
195 'variables' => array('menu_items' => NULL), |
|
196 'file' => 'system.admin.inc', |
|
197 ), |
|
198 'system_powered_by' => array( |
|
199 'variables' => array(), |
|
200 ), |
|
201 'system_compact_link' => array( |
|
202 'variables' => array(), |
|
203 ), |
|
204 'system_date_time_settings' => array( |
|
205 'render element' => 'form', |
|
206 'file' => 'system.admin.inc', |
|
207 ), |
|
208 )); |
|
209 } |
|
210 |
|
211 /** |
|
212 * Implements hook_permission(). |
|
213 */ |
|
214 function system_permission() { |
|
215 return array( |
|
216 'administer modules' => array( |
|
217 'title' => t('Administer modules'), |
|
218 ), |
|
219 'administer site configuration' => array( |
|
220 'title' => t('Administer site configuration'), |
|
221 'restrict access' => TRUE, |
|
222 ), |
|
223 'administer themes' => array( |
|
224 'title' => t('Administer themes'), |
|
225 ), |
|
226 'administer software updates' => array( |
|
227 'title' => t('Administer software updates'), |
|
228 'restrict access' => TRUE, |
|
229 ), |
|
230 'administer actions' => array( |
|
231 'title' => t('Administer actions'), |
|
232 ), |
|
233 'access administration pages' => array( |
|
234 'title' => t('Use the administration pages and help'), |
|
235 ), |
|
236 'access site in maintenance mode' => array( |
|
237 'title' => t('Use the site in maintenance mode'), |
|
238 ), |
|
239 'view the administration theme' => array( |
|
240 'title' => t('View the administration theme'), |
|
241 'description' => variable_get('admin_theme') ? '' : t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))), |
|
242 ), |
|
243 'access site reports' => array( |
|
244 'title' => t('View site reports'), |
|
245 'restrict access' => TRUE, |
|
246 ), |
|
247 'block IP addresses' => array( |
|
248 'title' => t('Block IP addresses'), |
|
249 ), |
|
250 ); |
|
251 } |
|
252 |
|
253 /** |
|
254 * Implements hook_hook_info(). |
|
255 */ |
|
256 function system_hook_info() { |
|
257 $hooks['token_info'] = array( |
|
258 'group' => 'tokens', |
|
259 ); |
|
260 $hooks['token_info_alter'] = array( |
|
261 'group' => 'tokens', |
|
262 ); |
|
263 $hooks['tokens'] = array( |
|
264 'group' => 'tokens', |
|
265 ); |
|
266 $hooks['tokens_alter'] = array( |
|
267 'group' => 'tokens', |
|
268 ); |
|
269 |
|
270 return $hooks; |
|
271 } |
|
272 |
|
273 /** |
|
274 * Implements hook_entity_info(). |
|
275 */ |
|
276 function system_entity_info() { |
|
277 return array( |
|
278 'file' => array( |
|
279 'label' => t('File'), |
|
280 'base table' => 'file_managed', |
|
281 'entity keys' => array( |
|
282 'id' => 'fid', |
|
283 'label' => 'filename', |
|
284 ), |
|
285 'static cache' => FALSE, |
|
286 ), |
|
287 ); |
|
288 } |
|
289 |
|
290 /** |
|
291 * Implements hook_element_info(). |
|
292 */ |
|
293 function system_element_info() { |
|
294 // Top level elements. |
|
295 $types['form'] = array( |
|
296 '#method' => 'post', |
|
297 '#action' => request_uri(), |
|
298 '#theme_wrappers' => array('form'), |
|
299 ); |
|
300 $types['page'] = array( |
|
301 '#show_messages' => TRUE, |
|
302 '#theme' => 'page', |
|
303 '#theme_wrappers' => array('html'), |
|
304 ); |
|
305 // By default, we don't want Ajax commands being rendered in the context of an |
|
306 // HTML page, so we don't provide defaults for #theme or #theme_wrappers. |
|
307 // However, modules can set these properties (for example, to provide an HTML |
|
308 // debugging page that displays rather than executes Ajax commands). |
|
309 $types['ajax'] = array( |
|
310 '#header' => TRUE, |
|
311 '#commands' => array(), |
|
312 '#error' => NULL, |
|
313 ); |
|
314 $types['html_tag'] = array( |
|
315 '#theme' => 'html_tag', |
|
316 '#pre_render' => array('drupal_pre_render_conditional_comments'), |
|
317 '#attributes' => array(), |
|
318 '#value' => NULL, |
|
319 ); |
|
320 $types['styles'] = array( |
|
321 '#items' => array(), |
|
322 '#pre_render' => array('drupal_pre_render_styles'), |
|
323 '#group_callback' => 'drupal_group_css', |
|
324 '#aggregate_callback' => 'drupal_aggregate_css', |
|
325 ); |
|
326 |
|
327 // Input elements. |
|
328 $types['submit'] = array( |
|
329 '#input' => TRUE, |
|
330 '#name' => 'op', |
|
331 '#button_type' => 'submit', |
|
332 '#executes_submit_callback' => TRUE, |
|
333 '#limit_validation_errors' => FALSE, |
|
334 '#process' => array('ajax_process_form'), |
|
335 '#theme_wrappers' => array('button'), |
|
336 ); |
|
337 $types['button'] = array( |
|
338 '#input' => TRUE, |
|
339 '#name' => 'op', |
|
340 '#button_type' => 'submit', |
|
341 '#executes_submit_callback' => FALSE, |
|
342 '#limit_validation_errors' => FALSE, |
|
343 '#process' => array('ajax_process_form'), |
|
344 '#theme_wrappers' => array('button'), |
|
345 ); |
|
346 $types['image_button'] = array( |
|
347 '#input' => TRUE, |
|
348 '#button_type' => 'submit', |
|
349 '#executes_submit_callback' => TRUE, |
|
350 '#limit_validation_errors' => FALSE, |
|
351 '#process' => array('ajax_process_form'), |
|
352 '#return_value' => TRUE, |
|
353 '#has_garbage_value' => TRUE, |
|
354 '#src' => NULL, |
|
355 '#theme_wrappers' => array('image_button'), |
|
356 ); |
|
357 $types['textfield'] = array( |
|
358 '#input' => TRUE, |
|
359 '#size' => 60, |
|
360 '#maxlength' => 128, |
|
361 '#autocomplete_path' => FALSE, |
|
362 '#process' => array('form_process_autocomplete', 'ajax_process_form'), |
|
363 '#theme' => 'textfield', |
|
364 '#theme_wrappers' => array('form_element'), |
|
365 ); |
|
366 $types['machine_name'] = array( |
|
367 '#input' => TRUE, |
|
368 '#default_value' => NULL, |
|
369 '#required' => TRUE, |
|
370 '#maxlength' => 64, |
|
371 '#size' => 60, |
|
372 '#autocomplete_path' => FALSE, |
|
373 '#process' => array('form_process_machine_name', 'ajax_process_form'), |
|
374 '#element_validate' => array('form_validate_machine_name'), |
|
375 '#theme' => 'textfield', |
|
376 '#theme_wrappers' => array('form_element'), |
|
377 // Use the same value callback as for textfields; this ensures that we only |
|
378 // get string values. |
|
379 '#value_callback' => 'form_type_textfield_value', |
|
380 ); |
|
381 $types['password'] = array( |
|
382 '#input' => TRUE, |
|
383 '#size' => 60, |
|
384 '#maxlength' => 128, |
|
385 '#process' => array('ajax_process_form'), |
|
386 '#theme' => 'password', |
|
387 '#theme_wrappers' => array('form_element'), |
|
388 // Use the same value callback as for textfields; this ensures that we only |
|
389 // get string values. |
|
390 '#value_callback' => 'form_type_textfield_value', |
|
391 ); |
|
392 $types['password_confirm'] = array( |
|
393 '#input' => TRUE, |
|
394 '#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'), |
|
395 '#theme_wrappers' => array('form_element'), |
|
396 ); |
|
397 $types['textarea'] = array( |
|
398 '#input' => TRUE, |
|
399 '#cols' => 60, |
|
400 '#rows' => 5, |
|
401 '#resizable' => TRUE, |
|
402 '#process' => array('ajax_process_form'), |
|
403 '#theme' => 'textarea', |
|
404 '#theme_wrappers' => array('form_element'), |
|
405 ); |
|
406 $types['radios'] = array( |
|
407 '#input' => TRUE, |
|
408 '#process' => array('form_process_radios'), |
|
409 '#theme_wrappers' => array('radios'), |
|
410 '#pre_render' => array('form_pre_render_conditional_form_element'), |
|
411 ); |
|
412 $types['radio'] = array( |
|
413 '#input' => TRUE, |
|
414 '#default_value' => NULL, |
|
415 '#process' => array('ajax_process_form'), |
|
416 '#theme' => 'radio', |
|
417 '#theme_wrappers' => array('form_element'), |
|
418 '#title_display' => 'after', |
|
419 ); |
|
420 $types['checkboxes'] = array( |
|
421 '#input' => TRUE, |
|
422 '#process' => array('form_process_checkboxes'), |
|
423 '#theme_wrappers' => array('checkboxes'), |
|
424 '#pre_render' => array('form_pre_render_conditional_form_element'), |
|
425 ); |
|
426 $types['checkbox'] = array( |
|
427 '#input' => TRUE, |
|
428 '#return_value' => 1, |
|
429 '#theme' => 'checkbox', |
|
430 '#process' => array('form_process_checkbox', 'ajax_process_form'), |
|
431 '#theme_wrappers' => array('form_element'), |
|
432 '#title_display' => 'after', |
|
433 ); |
|
434 $types['select'] = array( |
|
435 '#input' => TRUE, |
|
436 '#multiple' => FALSE, |
|
437 '#process' => array('form_process_select', 'ajax_process_form'), |
|
438 '#theme' => 'select', |
|
439 '#theme_wrappers' => array('form_element'), |
|
440 ); |
|
441 $types['weight'] = array( |
|
442 '#input' => TRUE, |
|
443 '#delta' => 10, |
|
444 '#default_value' => 0, |
|
445 '#process' => array('form_process_weight', 'ajax_process_form'), |
|
446 ); |
|
447 $types['date'] = array( |
|
448 '#input' => TRUE, |
|
449 '#element_validate' => array('date_validate'), |
|
450 '#process' => array('form_process_date'), |
|
451 '#theme' => 'date', |
|
452 '#theme_wrappers' => array('form_element'), |
|
453 ); |
|
454 $types['file'] = array( |
|
455 '#input' => TRUE, |
|
456 '#size' => 60, |
|
457 '#theme' => 'file', |
|
458 '#theme_wrappers' => array('form_element'), |
|
459 ); |
|
460 $types['tableselect'] = array( |
|
461 '#input' => TRUE, |
|
462 '#js_select' => TRUE, |
|
463 '#multiple' => TRUE, |
|
464 '#process' => array('form_process_tableselect'), |
|
465 '#options' => array(), |
|
466 '#empty' => '', |
|
467 '#theme' => 'tableselect', |
|
468 ); |
|
469 |
|
470 // Form structure. |
|
471 $types['item'] = array( |
|
472 '#markup' => '', |
|
473 '#pre_render' => array('drupal_pre_render_markup'), |
|
474 '#theme_wrappers' => array('form_element'), |
|
475 ); |
|
476 $types['hidden'] = array( |
|
477 '#input' => TRUE, |
|
478 '#process' => array('ajax_process_form'), |
|
479 '#theme' => 'hidden', |
|
480 ); |
|
481 $types['value'] = array( |
|
482 '#input' => TRUE, |
|
483 ); |
|
484 $types['markup'] = array( |
|
485 '#markup' => '', |
|
486 '#pre_render' => array('drupal_pre_render_markup'), |
|
487 ); |
|
488 $types['link'] = array( |
|
489 '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'), |
|
490 ); |
|
491 $types['fieldset'] = array( |
|
492 '#collapsible' => FALSE, |
|
493 '#collapsed' => FALSE, |
|
494 '#value' => NULL, |
|
495 '#process' => array('form_process_fieldset', 'ajax_process_form'), |
|
496 '#pre_render' => array('form_pre_render_fieldset'), |
|
497 '#theme_wrappers' => array('fieldset'), |
|
498 ); |
|
499 $types['vertical_tabs'] = array( |
|
500 '#theme_wrappers' => array('vertical_tabs'), |
|
501 '#default_tab' => '', |
|
502 '#process' => array('form_process_vertical_tabs'), |
|
503 ); |
|
504 |
|
505 $types['container'] = array( |
|
506 '#theme_wrappers' => array('container'), |
|
507 '#process' => array('form_process_container'), |
|
508 ); |
|
509 $types['actions'] = array( |
|
510 '#theme_wrappers' => array('container'), |
|
511 '#process' => array('form_process_actions', 'form_process_container'), |
|
512 '#weight' => 100, |
|
513 ); |
|
514 |
|
515 $types['token'] = array( |
|
516 '#input' => TRUE, |
|
517 '#theme' => 'hidden', |
|
518 ); |
|
519 |
|
520 return $types; |
|
521 } |
|
522 |
|
523 /** |
|
524 * Implements hook_menu(). |
|
525 */ |
|
526 function system_menu() { |
|
527 $items['system/files'] = array( |
|
528 'title' => 'File download', |
|
529 'page callback' => 'file_download', |
|
530 'page arguments' => array('private'), |
|
531 'access callback' => TRUE, |
|
532 'type' => MENU_CALLBACK, |
|
533 ); |
|
534 $items['system/temporary'] = array( |
|
535 'title' => 'Temporary files', |
|
536 'page callback' => 'file_download', |
|
537 'page arguments' => array('temporary'), |
|
538 'access callback' => TRUE, |
|
539 'type' => MENU_CALLBACK, |
|
540 ); |
|
541 $items['system/ajax'] = array( |
|
542 'title' => 'AHAH callback', |
|
543 'page callback' => 'ajax_form_callback', |
|
544 'delivery callback' => 'ajax_deliver', |
|
545 'access callback' => TRUE, |
|
546 'theme callback' => 'ajax_base_page_theme', |
|
547 'type' => MENU_CALLBACK, |
|
548 'file path' => 'includes', |
|
549 'file' => 'form.inc', |
|
550 ); |
|
551 $items['system/timezone'] = array( |
|
552 'title' => 'Time zone', |
|
553 'page callback' => 'system_timezone', |
|
554 'access callback' => TRUE, |
|
555 'type' => MENU_CALLBACK, |
|
556 'file' => 'system.admin.inc', |
|
557 ); |
|
558 $items['admin'] = array( |
|
559 'title' => 'Administration', |
|
560 'access arguments' => array('access administration pages'), |
|
561 'page callback' => 'system_admin_menu_block_page', |
|
562 'weight' => 9, |
|
563 'menu_name' => 'management', |
|
564 'file' => 'system.admin.inc', |
|
565 ); |
|
566 $items['admin/compact'] = array( |
|
567 'title' => 'Compact mode', |
|
568 'page callback' => 'system_admin_compact_page', |
|
569 'access arguments' => array('access administration pages'), |
|
570 'type' => MENU_CALLBACK, |
|
571 'file' => 'system.admin.inc', |
|
572 ); |
|
573 $items['admin/tasks'] = array( |
|
574 'title' => 'Tasks', |
|
575 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
576 'weight' => -20, |
|
577 ); |
|
578 $items['admin/index'] = array( |
|
579 'title' => 'Index', |
|
580 'page callback' => 'system_admin_index', |
|
581 'access arguments' => array('access administration pages'), |
|
582 'type' => MENU_LOCAL_TASK, |
|
583 'weight' => -18, |
|
584 'file' => 'system.admin.inc', |
|
585 ); |
|
586 |
|
587 // Menu items that are basically just menu blocks. |
|
588 $items['admin/structure'] = array( |
|
589 'title' => 'Structure', |
|
590 'description' => 'Administer blocks, content types, menus, etc.', |
|
591 'position' => 'right', |
|
592 'weight' => -8, |
|
593 'page callback' => 'system_admin_menu_block_page', |
|
594 'access arguments' => array('access administration pages'), |
|
595 'file' => 'system.admin.inc', |
|
596 ); |
|
597 // Appearance. |
|
598 $items['admin/appearance'] = array( |
|
599 'title' => 'Appearance', |
|
600 'description' => 'Select and configure your themes.', |
|
601 'page callback' => 'system_themes_page', |
|
602 'access arguments' => array('administer themes'), |
|
603 'position' => 'left', |
|
604 'weight' => -6, |
|
605 'file' => 'system.admin.inc', |
|
606 ); |
|
607 $items['admin/appearance/list'] = array( |
|
608 'title' => 'List', |
|
609 'description' => 'Select and configure your theme', |
|
610 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
611 'weight' => -1, |
|
612 'file' => 'system.admin.inc', |
|
613 ); |
|
614 $items['admin/appearance/enable'] = array( |
|
615 'title' => 'Enable theme', |
|
616 'page callback' => 'system_theme_enable', |
|
617 'access arguments' => array('administer themes'), |
|
618 'type' => MENU_CALLBACK, |
|
619 'file' => 'system.admin.inc', |
|
620 ); |
|
621 $items['admin/appearance/disable'] = array( |
|
622 'title' => 'Disable theme', |
|
623 'page callback' => 'system_theme_disable', |
|
624 'access arguments' => array('administer themes'), |
|
625 'type' => MENU_CALLBACK, |
|
626 'file' => 'system.admin.inc', |
|
627 ); |
|
628 $items['admin/appearance/default'] = array( |
|
629 'title' => 'Set default theme', |
|
630 'page callback' => 'system_theme_default', |
|
631 'access arguments' => array('administer themes'), |
|
632 'type' => MENU_CALLBACK, |
|
633 'file' => 'system.admin.inc', |
|
634 ); |
|
635 $items['admin/appearance/settings'] = array( |
|
636 'title' => 'Settings', |
|
637 'description' => 'Configure default and theme specific settings.', |
|
638 'page callback' => 'drupal_get_form', |
|
639 'page arguments' => array('system_theme_settings'), |
|
640 'access arguments' => array('administer themes'), |
|
641 'type' => MENU_LOCAL_TASK, |
|
642 'file' => 'system.admin.inc', |
|
643 'weight' => 20, |
|
644 ); |
|
645 // Theme configuration subtabs. |
|
646 $items['admin/appearance/settings/global'] = array( |
|
647 'title' => 'Global settings', |
|
648 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
649 'weight' => -1, |
|
650 ); |
|
651 |
|
652 foreach (list_themes() as $theme) { |
|
653 $items['admin/appearance/settings/' . $theme->name] = array( |
|
654 'title' => $theme->info['name'], |
|
655 'page arguments' => array('system_theme_settings', $theme->name), |
|
656 'type' => MENU_LOCAL_TASK, |
|
657 'access callback' => '_system_themes_access', |
|
658 'access arguments' => array($theme), |
|
659 'file' => 'system.admin.inc', |
|
660 ); |
|
661 } |
|
662 |
|
663 // Modules. |
|
664 $items['admin/modules'] = array( |
|
665 'title' => 'Modules', |
|
666 'description' => 'Extend site functionality.', |
|
667 'page callback' => 'drupal_get_form', |
|
668 'page arguments' => array('system_modules'), |
|
669 'access arguments' => array('administer modules'), |
|
670 'file' => 'system.admin.inc', |
|
671 'weight' => -2, |
|
672 ); |
|
673 $items['admin/modules/list'] = array( |
|
674 'title' => 'List', |
|
675 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
676 ); |
|
677 $items['admin/modules/list/confirm'] = array( |
|
678 'title' => 'List', |
|
679 'access arguments' => array('administer modules'), |
|
680 'type' => MENU_VISIBLE_IN_BREADCRUMB, |
|
681 ); |
|
682 $items['admin/modules/uninstall'] = array( |
|
683 'title' => 'Uninstall', |
|
684 'page arguments' => array('system_modules_uninstall'), |
|
685 'access arguments' => array('administer modules'), |
|
686 'type' => MENU_LOCAL_TASK, |
|
687 'file' => 'system.admin.inc', |
|
688 'weight' => 20, |
|
689 ); |
|
690 $items['admin/modules/uninstall/confirm'] = array( |
|
691 'title' => 'Uninstall', |
|
692 'access arguments' => array('administer modules'), |
|
693 'type' => MENU_VISIBLE_IN_BREADCRUMB, |
|
694 'file' => 'system.admin.inc', |
|
695 ); |
|
696 |
|
697 // Configuration. |
|
698 $items['admin/config'] = array( |
|
699 'title' => 'Configuration', |
|
700 'description' => 'Administer settings.', |
|
701 'page callback' => 'system_admin_config_page', |
|
702 'access arguments' => array('access administration pages'), |
|
703 'file' => 'system.admin.inc', |
|
704 ); |
|
705 |
|
706 // IP address blocking. |
|
707 $items['admin/config/people/ip-blocking'] = array( |
|
708 'title' => 'IP address blocking', |
|
709 'description' => 'Manage blocked IP addresses.', |
|
710 'page callback' => 'system_ip_blocking', |
|
711 'access arguments' => array('block IP addresses'), |
|
712 'file' => 'system.admin.inc', |
|
713 'weight' => 10, |
|
714 ); |
|
715 $items['admin/config/people/ip-blocking/delete/%blocked_ip'] = array( |
|
716 'title' => 'Delete IP address', |
|
717 'page callback' => 'drupal_get_form', |
|
718 'page arguments' => array('system_ip_blocking_delete', 5), |
|
719 'access arguments' => array('block IP addresses'), |
|
720 'file' => 'system.admin.inc', |
|
721 ); |
|
722 |
|
723 // Media settings. |
|
724 $items['admin/config/media'] = array( |
|
725 'title' => 'Media', |
|
726 'description' => 'Media tools.', |
|
727 'position' => 'left', |
|
728 'weight' => -10, |
|
729 'page callback' => 'system_admin_menu_block_page', |
|
730 'access arguments' => array('access administration pages'), |
|
731 'file' => 'system.admin.inc', |
|
732 ); |
|
733 $items['admin/config/media/file-system'] = array( |
|
734 'title' => 'File system', |
|
735 'description' => 'Tell Drupal where to store uploaded files and how they are accessed.', |
|
736 'page callback' => 'drupal_get_form', |
|
737 'page arguments' => array('system_file_system_settings'), |
|
738 'access arguments' => array('administer site configuration'), |
|
739 'weight' => -10, |
|
740 'file' => 'system.admin.inc', |
|
741 ); |
|
742 $items['admin/config/media/image-toolkit'] = array( |
|
743 'title' => 'Image toolkit', |
|
744 'description' => 'Choose which image toolkit to use if you have installed optional toolkits.', |
|
745 'page callback' => 'drupal_get_form', |
|
746 'page arguments' => array('system_image_toolkit_settings'), |
|
747 'access arguments' => array('administer site configuration'), |
|
748 'weight' => 20, |
|
749 'file' => 'system.admin.inc', |
|
750 ); |
|
751 |
|
752 // Service settings. |
|
753 $items['admin/config/services'] = array( |
|
754 'title' => 'Web services', |
|
755 'description' => 'Tools related to web services.', |
|
756 'position' => 'right', |
|
757 'weight' => 0, |
|
758 'page callback' => 'system_admin_menu_block_page', |
|
759 'access arguments' => array('access administration pages'), |
|
760 'file' => 'system.admin.inc', |
|
761 ); |
|
762 $items['admin/config/services/rss-publishing'] = array( |
|
763 'title' => 'RSS publishing', |
|
764 'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.', |
|
765 'page callback' => 'drupal_get_form', |
|
766 'page arguments' => array('system_rss_feeds_settings'), |
|
767 'access arguments' => array('administer site configuration'), |
|
768 'file' => 'system.admin.inc', |
|
769 ); |
|
770 |
|
771 // Development settings. |
|
772 $items['admin/config/development'] = array( |
|
773 'title' => 'Development', |
|
774 'description' => 'Development tools.', |
|
775 'position' => 'right', |
|
776 'weight' => -10, |
|
777 'page callback' => 'system_admin_menu_block_page', |
|
778 'access arguments' => array('access administration pages'), |
|
779 'file' => 'system.admin.inc', |
|
780 ); |
|
781 $items['admin/config/development/maintenance'] = array( |
|
782 'title' => 'Maintenance mode', |
|
783 'description' => 'Take the site offline for maintenance or bring it back online.', |
|
784 'page callback' => 'drupal_get_form', |
|
785 'page arguments' => array('system_site_maintenance_mode'), |
|
786 'access arguments' => array('administer site configuration'), |
|
787 'file' => 'system.admin.inc', |
|
788 'weight' => -10, |
|
789 ); |
|
790 $items['admin/config/development/performance'] = array( |
|
791 'title' => 'Performance', |
|
792 'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.', |
|
793 'page callback' => 'drupal_get_form', |
|
794 'page arguments' => array('system_performance_settings'), |
|
795 'access arguments' => array('administer site configuration'), |
|
796 'file' => 'system.admin.inc', |
|
797 'weight' => -20, |
|
798 ); |
|
799 $items['admin/config/development/logging'] = array( |
|
800 'title' => 'Logging and errors', |
|
801 'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.", |
|
802 'page callback' => 'drupal_get_form', |
|
803 'page arguments' => array('system_logging_settings'), |
|
804 'access arguments' => array('administer site configuration'), |
|
805 'file' => 'system.admin.inc', |
|
806 'weight' => -15, |
|
807 ); |
|
808 |
|
809 // Regional and date settings. |
|
810 $items['admin/config/regional'] = array( |
|
811 'title' => 'Regional and language', |
|
812 'description' => 'Regional settings, localization and translation.', |
|
813 'position' => 'left', |
|
814 'weight' => -5, |
|
815 'page callback' => 'system_admin_menu_block_page', |
|
816 'access arguments' => array('access administration pages'), |
|
817 'file' => 'system.admin.inc', |
|
818 ); |
|
819 $items['admin/config/regional/settings'] = array( |
|
820 'title' => 'Regional settings', |
|
821 'description' => "Settings for the site's default time zone and country.", |
|
822 'page callback' => 'drupal_get_form', |
|
823 'page arguments' => array('system_regional_settings'), |
|
824 'access arguments' => array('administer site configuration'), |
|
825 'weight' => -20, |
|
826 'file' => 'system.admin.inc', |
|
827 ); |
|
828 $items['admin/config/regional/date-time'] = array( |
|
829 'title' => 'Date and time', |
|
830 'description' => 'Configure display formats for date and time.', |
|
831 'page callback' => 'drupal_get_form', |
|
832 'page arguments' => array('system_date_time_settings'), |
|
833 'access arguments' => array('administer site configuration'), |
|
834 'weight' => -15, |
|
835 'file' => 'system.admin.inc', |
|
836 ); |
|
837 $items['admin/config/regional/date-time/types'] = array( |
|
838 'title' => 'Types', |
|
839 'description' => 'Configure display formats for date and time.', |
|
840 'page callback' => 'drupal_get_form', |
|
841 'page arguments' => array('system_date_time_settings'), |
|
842 'access arguments' => array('administer site configuration'), |
|
843 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
844 'weight' => -10, |
|
845 'file' => 'system.admin.inc', |
|
846 ); |
|
847 $items['admin/config/regional/date-time/types/add'] = array( |
|
848 'title' => 'Add date type', |
|
849 'description' => 'Add new date type.', |
|
850 'page callback' => 'drupal_get_form', |
|
851 'page arguments' => array('system_add_date_format_type_form'), |
|
852 'access arguments' => array('administer site configuration'), |
|
853 'type' => MENU_LOCAL_ACTION, |
|
854 'weight' => -10, |
|
855 'file' => 'system.admin.inc', |
|
856 ); |
|
857 $items['admin/config/regional/date-time/types/%/delete'] = array( |
|
858 'title' => 'Delete date type', |
|
859 'description' => 'Allow users to delete a configured date type.', |
|
860 'page callback' => 'drupal_get_form', |
|
861 'page arguments' => array('system_delete_date_format_type_form', 5), |
|
862 'access arguments' => array('administer site configuration'), |
|
863 'file' => 'system.admin.inc', |
|
864 ); |
|
865 $items['admin/config/regional/date-time/formats'] = array( |
|
866 'title' => 'Formats', |
|
867 'description' => 'Configure display format strings for date and time.', |
|
868 'page callback' => 'system_date_time_formats', |
|
869 'access arguments' => array('administer site configuration'), |
|
870 'type' => MENU_LOCAL_TASK, |
|
871 'weight' => -9, |
|
872 'file' => 'system.admin.inc', |
|
873 ); |
|
874 $items['admin/config/regional/date-time/formats/add'] = array( |
|
875 'title' => 'Add format', |
|
876 'description' => 'Allow users to add additional date formats.', |
|
877 'type' => MENU_LOCAL_ACTION, |
|
878 'page callback' => 'drupal_get_form', |
|
879 'page arguments' => array('system_configure_date_formats_form'), |
|
880 'access arguments' => array('administer site configuration'), |
|
881 'weight' => -10, |
|
882 'file' => 'system.admin.inc', |
|
883 ); |
|
884 $items['admin/config/regional/date-time/formats/%/edit'] = array( |
|
885 'title' => 'Edit date format', |
|
886 'description' => 'Allow users to edit a configured date format.', |
|
887 'page callback' => 'drupal_get_form', |
|
888 'page arguments' => array('system_configure_date_formats_form', 5), |
|
889 'access arguments' => array('administer site configuration'), |
|
890 'file' => 'system.admin.inc', |
|
891 ); |
|
892 $items['admin/config/regional/date-time/formats/%/delete'] = array( |
|
893 'title' => 'Delete date format', |
|
894 'description' => 'Allow users to delete a configured date format.', |
|
895 'page callback' => 'drupal_get_form', |
|
896 'page arguments' => array('system_date_delete_format_form', 5), |
|
897 'access arguments' => array('administer site configuration'), |
|
898 'file' => 'system.admin.inc', |
|
899 ); |
|
900 $items['admin/config/regional/date-time/formats/lookup'] = array( |
|
901 'title' => 'Date and time lookup', |
|
902 'page callback' => 'system_date_time_lookup', |
|
903 'access arguments' => array('administer site configuration'), |
|
904 'type' => MENU_CALLBACK, |
|
905 'file' => 'system.admin.inc', |
|
906 ); |
|
907 |
|
908 // Search settings. |
|
909 $items['admin/config/search'] = array( |
|
910 'title' => 'Search and metadata', |
|
911 'description' => 'Local site search, metadata and SEO.', |
|
912 'position' => 'left', |
|
913 'weight' => -10, |
|
914 'page callback' => 'system_admin_menu_block_page', |
|
915 'access arguments' => array('access administration pages'), |
|
916 'file' => 'system.admin.inc', |
|
917 ); |
|
918 $items['admin/config/search/clean-urls'] = array( |
|
919 'title' => 'Clean URLs', |
|
920 'description' => 'Enable or disable clean URLs for your site.', |
|
921 'page callback' => 'drupal_get_form', |
|
922 'page arguments' => array('system_clean_url_settings'), |
|
923 'access arguments' => array('administer site configuration'), |
|
924 'file' => 'system.admin.inc', |
|
925 'weight' => 5, |
|
926 ); |
|
927 $items['admin/config/search/clean-urls/check'] = array( |
|
928 'title' => 'Clean URL check', |
|
929 'page callback' => 'drupal_json_output', |
|
930 'page arguments' => array(array('status' => TRUE)), |
|
931 'access callback' => TRUE, |
|
932 'type' => MENU_CALLBACK, |
|
933 'file' => 'system.admin.inc', |
|
934 ); |
|
935 |
|
936 // System settings. |
|
937 $items['admin/config/system'] = array( |
|
938 'title' => 'System', |
|
939 'description' => 'General system related configuration.', |
|
940 'position' => 'right', |
|
941 'weight' => -20, |
|
942 'page callback' => 'system_admin_menu_block_page', |
|
943 'access arguments' => array('access administration pages'), |
|
944 'file' => 'system.admin.inc', |
|
945 ); |
|
946 $items['admin/config/system/actions'] = array( |
|
947 'title' => 'Actions', |
|
948 'description' => 'Manage the actions defined for your site.', |
|
949 'access arguments' => array('administer actions'), |
|
950 'page callback' => 'system_actions_manage', |
|
951 'file' => 'system.admin.inc', |
|
952 ); |
|
953 $items['admin/config/system/actions/manage'] = array( |
|
954 'title' => 'Manage actions', |
|
955 'description' => 'Manage the actions defined for your site.', |
|
956 'page callback' => 'system_actions_manage', |
|
957 'type' => MENU_DEFAULT_LOCAL_TASK, |
|
958 'weight' => -2, |
|
959 'file' => 'system.admin.inc', |
|
960 ); |
|
961 $items['admin/config/system/actions/configure'] = array( |
|
962 'title' => 'Configure an advanced action', |
|
963 'page callback' => 'drupal_get_form', |
|
964 'page arguments' => array('system_actions_configure'), |
|
965 'access arguments' => array('administer actions'), |
|
966 'type' => MENU_VISIBLE_IN_BREADCRUMB, |
|
967 'file' => 'system.admin.inc', |
|
968 ); |
|
969 $items['admin/config/system/actions/delete/%actions'] = array( |
|
970 'title' => 'Delete action', |
|
971 'description' => 'Delete an action.', |
|
972 'page callback' => 'drupal_get_form', |
|
973 'page arguments' => array('system_actions_delete_form', 5), |
|
974 'access arguments' => array('administer actions'), |
|
975 'file' => 'system.admin.inc', |
|
976 ); |
|
977 $items['admin/config/system/actions/orphan'] = array( |
|
978 'title' => 'Remove orphans', |
|
979 'page callback' => 'system_actions_remove_orphans', |
|
980 'access arguments' => array('administer actions'), |
|
981 'type' => MENU_CALLBACK, |
|
982 'file' => 'system.admin.inc', |
|
983 ); |
|
984 $items['admin/config/system/site-information'] = array( |
|
985 'title' => 'Site information', |
|
986 'description' => 'Change site name, e-mail address, slogan, default front page, and number of posts per page, error pages.', |
|
987 'page callback' => 'drupal_get_form', |
|
988 'page arguments' => array('system_site_information_settings'), |
|
989 'access arguments' => array('administer site configuration'), |
|
990 'file' => 'system.admin.inc', |
|
991 'weight' => -20, |
|
992 ); |
|
993 $items['admin/config/system/cron'] = array( |
|
994 'title' => 'Cron', |
|
995 'description' => 'Manage automatic site maintenance tasks.', |
|
996 'page callback' => 'drupal_get_form', |
|
997 'page arguments' => array('system_cron_settings'), |
|
998 'access arguments' => array('administer site configuration'), |
|
999 'file' => 'system.admin.inc', |
|
1000 'weight' => 20, |
|
1001 ); |
|
1002 // Additional categories |
|
1003 $items['admin/config/user-interface'] = array( |
|
1004 'title' => 'User interface', |
|
1005 'description' => 'Tools that enhance the user interface.', |
|
1006 'position' => 'right', |
|
1007 'page callback' => 'system_admin_menu_block_page', |
|
1008 'access arguments' => array('access administration pages'), |
|
1009 'file' => 'system.admin.inc', |
|
1010 'weight' => -15, |
|
1011 ); |
|
1012 $items['admin/config/workflow'] = array( |
|
1013 'title' => 'Workflow', |
|
1014 'description' => 'Content workflow, editorial workflow tools.', |
|
1015 'position' => 'right', |
|
1016 'weight' => 5, |
|
1017 'page callback' => 'system_admin_menu_block_page', |
|
1018 'access arguments' => array('access administration pages'), |
|
1019 'file' => 'system.admin.inc', |
|
1020 ); |
|
1021 $items['admin/config/content'] = array( |
|
1022 'title' => 'Content authoring', |
|
1023 'description' => 'Settings related to formatting and authoring content.', |
|
1024 'position' => 'left', |
|
1025 'weight' => -15, |
|
1026 'page callback' => 'system_admin_menu_block_page', |
|
1027 'access arguments' => array('access administration pages'), |
|
1028 'file' => 'system.admin.inc', |
|
1029 ); |
|
1030 |
|
1031 // Reports. |
|
1032 $items['admin/reports'] = array( |
|
1033 'title' => 'Reports', |
|
1034 'description' => 'View reports, updates, and errors.', |
|
1035 'page callback' => 'system_admin_menu_block_page', |
|
1036 'access arguments' => array('access site reports'), |
|
1037 'weight' => 5, |
|
1038 'position' => 'left', |
|
1039 'file' => 'system.admin.inc', |
|
1040 ); |
|
1041 $items['admin/reports/status'] = array( |
|
1042 'title' => 'Status report', |
|
1043 'description' => "Get a status report about your site's operation and any detected problems.", |
|
1044 'page callback' => 'system_status', |
|
1045 'weight' => -60, |
|
1046 'access arguments' => array('administer site configuration'), |
|
1047 'file' => 'system.admin.inc', |
|
1048 ); |
|
1049 $items['admin/reports/status/run-cron'] = array( |
|
1050 'title' => 'Run cron', |
|
1051 'page callback' => 'system_run_cron', |
|
1052 'access arguments' => array('administer site configuration'), |
|
1053 'type' => MENU_CALLBACK, |
|
1054 'file' => 'system.admin.inc', |
|
1055 ); |
|
1056 $items['admin/reports/status/php'] = array( |
|
1057 'title' => 'PHP', |
|
1058 'page callback' => 'system_php', |
|
1059 'access arguments' => array('administer site configuration'), |
|
1060 'type' => MENU_CALLBACK, |
|
1061 'file' => 'system.admin.inc', |
|
1062 ); |
|
1063 |
|
1064 // Default page for batch operations. |
|
1065 $items['batch'] = array( |
|
1066 'page callback' => 'system_batch_page', |
|
1067 'access callback' => TRUE, |
|
1068 'theme callback' => '_system_batch_theme', |
|
1069 'type' => MENU_CALLBACK, |
|
1070 'file' => 'system.admin.inc', |
|
1071 ); |
|
1072 return $items; |
|
1073 } |
|
1074 |
|
1075 /** |
|
1076 * Theme callback for the default batch page. |
|
1077 */ |
|
1078 function _system_batch_theme() { |
|
1079 // Retrieve the current state of the batch. |
|
1080 $batch = &batch_get(); |
|
1081 if (!$batch && isset($_REQUEST['id'])) { |
|
1082 require_once DRUPAL_ROOT . '/includes/batch.inc'; |
|
1083 $batch = batch_load($_REQUEST['id']); |
|
1084 } |
|
1085 // Use the same theme as the page that started the batch. |
|
1086 if (!empty($batch['theme'])) { |
|
1087 return $batch['theme']; |
|
1088 } |
|
1089 } |
|
1090 |
|
1091 /** |
|
1092 * Implements hook_library(). |
|
1093 */ |
|
1094 function system_library() { |
|
1095 // Drupal's Ajax framework. |
|
1096 $libraries['drupal.ajax'] = array( |
|
1097 'title' => 'Drupal AJAX', |
|
1098 'website' => 'http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax/7', |
|
1099 'version' => VERSION, |
|
1100 'js' => array( |
|
1101 'misc/ajax.js' => array('group' => JS_LIBRARY, 'weight' => 2), |
|
1102 ), |
|
1103 'dependencies' => array( |
|
1104 array('system', 'drupal.progress'), |
|
1105 ), |
|
1106 ); |
|
1107 |
|
1108 // Drupal's batch API. |
|
1109 $libraries['drupal.batch'] = array( |
|
1110 'title' => 'Drupal batch API', |
|
1111 'version' => VERSION, |
|
1112 'js' => array( |
|
1113 'misc/batch.js' => array('group' => JS_DEFAULT, 'cache' => FALSE), |
|
1114 ), |
|
1115 'dependencies' => array( |
|
1116 array('system', 'drupal.progress'), |
|
1117 ), |
|
1118 ); |
|
1119 |
|
1120 // Drupal's progress indicator. |
|
1121 $libraries['drupal.progress'] = array( |
|
1122 'title' => 'Drupal progress indicator', |
|
1123 'version' => VERSION, |
|
1124 'js' => array( |
|
1125 'misc/progress.js' => array('group' => JS_DEFAULT), |
|
1126 ), |
|
1127 ); |
|
1128 |
|
1129 // Drupal's form library. |
|
1130 $libraries['drupal.form'] = array( |
|
1131 'title' => 'Drupal form library', |
|
1132 'version' => VERSION, |
|
1133 'js' => array( |
|
1134 'misc/form.js' => array('group' => JS_LIBRARY, 'weight' => 1), |
|
1135 ), |
|
1136 ); |
|
1137 |
|
1138 // Drupal's states library. |
|
1139 $libraries['drupal.states'] = array( |
|
1140 'title' => 'Drupal states', |
|
1141 'version' => VERSION, |
|
1142 'js' => array( |
|
1143 'misc/states.js' => array('group' => JS_LIBRARY, 'weight' => 1), |
|
1144 ), |
|
1145 ); |
|
1146 |
|
1147 // Drupal's collapsible fieldset. |
|
1148 $libraries['drupal.collapse'] = array( |
|
1149 'title' => 'Drupal collapsible fieldset', |
|
1150 'version' => VERSION, |
|
1151 'js' => array( |
|
1152 'misc/collapse.js' => array('group' => JS_DEFAULT), |
|
1153 ), |
|
1154 'dependencies' => array( |
|
1155 // collapse.js relies on drupalGetSummary in form.js |
|
1156 array('system', 'drupal.form'), |
|
1157 ), |
|
1158 ); |
|
1159 |
|
1160 // Drupal's resizable textarea. |
|
1161 $libraries['drupal.textarea'] = array( |
|
1162 'title' => 'Drupal resizable textarea', |
|
1163 'version' => VERSION, |
|
1164 'js' => array( |
|
1165 'misc/textarea.js' => array('group' => JS_DEFAULT), |
|
1166 ), |
|
1167 ); |
|
1168 |
|
1169 // Drupal's autocomplete widget. |
|
1170 $libraries['drupal.autocomplete'] = array( |
|
1171 'title' => 'Drupal autocomplete', |
|
1172 'version' => VERSION, |
|
1173 'js' => array( |
|
1174 'misc/autocomplete.js' => array('group' => JS_DEFAULT), |
|
1175 ), |
|
1176 ); |
|
1177 |
|
1178 // jQuery. |
|
1179 $libraries['jquery'] = array( |
|
1180 'title' => 'jQuery', |
|
1181 'website' => 'http://jquery.com', |
|
1182 'version' => '1.4.4', |
|
1183 'js' => array( |
|
1184 'misc/jquery.js' => array('group' => JS_LIBRARY, 'weight' => -20), |
|
1185 ), |
|
1186 ); |
|
1187 |
|
1188 // jQuery Once. |
|
1189 $libraries['jquery.once'] = array( |
|
1190 'title' => 'jQuery Once', |
|
1191 'website' => 'http://plugins.jquery.com/project/once', |
|
1192 'version' => '1.2', |
|
1193 'js' => array( |
|
1194 'misc/jquery.once.js' => array('group' => JS_LIBRARY, 'weight' => -19), |
|
1195 ), |
|
1196 ); |
|
1197 |
|
1198 // jQuery Form Plugin. |
|
1199 $libraries['jquery.form'] = array( |
|
1200 'title' => 'jQuery Form Plugin', |
|
1201 'website' => 'http://malsup.com/jquery/form/', |
|
1202 'version' => '2.52', |
|
1203 'js' => array( |
|
1204 'misc/jquery.form.js' => array(), |
|
1205 ), |
|
1206 'dependencies' => array( |
|
1207 array('system', 'jquery.cookie'), |
|
1208 ), |
|
1209 ); |
|
1210 |
|
1211 // jQuery BBQ plugin. |
|
1212 $libraries['jquery.bbq'] = array( |
|
1213 'title' => 'jQuery BBQ', |
|
1214 'website' => 'http://benalman.com/projects/jquery-bbq-plugin/', |
|
1215 'version' => '1.2.1', |
|
1216 'js' => array( |
|
1217 'misc/jquery.ba-bbq.js' => array(), |
|
1218 ), |
|
1219 ); |
|
1220 |
|
1221 // Vertical Tabs. |
|
1222 $libraries['drupal.vertical-tabs'] = array( |
|
1223 'title' => 'Vertical Tabs', |
|
1224 'website' => 'http://drupal.org/node/323112', |
|
1225 'version' => '1.0', |
|
1226 'js' => array( |
|
1227 'misc/vertical-tabs.js' => array(), |
|
1228 ), |
|
1229 'css' => array( |
|
1230 'misc/vertical-tabs.css' => array(), |
|
1231 ), |
|
1232 'dependencies' => array( |
|
1233 // Vertical tabs relies on drupalGetSummary in form.js |
|
1234 array('system', 'drupal.form'), |
|
1235 ), |
|
1236 ); |
|
1237 |
|
1238 // Farbtastic. |
|
1239 $libraries['farbtastic'] = array( |
|
1240 'title' => 'Farbtastic', |
|
1241 'website' => 'http://code.google.com/p/farbtastic/', |
|
1242 'version' => '1.2', |
|
1243 'js' => array( |
|
1244 'misc/farbtastic/farbtastic.js' => array(), |
|
1245 ), |
|
1246 'css' => array( |
|
1247 'misc/farbtastic/farbtastic.css' => array(), |
|
1248 ), |
|
1249 ); |
|
1250 |
|
1251 // Cookie. |
|
1252 $libraries['jquery.cookie'] = array( |
|
1253 'title' => 'Cookie', |
|
1254 'website' => 'http://plugins.jquery.com/project/cookie', |
|
1255 'version' => '1.0', |
|
1256 'js' => array( |
|
1257 'misc/jquery.cookie.js' => array(), |
|
1258 ), |
|
1259 ); |
|
1260 |
|
1261 // jQuery UI. |
|
1262 $libraries['ui'] = array( |
|
1263 'title' => 'jQuery UI: Core', |
|
1264 'website' => 'http://jqueryui.com', |
|
1265 'version' => '1.8.7', |
|
1266 'js' => array( |
|
1267 'misc/ui/jquery.ui.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -11), |
|
1268 ), |
|
1269 'css' => array( |
|
1270 'misc/ui/jquery.ui.core.css' => array(), |
|
1271 'misc/ui/jquery.ui.theme.css' => array(), |
|
1272 ), |
|
1273 ); |
|
1274 $libraries['ui.accordion'] = array( |
|
1275 'title' => 'jQuery UI: Accordion', |
|
1276 'website' => 'http://jqueryui.com/demos/accordion/', |
|
1277 'version' => '1.8.7', |
|
1278 'js' => array( |
|
1279 'misc/ui/jquery.ui.accordion.min.js' => array(), |
|
1280 ), |
|
1281 'css' => array( |
|
1282 'misc/ui/jquery.ui.accordion.css' => array(), |
|
1283 ), |
|
1284 'dependencies' => array( |
|
1285 array('system', 'ui.widget'), |
|
1286 ), |
|
1287 ); |
|
1288 $libraries['ui.autocomplete'] = array( |
|
1289 'title' => 'jQuery UI: Autocomplete', |
|
1290 'website' => 'http://jqueryui.com/demos/autocomplete/', |
|
1291 'version' => '1.8.7', |
|
1292 'js' => array( |
|
1293 'misc/ui/jquery.ui.autocomplete.min.js' => array(), |
|
1294 ), |
|
1295 'css' => array( |
|
1296 'misc/ui/jquery.ui.autocomplete.css' => array(), |
|
1297 ), |
|
1298 'dependencies' => array( |
|
1299 array('system', 'ui.widget'), |
|
1300 array('system', 'ui.position'), |
|
1301 ), |
|
1302 ); |
|
1303 $libraries['ui.button'] = array( |
|
1304 'title' => 'jQuery UI: Button', |
|
1305 'website' => 'http://jqueryui.com/demos/button/', |
|
1306 'version' => '1.8.7', |
|
1307 'js' => array( |
|
1308 'misc/ui/jquery.ui.button.min.js' => array(), |
|
1309 ), |
|
1310 'css' => array( |
|
1311 'misc/ui/jquery.ui.button.css' => array(), |
|
1312 ), |
|
1313 'dependencies' => array( |
|
1314 array('system', 'ui.widget'), |
|
1315 ), |
|
1316 ); |
|
1317 $libraries['ui.datepicker'] = array( |
|
1318 'title' => 'jQuery UI: Date Picker', |
|
1319 'website' => 'http://jqueryui.com/demos/datepicker/', |
|
1320 'version' => '1.8.7', |
|
1321 'js' => array( |
|
1322 'misc/ui/jquery.ui.datepicker.min.js' => array(), |
|
1323 ), |
|
1324 'css' => array( |
|
1325 'misc/ui/jquery.ui.datepicker.css' => array(), |
|
1326 ), |
|
1327 'dependencies' => array( |
|
1328 array('system', 'ui'), |
|
1329 ), |
|
1330 ); |
|
1331 $libraries['ui.dialog'] = array( |
|
1332 'title' => 'jQuery UI: Dialog', |
|
1333 'website' => 'http://jqueryui.com/demos/dialog/', |
|
1334 'version' => '1.8.7', |
|
1335 'js' => array( |
|
1336 'misc/ui/jquery.ui.dialog.min.js' => array(), |
|
1337 ), |
|
1338 'css' => array( |
|
1339 'misc/ui/jquery.ui.dialog.css' => array(), |
|
1340 ), |
|
1341 'dependencies' => array( |
|
1342 array('system', 'ui.widget'), |
|
1343 array('system', 'ui.button'), |
|
1344 array('system', 'ui.draggable'), |
|
1345 array('system', 'ui.mouse'), |
|
1346 array('system', 'ui.position'), |
|
1347 array('system', 'ui.resizable'), |
|
1348 ), |
|
1349 ); |
|
1350 $libraries['ui.draggable'] = array( |
|
1351 'title' => 'jQuery UI: Draggable', |
|
1352 'website' => 'http://jqueryui.com/demos/draggable/', |
|
1353 'version' => '1.8.7', |
|
1354 'js' => array( |
|
1355 'misc/ui/jquery.ui.draggable.min.js' => array(), |
|
1356 ), |
|
1357 'dependencies' => array( |
|
1358 array('system', 'ui.widget'), |
|
1359 array('system', 'ui.mouse'), |
|
1360 ), |
|
1361 ); |
|
1362 $libraries['ui.droppable'] = array( |
|
1363 'title' => 'jQuery UI: Droppable', |
|
1364 'website' => 'http://jqueryui.com/demos/droppable/', |
|
1365 'version' => '1.8.7', |
|
1366 'js' => array( |
|
1367 'misc/ui/jquery.ui.droppable.min.js' => array(), |
|
1368 ), |
|
1369 'dependencies' => array( |
|
1370 array('system', 'ui.widget'), |
|
1371 array('system', 'ui.mouse'), |
|
1372 array('system', 'ui.draggable'), |
|
1373 ), |
|
1374 ); |
|
1375 $libraries['ui.mouse'] = array( |
|
1376 'title' => 'jQuery UI: Mouse', |
|
1377 'website' => 'http://docs.jquery.com/UI/Mouse', |
|
1378 'version' => '1.8.7', |
|
1379 'js' => array( |
|
1380 'misc/ui/jquery.ui.mouse.min.js' => array(), |
|
1381 ), |
|
1382 'dependencies' => array( |
|
1383 array('system', 'ui.widget'), |
|
1384 ), |
|
1385 ); |
|
1386 $libraries['ui.position'] = array( |
|
1387 'title' => 'jQuery UI: Position', |
|
1388 'website' => 'http://jqueryui.com/demos/position/', |
|
1389 'version' => '1.8.7', |
|
1390 'js' => array( |
|
1391 'misc/ui/jquery.ui.position.min.js' => array(), |
|
1392 ), |
|
1393 ); |
|
1394 $libraries['ui.progressbar'] = array( |
|
1395 'title' => 'jQuery UI: Progress Bar', |
|
1396 'website' => 'http://jqueryui.com/demos/progressbar/', |
|
1397 'version' => '1.8.7', |
|
1398 'js' => array( |
|
1399 'misc/ui/jquery.ui.progressbar.min.js' => array(), |
|
1400 ), |
|
1401 'css' => array( |
|
1402 'misc/ui/jquery.ui.progressbar.css' => array(), |
|
1403 ), |
|
1404 'dependencies' => array( |
|
1405 array('system', 'ui.widget'), |
|
1406 ), |
|
1407 ); |
|
1408 $libraries['ui.resizable'] = array( |
|
1409 'title' => 'jQuery UI: Resizable', |
|
1410 'website' => 'http://jqueryui.com/demos/resizable/', |
|
1411 'version' => '1.8.7', |
|
1412 'js' => array( |
|
1413 'misc/ui/jquery.ui.resizable.min.js' => array(), |
|
1414 ), |
|
1415 'css' => array( |
|
1416 'misc/ui/jquery.ui.resizable.css' => array(), |
|
1417 ), |
|
1418 'dependencies' => array( |
|
1419 array('system', 'ui.widget'), |
|
1420 array('system', 'ui.mouse'), |
|
1421 ), |
|
1422 ); |
|
1423 $libraries['ui.selectable'] = array( |
|
1424 'title' => 'jQuery UI: Selectable', |
|
1425 'website' => 'http://jqueryui.com/demos/selectable/', |
|
1426 'version' => '1.8.7', |
|
1427 'js' => array( |
|
1428 'misc/ui/jquery.ui.selectable.min.js' => array(), |
|
1429 ), |
|
1430 'css' => array( |
|
1431 'misc/ui/jquery.ui.selectable.css' => array(), |
|
1432 ), |
|
1433 'dependencies' => array( |
|
1434 array('system', 'ui.widget'), |
|
1435 array('system', 'ui.mouse'), |
|
1436 ), |
|
1437 ); |
|
1438 $libraries['ui.slider'] = array( |
|
1439 'title' => 'jQuery UI: Slider', |
|
1440 'website' => 'http://jqueryui.com/demos/slider/', |
|
1441 'version' => '1.8.7', |
|
1442 'js' => array( |
|
1443 'misc/ui/jquery.ui.slider.min.js' => array(), |
|
1444 ), |
|
1445 'css' => array( |
|
1446 'misc/ui/jquery.ui.slider.css' => array(), |
|
1447 ), |
|
1448 'dependencies' => array( |
|
1449 array('system', 'ui.widget'), |
|
1450 array('system', 'ui.mouse'), |
|
1451 ), |
|
1452 ); |
|
1453 $libraries['ui.sortable'] = array( |
|
1454 'title' => 'jQuery UI: Sortable', |
|
1455 'website' => 'http://jqueryui.com/demos/sortable/', |
|
1456 'version' => '1.8.7', |
|
1457 'js' => array( |
|
1458 'misc/ui/jquery.ui.sortable.min.js' => array(), |
|
1459 ), |
|
1460 'dependencies' => array( |
|
1461 array('system', 'ui.widget'), |
|
1462 array('system', 'ui.mouse'), |
|
1463 ), |
|
1464 ); |
|
1465 $libraries['ui.tabs'] = array( |
|
1466 'title' => 'jQuery UI: Tabs', |
|
1467 'website' => 'http://jqueryui.com/demos/tabs/', |
|
1468 'version' => '1.8.7', |
|
1469 'js' => array( |
|
1470 'misc/ui/jquery.ui.tabs.min.js' => array(), |
|
1471 ), |
|
1472 'css' => array( |
|
1473 'misc/ui/jquery.ui.tabs.css' => array(), |
|
1474 ), |
|
1475 'dependencies' => array( |
|
1476 array('system', 'ui.widget'), |
|
1477 ), |
|
1478 ); |
|
1479 $libraries['ui.widget'] = array( |
|
1480 'title' => 'jQuery UI: Widget', |
|
1481 'website' => 'http://docs.jquery.com/UI/Widget', |
|
1482 'version' => '1.8.7', |
|
1483 'js' => array( |
|
1484 'misc/ui/jquery.ui.widget.min.js' => array('group' => JS_LIBRARY, 'weight' => -10), |
|
1485 ), |
|
1486 'dependencies' => array( |
|
1487 array('system', 'ui'), |
|
1488 ), |
|
1489 ); |
|
1490 $libraries['effects'] = array( |
|
1491 'title' => 'jQuery UI: Effects', |
|
1492 'website' => 'http://jqueryui.com/demos/effect/', |
|
1493 'version' => '1.8.7', |
|
1494 'js' => array( |
|
1495 'misc/ui/jquery.effects.core.min.js' => array('group' => JS_LIBRARY, 'weight' => -9), |
|
1496 ), |
|
1497 ); |
|
1498 $libraries['effects.blind'] = array( |
|
1499 'title' => 'jQuery UI: Effects Blind', |
|
1500 'website' => 'http://jqueryui.com/demos/effect/', |
|
1501 'version' => '1.8.7', |
|
1502 'js' => array( |
|
1503 'misc/ui/jquery.effects.blind.min.js' => array(), |
|
1504 ), |
|
1505 'dependencies' => array( |
|
1506 array('system', 'effects'), |
|
1507 ), |
|
1508 ); |
|
1509 $libraries['effects.bounce'] = array( |
|
1510 'title' => 'jQuery UI: Effects Bounce', |
|
1511 'website' => 'http://jqueryui.com/demos/effect/', |
|
1512 'version' => '1.8.7', |
|
1513 'js' => array( |
|
1514 'misc/ui/jquery.effects.bounce.min.js' => array(), |
|
1515 ), |
|
1516 'dependencies' => array( |
|
1517 array('system', 'effects'), |
|
1518 ), |
|
1519 ); |
|
1520 $libraries['effects.clip'] = array( |
|
1521 'title' => 'jQuery UI: Effects Clip', |
|
1522 'website' => 'http://jqueryui.com/demos/effect/', |
|
1523 'version' => '1.8.7', |
|
1524 'js' => array( |
|
1525 'misc/ui/jquery.effects.clip.min.js' => array(), |
|
1526 ), |
|
1527 'dependencies' => array( |
|
1528 array('system', 'effects'), |
|
1529 ), |
|
1530 ); |
|
1531 $libraries['effects.drop'] = array( |
|
1532 'title' => 'jQuery UI: Effects Drop', |
|
1533 'website' => 'http://jqueryui.com/demos/effect/', |
|
1534 'version' => '1.8.7', |
|
1535 'js' => array( |
|
1536 'misc/ui/jquery.effects.drop.min.js' => array(), |
|
1537 ), |
|
1538 'dependencies' => array( |
|
1539 array('system', 'effects'), |
|
1540 ), |
|
1541 ); |
|
1542 $libraries['effects.explode'] = array( |
|
1543 'title' => 'jQuery UI: Effects Explode', |
|
1544 'website' => 'http://jqueryui.com/demos/effect/', |
|
1545 'version' => '1.8.7', |
|
1546 'js' => array( |
|
1547 'misc/ui/jquery.effects.explode.min.js' => array(), |
|
1548 ), |
|
1549 'dependencies' => array( |
|
1550 array('system', 'effects'), |
|
1551 ), |
|
1552 ); |
|
1553 $libraries['effects.fade'] = array( |
|
1554 'title' => 'jQuery UI: Effects Fade', |
|
1555 'website' => 'http://jqueryui.com/demos/effect/', |
|
1556 'version' => '1.8.7', |
|
1557 'js' => array( |
|
1558 'misc/ui/jquery.effects.fade.min.js' => array(), |
|
1559 ), |
|
1560 'dependencies' => array( |
|
1561 array('system', 'effects'), |
|
1562 ), |
|
1563 ); |
|
1564 $libraries['effects.fold'] = array( |
|
1565 'title' => 'jQuery UI: Effects Fold', |
|
1566 'website' => 'http://jqueryui.com/demos/effect/', |
|
1567 'version' => '1.8.7', |
|
1568 'js' => array( |
|
1569 'misc/ui/jquery.effects.fold.min.js' => array(), |
|
1570 ), |
|
1571 'dependencies' => array( |
|
1572 array('system', 'effects'), |
|
1573 ), |
|
1574 ); |
|
1575 $libraries['effects.highlight'] = array( |
|
1576 'title' => 'jQuery UI: Effects Highlight', |
|
1577 'website' => 'http://jqueryui.com/demos/effect/', |
|
1578 'version' => '1.8.7', |
|
1579 'js' => array( |
|
1580 'misc/ui/jquery.effects.highlight.min.js' => array(), |
|
1581 ), |
|
1582 'dependencies' => array( |
|
1583 array('system', 'effects'), |
|
1584 ), |
|
1585 ); |
|
1586 $libraries['effects.pulsate'] = array( |
|
1587 'title' => 'jQuery UI: Effects Pulsate', |
|
1588 'website' => 'http://jqueryui.com/demos/effect/', |
|
1589 'version' => '1.8.7', |
|
1590 'js' => array( |
|
1591 'misc/ui/jquery.effects.pulsate.min.js' => array(), |
|
1592 ), |
|
1593 'dependencies' => array( |
|
1594 array('system', 'effects'), |
|
1595 ), |
|
1596 ); |
|
1597 $libraries['effects.scale'] = array( |
|
1598 'title' => 'jQuery UI: Effects Scale', |
|
1599 'website' => 'http://jqueryui.com/demos/effect/', |
|
1600 'version' => '1.8.7', |
|
1601 'js' => array( |
|
1602 'misc/ui/jquery.effects.scale.min.js' => array(), |
|
1603 ), |
|
1604 'dependencies' => array( |
|
1605 array('system', 'effects'), |
|
1606 ), |
|
1607 ); |
|
1608 $libraries['effects.shake'] = array( |
|
1609 'title' => 'jQuery UI: Effects Shake', |
|
1610 'website' => 'http://jqueryui.com/demos/effect/', |
|
1611 'version' => '1.8.7', |
|
1612 'js' => array( |
|
1613 'misc/ui/jquery.effects.shake.min.js' => array(), |
|
1614 ), |
|
1615 'dependencies' => array( |
|
1616 array('system', 'effects'), |
|
1617 ), |
|
1618 ); |
|
1619 $libraries['effects.slide'] = array( |
|
1620 'title' => 'jQuery UI: Effects Slide', |
|
1621 'website' => 'http://jqueryui.com/demos/effect/', |
|
1622 'version' => '1.8.7', |
|
1623 'js' => array( |
|
1624 'misc/ui/jquery.effects.slide.min.js' => array(), |
|
1625 ), |
|
1626 'dependencies' => array( |
|
1627 array('system', 'effects'), |
|
1628 ), |
|
1629 ); |
|
1630 $libraries['effects.transfer'] = array( |
|
1631 'title' => 'jQuery UI: Effects Transfer', |
|
1632 'website' => 'http://jqueryui.com/demos/effect/', |
|
1633 'version' => '1.8.7', |
|
1634 'js' => array( |
|
1635 'misc/ui/jquery.effects.transfer.min.js' => array(), |
|
1636 ), |
|
1637 'dependencies' => array( |
|
1638 array('system', 'effects'), |
|
1639 ), |
|
1640 ); |
|
1641 |
|
1642 // These library names are deprecated. Earlier versions of Drupal 7 didn't |
|
1643 // consistently namespace their libraries, so these names are included for |
|
1644 // backwards compatibility with those versions. |
|
1645 $libraries['once'] = &$libraries['jquery.once']; |
|
1646 $libraries['form'] = &$libraries['jquery.form']; |
|
1647 $libraries['jquery-bbq'] = &$libraries['jquery.bbq']; |
|
1648 $libraries['vertical-tabs'] = &$libraries['drupal.vertical-tabs']; |
|
1649 $libraries['cookie'] = &$libraries['jquery.cookie']; |
|
1650 |
|
1651 return $libraries; |
|
1652 } |
|
1653 |
|
1654 /** |
|
1655 * Implements hook_stream_wrappers(). |
|
1656 */ |
|
1657 function system_stream_wrappers() { |
|
1658 $wrappers = array( |
|
1659 'public' => array( |
|
1660 'name' => t('Public files'), |
|
1661 'class' => 'DrupalPublicStreamWrapper', |
|
1662 'description' => t('Public local files served by the webserver.'), |
|
1663 'type' => STREAM_WRAPPERS_LOCAL_NORMAL, |
|
1664 ), |
|
1665 'temporary' => array( |
|
1666 'name' => t('Temporary files'), |
|
1667 'class' => 'DrupalTemporaryStreamWrapper', |
|
1668 'description' => t('Temporary local files for upload and previews.'), |
|
1669 'type' => STREAM_WRAPPERS_LOCAL_HIDDEN, |
|
1670 ), |
|
1671 ); |
|
1672 |
|
1673 // Only register the private file stream wrapper if a file path has been set. |
|
1674 if (variable_get('file_private_path', FALSE)) { |
|
1675 $wrappers['private'] = array( |
|
1676 'name' => t('Private files'), |
|
1677 'class' => 'DrupalPrivateStreamWrapper', |
|
1678 'description' => t('Private local files served by Drupal.'), |
|
1679 'type' => STREAM_WRAPPERS_LOCAL_NORMAL, |
|
1680 ); |
|
1681 } |
|
1682 |
|
1683 return $wrappers; |
|
1684 } |
|
1685 |
|
1686 /** |
|
1687 * Retrieve a blocked IP address from the database. |
|
1688 * |
|
1689 * @param $iid integer |
|
1690 * The ID of the blocked IP address to retrieve. |
|
1691 * |
|
1692 * @return |
|
1693 * The blocked IP address from the database as an array. |
|
1694 */ |
|
1695 function blocked_ip_load($iid) { |
|
1696 return db_query("SELECT * FROM {blocked_ips} WHERE iid = :iid", array(':iid' => $iid))->fetchAssoc(); |
|
1697 } |
|
1698 |
|
1699 /** |
|
1700 * Menu item access callback - only admin or enabled themes can be accessed. |
|
1701 */ |
|
1702 function _system_themes_access($theme) { |
|
1703 return user_access('administer themes') && drupal_theme_access($theme); |
|
1704 } |
|
1705 |
|
1706 /** |
|
1707 * @defgroup authorize Authorized operations |
|
1708 * @{ |
|
1709 * Functions to run operations with elevated privileges via authorize.php. |
|
1710 * |
|
1711 * Because of the Update manager functionality included in Drupal core, there |
|
1712 * is a mechanism for running operations with elevated file system privileges, |
|
1713 * the top-level authorize.php script. This script runs at a reduced Drupal |
|
1714 * bootstrap level so that it is not reliant on the entire site being |
|
1715 * functional. The operations use a FileTransfer class to manipulate code |
|
1716 * installed on the system as the user that owns the files, not the user that |
|
1717 * the httpd is running as. |
|
1718 * |
|
1719 * The first setup is to define a callback function that should be authorized |
|
1720 * to run with the elevated privileges. This callback should take a |
|
1721 * FileTransfer as its first argument, although you can define an array of |
|
1722 * other arguments it should be invoked with. The callback should be placed in |
|
1723 * a separate .inc file that will be included by authorize.php. |
|
1724 * |
|
1725 * To run the operation, certain data must be saved into the SESSION, and then |
|
1726 * the flow of control should be redirected to the authorize.php script. There |
|
1727 * are two ways to do this, either to call system_authorized_run() directly, |
|
1728 * or to call system_authorized_init() and then redirect to authorize.php, |
|
1729 * using the URL from system_authorized_get_url(). Redirecting yourself is |
|
1730 * necessary when your authorized operation is being triggered by a form |
|
1731 * submit handler, since calling drupal_goto() in a submit handler is a bad |
|
1732 * idea, and you should instead set $form_state['redirect']. |
|
1733 * |
|
1734 * Once the SESSION is setup for the operation and the user is redirected to |
|
1735 * authorize.php, they will be prompted for their connection credentials (core |
|
1736 * provides FTP and SSH by default, although other connection classes can be |
|
1737 * added via contributed modules). With valid credentials, authorize.php will |
|
1738 * instantiate the appropriate FileTransfer object, and then invoke the |
|
1739 * desired operation passing in that object. The authorize.php script can act |
|
1740 * as a Batch API processing page, if the operation requires a batch. |
|
1741 * |
|
1742 * @see authorize.php |
|
1743 * @see FileTransfer |
|
1744 * @see hook_filetransfer_info() |
|
1745 */ |
|
1746 |
|
1747 /** |
|
1748 * Setup a given callback to run via authorize.php with elevated privileges. |
|
1749 * |
|
1750 * To use authorize.php, certain variables must be stashed into $_SESSION. This |
|
1751 * function sets up all the necessary $_SESSION variables. The calling function |
|
1752 * should then redirect to authorize.php, using the full path returned by |
|
1753 * system_authorized_get_url(). That initiates the workflow that will eventually |
|
1754 * lead to the callback being invoked. The callback will be invoked at a low |
|
1755 * bootstrap level, without all modules being invoked, so it needs to be careful |
|
1756 * not to assume any code exists. Example (system_authorized_run()): |
|
1757 * @code |
|
1758 * system_authorized_init($callback, $file, $arguments, $page_title); |
|
1759 * drupal_goto(system_authorized_get_url()); |
|
1760 * @endcode |
|
1761 * Example (update_manager_install_form_submit()): |
|
1762 * @code |
|
1763 * system_authorized_init('update_authorize_run_install', |
|
1764 * drupal_get_path('module', 'update') . '/update.authorize.inc', |
|
1765 * $arguments, t('Update manager')); |
|
1766 * $form_state['redirect'] = system_authorized_get_url(); |
|
1767 * @endcode |
|
1768 * |
|
1769 * @param $callback |
|
1770 * The name of the function to invoke once the user authorizes the operation. |
|
1771 * @param $file |
|
1772 * The full path to the file where the callback function is implemented. |
|
1773 * @param $arguments |
|
1774 * Optional array of arguments to pass into the callback when it is invoked. |
|
1775 * Note that the first argument to the callback is always the FileTransfer |
|
1776 * object created by authorize.php when the user authorizes the operation. |
|
1777 * @param $page_title |
|
1778 * Optional string to use as the page title once redirected to authorize.php. |
|
1779 * @return |
|
1780 * Nothing, this function just initializes variables in the user's session. |
|
1781 */ |
|
1782 function system_authorized_init($callback, $file, $arguments = array(), $page_title = NULL) { |
|
1783 // First, figure out what file transfer backends the site supports, and put |
|
1784 // all of those in the SESSION so that authorize.php has access to all of |
|
1785 // them via the class autoloader, even without a full bootstrap. |
|
1786 $_SESSION['authorize_filetransfer_info'] = drupal_get_filetransfer_info(); |
|
1787 |
|
1788 // Now, define the callback to invoke. |
|
1789 $_SESSION['authorize_operation'] = array( |
|
1790 'callback' => $callback, |
|
1791 'file' => $file, |
|
1792 'arguments' => $arguments, |
|
1793 ); |
|
1794 |
|
1795 if (isset($page_title)) { |
|
1796 $_SESSION['authorize_operation']['page_title'] = $page_title; |
|
1797 } |
|
1798 } |
|
1799 |
|
1800 /** |
|
1801 * Return the URL for the authorize.php script. |
|
1802 * |
|
1803 * @param array $options |
|
1804 * Optional array of options to pass to url(). |
|
1805 * @return |
|
1806 * The full URL to authorize.php, using HTTPS if available. |
|
1807 * |
|
1808 * @see system_authorized_init() |
|
1809 */ |
|
1810 function system_authorized_get_url(array $options = array()) { |
|
1811 global $base_url; |
|
1812 // Force HTTPS if available, regardless of what the caller specifies. |
|
1813 $options['https'] = TRUE; |
|
1814 // We prefix with $base_url so we get a full path even if clean URLs are |
|
1815 // disabled. |
|
1816 return url($base_url . '/authorize.php', $options); |
|
1817 } |
|
1818 |
|
1819 /** |
|
1820 * Returns the URL for the authorize.php script when it is processing a batch. |
|
1821 */ |
|
1822 function system_authorized_batch_processing_url() { |
|
1823 return system_authorized_get_url(array('query' => array('batch' => '1'))); |
|
1824 } |
|
1825 |
|
1826 /** |
|
1827 * Setup and invoke an operation using authorize.php. |
|
1828 * |
|
1829 * @see system_authorized_init() |
|
1830 */ |
|
1831 function system_authorized_run($callback, $file, $arguments = array(), $page_title = NULL) { |
|
1832 system_authorized_init($callback, $file, $arguments, $page_title); |
|
1833 drupal_goto(system_authorized_get_url()); |
|
1834 } |
|
1835 |
|
1836 /** |
|
1837 * Use authorize.php to run batch_process(). |
|
1838 * |
|
1839 * @see batch_process() |
|
1840 */ |
|
1841 function system_authorized_batch_process() { |
|
1842 $finish_url = system_authorized_get_url(); |
|
1843 $process_url = system_authorized_batch_processing_url(); |
|
1844 batch_process($finish_url, $process_url); |
|
1845 } |
|
1846 |
|
1847 /** |
|
1848 * @} End of "defgroup authorize". |
|
1849 */ |
|
1850 |
|
1851 /** |
|
1852 * Implements hook_updater_info(). |
|
1853 */ |
|
1854 function system_updater_info() { |
|
1855 return array( |
|
1856 'module' => array( |
|
1857 'class' => 'ModuleUpdater', |
|
1858 'name' => t('Update modules'), |
|
1859 'weight' => 0, |
|
1860 ), |
|
1861 'theme' => array( |
|
1862 'class' => 'ThemeUpdater', |
|
1863 'name' => t('Update themes'), |
|
1864 'weight' => 0, |
|
1865 ), |
|
1866 ); |
|
1867 } |
|
1868 |
|
1869 /** |
|
1870 * Implements hook_filetransfer_info(). |
|
1871 */ |
|
1872 function system_filetransfer_info() { |
|
1873 $backends = array(); |
|
1874 |
|
1875 // This is the default, will be available on most systems. |
|
1876 if (function_exists('ftp_connect')) { |
|
1877 $backends['ftp'] = array( |
|
1878 'title' => t('FTP'), |
|
1879 'class' => 'FileTransferFTP', |
|
1880 'file' => 'ftp.inc', |
|
1881 'file path' => 'includes/filetransfer', |
|
1882 'weight' => 0, |
|
1883 ); |
|
1884 } |
|
1885 |
|
1886 // SSH2 lib connection is only available if the proper PHP extension is |
|
1887 // installed. |
|
1888 if (function_exists('ssh2_connect')) { |
|
1889 $backends['ssh'] = array( |
|
1890 'title' => t('SSH'), |
|
1891 'class' => 'FileTransferSSH', |
|
1892 'file' => 'ssh.inc', |
|
1893 'file path' => 'includes/filetransfer', |
|
1894 'weight' => 20, |
|
1895 ); |
|
1896 } |
|
1897 return $backends; |
|
1898 } |
|
1899 |
|
1900 /** |
|
1901 * Implements hook_init(). |
|
1902 */ |
|
1903 function system_init() { |
|
1904 $path = drupal_get_path('module', 'system'); |
|
1905 // Add the CSS for this module. These aren't in system.info, because they |
|
1906 // need to be in the CSS_SYSTEM group rather than the CSS_DEFAULT group. |
|
1907 drupal_add_css($path . '/system.base.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE)); |
|
1908 if (path_is_admin(current_path())) { |
|
1909 drupal_add_css($path . '/system.admin.css', array('group' => CSS_SYSTEM)); |
|
1910 } |
|
1911 drupal_add_css($path . '/system.menus.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE)); |
|
1912 drupal_add_css($path . '/system.messages.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE)); |
|
1913 drupal_add_css($path . '/system.theme.css', array('group' => CSS_SYSTEM, 'every_page' => TRUE)); |
|
1914 |
|
1915 // Ignore slave database servers for this request. |
|
1916 // |
|
1917 // In Drupal's distributed database structure, new data is written to the |
|
1918 // master and then propagated to the slave servers. This means there is a |
|
1919 // lag between when data is written to the master and when it is available on |
|
1920 // the slave. At these times, we will want to avoid using a slave server |
|
1921 // temporarily. For example, if a user posts a new node then we want to |
|
1922 // disable the slave server for that user temporarily to allow the slave |
|
1923 // server to catch up. That way, that user will see their changes immediately |
|
1924 // while for other users we still get the benefits of having a slave server, |
|
1925 // just with slightly stale data. Code that wants to disable the slave |
|
1926 // server should use the db_ignore_slave() function to set |
|
1927 // $_SESSION['ignore_slave_server'] to the timestamp after which the slave |
|
1928 // can be re-enabled. |
|
1929 if (isset($_SESSION['ignore_slave_server'])) { |
|
1930 if ($_SESSION['ignore_slave_server'] >= REQUEST_TIME) { |
|
1931 Database::ignoreTarget('default', 'slave'); |
|
1932 } |
|
1933 else { |
|
1934 unset($_SESSION['ignore_slave_server']); |
|
1935 } |
|
1936 } |
|
1937 |
|
1938 // Add CSS/JS files from module .info files. |
|
1939 system_add_module_assets(); |
|
1940 } |
|
1941 |
|
1942 /** |
|
1943 * Adds CSS and JavaScript files declared in module .info files. |
|
1944 */ |
|
1945 function system_add_module_assets() { |
|
1946 foreach (system_get_info('module') as $module => $info) { |
|
1947 if (!empty($info['stylesheets'])) { |
|
1948 foreach ($info['stylesheets'] as $media => $stylesheets) { |
|
1949 foreach ($stylesheets as $stylesheet) { |
|
1950 drupal_add_css($stylesheet, array('every_page' => TRUE, 'media' => $media)); |
|
1951 } |
|
1952 } |
|
1953 } |
|
1954 if (!empty($info['scripts'])) { |
|
1955 foreach ($info['scripts'] as $script) { |
|
1956 drupal_add_js($script, array('every_page' => TRUE)); |
|
1957 } |
|
1958 } |
|
1959 } |
|
1960 } |
|
1961 |
|
1962 /** |
|
1963 * Implements hook_custom_theme(). |
|
1964 */ |
|
1965 function system_custom_theme() { |
|
1966 if (user_access('view the administration theme') && path_is_admin(current_path())) { |
|
1967 return variable_get('admin_theme'); |
|
1968 } |
|
1969 } |
|
1970 |
|
1971 /** |
|
1972 * Implements hook_form_FORM_ID_alter(). |
|
1973 */ |
|
1974 function system_form_user_profile_form_alter(&$form, &$form_state) { |
|
1975 if ($form['#user_category'] == 'account') { |
|
1976 if (variable_get('configurable_timezones', 1)) { |
|
1977 system_user_timezone($form, $form_state); |
|
1978 } |
|
1979 return $form; |
|
1980 } |
|
1981 } |
|
1982 |
|
1983 /** |
|
1984 * Implements hook_form_FORM_ID_alter(). |
|
1985 */ |
|
1986 function system_form_user_register_form_alter(&$form, &$form_state) { |
|
1987 if (variable_get('configurable_timezones', 1)) { |
|
1988 if (variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) == DRUPAL_USER_TIMEZONE_SELECT) { |
|
1989 system_user_timezone($form, $form_state); |
|
1990 } |
|
1991 else { |
|
1992 $form['account']['timezone'] = array( |
|
1993 '#type' => 'hidden', |
|
1994 '#value' => variable_get('user_default_timezone', DRUPAL_USER_TIMEZONE_DEFAULT) ? '' : variable_get('date_default_timezone', ''), |
|
1995 ); |
|
1996 } |
|
1997 return $form; |
|
1998 } |
|
1999 } |
|
2000 |
|
2001 /** |
|
2002 * Implements hook_user_login(). |
|
2003 */ |
|
2004 function system_user_login(&$edit, $account) { |
|
2005 // If the user has a NULL time zone, notify them to set a time zone. |
|
2006 if (!$account->timezone && variable_get('configurable_timezones', 1) && variable_get('empty_timezone_message', 0)) { |
|
2007 drupal_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/$account->uid/edit", array('query' => drupal_get_destination(), 'fragment' => 'edit-timezone'))))); |
|
2008 } |
|
2009 } |
|
2010 |
|
2011 /** |
|
2012 * Add the time zone field to the user edit and register forms. |
|
2013 */ |
|
2014 function system_user_timezone(&$form, &$form_state) { |
|
2015 global $user; |
|
2016 |
|
2017 $account = $form['#user']; |
|
2018 |
|
2019 $form['timezone'] = array( |
|
2020 '#type' => 'fieldset', |
|
2021 '#title' => t('Locale settings'), |
|
2022 '#weight' => 6, |
|
2023 '#collapsible' => TRUE, |
|
2024 ); |
|
2025 $form['timezone']['timezone'] = array( |
|
2026 '#type' => 'select', |
|
2027 '#title' => t('Time zone'), |
|
2028 '#default_value' => isset($account->timezone) ? $account->timezone : ($account->uid == $user->uid ? variable_get('date_default_timezone', '') : ''), |
|
2029 '#options' => system_time_zones($account->uid != $user->uid), |
|
2030 '#description' => t('Select the desired local time and time zone. Dates and times throughout this site will be displayed using this time zone.'), |
|
2031 ); |
|
2032 if (!isset($account->timezone) && $account->uid == $user->uid && empty($form_state['input']['timezone'])) { |
|
2033 $form['timezone']['timezone']['#attributes'] = array('class' => array('timezone-detect')); |
|
2034 drupal_add_js('misc/timezone.js'); |
|
2035 } |
|
2036 } |
|
2037 |
|
2038 /** |
|
2039 * Implements hook_block_info(). |
|
2040 */ |
|
2041 function system_block_info() { |
|
2042 $blocks['main'] = array( |
|
2043 'info' => t('Main page content'), |
|
2044 // Cached elsewhere. |
|
2045 'cache' => DRUPAL_NO_CACHE, |
|
2046 // Auto-enable in 'content' region by default, which always exists. |
|
2047 // @see system_themes_page(), drupal_render_page() |
|
2048 'status' => 1, |
|
2049 'region' => 'content', |
|
2050 ); |
|
2051 $blocks['powered-by'] = array( |
|
2052 'info' => t('Powered by Drupal'), |
|
2053 'weight' => '10', |
|
2054 'cache' => DRUPAL_NO_CACHE, |
|
2055 ); |
|
2056 $blocks['help'] = array( |
|
2057 'info' => t('System help'), |
|
2058 'weight' => '5', |
|
2059 'cache' => DRUPAL_NO_CACHE, |
|
2060 // Auto-enable in 'help' region by default, if the theme defines one. |
|
2061 'status' => 1, |
|
2062 'region' => 'help', |
|
2063 ); |
|
2064 // System-defined menu blocks. |
|
2065 foreach (menu_list_system_menus() as $menu_name => $title) { |
|
2066 $blocks[$menu_name]['info'] = t($title); |
|
2067 // Menu blocks can't be cached because each menu item can have |
|
2068 // a custom access callback. menu.inc manages its own caching. |
|
2069 $blocks[$menu_name]['cache'] = DRUPAL_NO_CACHE; |
|
2070 } |
|
2071 return $blocks; |
|
2072 } |
|
2073 |
|
2074 /** |
|
2075 * Implements hook_block_view(). |
|
2076 * |
|
2077 * Generate a block with a promotional link to Drupal.org and |
|
2078 * all system menu blocks. |
|
2079 */ |
|
2080 function system_block_view($delta = '') { |
|
2081 $block = array(); |
|
2082 switch ($delta) { |
|
2083 case 'main': |
|
2084 $block['subject'] = NULL; |
|
2085 $block['content'] = drupal_set_page_content(); |
|
2086 return $block; |
|
2087 case 'powered-by': |
|
2088 $block['subject'] = NULL; |
|
2089 $block['content'] = theme('system_powered_by'); |
|
2090 return $block; |
|
2091 case 'help': |
|
2092 $block['subject'] = NULL; |
|
2093 $block['content'] = menu_get_active_help(); |
|
2094 return $block; |
|
2095 default: |
|
2096 // All system menu blocks. |
|
2097 $system_menus = menu_list_system_menus(); |
|
2098 if (isset($system_menus[$delta])) { |
|
2099 $block['subject'] = t($system_menus[$delta]); |
|
2100 $block['content'] = menu_tree($delta); |
|
2101 return $block; |
|
2102 } |
|
2103 break; |
|
2104 } |
|
2105 } |
|
2106 |
|
2107 /** |
|
2108 * Implements hook_preprocess_block(). |
|
2109 */ |
|
2110 function system_preprocess_block(&$variables) { |
|
2111 // System menu blocks should get the same class as menu module blocks. |
|
2112 if ($variables['block']->module == 'system' && in_array($variables['block']->delta, array_keys(menu_list_system_menus()))) { |
|
2113 $variables['classes_array'][] = 'block-menu'; |
|
2114 } |
|
2115 } |
|
2116 |
|
2117 /** |
|
2118 * Provide a single block on the administration overview page. |
|
2119 * |
|
2120 * @param $item |
|
2121 * The menu item to be displayed. |
|
2122 */ |
|
2123 function system_admin_menu_block($item) { |
|
2124 $cache = &drupal_static(__FUNCTION__, array()); |
|
2125 // If we are calling this function for a menu item that corresponds to a |
|
2126 // local task (for example, admin/tasks), then we want to retrieve the |
|
2127 // parent item's child links, not this item's (since this item won't have |
|
2128 // any). |
|
2129 if ($item['tab_root'] != $item['path']) { |
|
2130 $item = menu_get_item($item['tab_root_href']); |
|
2131 } |
|
2132 |
|
2133 if (!isset($item['mlid'])) { |
|
2134 $item += db_query("SELECT mlid, menu_name FROM {menu_links} ml WHERE ml.router_path = :path AND module = 'system'", array(':path' => $item['path']))->fetchAssoc(); |
|
2135 } |
|
2136 |
|
2137 if (isset($cache[$item['mlid']])) { |
|
2138 return $cache[$item['mlid']]; |
|
2139 } |
|
2140 |
|
2141 $content = array(); |
|
2142 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)); |
|
2143 $query->join('menu_router', 'm', 'm.path = ml.router_path'); |
|
2144 $query |
|
2145 ->fields('ml') |
|
2146 // Weight should be taken from {menu_links}, not {menu_router}. |
|
2147 ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight'))) |
|
2148 ->condition('ml.plid', $item['mlid']) |
|
2149 ->condition('ml.menu_name', $item['menu_name']) |
|
2150 ->condition('ml.hidden', 0); |
|
2151 |
|
2152 foreach ($query->execute() as $link) { |
|
2153 _menu_link_translate($link); |
|
2154 if ($link['access']) { |
|
2155 // The link description, either derived from 'description' in |
|
2156 // hook_menu() or customized via menu module is used as title attribute. |
|
2157 if (!empty($link['localized_options']['attributes']['title'])) { |
|
2158 $link['description'] = $link['localized_options']['attributes']['title']; |
|
2159 unset($link['localized_options']['attributes']['title']); |
|
2160 } |
|
2161 // Prepare for sorting as in function _menu_tree_check_access(). |
|
2162 // The weight is offset so it is always positive, with a uniform 5-digits. |
|
2163 $key = (50000 + $link['weight']) . ' ' . drupal_strtolower($link['title']) . ' ' . $link['mlid']; |
|
2164 $content[$key] = $link; |
|
2165 } |
|
2166 } |
|
2167 ksort($content); |
|
2168 $cache[$item['mlid']] = $content; |
|
2169 return $content; |
|
2170 } |
|
2171 |
|
2172 /** |
|
2173 * Checks the existence of the directory specified in $form_element. |
|
2174 * |
|
2175 * This function is called from the system_settings form to check all core |
|
2176 * file directories (file_public_path, file_private_path, file_temporary_path). |
|
2177 * |
|
2178 * @param $form_element |
|
2179 * The form element containing the name of the directory to check. |
|
2180 */ |
|
2181 function system_check_directory($form_element) { |
|
2182 $directory = $form_element['#value']; |
|
2183 if (strlen($directory) == 0) { |
|
2184 return $form_element; |
|
2185 } |
|
2186 |
|
2187 if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) { |
|
2188 // If the directory does not exists and cannot be created. |
|
2189 form_set_error($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory))); |
|
2190 watchdog('file system', 'The directory %directory does not exist and could not be created.', array('%directory' => $directory), WATCHDOG_ERROR); |
|
2191 } |
|
2192 |
|
2193 if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) { |
|
2194 // If the directory is not writable and cannot be made so. |
|
2195 form_set_error($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory))); |
|
2196 watchdog('file system', 'The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory), WATCHDOG_ERROR); |
|
2197 } |
|
2198 elseif (is_dir($directory)) { |
|
2199 if ($form_element['#name'] == 'file_public_path') { |
|
2200 // Create public .htaccess file. |
|
2201 file_create_htaccess($directory, FALSE); |
|
2202 } |
|
2203 else { |
|
2204 // Create private .htaccess file. |
|
2205 file_create_htaccess($directory); |
|
2206 } |
|
2207 } |
|
2208 |
|
2209 return $form_element; |
|
2210 } |
|
2211 |
|
2212 /** |
|
2213 * Retrieves the current status of an array of files in the system table. |
|
2214 * |
|
2215 * @param $files |
|
2216 * An array of files to check. |
|
2217 * @param $type |
|
2218 * The type of the files. |
|
2219 */ |
|
2220 function system_get_files_database(&$files, $type) { |
|
2221 // Extract current files from database. |
|
2222 $result = db_query("SELECT filename, name, type, status, schema_version, weight FROM {system} WHERE type = :type", array(':type' => $type)); |
|
2223 foreach ($result as $file) { |
|
2224 if (isset($files[$file->name]) && is_object($files[$file->name])) { |
|
2225 $file->uri = $file->filename; |
|
2226 foreach ($file as $key => $value) { |
|
2227 if (!isset($files[$file->name]->$key)) { |
|
2228 $files[$file->name]->$key = $value; |
|
2229 } |
|
2230 } |
|
2231 } |
|
2232 } |
|
2233 } |
|
2234 |
|
2235 /** |
|
2236 * Updates the records in the system table based on the files array. |
|
2237 * |
|
2238 * @param $files |
|
2239 * An array of files. |
|
2240 * @param $type |
|
2241 * The type of the files. |
|
2242 */ |
|
2243 function system_update_files_database(&$files, $type) { |
|
2244 $result = db_query("SELECT * FROM {system} WHERE type = :type", array(':type' => $type)); |
|
2245 |
|
2246 // Add all files that need to be deleted to a DatabaseCondition. |
|
2247 $delete = db_or(); |
|
2248 foreach ($result as $file) { |
|
2249 if (isset($files[$file->name]) && is_object($files[$file->name])) { |
|
2250 // Keep the old filename from the database in case the file has moved. |
|
2251 $old_filename = $file->filename; |
|
2252 |
|
2253 $updated_fields = array(); |
|
2254 |
|
2255 // Handle info specially, compare the serialized value. |
|
2256 $serialized_info = serialize($files[$file->name]->info); |
|
2257 if ($serialized_info != $file->info) { |
|
2258 $updated_fields['info'] = $serialized_info; |
|
2259 } |
|
2260 unset($file->info); |
|
2261 |
|
2262 // Scan remaining fields to find only the updated values. |
|
2263 foreach ($file as $key => $value) { |
|
2264 if (isset($files[$file->name]->$key) && $files[$file->name]->$key != $value) { |
|
2265 $updated_fields[$key] = $files[$file->name]->$key; |
|
2266 } |
|
2267 } |
|
2268 |
|
2269 // Update the record. |
|
2270 if (count($updated_fields)) { |
|
2271 db_update('system') |
|
2272 ->fields($updated_fields) |
|
2273 ->condition('filename', $old_filename) |
|
2274 ->execute(); |
|
2275 } |
|
2276 |
|
2277 // Indicate that the file exists already. |
|
2278 $files[$file->name]->exists = TRUE; |
|
2279 } |
|
2280 else { |
|
2281 // File is not found in file system, so delete record from the system table. |
|
2282 $delete->condition('filename', $file->filename); |
|
2283 } |
|
2284 } |
|
2285 |
|
2286 if (count($delete) > 0) { |
|
2287 // Delete all missing files from the system table, but only if the plugin |
|
2288 // has never been installed. |
|
2289 db_delete('system') |
|
2290 ->condition($delete) |
|
2291 ->condition('schema_version', -1) |
|
2292 ->execute(); |
|
2293 } |
|
2294 |
|
2295 // All remaining files are not in the system table, so we need to add them. |
|
2296 $query = db_insert('system')->fields(array('filename', 'name', 'type', 'owner', 'info')); |
|
2297 foreach ($files as &$file) { |
|
2298 if (isset($file->exists)) { |
|
2299 unset($file->exists); |
|
2300 } |
|
2301 else { |
|
2302 $query->values(array( |
|
2303 'filename' => $file->uri, |
|
2304 'name' => $file->name, |
|
2305 'type' => $type, |
|
2306 'owner' => isset($file->owner) ? $file->owner : '', |
|
2307 'info' => serialize($file->info), |
|
2308 )); |
|
2309 $file->type = $type; |
|
2310 $file->status = 0; |
|
2311 $file->schema_version = -1; |
|
2312 } |
|
2313 } |
|
2314 $query->execute(); |
|
2315 |
|
2316 // If any module or theme was moved to a new location, we need to reset the |
|
2317 // system_list() cache or we will continue to load the old copy, look for |
|
2318 // schema updates in the wrong place, etc. |
|
2319 system_list_reset(); |
|
2320 } |
|
2321 |
|
2322 /** |
|
2323 * Returns an array of information about enabled modules or themes. |
|
2324 * |
|
2325 * This function returns the information from the {system} table corresponding |
|
2326 * to the cached contents of the .info file for each active module or theme. |
|
2327 * |
|
2328 * @param $type |
|
2329 * Either 'module' or 'theme'. |
|
2330 * @param $name |
|
2331 * (optional) The name of a module or theme whose information shall be |
|
2332 * returned. If omitted, all records for the provided $type will be returned. |
|
2333 * If $name does not exist in the provided $type or is not enabled, an empty |
|
2334 * array will be returned. |
|
2335 * |
|
2336 * @return |
|
2337 * An associative array of module or theme information keyed by name, or only |
|
2338 * information for $name, if given. If no records are available, an empty |
|
2339 * array is returned. |
|
2340 * |
|
2341 * @see system_rebuild_module_data() |
|
2342 * @see system_rebuild_theme_data() |
|
2343 */ |
|
2344 function system_get_info($type, $name = NULL) { |
|
2345 $info = array(); |
|
2346 if ($type == 'module') { |
|
2347 $type = 'module_enabled'; |
|
2348 } |
|
2349 $list = system_list($type); |
|
2350 foreach ($list as $shortname => $item) { |
|
2351 if (!empty($item->status)) { |
|
2352 $info[$shortname] = $item->info; |
|
2353 } |
|
2354 } |
|
2355 if (isset($name)) { |
|
2356 return isset($info[$name]) ? $info[$name] : array(); |
|
2357 } |
|
2358 return $info; |
|
2359 } |
|
2360 |
|
2361 /** |
|
2362 * Helper function to scan and collect module .info data. |
|
2363 * |
|
2364 * @return |
|
2365 * An associative array of module information. |
|
2366 */ |
|
2367 function _system_rebuild_module_data() { |
|
2368 // Find modules |
|
2369 $modules = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.module$/', 'modules', 'name', 0); |
|
2370 |
|
2371 // Include the installation profile in modules that are loaded. |
|
2372 $profile = drupal_get_profile(); |
|
2373 $modules[$profile] = new stdClass(); |
|
2374 $modules[$profile]->name = $profile; |
|
2375 $modules[$profile]->uri = 'profiles/' . $profile . '/' . $profile . '.profile'; |
|
2376 $modules[$profile]->filename = $profile . '.profile'; |
|
2377 |
|
2378 // Installation profile hooks are always executed last. |
|
2379 $modules[$profile]->weight = 1000; |
|
2380 |
|
2381 // Set defaults for module info. |
|
2382 $defaults = array( |
|
2383 'dependencies' => array(), |
|
2384 'description' => '', |
|
2385 'package' => 'Other', |
|
2386 'version' => NULL, |
|
2387 'php' => DRUPAL_MINIMUM_PHP, |
|
2388 'files' => array(), |
|
2389 'bootstrap' => 0, |
|
2390 ); |
|
2391 |
|
2392 // Read info files for each module. |
|
2393 foreach ($modules as $key => $module) { |
|
2394 // The module system uses the key 'filename' instead of 'uri' so copy the |
|
2395 // value so it will be used by the modules system. |
|
2396 $modules[$key]->filename = $module->uri; |
|
2397 |
|
2398 // Look for the info file. |
|
2399 $module->info = drupal_parse_info_file(dirname($module->uri) . '/' . $module->name . '.info'); |
|
2400 |
|
2401 // Skip modules that don't provide info. |
|
2402 if (empty($module->info)) { |
|
2403 unset($modules[$key]); |
|
2404 continue; |
|
2405 } |
|
2406 |
|
2407 // Add the info file modification time, so it becomes available for |
|
2408 // contributed modules to use for ordering module lists. |
|
2409 $module->info['mtime'] = filemtime(dirname($module->uri) . '/' . $module->name . '.info'); |
|
2410 |
|
2411 // Merge in defaults and save. |
|
2412 $modules[$key]->info = $module->info + $defaults; |
|
2413 |
|
2414 // The "name" key is required, but to avoid a fatal error in the menu system |
|
2415 // we set a reasonable default if it is not provided. |
|
2416 $modules[$key]->info += array('name' => $key); |
|
2417 |
|
2418 // Prefix stylesheets and scripts with module path. |
|
2419 $path = dirname($module->uri); |
|
2420 if (isset($module->info['stylesheets'])) { |
|
2421 $module->info['stylesheets'] = _system_info_add_path($module->info['stylesheets'], $path); |
|
2422 } |
|
2423 if (isset($module->info['scripts'])) { |
|
2424 $module->info['scripts'] = _system_info_add_path($module->info['scripts'], $path); |
|
2425 } |
|
2426 |
|
2427 // Installation profiles are hidden by default, unless explicitly specified |
|
2428 // otherwise in the .info file. |
|
2429 if ($key == $profile && !isset($modules[$key]->info['hidden'])) { |
|
2430 $modules[$key]->info['hidden'] = TRUE; |
|
2431 } |
|
2432 |
|
2433 // Invoke hook_system_info_alter() to give installed modules a chance to |
|
2434 // modify the data in the .info files if necessary. |
|
2435 $type = 'module'; |
|
2436 drupal_alter('system_info', $modules[$key]->info, $modules[$key], $type); |
|
2437 } |
|
2438 |
|
2439 if (isset($modules[$profile])) { |
|
2440 // The installation profile is required, if it's a valid module. |
|
2441 $modules[$profile]->info['required'] = TRUE; |
|
2442 // Add a default distribution name if the profile did not provide one. This |
|
2443 // matches the default value used in install_profile_info(). |
|
2444 if (!isset($modules[$profile]->info['distribution_name'])) { |
|
2445 $modules[$profile]->info['distribution_name'] = 'Drupal'; |
|
2446 } |
|
2447 } |
|
2448 |
|
2449 return $modules; |
|
2450 } |
|
2451 |
|
2452 /** |
|
2453 * Rebuild, save, and return data about all currently available modules. |
|
2454 * |
|
2455 * @return |
|
2456 * Array of all available modules and their data. |
|
2457 */ |
|
2458 function system_rebuild_module_data() { |
|
2459 $modules_cache = &drupal_static(__FUNCTION__); |
|
2460 // Only rebuild once per request. $modules and $modules_cache cannot be |
|
2461 // combined into one variable, because the $modules_cache variable is reset by |
|
2462 // reference from system_list_reset() during the rebuild. |
|
2463 if (!isset($modules_cache)) { |
|
2464 $modules = _system_rebuild_module_data(); |
|
2465 ksort($modules); |
|
2466 system_get_files_database($modules, 'module'); |
|
2467 system_update_files_database($modules, 'module'); |
|
2468 $modules = _module_build_dependencies($modules); |
|
2469 $modules_cache = $modules; |
|
2470 } |
|
2471 return $modules_cache; |
|
2472 } |
|
2473 |
|
2474 /** |
|
2475 * Refresh bootstrap column in the system table. |
|
2476 * |
|
2477 * This is called internally by module_enable/disable() to flag modules that |
|
2478 * implement hooks used during bootstrap, such as hook_boot(). These modules |
|
2479 * are loaded earlier to invoke the hooks. |
|
2480 */ |
|
2481 function _system_update_bootstrap_status() { |
|
2482 $bootstrap_modules = array(); |
|
2483 foreach (bootstrap_hooks() as $hook) { |
|
2484 foreach (module_implements($hook) as $module) { |
|
2485 $bootstrap_modules[] = $module; |
|
2486 } |
|
2487 } |
|
2488 $query = db_update('system')->fields(array('bootstrap' => 0)); |
|
2489 if ($bootstrap_modules) { |
|
2490 db_update('system') |
|
2491 ->fields(array('bootstrap' => 1)) |
|
2492 ->condition('name', $bootstrap_modules, 'IN') |
|
2493 ->execute(); |
|
2494 $query->condition('name', $bootstrap_modules, 'NOT IN'); |
|
2495 } |
|
2496 $query->execute(); |
|
2497 // Reset the cached list of bootstrap modules. |
|
2498 system_list_reset(); |
|
2499 } |
|
2500 |
|
2501 /** |
|
2502 * Helper function to scan and collect theme .info data and their engines. |
|
2503 * |
|
2504 * @return |
|
2505 * An associative array of themes information. |
|
2506 */ |
|
2507 function _system_rebuild_theme_data() { |
|
2508 // Find themes |
|
2509 $themes = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.info$/', 'themes'); |
|
2510 // Allow modules to add further themes. |
|
2511 if ($module_themes = module_invoke_all('system_theme_info')) { |
|
2512 foreach ($module_themes as $name => $uri) { |
|
2513 // @see file_scan_directory() |
|
2514 $themes[$name] = (object) array( |
|
2515 'uri' => $uri, |
|
2516 'filename' => pathinfo($uri, PATHINFO_FILENAME), |
|
2517 'name' => $name, |
|
2518 ); |
|
2519 } |
|
2520 } |
|
2521 |
|
2522 // Find theme engines |
|
2523 $engines = drupal_system_listing('/^' . DRUPAL_PHP_FUNCTION_PATTERN . '\.engine$/', 'themes/engines'); |
|
2524 // Allow modules to add further theme engines. |
|
2525 if ($module_engines = module_invoke_all('system_theme_engine_info')) { |
|
2526 foreach ($module_engines as $name => $theme_engine_path) { |
|
2527 $engines[$name] = (object) array( |
|
2528 'uri' => $theme_engine_path, |
|
2529 'filename' => basename($theme_engine_path), |
|
2530 'name' => $name, |
|
2531 ); |
|
2532 } |
|
2533 } |
|
2534 |
|
2535 // Set defaults for theme info. |
|
2536 $defaults = array( |
|
2537 'engine' => 'phptemplate', |
|
2538 'regions' => array( |
|
2539 'sidebar_first' => 'Left sidebar', |
|
2540 'sidebar_second' => 'Right sidebar', |
|
2541 'content' => 'Content', |
|
2542 'header' => 'Header', |
|
2543 'footer' => 'Footer', |
|
2544 'highlighted' => 'Highlighted', |
|
2545 'help' => 'Help', |
|
2546 'page_top' => 'Page top', |
|
2547 'page_bottom' => 'Page bottom', |
|
2548 ), |
|
2549 'description' => '', |
|
2550 'features' => _system_default_theme_features(), |
|
2551 'screenshot' => 'screenshot.png', |
|
2552 'php' => DRUPAL_MINIMUM_PHP, |
|
2553 'stylesheets' => array(), |
|
2554 'scripts' => array(), |
|
2555 ); |
|
2556 |
|
2557 $sub_themes = array(); |
|
2558 // Read info files for each theme |
|
2559 foreach ($themes as $key => $theme) { |
|
2560 $themes[$key]->filename = $theme->uri; |
|
2561 $themes[$key]->info = drupal_parse_info_file($theme->uri) + $defaults; |
|
2562 |
|
2563 // The "name" key is required, but to avoid a fatal error in the menu system |
|
2564 // we set a reasonable default if it is not provided. |
|
2565 $themes[$key]->info += array('name' => $key); |
|
2566 |
|
2567 // Add the info file modification time, so it becomes available for |
|
2568 // contributed modules to use for ordering theme lists. |
|
2569 $themes[$key]->info['mtime'] = filemtime($theme->uri); |
|
2570 |
|
2571 // Invoke hook_system_info_alter() to give installed modules a chance to |
|
2572 // modify the data in the .info files if necessary. |
|
2573 $type = 'theme'; |
|
2574 drupal_alter('system_info', $themes[$key]->info, $themes[$key], $type); |
|
2575 |
|
2576 if (!empty($themes[$key]->info['base theme'])) { |
|
2577 $sub_themes[] = $key; |
|
2578 } |
|
2579 if ($themes[$key]->info['engine'] == 'theme') { |
|
2580 $filename = dirname($themes[$key]->uri) . '/' . $themes[$key]->name . '.theme'; |
|
2581 if (file_exists($filename)) { |
|
2582 $themes[$key]->owner = $filename; |
|
2583 $themes[$key]->prefix = $key; |
|
2584 } |
|
2585 } |
|
2586 else { |
|
2587 $engine = $themes[$key]->info['engine']; |
|
2588 if (isset($engines[$engine])) { |
|
2589 $themes[$key]->owner = $engines[$engine]->uri; |
|
2590 $themes[$key]->prefix = $engines[$engine]->name; |
|
2591 $themes[$key]->template = TRUE; |
|
2592 } |
|
2593 } |
|
2594 |
|
2595 // Prefix stylesheets and scripts with module path. |
|
2596 $path = dirname($theme->uri); |
|
2597 $theme->info['stylesheets'] = _system_info_add_path($theme->info['stylesheets'], $path); |
|
2598 $theme->info['scripts'] = _system_info_add_path($theme->info['scripts'], $path); |
|
2599 |
|
2600 // Give the screenshot proper path information. |
|
2601 if (!empty($themes[$key]->info['screenshot'])) { |
|
2602 $themes[$key]->info['screenshot'] = $path . '/' . $themes[$key]->info['screenshot']; |
|
2603 } |
|
2604 } |
|
2605 |
|
2606 // Now that we've established all our master themes, go back and fill in data |
|
2607 // for subthemes. |
|
2608 foreach ($sub_themes as $key) { |
|
2609 $themes[$key]->base_themes = drupal_find_base_themes($themes, $key); |
|
2610 // Don't proceed if there was a problem with the root base theme. |
|
2611 if (!current($themes[$key]->base_themes)) { |
|
2612 continue; |
|
2613 } |
|
2614 $base_key = key($themes[$key]->base_themes); |
|
2615 foreach (array_keys($themes[$key]->base_themes) as $base_theme) { |
|
2616 $themes[$base_theme]->sub_themes[$key] = $themes[$key]->info['name']; |
|
2617 } |
|
2618 // Copy the 'owner' and 'engine' over if the top level theme uses a theme |
|
2619 // engine. |
|
2620 if (isset($themes[$base_key]->owner)) { |
|
2621 if (isset($themes[$base_key]->info['engine'])) { |
|
2622 $themes[$key]->info['engine'] = $themes[$base_key]->info['engine']; |
|
2623 $themes[$key]->owner = $themes[$base_key]->owner; |
|
2624 $themes[$key]->prefix = $themes[$base_key]->prefix; |
|
2625 } |
|
2626 else { |
|
2627 $themes[$key]->prefix = $key; |
|
2628 } |
|
2629 } |
|
2630 } |
|
2631 |
|
2632 return $themes; |
|
2633 } |
|
2634 |
|
2635 /** |
|
2636 * Rebuild, save, and return data about all currently available themes. |
|
2637 * |
|
2638 * @return |
|
2639 * Array of all available themes and their data. |
|
2640 */ |
|
2641 function system_rebuild_theme_data() { |
|
2642 $themes = _system_rebuild_theme_data(); |
|
2643 ksort($themes); |
|
2644 system_get_files_database($themes, 'theme'); |
|
2645 system_update_files_database($themes, 'theme'); |
|
2646 return $themes; |
|
2647 } |
|
2648 |
|
2649 /** |
|
2650 * Prefixes all values in an .info file array with a given path. |
|
2651 * |
|
2652 * This helper function is mainly used to prefix all array values of an .info |
|
2653 * file property with a single given path (to the module or theme); e.g., to |
|
2654 * prefix all values of the 'stylesheets' or 'scripts' properties with the file |
|
2655 * path to the defining module/theme. |
|
2656 * |
|
2657 * @param $info |
|
2658 * A nested array of data of an .info file to be processed. |
|
2659 * @param $path |
|
2660 * A file path to prepend to each value in $info. |
|
2661 * |
|
2662 * @return |
|
2663 * The $info array with prefixed values. |
|
2664 * |
|
2665 * @see _system_rebuild_module_data() |
|
2666 * @see _system_rebuild_theme_data() |
|
2667 */ |
|
2668 function _system_info_add_path($info, $path) { |
|
2669 foreach ($info as $key => $value) { |
|
2670 // Recurse into nested values until we reach the deepest level. |
|
2671 if (is_array($value)) { |
|
2672 $info[$key] = _system_info_add_path($info[$key], $path); |
|
2673 } |
|
2674 // Unset the original value's key and set the new value with prefix, using |
|
2675 // the original value as key, so original values can still be looked up. |
|
2676 else { |
|
2677 unset($info[$key]); |
|
2678 $info[$value] = $path . '/' . $value; |
|
2679 } |
|
2680 } |
|
2681 return $info; |
|
2682 } |
|
2683 |
|
2684 /** |
|
2685 * Returns an array of default theme features. |
|
2686 */ |
|
2687 function _system_default_theme_features() { |
|
2688 return array( |
|
2689 'logo', |
|
2690 'favicon', |
|
2691 'name', |
|
2692 'slogan', |
|
2693 'node_user_picture', |
|
2694 'comment_user_picture', |
|
2695 'comment_user_verification', |
|
2696 'main_menu', |
|
2697 'secondary_menu', |
|
2698 ); |
|
2699 } |
|
2700 |
|
2701 /** |
|
2702 * Find all the base themes for the specified theme. |
|
2703 * |
|
2704 * This function has been deprecated in favor of drupal_find_base_themes(). |
|
2705 */ |
|
2706 function system_find_base_themes($themes, $key, $used_keys = array()) { |
|
2707 return drupal_find_base_themes($themes, $key, $used_keys); |
|
2708 } |
|
2709 |
|
2710 /** |
|
2711 * Get a list of available regions from a specified theme. |
|
2712 * |
|
2713 * @param $theme_key |
|
2714 * The name of a theme. |
|
2715 * @param $show |
|
2716 * Possible values: REGIONS_ALL or REGIONS_VISIBLE. Visible excludes hidden |
|
2717 * regions. |
|
2718 * @param bool $labels |
|
2719 * (optional) Boolean to specify whether the human readable machine names |
|
2720 * should be returned or not. Defaults to TRUE, but calling code can set |
|
2721 * this to FALSE for better performance, if it only needs machine names. |
|
2722 * |
|
2723 * @return array |
|
2724 * An associative array of regions in the form $region['name'] = 'description' |
|
2725 * if $labels is set to TRUE, or $region['name'] = 'name', if $labels is set |
|
2726 * to FALSE. |
|
2727 */ |
|
2728 function system_region_list($theme_key, $show = REGIONS_ALL, $labels = TRUE) { |
|
2729 $themes = list_themes(); |
|
2730 if (!isset($themes[$theme_key])) { |
|
2731 return array(); |
|
2732 } |
|
2733 |
|
2734 $list = array(); |
|
2735 $info = $themes[$theme_key]->info; |
|
2736 // If requested, suppress hidden regions. See block_admin_display_form(). |
|
2737 foreach ($info['regions'] as $name => $label) { |
|
2738 if ($show == REGIONS_ALL || !isset($info['regions_hidden']) || !in_array($name, $info['regions_hidden'])) { |
|
2739 if ($labels) { |
|
2740 $list[$name] = t($label); |
|
2741 } |
|
2742 else { |
|
2743 $list[$name] = $name; |
|
2744 } |
|
2745 } |
|
2746 } |
|
2747 return $list; |
|
2748 } |
|
2749 |
|
2750 /** |
|
2751 * Implements hook_system_info_alter(). |
|
2752 */ |
|
2753 function system_system_info_alter(&$info, $file, $type) { |
|
2754 // Remove page-top and page-bottom from the blocks UI since they are reserved for |
|
2755 // modules to populate from outside the blocks system. |
|
2756 if ($type == 'theme') { |
|
2757 $info['regions_hidden'][] = 'page_top'; |
|
2758 $info['regions_hidden'][] = 'page_bottom'; |
|
2759 } |
|
2760 } |
|
2761 |
|
2762 /** |
|
2763 * Get the name of the default region for a given theme. |
|
2764 * |
|
2765 * @param $theme |
|
2766 * The name of a theme. |
|
2767 * |
|
2768 * @return |
|
2769 * A string that is the region name. |
|
2770 */ |
|
2771 function system_default_region($theme) { |
|
2772 $regions = system_region_list($theme, REGIONS_VISIBLE, FALSE); |
|
2773 return $regions ? reset($regions) : ''; |
|
2774 } |
|
2775 |
|
2776 /** |
|
2777 * Sets up a form to save information automatically. |
|
2778 * |
|
2779 * This function adds a submit handler and a submit button to a form array. The |
|
2780 * submit function saves all the data in the form, using variable_set(), to |
|
2781 * variables named the same as the keys in the form array. Note that this means |
|
2782 * you should normally prefix your form array keys with your module name, so |
|
2783 * that they are unique when passed into variable_set(). |
|
2784 * |
|
2785 * If you need to manipulate the data in a custom manner, you can either put |
|
2786 * your own submission handler in the form array before calling this function, |
|
2787 * or just use your own submission handler instead of calling this function. |
|
2788 * |
|
2789 * @param $form |
|
2790 * An associative array containing the structure of the form. |
|
2791 * |
|
2792 * @return |
|
2793 * The form structure. |
|
2794 * |
|
2795 * @see system_settings_form_submit() |
|
2796 * |
|
2797 * @ingroup forms |
|
2798 */ |
|
2799 function system_settings_form($form) { |
|
2800 $form['actions']['#type'] = 'actions'; |
|
2801 $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration')); |
|
2802 |
|
2803 if (!empty($_POST) && form_get_errors()) { |
|
2804 drupal_set_message(t('The settings have not been saved because of the errors.'), 'error'); |
|
2805 } |
|
2806 $form['#submit'][] = 'system_settings_form_submit'; |
|
2807 // By default, render the form using theme_system_settings_form(). |
|
2808 if (!isset($form['#theme'])) { |
|
2809 $form['#theme'] = 'system_settings_form'; |
|
2810 } |
|
2811 return $form; |
|
2812 } |
|
2813 |
|
2814 /** |
|
2815 * Form submission handler for system_settings_form(). |
|
2816 * |
|
2817 * If you want node type configure style handling of your checkboxes, |
|
2818 * add an array_filter value to your form. |
|
2819 */ |
|
2820 function system_settings_form_submit($form, &$form_state) { |
|
2821 // Exclude unnecessary elements. |
|
2822 form_state_values_clean($form_state); |
|
2823 |
|
2824 foreach ($form_state['values'] as $key => $value) { |
|
2825 if (is_array($value) && isset($form_state['values']['array_filter'])) { |
|
2826 $value = array_keys(array_filter($value)); |
|
2827 } |
|
2828 variable_set($key, $value); |
|
2829 } |
|
2830 |
|
2831 drupal_set_message(t('The configuration options have been saved.')); |
|
2832 } |
|
2833 |
|
2834 /** |
|
2835 * Helper function to sort requirements. |
|
2836 */ |
|
2837 function _system_sort_requirements($a, $b) { |
|
2838 if (!isset($a['weight'])) { |
|
2839 if (!isset($b['weight'])) { |
|
2840 return strcasecmp($a['title'], $b['title']); |
|
2841 } |
|
2842 return -$b['weight']; |
|
2843 } |
|
2844 return isset($b['weight']) ? $a['weight'] - $b['weight'] : $a['weight']; |
|
2845 } |
|
2846 |
|
2847 /** |
|
2848 * Generates a form array for a confirmation form. |
|
2849 * |
|
2850 * This function returns a complete form array for confirming an action. The |
|
2851 * form contains a confirm button as well as a cancellation link that allows a |
|
2852 * user to abort the action. |
|
2853 * |
|
2854 * If the submit handler for a form that implements confirm_form() is invoked, |
|
2855 * the user successfully confirmed the action. You should never directly |
|
2856 * inspect $_POST to see if an action was confirmed. |
|
2857 * |
|
2858 * Note - if the parameters $question, $description, $yes, or $no could contain |
|
2859 * any user input (such as node titles or taxonomy terms), it is the |
|
2860 * responsibility of the code calling confirm_form() to sanitize them first with |
|
2861 * a function like check_plain() or filter_xss(). |
|
2862 * |
|
2863 * @param $form |
|
2864 * Additional elements to add to the form. These can be regular form elements, |
|
2865 * #value elements, etc., and their values will be available to the submit |
|
2866 * handler. |
|
2867 * @param $question |
|
2868 * The question to ask the user (e.g. "Are you sure you want to delete the |
|
2869 * block <em>foo</em>?"). The page title will be set to this value. |
|
2870 * @param $path |
|
2871 * The page to go to if the user cancels the action. This can be either: |
|
2872 * - A string containing a Drupal path. |
|
2873 * - An associative array with a 'path' key. Additional array values are |
|
2874 * passed as the $options parameter to l(). |
|
2875 * If the 'destination' query parameter is set in the URL when viewing a |
|
2876 * confirmation form, that value will be used instead of $path. |
|
2877 * @param $description |
|
2878 * Additional text to display. Defaults to t('This action cannot be undone.'). |
|
2879 * @param $yes |
|
2880 * A caption for the button that confirms the action (e.g. "Delete", |
|
2881 * "Replace", ...). Defaults to t('Confirm'). |
|
2882 * @param $no |
|
2883 * A caption for the link which cancels the action (e.g. "Cancel"). Defaults |
|
2884 * to t('Cancel'). |
|
2885 * @param $name |
|
2886 * The internal name used to refer to the confirmation item. |
|
2887 * |
|
2888 * @return |
|
2889 * The form array. |
|
2890 */ |
|
2891 function confirm_form($form, $question, $path, $description = NULL, $yes = NULL, $no = NULL, $name = 'confirm') { |
|
2892 $description = isset($description) ? $description : t('This action cannot be undone.'); |
|
2893 |
|
2894 // Prepare cancel link. |
|
2895 if (isset($_GET['destination'])) { |
|
2896 $options = drupal_parse_url($_GET['destination']); |
|
2897 } |
|
2898 elseif (is_array($path)) { |
|
2899 $options = $path; |
|
2900 } |
|
2901 else { |
|
2902 $options = array('path' => $path); |
|
2903 } |
|
2904 |
|
2905 drupal_set_title($question, PASS_THROUGH); |
|
2906 |
|
2907 $form['#attributes']['class'][] = 'confirmation'; |
|
2908 $form['description'] = array('#markup' => $description); |
|
2909 $form[$name] = array('#type' => 'hidden', '#value' => 1); |
|
2910 |
|
2911 $form['actions'] = array('#type' => 'actions'); |
|
2912 $form['actions']['submit'] = array( |
|
2913 '#type' => 'submit', |
|
2914 '#value' => $yes ? $yes : t('Confirm'), |
|
2915 ); |
|
2916 $form['actions']['cancel'] = array( |
|
2917 '#type' => 'link', |
|
2918 '#title' => $no ? $no : t('Cancel'), |
|
2919 '#href' => $options['path'], |
|
2920 '#options' => $options, |
|
2921 ); |
|
2922 // By default, render the form using theme_confirm_form(). |
|
2923 if (!isset($form['#theme'])) { |
|
2924 $form['#theme'] = 'confirm_form'; |
|
2925 } |
|
2926 return $form; |
|
2927 } |
|
2928 |
|
2929 /** |
|
2930 * Determines whether the current user is in compact mode. |
|
2931 * |
|
2932 * Compact mode shows certain administration pages with less description text, |
|
2933 * such as the configuration page and the permissions page. |
|
2934 * |
|
2935 * Whether the user is in compact mode is determined by a cookie, which is set |
|
2936 * for the user by system_admin_compact_page(). |
|
2937 * |
|
2938 * If the user does not have the cookie, the default value is given by the |
|
2939 * system variable 'admin_compact_mode', which itself defaults to FALSE. This |
|
2940 * does not have a user interface to set it: it is a hidden variable which can |
|
2941 * be set in the settings.php file. |
|
2942 * |
|
2943 * @return |
|
2944 * TRUE when in compact mode, FALSE when in expanded mode. |
|
2945 */ |
|
2946 function system_admin_compact_mode() { |
|
2947 // PHP converts dots into underscores in cookie names to avoid problems with |
|
2948 // its parser, so we use a converted cookie name. |
|
2949 return isset($_COOKIE['Drupal_visitor_admin_compact_mode']) ? $_COOKIE['Drupal_visitor_admin_compact_mode'] : variable_get('admin_compact_mode', FALSE); |
|
2950 } |
|
2951 |
|
2952 /** |
|
2953 * Menu callback; Sets whether the admin menu is in compact mode or not. |
|
2954 * |
|
2955 * @param $mode |
|
2956 * Valid values are 'on' and 'off'. |
|
2957 */ |
|
2958 function system_admin_compact_page($mode = 'off') { |
|
2959 user_cookie_save(array('admin_compact_mode' => ($mode == 'on'))); |
|
2960 drupal_goto(); |
|
2961 } |
|
2962 |
|
2963 /** |
|
2964 * Generate a list of tasks offered by a specified module. |
|
2965 * |
|
2966 * @param $module |
|
2967 * Module name. |
|
2968 * @param $info |
|
2969 * The module's information, as provided by system_get_info(). |
|
2970 * |
|
2971 * @return |
|
2972 * An array of task links. |
|
2973 */ |
|
2974 function system_get_module_admin_tasks($module, $info) { |
|
2975 $links = &drupal_static(__FUNCTION__); |
|
2976 |
|
2977 if (!isset($links)) { |
|
2978 $links = array(); |
|
2979 $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC)); |
|
2980 $query->join('menu_router', 'm', 'm.path = ml.router_path'); |
|
2981 $query |
|
2982 ->fields('ml') |
|
2983 // Weight should be taken from {menu_links}, not {menu_router}. |
|
2984 ->fields('m', array_diff(drupal_schema_fields_sql('menu_router'), array('weight'))) |
|
2985 ->condition('ml.link_path', 'admin/%', 'LIKE') |
|
2986 ->condition('ml.hidden', 0, '>=') |
|
2987 ->condition('ml.module', 'system') |
|
2988 ->condition('m.number_parts', 1, '>') |
|
2989 ->condition('m.page_callback', 'system_admin_menu_block_page', '<>'); |
|
2990 foreach ($query->execute() as $link) { |
|
2991 _menu_link_translate($link); |
|
2992 if ($link['access']) { |
|
2993 $links[$link['router_path']] = $link; |
|
2994 } |
|
2995 } |
|
2996 } |
|
2997 |
|
2998 $admin_tasks = array(); |
|
2999 $titles = array(); |
|
3000 if ($menu = module_invoke($module, 'menu')) { |
|
3001 foreach ($menu as $path => $item) { |
|
3002 if (isset($links[$path])) { |
|
3003 $task = $links[$path]; |
|
3004 // The link description, either derived from 'description' in |
|
3005 // hook_menu() or customized via menu module is used as title attribute. |
|
3006 if (!empty($task['localized_options']['attributes']['title'])) { |
|
3007 $task['description'] = $task['localized_options']['attributes']['title']; |
|
3008 unset($task['localized_options']['attributes']['title']); |
|
3009 } |
|
3010 |
|
3011 // Check the admin tasks for duplicate names. If one is found, |
|
3012 // append the parent menu item's title to differentiate. |
|
3013 $duplicate_path = array_search($task['title'], $titles); |
|
3014 if ($duplicate_path !== FALSE) { |
|
3015 if ($parent = menu_link_load($task['plid'])) { |
|
3016 // Append the parent item's title to this task's title. |
|
3017 $task['title'] = t('@original_title (@parent_title)', array('@original_title' => $task['title'], '@parent_title' => $parent['title'])); |
|
3018 } |
|
3019 if ($parent = menu_link_load($admin_tasks[$duplicate_path]['plid'])) { |
|
3020 // Append the parent item's title to the duplicated task's title. |
|
3021 // We use $links[$duplicate_path] in case there are triplicates. |
|
3022 $admin_tasks[$duplicate_path]['title'] = t('@original_title (@parent_title)', array('@original_title' => $links[$duplicate_path]['title'], '@parent_title' => $parent['title'])); |
|
3023 } |
|
3024 } |
|
3025 else { |
|
3026 $titles[$path] = $task['title']; |
|
3027 } |
|
3028 |
|
3029 $admin_tasks[$path] = $task; |
|
3030 } |
|
3031 } |
|
3032 } |
|
3033 |
|
3034 // Append link for permissions. |
|
3035 if (module_hook($module, 'permission')) { |
|
3036 $item = menu_get_item('admin/people/permissions'); |
|
3037 if (!empty($item['access'])) { |
|
3038 $item['link_path'] = $item['href']; |
|
3039 $item['title'] = t('Configure @module permissions', array('@module' => $info['name'])); |
|
3040 unset($item['description']); |
|
3041 $item['localized_options']['fragment'] = 'module-' . $module; |
|
3042 $admin_tasks["admin/people/permissions#module-$module"] = $item; |
|
3043 } |
|
3044 } |
|
3045 |
|
3046 return $admin_tasks; |
|
3047 } |
|
3048 |
|
3049 /** |
|
3050 * Implements hook_cron(). |
|
3051 * |
|
3052 * Remove older rows from flood and batch table. Remove old temporary files. |
|
3053 */ |
|
3054 function system_cron() { |
|
3055 // Cleanup the flood. |
|
3056 db_delete('flood') |
|
3057 ->condition('expiration', REQUEST_TIME, '<') |
|
3058 ->execute(); |
|
3059 |
|
3060 // Remove temporary files that are older than DRUPAL_MAXIMUM_TEMP_FILE_AGE. |
|
3061 // Use separate placeholders for the status to avoid a bug in some versions |
|
3062 // of PHP. See http://drupal.org/node/352956. |
|
3063 $result = db_query('SELECT fid FROM {file_managed} WHERE status <> :permanent AND timestamp < :timestamp', array( |
|
3064 ':permanent' => FILE_STATUS_PERMANENT, |
|
3065 ':timestamp' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE |
|
3066 )); |
|
3067 foreach ($result as $row) { |
|
3068 if ($file = file_load($row->fid)) { |
|
3069 $references = file_usage_list($file); |
|
3070 if (empty($references)) { |
|
3071 if (!file_delete($file)) { |
|
3072 watchdog('file system', 'Could not delete temporary file "%path" during garbage collection', array('%path' => $file->uri), WATCHDOG_ERROR); |
|
3073 } |
|
3074 } |
|
3075 else { |
|
3076 watchdog('file system', 'Did not delete temporary file "%path" during garbage collection, because it is in use by the following modules: %modules.', array('%path' => $file->uri, '%modules' => implode(', ', array_keys($references))), WATCHDOG_INFO); |
|
3077 } |
|
3078 } |
|
3079 } |
|
3080 |
|
3081 // Delete expired cache entries. |
|
3082 // Avoid invoking hook_flush_cashes() on every cron run because some modules |
|
3083 // use this hook to perform expensive rebuilding operations (which are only |
|
3084 // designed to happen on full cache clears), rather than just returning a |
|
3085 // list of cache tables to be cleared. |
|
3086 $cache_object = cache_get('system_cache_tables'); |
|
3087 if (empty($cache_object)) { |
|
3088 $core = array('cache', 'cache_path', 'cache_filter', 'cache_page', 'cache_form', 'cache_menu'); |
|
3089 $cache_tables = array_merge(module_invoke_all('flush_caches'), $core); |
|
3090 cache_set('system_cache_tables', $cache_tables); |
|
3091 } |
|
3092 else { |
|
3093 $cache_tables = $cache_object->data; |
|
3094 } |
|
3095 foreach ($cache_tables as $table) { |
|
3096 cache_clear_all(NULL, $table); |
|
3097 } |
|
3098 |
|
3099 // Cleanup the batch table and the queue for failed batches. |
|
3100 db_delete('batch') |
|
3101 ->condition('timestamp', REQUEST_TIME - 864000, '<') |
|
3102 ->execute(); |
|
3103 db_delete('queue') |
|
3104 ->condition('created', REQUEST_TIME - 864000, '<') |
|
3105 ->condition('name', 'drupal_batch:%', 'LIKE') |
|
3106 ->execute(); |
|
3107 |
|
3108 // Reset expired items in the default queue implementation table. If that's |
|
3109 // not used, this will simply be a no-op. |
|
3110 db_update('queue') |
|
3111 ->fields(array( |
|
3112 'expire' => 0, |
|
3113 )) |
|
3114 ->condition('expire', 0, '<>') |
|
3115 ->condition('expire', REQUEST_TIME, '<') |
|
3116 ->execute(); |
|
3117 } |
|
3118 |
|
3119 /** |
|
3120 * Implements hook_flush_caches(). |
|
3121 */ |
|
3122 function system_flush_caches() { |
|
3123 // Rebuild list of date formats. |
|
3124 system_date_formats_rebuild(); |
|
3125 // Reset the menu static caches. |
|
3126 menu_reset_static_cache(); |
|
3127 } |
|
3128 |
|
3129 /** |
|
3130 * Implements hook_action_info(). |
|
3131 */ |
|
3132 function system_action_info() { |
|
3133 return array( |
|
3134 'system_message_action' => array( |
|
3135 'type' => 'system', |
|
3136 'label' => t('Display a message to the user'), |
|
3137 'configurable' => TRUE, |
|
3138 'triggers' => array('any'), |
|
3139 ), |
|
3140 'system_send_email_action' => array( |
|
3141 'type' => 'system', |
|
3142 'label' => t('Send e-mail'), |
|
3143 'configurable' => TRUE, |
|
3144 'triggers' => array('any'), |
|
3145 ), |
|
3146 'system_block_ip_action' => array( |
|
3147 'type' => 'user', |
|
3148 'label' => t('Ban IP address of current user'), |
|
3149 'configurable' => FALSE, |
|
3150 'triggers' => array('any'), |
|
3151 ), |
|
3152 'system_goto_action' => array( |
|
3153 'type' => 'system', |
|
3154 'label' => t('Redirect to URL'), |
|
3155 'configurable' => TRUE, |
|
3156 'triggers' => array('any'), |
|
3157 ), |
|
3158 ); |
|
3159 } |
|
3160 |
|
3161 /** |
|
3162 * Return a form definition so the Send email action can be configured. |
|
3163 * |
|
3164 * @param $context |
|
3165 * Default values (if we are editing an existing action instance). |
|
3166 * |
|
3167 * @return |
|
3168 * Form definition. |
|
3169 * |
|
3170 * @see system_send_email_action_validate() |
|
3171 * @see system_send_email_action_submit() |
|
3172 */ |
|
3173 function system_send_email_action_form($context) { |
|
3174 // Set default values for form. |
|
3175 if (!isset($context['recipient'])) { |
|
3176 $context['recipient'] = ''; |
|
3177 } |
|
3178 if (!isset($context['subject'])) { |
|
3179 $context['subject'] = ''; |
|
3180 } |
|
3181 if (!isset($context['message'])) { |
|
3182 $context['message'] = ''; |
|
3183 } |
|
3184 |
|
3185 $form['recipient'] = array( |
|
3186 '#type' => 'textfield', |
|
3187 '#title' => t('Recipient'), |
|
3188 '#default_value' => $context['recipient'], |
|
3189 '#maxlength' => '254', |
|
3190 '#description' => t('The email address to which the message should be sent OR enter [node:author:mail], [comment:author:mail], etc. if you would like to send an e-mail to the author of the original post.'), |
|
3191 ); |
|
3192 $form['subject'] = array( |
|
3193 '#type' => 'textfield', |
|
3194 '#title' => t('Subject'), |
|
3195 '#default_value' => $context['subject'], |
|
3196 '#maxlength' => '254', |
|
3197 '#description' => t('The subject of the message.'), |
|
3198 ); |
|
3199 $form['message'] = array( |
|
3200 '#type' => 'textarea', |
|
3201 '#title' => t('Message'), |
|
3202 '#default_value' => $context['message'], |
|
3203 '#cols' => '80', |
|
3204 '#rows' => '20', |
|
3205 '#description' => t('The message that should be sent. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'), |
|
3206 ); |
|
3207 return $form; |
|
3208 } |
|
3209 |
|
3210 /** |
|
3211 * Validate system_send_email_action form submissions. |
|
3212 */ |
|
3213 function system_send_email_action_validate($form, $form_state) { |
|
3214 $form_values = $form_state['values']; |
|
3215 // Validate the configuration form. |
|
3216 if (!valid_email_address($form_values['recipient']) && strpos($form_values['recipient'], ':mail') === FALSE) { |
|
3217 // We want the literal %author placeholder to be emphasized in the error message. |
|
3218 form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]'))); |
|
3219 } |
|
3220 } |
|
3221 |
|
3222 /** |
|
3223 * Process system_send_email_action form submissions. |
|
3224 */ |
|
3225 function system_send_email_action_submit($form, $form_state) { |
|
3226 $form_values = $form_state['values']; |
|
3227 // Process the HTML form to store configuration. The keyed array that |
|
3228 // we return will be serialized to the database. |
|
3229 $params = array( |
|
3230 'recipient' => $form_values['recipient'], |
|
3231 'subject' => $form_values['subject'], |
|
3232 'message' => $form_values['message'], |
|
3233 ); |
|
3234 return $params; |
|
3235 } |
|
3236 |
|
3237 /** |
|
3238 * Sends an e-mail message. |
|
3239 * |
|
3240 * @param object $entity |
|
3241 * An optional node object, which will be added as $context['node'] if |
|
3242 * provided. |
|
3243 * @param array $context |
|
3244 * Array with the following elements: |
|
3245 * - 'recipient': E-mail message recipient. This will be passed through |
|
3246 * token_replace(). |
|
3247 * - 'subject': The subject of the message. This will be passed through |
|
3248 * token_replace(). |
|
3249 * - 'message': The message to send. This will be passed through |
|
3250 * token_replace(). |
|
3251 * - Other elements will be used as the data for token replacement. |
|
3252 * |
|
3253 * @ingroup actions |
|
3254 */ |
|
3255 function system_send_email_action($entity, $context) { |
|
3256 if (empty($context['node'])) { |
|
3257 $context['node'] = $entity; |
|
3258 } |
|
3259 |
|
3260 $recipient = token_replace($context['recipient'], $context); |
|
3261 |
|
3262 // If the recipient is a registered user with a language preference, use |
|
3263 // the recipient's preferred language. Otherwise, use the system default |
|
3264 // language. |
|
3265 $recipient_account = user_load_by_mail($recipient); |
|
3266 if ($recipient_account) { |
|
3267 $language = user_preferred_language($recipient_account); |
|
3268 } |
|
3269 else { |
|
3270 $language = language_default(); |
|
3271 } |
|
3272 $params = array('context' => $context); |
|
3273 |
|
3274 if (drupal_mail('system', 'action_send_email', $recipient, $language, $params)) { |
|
3275 watchdog('action', 'Sent email to %recipient', array('%recipient' => $recipient)); |
|
3276 } |
|
3277 else { |
|
3278 watchdog('error', 'Unable to send email to %recipient', array('%recipient' => $recipient)); |
|
3279 } |
|
3280 } |
|
3281 |
|
3282 /** |
|
3283 * Implements hook_mail(). |
|
3284 */ |
|
3285 function system_mail($key, &$message, $params) { |
|
3286 $context = $params['context']; |
|
3287 |
|
3288 $subject = token_replace($context['subject'], $context); |
|
3289 $body = token_replace($context['message'], $context); |
|
3290 |
|
3291 $message['subject'] .= str_replace(array("\r", "\n"), '', $subject); |
|
3292 $message['body'][] = $body; |
|
3293 } |
|
3294 |
|
3295 function system_message_action_form($context) { |
|
3296 $form['message'] = array( |
|
3297 '#type' => 'textarea', |
|
3298 '#title' => t('Message'), |
|
3299 '#default_value' => isset($context['message']) ? $context['message'] : '', |
|
3300 '#required' => TRUE, |
|
3301 '#rows' => '8', |
|
3302 '#description' => t('The message to be displayed to the current user. You may include placeholders like [node:title], [user:name], and [comment:body] to represent data that will be different each time message is sent. Not all placeholders will be available in all contexts.'), |
|
3303 ); |
|
3304 return $form; |
|
3305 } |
|
3306 |
|
3307 function system_message_action_submit($form, $form_state) { |
|
3308 return array('message' => $form_state['values']['message']); |
|
3309 } |
|
3310 |
|
3311 /** |
|
3312 * Sends a message to the current user's screen. |
|
3313 * |
|
3314 * @param object $entity |
|
3315 * An optional node object, which will be added as $context['node'] if |
|
3316 * provided. |
|
3317 * @param array $context |
|
3318 * Array with the following elements: |
|
3319 * - 'message': The message to send. This will be passed through |
|
3320 * token_replace(). |
|
3321 * - Other elements will be used as the data for token replacement in |
|
3322 * the message. |
|
3323 * |
|
3324 * @ingroup actions |
|
3325 */ |
|
3326 function system_message_action(&$entity, $context = array()) { |
|
3327 if (empty($context['node'])) { |
|
3328 $context['node'] = $entity; |
|
3329 } |
|
3330 |
|
3331 $context['message'] = token_replace(filter_xss_admin($context['message']), $context); |
|
3332 drupal_set_message($context['message']); |
|
3333 } |
|
3334 |
|
3335 /** |
|
3336 * Settings form for system_goto_action(). |
|
3337 */ |
|
3338 function system_goto_action_form($context) { |
|
3339 $form['url'] = array( |
|
3340 '#type' => 'textfield', |
|
3341 '#title' => t('URL'), |
|
3342 '#description' => t('The URL to which the user should be redirected. This can be an internal path like node/1234 or an external URL like http://example.com.'), |
|
3343 '#default_value' => isset($context['url']) ? $context['url'] : '', |
|
3344 '#required' => TRUE, |
|
3345 ); |
|
3346 return $form; |
|
3347 } |
|
3348 |
|
3349 function system_goto_action_submit($form, $form_state) { |
|
3350 return array( |
|
3351 'url' => $form_state['values']['url'] |
|
3352 ); |
|
3353 } |
|
3354 |
|
3355 /** |
|
3356 * Redirects to a different URL. |
|
3357 * |
|
3358 * @param $entity |
|
3359 * Ignored. |
|
3360 * @param array $context |
|
3361 * Array with the following elements: |
|
3362 * - 'url': URL to redirect to. This will be passed through |
|
3363 * token_replace(). |
|
3364 * - Other elements will be used as the data for token replacement. |
|
3365 * |
|
3366 * @ingroup actions |
|
3367 */ |
|
3368 function system_goto_action($entity, $context) { |
|
3369 drupal_goto(token_replace($context['url'], $context)); |
|
3370 } |
|
3371 |
|
3372 /** |
|
3373 * Blocks the current user's IP address. |
|
3374 * |
|
3375 * @ingroup actions |
|
3376 */ |
|
3377 function system_block_ip_action() { |
|
3378 $ip = ip_address(); |
|
3379 db_merge('blocked_ips') |
|
3380 ->key(array('ip' => $ip)) |
|
3381 ->fields(array('ip' => $ip)) |
|
3382 ->execute(); |
|
3383 watchdog('action', 'Banned IP address %ip', array('%ip' => $ip)); |
|
3384 } |
|
3385 |
|
3386 /** |
|
3387 * Generate an array of time zones and their local time&date. |
|
3388 * |
|
3389 * @param $blank |
|
3390 * If evaluates true, prepend an empty time zone option to the array. |
|
3391 */ |
|
3392 function system_time_zones($blank = NULL) { |
|
3393 $zonelist = timezone_identifiers_list(); |
|
3394 $zones = $blank ? array('' => t('- None selected -')) : array(); |
|
3395 foreach ($zonelist as $zone) { |
|
3396 // Because many time zones exist in PHP only for backward compatibility |
|
3397 // reasons and should not be used, the list is filtered by a regular |
|
3398 // expression. |
|
3399 if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!', $zone)) { |
|
3400 $zones[$zone] = t('@zone: @date', array('@zone' => t(str_replace('_', ' ', $zone)), '@date' => format_date(REQUEST_TIME, 'custom', variable_get('date_format_long', 'l, F j, Y - H:i') . ' O', $zone))); |
|
3401 } |
|
3402 } |
|
3403 // Sort the translated time zones alphabetically. |
|
3404 asort($zones); |
|
3405 return $zones; |
|
3406 } |
|
3407 |
|
3408 /** |
|
3409 * Checks whether the server is capable of issuing HTTP requests. |
|
3410 * |
|
3411 * The function sets the drupal_http_request_fail system variable to TRUE if |
|
3412 * drupal_http_request() does not work and then the system status report page |
|
3413 * will contain an error. |
|
3414 * |
|
3415 * @return |
|
3416 * TRUE if this installation can issue HTTP requests. |
|
3417 */ |
|
3418 function system_check_http_request() { |
|
3419 // Try to get the content of the front page via drupal_http_request(). |
|
3420 $result = drupal_http_request(url('', array('absolute' => TRUE)), array('max_redirects' => 0)); |
|
3421 // We only care that we get a http response - this means that Drupal |
|
3422 // can make a http request. |
|
3423 $works = isset($result->code) && ($result->code >= 100) && ($result->code < 600); |
|
3424 variable_set('drupal_http_request_fails', !$works); |
|
3425 return $works; |
|
3426 } |
|
3427 |
|
3428 /** |
|
3429 * Menu callback; Retrieve a JSON object containing a suggested time zone name. |
|
3430 */ |
|
3431 function system_timezone($abbreviation = '', $offset = -1, $is_daylight_saving_time = NULL) { |
|
3432 // An abbreviation of "0" passed in the callback arguments should be |
|
3433 // interpreted as the empty string. |
|
3434 $abbreviation = $abbreviation ? $abbreviation : ''; |
|
3435 $timezone = timezone_name_from_abbr($abbreviation, intval($offset), $is_daylight_saving_time); |
|
3436 drupal_json_output($timezone); |
|
3437 } |
|
3438 |
|
3439 /** |
|
3440 * Returns HTML for the Powered by Drupal text. |
|
3441 * |
|
3442 * @ingroup themeable |
|
3443 */ |
|
3444 function theme_system_powered_by() { |
|
3445 return '<span>' . t('Powered by <a href="@poweredby">Drupal</a>', array('@poweredby' => 'https://www.drupal.org')) . '</span>'; |
|
3446 } |
|
3447 |
|
3448 /** |
|
3449 * Returns HTML for a link to show or hide inline help descriptions. |
|
3450 * |
|
3451 * @ingroup themeable |
|
3452 */ |
|
3453 function theme_system_compact_link() { |
|
3454 $output = '<div class="compact-link">'; |
|
3455 if (system_admin_compact_mode()) { |
|
3456 $output .= l(t('Show descriptions'), 'admin/compact/off', array('attributes' => array('title' => t('Expand layout to include descriptions.')), 'query' => drupal_get_destination())); |
|
3457 } |
|
3458 else { |
|
3459 $output .= l(t('Hide descriptions'), 'admin/compact/on', array('attributes' => array('title' => t('Compress layout by hiding descriptions.')), 'query' => drupal_get_destination())); |
|
3460 } |
|
3461 $output .= '</div>'; |
|
3462 |
|
3463 return $output; |
|
3464 } |
|
3465 |
|
3466 /** |
|
3467 * Implements hook_image_toolkits(). |
|
3468 */ |
|
3469 function system_image_toolkits() { |
|
3470 include_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'system') . '/' . 'image.gd.inc'; |
|
3471 return array( |
|
3472 'gd' => array( |
|
3473 'title' => t('GD2 image manipulation toolkit'), |
|
3474 'available' => function_exists('image_gd_check_settings') && image_gd_check_settings(), |
|
3475 ), |
|
3476 ); |
|
3477 } |
|
3478 |
|
3479 /** |
|
3480 * Attempts to get a file using drupal_http_request and to store it locally. |
|
3481 * |
|
3482 * @param string $url |
|
3483 * The URL of the file to grab. |
|
3484 * @param string $destination |
|
3485 * Stream wrapper URI specifying where the file should be placed. If a |
|
3486 * directory path is provided, the file is saved into that directory under |
|
3487 * its original name. If the path contains a filename as well, that one will |
|
3488 * be used instead. |
|
3489 * If this value is omitted, the site's default files scheme will be used, |
|
3490 * usually "public://". |
|
3491 * @param bool $managed |
|
3492 * If this is set to TRUE, the file API hooks will be invoked and the file is |
|
3493 * registered in the database. |
|
3494 * @param int $replace |
|
3495 * Replace behavior when the destination file already exists: |
|
3496 * - FILE_EXISTS_REPLACE: Replace the existing file. |
|
3497 * - FILE_EXISTS_RENAME: Append _{incrementing number} until the filename is |
|
3498 * unique. |
|
3499 * - FILE_EXISTS_ERROR: Do nothing and return FALSE. |
|
3500 * |
|
3501 * @return mixed |
|
3502 * One of these possibilities: |
|
3503 * - If it succeeds and $managed is FALSE, the location where the file was |
|
3504 * saved. |
|
3505 * - If it succeeds and $managed is TRUE, a \Drupal\file\FileInterface |
|
3506 * object which describes the file. |
|
3507 * - If it fails, FALSE. |
|
3508 */ |
|
3509 function system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME) { |
|
3510 $parsed_url = parse_url($url); |
|
3511 if (!isset($destination)) { |
|
3512 $path = file_build_uri(drupal_basename($parsed_url['path'])); |
|
3513 } |
|
3514 else { |
|
3515 if (is_dir(drupal_realpath($destination))) { |
|
3516 // Prevent URIs with triple slashes when glueing parts together. |
|
3517 $path = str_replace('///', '//', "$destination/") . drupal_basename($parsed_url['path']); |
|
3518 } |
|
3519 else { |
|
3520 $path = $destination; |
|
3521 } |
|
3522 } |
|
3523 $result = drupal_http_request($url); |
|
3524 if ($result->code != 200) { |
|
3525 drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error'); |
|
3526 return FALSE; |
|
3527 } |
|
3528 $local = $managed ? file_save_data($result->data, $path, $replace) : file_unmanaged_save_data($result->data, $path, $replace); |
|
3529 if (!$local) { |
|
3530 drupal_set_message(t('@remote could not be saved to @path.', array('@remote' => $url, '@path' => $path)), 'error'); |
|
3531 } |
|
3532 |
|
3533 return $local; |
|
3534 } |
|
3535 |
|
3536 /** |
|
3537 * Implements hook_page_alter(). |
|
3538 */ |
|
3539 function system_page_alter(&$page) { |
|
3540 // Find all non-empty page regions, and add a theme wrapper function that |
|
3541 // allows them to be consistently themed. |
|
3542 foreach (system_region_list($GLOBALS['theme'], REGIONS_ALL, FALSE) as $region) { |
|
3543 if (!empty($page[$region])) { |
|
3544 $page[$region]['#theme_wrappers'][] = 'region'; |
|
3545 $page[$region]['#region'] = $region; |
|
3546 } |
|
3547 } |
|
3548 } |
|
3549 |
|
3550 /** |
|
3551 * Run the automated cron if enabled. |
|
3552 */ |
|
3553 function system_run_automated_cron() { |
|
3554 // If the site is not fully installed, suppress the automated cron run. |
|
3555 // Otherwise it could be triggered prematurely by Ajax requests during |
|
3556 // installation. |
|
3557 if (($threshold = variable_get('cron_safe_threshold', DRUPAL_CRON_DEFAULT_THRESHOLD)) > 0 && variable_get('install_task') == 'done') { |
|
3558 $cron_last = variable_get('cron_last', NULL); |
|
3559 if (!isset($cron_last) || (REQUEST_TIME - $cron_last > $threshold)) { |
|
3560 drupal_cron_run(); |
|
3561 } |
|
3562 } |
|
3563 } |
|
3564 |
|
3565 /** |
|
3566 * Gets the list of available date types and attributes. |
|
3567 * |
|
3568 * @param $type |
|
3569 * (optional) The date type name. |
|
3570 * |
|
3571 * @return |
|
3572 * An associative array of date type information keyed by the date type name. |
|
3573 * Each date type information array has the following elements: |
|
3574 * - type: The machine-readable name of the date type. |
|
3575 * - title: The human-readable name of the date type. |
|
3576 * - locked: A boolean indicating whether or not this date type should be |
|
3577 * configurable from the user interface. |
|
3578 * - module: The name of the module that defined this date type in its |
|
3579 * hook_date_format_types(). An empty string if the date type was |
|
3580 * user-defined. |
|
3581 * - is_new: A boolean indicating whether or not this date type is as of yet |
|
3582 * unsaved in the database. |
|
3583 * If $type was defined, only a single associative array with the above |
|
3584 * elements is returned. |
|
3585 */ |
|
3586 function system_get_date_types($type = NULL) { |
|
3587 $types = &drupal_static(__FUNCTION__); |
|
3588 |
|
3589 if (!isset($types)) { |
|
3590 $types = _system_date_format_types_build(); |
|
3591 } |
|
3592 |
|
3593 return $type ? (isset($types[$type]) ? $types[$type] : FALSE) : $types; |
|
3594 } |
|
3595 |
|
3596 /** |
|
3597 * Implements hook_date_format_types(). |
|
3598 */ |
|
3599 function system_date_format_types() { |
|
3600 return array( |
|
3601 'long' => t('Long'), |
|
3602 'medium' => t('Medium'), |
|
3603 'short' => t('Short'), |
|
3604 ); |
|
3605 } |
|
3606 |
|
3607 /** |
|
3608 * Implements hook_date_formats(). |
|
3609 */ |
|
3610 function system_date_formats() { |
|
3611 include_once DRUPAL_ROOT . '/includes/date.inc'; |
|
3612 return system_default_date_formats(); |
|
3613 } |
|
3614 |
|
3615 /** |
|
3616 * Gets the list of defined date formats and attributes. |
|
3617 * |
|
3618 * @param $type |
|
3619 * (optional) The date type name. |
|
3620 * |
|
3621 * @return |
|
3622 * An associative array of date formats. The top-level keys are the names of |
|
3623 * the date types that the date formats belong to. The values are in turn |
|
3624 * associative arrays keyed by the format string, with the following keys: |
|
3625 * - dfid: The date format ID. |
|
3626 * - format: The format string. |
|
3627 * - type: The machine-readable name of the date type. |
|
3628 * - locales: An array of language codes. This can include both 2 character |
|
3629 * language codes like 'en and 'fr' and 5 character language codes like |
|
3630 * 'en-gb' and 'en-us'. |
|
3631 * - locked: A boolean indicating whether or not this date type should be |
|
3632 * configurable from the user interface. |
|
3633 * - module: The name of the module that defined this date format in its |
|
3634 * hook_date_formats(). An empty string if the format was user-defined. |
|
3635 * - is_new: A boolean indicating whether or not this date type is as of yet |
|
3636 * unsaved in the database. |
|
3637 * If $type was defined, only the date formats associated with the given date |
|
3638 * type are returned, in a single associative array keyed by format string. |
|
3639 */ |
|
3640 function system_get_date_formats($type = NULL) { |
|
3641 $date_formats = &drupal_static(__FUNCTION__); |
|
3642 |
|
3643 if (!isset($date_formats)) { |
|
3644 $date_formats = _system_date_formats_build(); |
|
3645 } |
|
3646 |
|
3647 return $type ? (isset($date_formats[$type]) ? $date_formats[$type] : FALSE) : $date_formats; |
|
3648 } |
|
3649 |
|
3650 /** |
|
3651 * Gets the format details for a particular format ID. |
|
3652 * |
|
3653 * @param $dfid |
|
3654 * A date format ID. |
|
3655 * |
|
3656 * @return |
|
3657 * A date format object with the following properties: |
|
3658 * - dfid: The date format ID. |
|
3659 * - format: The date format string. |
|
3660 * - type: The name of the date type. |
|
3661 * - locked: Whether the date format can be changed or not. |
|
3662 */ |
|
3663 function system_get_date_format($dfid) { |
|
3664 return db_query('SELECT df.dfid, df.format, df.type, df.locked FROM {date_formats} df WHERE df.dfid = :dfid', array(':dfid' => $dfid))->fetch(); |
|
3665 } |
|
3666 |
|
3667 /** |
|
3668 * Resets the database cache of date formats and saves all new date formats. |
|
3669 */ |
|
3670 function system_date_formats_rebuild() { |
|
3671 drupal_static_reset('system_get_date_formats'); |
|
3672 $date_formats = system_get_date_formats(NULL); |
|
3673 |
|
3674 foreach ($date_formats as $type => $formats) { |
|
3675 foreach ($formats as $format => $info) { |
|
3676 system_date_format_save($info); |
|
3677 } |
|
3678 } |
|
3679 |
|
3680 // Rebuild configured date formats locale list. |
|
3681 drupal_static_reset('system_date_format_locale'); |
|
3682 system_date_format_locale(); |
|
3683 |
|
3684 _system_date_formats_build(); |
|
3685 } |
|
3686 |
|
3687 /** |
|
3688 * Gets the appropriate date format string for a date type and locale. |
|
3689 * |
|
3690 * @param $langcode |
|
3691 * (optional) Language code for the current locale. This can be a 2 character |
|
3692 * language code like 'en' and 'fr' or a 5 character language code like |
|
3693 * 'en-gb' and 'en-us'. |
|
3694 * @param $type |
|
3695 * (optional) The date type name. |
|
3696 * |
|
3697 * @return |
|
3698 * If $type and $langcode are specified, returns the corresponding date format |
|
3699 * string. If only $langcode is specified, returns an array of all date |
|
3700 * format strings for that locale, keyed by the date type. If neither is |
|
3701 * specified, or if no matching formats are found, returns FALSE. |
|
3702 */ |
|
3703 function system_date_format_locale($langcode = NULL, $type = NULL) { |
|
3704 $formats = &drupal_static(__FUNCTION__); |
|
3705 |
|
3706 if (empty($formats)) { |
|
3707 $formats = array(); |
|
3708 $result = db_query("SELECT format, type, language FROM {date_format_locale}"); |
|
3709 foreach ($result as $record) { |
|
3710 if (!isset($formats[$record->language])) { |
|
3711 $formats[$record->language] = array(); |
|
3712 } |
|
3713 $formats[$record->language][$record->type] = $record->format; |
|
3714 } |
|
3715 } |
|
3716 |
|
3717 if ($type && $langcode && !empty($formats[$langcode][$type])) { |
|
3718 return $formats[$langcode][$type]; |
|
3719 } |
|
3720 elseif ($langcode && !empty($formats[$langcode])) { |
|
3721 return $formats[$langcode]; |
|
3722 } |
|
3723 |
|
3724 return FALSE; |
|
3725 } |
|
3726 |
|
3727 /** |
|
3728 * Builds and returns information about available date types. |
|
3729 * |
|
3730 * @return |
|
3731 * An associative array of date type information keyed by name. Each date type |
|
3732 * information array has the following elements: |
|
3733 * - type: The machine-readable name of the date type. |
|
3734 * - title: The human-readable name of the date type. |
|
3735 * - locked: A boolean indicating whether or not this date type should be |
|
3736 * configurable from the user interface. |
|
3737 * - module: The name of the module that defined this format in its |
|
3738 * hook_date_format_types(). An empty string if the format was user-defined. |
|
3739 * - is_new: A boolean indicating whether or not this date type is as of yet |
|
3740 * unsaved in the database. |
|
3741 */ |
|
3742 function _system_date_format_types_build() { |
|
3743 $types = array(); |
|
3744 |
|
3745 // Get list of modules that implement hook_date_format_types(). |
|
3746 $modules = module_implements('date_format_types'); |
|
3747 |
|
3748 foreach ($modules as $module) { |
|
3749 $module_types = module_invoke($module, 'date_format_types'); |
|
3750 foreach ($module_types as $module_type => $type_title) { |
|
3751 $type = array(); |
|
3752 $type['module'] = $module; |
|
3753 $type['type'] = $module_type; |
|
3754 $type['title'] = $type_title; |
|
3755 $type['locked'] = 1; |
|
3756 // Will be over-ridden later if in the db. |
|
3757 $type['is_new'] = TRUE; |
|
3758 $types[$module_type] = $type; |
|
3759 } |
|
3760 } |
|
3761 |
|
3762 // Get custom formats added to the database by the end user. |
|
3763 $result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_type} dft ORDER BY dft.title'); |
|
3764 foreach ($result as $record) { |
|
3765 if (!isset($types[$record->type])) { |
|
3766 $type = array(); |
|
3767 $type['is_new'] = FALSE; |
|
3768 $type['module'] = ''; |
|
3769 $type['type'] = $record->type; |
|
3770 $type['title'] = $record->title; |
|
3771 $type['locked'] = $record->locked; |
|
3772 $types[$record->type] = $type; |
|
3773 } |
|
3774 else { |
|
3775 $type = array(); |
|
3776 $type['is_new'] = FALSE; // Over-riding previous setting. |
|
3777 $types[$record->type] = array_merge($types[$record->type], $type); |
|
3778 } |
|
3779 } |
|
3780 |
|
3781 // Allow other modules to modify these date types. |
|
3782 drupal_alter('date_format_types', $types); |
|
3783 |
|
3784 return $types; |
|
3785 } |
|
3786 |
|
3787 /** |
|
3788 * Builds and returns information about available date formats. |
|
3789 * |
|
3790 * @return |
|
3791 * An associative array of date formats. The top-level keys are the names of |
|
3792 * the date types that the date formats belong to. The values are in turn |
|
3793 * associative arrays keyed by format with the following keys: |
|
3794 * - dfid: The date format ID. |
|
3795 * - format: The PHP date format string. |
|
3796 * - type: The machine-readable name of the date type the format belongs to. |
|
3797 * - locales: An array of language codes. This can include both 2 character |
|
3798 * language codes like 'en and 'fr' and 5 character language codes like |
|
3799 * 'en-gb' and 'en-us'. |
|
3800 * - locked: A boolean indicating whether or not this date type should be |
|
3801 * configurable from the user interface. |
|
3802 * - module: The name of the module that defined this format in its |
|
3803 * hook_date_formats(). An empty string if the format was user-defined. |
|
3804 * - is_new: A boolean indicating whether or not this date type is as of yet |
|
3805 * unsaved in the database. |
|
3806 */ |
|
3807 function _system_date_formats_build() { |
|
3808 $date_formats = array(); |
|
3809 |
|
3810 // First handle hook_date_format_types(). |
|
3811 $types = _system_date_format_types_build(); |
|
3812 foreach ($types as $type => $info) { |
|
3813 system_date_format_type_save($info); |
|
3814 } |
|
3815 |
|
3816 // Get formats supplied by various contrib modules. |
|
3817 $module_formats = module_invoke_all('date_formats'); |
|
3818 |
|
3819 foreach ($module_formats as $module_format) { |
|
3820 // System types are locked. |
|
3821 $module_format['locked'] = 1; |
|
3822 // If no date type is specified, assign 'custom'. |
|
3823 if (!isset($module_format['type'])) { |
|
3824 $module_format['type'] = 'custom'; |
|
3825 } |
|
3826 if (!in_array($module_format['type'], array_keys($types))) { |
|
3827 continue; |
|
3828 } |
|
3829 if (!isset($date_formats[$module_format['type']])) { |
|
3830 $date_formats[$module_format['type']] = array(); |
|
3831 } |
|
3832 |
|
3833 // If another module already set this format, merge in the new settings. |
|
3834 if (isset($date_formats[$module_format['type']][$module_format['format']])) { |
|
3835 $date_formats[$module_format['type']][$module_format['format']] = array_merge_recursive($date_formats[$module_format['type']][$module_format['format']], $module_format); |
|
3836 } |
|
3837 else { |
|
3838 // This setting will be overridden later if it already exists in the db. |
|
3839 $module_format['is_new'] = TRUE; |
|
3840 $date_formats[$module_format['type']][$module_format['format']] = $module_format; |
|
3841 } |
|
3842 } |
|
3843 |
|
3844 // Get custom formats added to the database by the end user. |
|
3845 $result = db_query('SELECT df.dfid, df.format, df.type, df.locked, dfl.language FROM {date_formats} df LEFT JOIN {date_format_locale} dfl ON df.format = dfl.format AND df.type = dfl.type ORDER BY df.type, df.format'); |
|
3846 foreach ($result as $record) { |
|
3847 // If this date type isn't set, initialise the array. |
|
3848 if (!isset($date_formats[$record->type])) { |
|
3849 $date_formats[$record->type] = array(); |
|
3850 } |
|
3851 $format = (array) $record; |
|
3852 $format['is_new'] = FALSE; // It's in the db, so override this setting. |
|
3853 // If this format not already present, add it to the array. |
|
3854 if (!isset($date_formats[$record->type][$record->format])) { |
|
3855 $format['module'] = ''; |
|
3856 $format['locales'] = array($record->language); |
|
3857 $date_formats[$record->type][$record->format] = $format; |
|
3858 } |
|
3859 // Format already present, so merge in settings. |
|
3860 else { |
|
3861 if (!empty($record->language)) { |
|
3862 $format['locales'] = array_merge($date_formats[$record->type][$record->format]['locales'], array($record->language)); |
|
3863 } |
|
3864 $date_formats[$record->type][$record->format] = array_merge($date_formats[$record->type][$record->format], $format); |
|
3865 } |
|
3866 } |
|
3867 |
|
3868 // Allow other modules to modify these formats. |
|
3869 drupal_alter('date_formats', $date_formats); |
|
3870 |
|
3871 return $date_formats; |
|
3872 } |
|
3873 |
|
3874 /** |
|
3875 * Saves a date type to the database. |
|
3876 * |
|
3877 * @param $type |
|
3878 * A date type array containing the following keys: |
|
3879 * - type: The machine-readable name of the date type. |
|
3880 * - title: The human-readable name of the date type. |
|
3881 * - locked: A boolean indicating whether or not this date type should be |
|
3882 * configurable from the user interface. |
|
3883 * - is_new: A boolean indicating whether or not this date type is as of yet |
|
3884 * unsaved in the database. |
|
3885 */ |
|
3886 function system_date_format_type_save($type) { |
|
3887 $info = array(); |
|
3888 $info['type'] = $type['type']; |
|
3889 $info['title'] = $type['title']; |
|
3890 $info['locked'] = $type['locked']; |
|
3891 |
|
3892 // Update date_format table. |
|
3893 if (!empty($type['is_new'])) { |
|
3894 drupal_write_record('date_format_type', $info); |
|
3895 } |
|
3896 else { |
|
3897 drupal_write_record('date_format_type', $info, 'type'); |
|
3898 } |
|
3899 } |
|
3900 |
|
3901 /** |
|
3902 * Deletes a date type from the database. |
|
3903 * |
|
3904 * @param $type |
|
3905 * The machine-readable name of the date type. |
|
3906 */ |
|
3907 function system_date_format_type_delete($type) { |
|
3908 db_delete('date_formats') |
|
3909 ->condition('type', $type) |
|
3910 ->execute(); |
|
3911 db_delete('date_format_type') |
|
3912 ->condition('type', $type) |
|
3913 ->execute(); |
|
3914 db_delete('date_format_locale') |
|
3915 ->condition('type', $type) |
|
3916 ->execute(); |
|
3917 } |
|
3918 |
|
3919 /** |
|
3920 * Saves a date format to the database. |
|
3921 * |
|
3922 * @param $date_format |
|
3923 * A date format array containing the following keys: |
|
3924 * - type: The name of the date type this format is associated with. |
|
3925 * - format: The PHP date format string. |
|
3926 * - locked: A boolean indicating whether or not this format should be |
|
3927 * configurable from the user interface. |
|
3928 * @param $dfid |
|
3929 * If set, replace the existing date format having this ID with the |
|
3930 * information specified in $date_format. |
|
3931 * |
|
3932 * @see system_get_date_types() |
|
3933 * @see http://php.net/date |
|
3934 */ |
|
3935 function system_date_format_save($date_format, $dfid = 0) { |
|
3936 $info = array(); |
|
3937 $info['dfid'] = $dfid; |
|
3938 $info['type'] = $date_format['type']; |
|
3939 $info['format'] = $date_format['format']; |
|
3940 $info['locked'] = $date_format['locked']; |
|
3941 |
|
3942 // Update date_format table. |
|
3943 if (!empty($date_format['is_new'])) { |
|
3944 drupal_write_record('date_formats', $info); |
|
3945 } |
|
3946 else { |
|
3947 $keys = ($dfid ? array('dfid') : array('format', 'type')); |
|
3948 drupal_write_record('date_formats', $info, $keys); |
|
3949 } |
|
3950 |
|
3951 // Retrieve an array of language objects for enabled languages. |
|
3952 $languages = language_list('enabled'); |
|
3953 // This list is keyed off the value of $language->enabled; we want the ones |
|
3954 // that are enabled (value of 1). |
|
3955 $languages = $languages[1]; |
|
3956 |
|
3957 $locale_format = array(); |
|
3958 $locale_format['type'] = $date_format['type']; |
|
3959 $locale_format['format'] = $date_format['format']; |
|
3960 |
|
3961 // Check if the suggested language codes are configured and enabled. |
|
3962 if (!empty($date_format['locales'])) { |
|
3963 foreach ($date_format['locales'] as $langcode) { |
|
3964 // Only proceed if language is enabled. |
|
3965 if (isset($languages[$langcode])) { |
|
3966 $is_existing = (bool) db_query_range('SELECT 1 FROM {date_format_locale} WHERE type = :type AND language = :language', 0, 1, array(':type' => $date_format['type'], ':language' => $langcode))->fetchField(); |
|
3967 if (!$is_existing) { |
|
3968 $locale_format['language'] = $langcode; |
|
3969 drupal_write_record('date_format_locale', $locale_format); |
|
3970 } |
|
3971 } |
|
3972 } |
|
3973 } |
|
3974 } |
|
3975 |
|
3976 /** |
|
3977 * Deletes a date format from the database. |
|
3978 * |
|
3979 * @param $dfid |
|
3980 * The date format ID. |
|
3981 */ |
|
3982 function system_date_format_delete($dfid) { |
|
3983 db_delete('date_formats') |
|
3984 ->condition('dfid', $dfid) |
|
3985 ->execute(); |
|
3986 } |
|
3987 |
|
3988 /** |
|
3989 * Implements hook_archiver_info(). |
|
3990 */ |
|
3991 function system_archiver_info() { |
|
3992 $archivers['tar'] = array( |
|
3993 'class' => 'ArchiverTar', |
|
3994 'extensions' => array('tar', 'tgz', 'tar.gz', 'tar.bz2'), |
|
3995 ); |
|
3996 if (function_exists('zip_open')) { |
|
3997 $archivers['zip'] = array( |
|
3998 'class' => 'ArchiverZip', |
|
3999 'extensions' => array('zip'), |
|
4000 ); |
|
4001 } |
|
4002 return $archivers; |
|
4003 } |
|
4004 |
|
4005 /** |
|
4006 * Returns HTML for a confirmation form. |
|
4007 * |
|
4008 * By default this does not alter the appearance of a form at all, |
|
4009 * but is provided as a convenience for themers. |
|
4010 * |
|
4011 * @param $variables |
|
4012 * An associative array containing: |
|
4013 * - form: A render element representing the form. |
|
4014 * |
|
4015 * @ingroup themeable |
|
4016 */ |
|
4017 function theme_confirm_form($variables) { |
|
4018 return drupal_render_children($variables['form']); |
|
4019 } |
|
4020 |
|
4021 /** |
|
4022 * Returns HTML for a system settings form. |
|
4023 * |
|
4024 * By default this does not alter the appearance of a form at all, |
|
4025 * but is provided as a convenience for themers. |
|
4026 * |
|
4027 * @param $variables |
|
4028 * An associative array containing: |
|
4029 * - form: A render element representing the form. |
|
4030 * |
|
4031 * @ingroup themeable |
|
4032 */ |
|
4033 function theme_system_settings_form($variables) { |
|
4034 return drupal_render_children($variables['form']); |
|
4035 } |
|
4036 |
|
4037 /** |
|
4038 * Returns HTML for an exposed filter form. |
|
4039 * |
|
4040 * @param $variables |
|
4041 * An associative array containing: |
|
4042 * - form: An associative array containing the structure of the form. |
|
4043 * |
|
4044 * @return |
|
4045 * A string containing an HTML-formatted form. |
|
4046 * |
|
4047 * @ingroup themeable |
|
4048 */ |
|
4049 function theme_exposed_filters($variables) { |
|
4050 $form = $variables['form']; |
|
4051 $output = ''; |
|
4052 |
|
4053 if (isset($form['current'])) { |
|
4054 $items = array(); |
|
4055 foreach (element_children($form['current']) as $key) { |
|
4056 $items[] = drupal_render($form['current'][$key]); |
|
4057 } |
|
4058 $output .= theme('item_list', array('items' => $items, 'attributes' => array('class' => array('clearfix', 'current-filters')))); |
|
4059 } |
|
4060 |
|
4061 $output .= drupal_render_children($form); |
|
4062 |
|
4063 return '<div class="exposed-filters">' . $output . '</div>'; |
|
4064 } |
|
4065 |
|
4066 /** |
|
4067 * Implements hook_admin_paths(). |
|
4068 */ |
|
4069 function system_admin_paths() { |
|
4070 $paths = array( |
|
4071 'admin' => TRUE, |
|
4072 'admin/*' => TRUE, |
|
4073 'batch' => TRUE, |
|
4074 // This page should not be treated as administrative since it outputs its |
|
4075 // own content (outside of any administration theme). |
|
4076 'admin/reports/status/php' => FALSE, |
|
4077 ); |
|
4078 return $paths; |
|
4079 } |