system.module 136 KB
Newer Older
Dries's avatar
 
Dries committed
1
2
<?php

Dries's avatar
   
Dries committed
3
4
5
6
7
/**
 * @file
 * Configuration system that lets administrators modify the workings of the site.
 */

8
9
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Cache\Cache;
10
use Drupal\Core\Database\Database;
11
use Drupal\Core\Utility\ModuleInfo;
12
use Drupal\Core\TypedData\Primitive;
13
use Drupal\system\Plugin\block\block\SystemMenuBlock;
14
use Symfony\Component\HttpFoundation\JsonResponse;
15
16
use Symfony\Component\HttpFoundation\Response;

17
18
19
/**
 * Maximum age of temporary files in seconds.
 */
20
const DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600;
21

22
23
24
/**
 * New users will be set to the default time zone at registration.
 */
25
const DRUPAL_USER_TIMEZONE_DEFAULT = 0;
26
27
28
29

/**
 * New users will get an empty time zone at registration.
 */
30
const DRUPAL_USER_TIMEZONE_EMPTY = 1;
31
32
33
34

/**
 * New users will select their own timezone at registration.
 */
35
const DRUPAL_USER_TIMEZONE_SELECT = 2;
36

37
38
39
 /**
 * Disabled option on forms and settings
 */
40
const DRUPAL_DISABLED = 0;
41
42
43
44

/**
 * Optional option on forms and settings
 */
45
const DRUPAL_OPTIONAL = 1;
46
47
48
49

/**
 * Required option on forms and settings
 */
50
const DRUPAL_REQUIRED = 2;
51

52
/**
53
 * Return only visible regions.
54
55
 *
 * @see system_region_list()
56
 */
57
const REGIONS_VISIBLE = 'visible';
58
59

/**
60
 * Return all regions.
61
62
 *
 * @see system_region_list()
63
 */
64
const REGIONS_ALL = 'all';
65

Dries's avatar
   
Dries committed
66
/**
67
 * Implements hook_help().
Dries's avatar
   
Dries committed
68
 */
69
function system_help($path, $arg) {
70
71
  global $base_url;

72
  switch ($path) {
73
    case 'admin/help#system':
74
75
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
76
      $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>';
77
78
79
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Managing modules') . '</dt>';
80
      $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>';
81
82
83
84
85
      $output .= '<dt>' . t('Managing themes') . '</dt>';
      $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>';
      $output .= '<dt>' . t('Managing caching') . '</dt>';
      $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>';
      $output .= '<dt>' . t('Performing system maintenance') . '</dt>';
86
      $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>';
87
      $output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
88
      $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="@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'), '@site-info' => url('admin/config/system/site-information'), '@maintenance-mode' => url('admin/config/development/maintenance'))) . '</dd>';
89
      $output .= '</dl>';
90
      return $output;
91
    case 'admin/index':
92
      return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
93
    case 'admin/appearance':
94
      $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>';
95
      return $output;
96
    case 'admin/appearance/settings/' . $arg[3]:
97
98
99
      $theme_list = list_themes();
      $theme = $theme_list[$arg[3]];
      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>';
100
    case 'admin/appearance/settings':
101
      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>';
102
    case 'admin/modules':
103
      $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>';
104
105
      if (module_exists('update')) {
        if (update_manager_access()) {
106
          $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 . '/core/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
107
108
        }
        else {
109
          $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 . '/core/update.php', '@updates' => url('admin/reports/updates'))) . '</p>';
110
111
112
        }
      }
      else {
113
        $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 . '/core/update.php')) . '</p>';
114
      }
115
      return $output;
116
    case 'admin/modules/uninstall':
117
      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>';
118
    case 'admin/structure/block/manage':
119
      if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
120
        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>';
121
      }
122
      break;
123
    case 'admin/config/development/maintenance':
124
125
      global $user;
      if ($user->uid == 1) {
126
        return '<p>' . t('Use maintenance mode when making major updates, particularly if the updates could disrupt visitors or the update process. Examples include upgrading, importing or exporting content, modifying a theme, modifying content types, and making backups.') . '</p>';
127
      }
128
      break;
129
    case 'admin/reports/status':
130
      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. Before filing a support request, ensure that your web server meets the <a href=\"@system-requirements\">system requirements.</a>", array('@system-requirements' => 'http://drupal.org/requirements')) . '</p>';
131
  }
Dries's avatar
   
Dries committed
132
133
}

134
/**
135
 * Implements hook_theme().
136
 */
137
function system_theme() {
138
  return array_merge(drupal_common_theme(), array(
139
140
    'system_themes_page' => array(
      'variables' => array('theme_groups' => NULL),
141
      'file' => 'system.admin.inc',
142
    ),
143
    'system_settings_form' => array(
144
      'render element' => 'form',
145
146
    ),
    'confirm_form' => array(
147
      'render element' => 'form',
148
    ),
149
    'system_modules_details' => array(
150
      'render element' => 'form',
151
      'file' => 'system.admin.inc',
152
    ),
153
    'system_modules_incompatible' => array(
154
      'variables' => array('message' => NULL),
155
      'file' => 'system.admin.inc',
156
    ),
157
    'system_modules_uninstall' => array(
158
      'render element' => 'form',
159
      'file' => 'system.admin.inc',
160
161
    ),
    'status_report' => array(
162
      'render element' => 'requirements',
163
      'file' => 'system.admin.inc',
164
165
    ),
    'admin_page' => array(
166
      'variables' => array('blocks' => NULL),
167
      'file' => 'system.admin.inc',
168
169
    ),
    'admin_block' => array(
170
      'variables' => array('block' => NULL),
171
      'file' => 'system.admin.inc',
172
173
    ),
    'admin_block_content' => array(
174
      'variables' => array('content' => NULL),
175
      'file' => 'system.admin.inc',
176
    ),
177
    'system_admin_index' => array(
178
      'variables' => array('menu_items' => NULL),
179
      'file' => 'system.admin.inc',
180
    ),
181
    'system_powered_by' => array(
182
      'variables' => array(),
183
    ),
184
185
    'system_compact_link' => array(
      'variables' => array(),
186
    ),
187
188
189
    'system_date_format_localize_form' => array(
      'render element' => 'form',
    ),
190
191
192
193
    'system_plugin_ui_form' => array(
      'template' => 'system-plugin-ui-form',
      'render element' => 'form',
    ),
194
195
  ));
}
196

Dries's avatar
   
Dries committed
197
/**
198
 * Implements hook_permission().
Dries's avatar
   
Dries committed
199
 */
200
function system_permission() {
201
  return array(
202
203
204
    'administer modules' => array(
      'title' => t('Administer modules'),
    ),
205
206
    'administer site configuration' => array(
      'title' => t('Administer site configuration'),
207
      'restrict access' => TRUE,
208
    ),
209
210
211
    'administer themes' => array(
      'title' => t('Administer themes'),
    ),
212
    'administer software updates' => array(
213
214
      'title' => t('Administer software updates'),
      'restrict access' => TRUE,
215
    ),
216
    'access administration pages' => array(
217
      'title' => t('Use the administration pages and help'),
218
    ),
219
    'access site in maintenance mode' => array(
220
      'title' => t('Use the site in maintenance mode'),
221
    ),
222
223
    'view the administration theme' => array(
      'title' => t('View the administration theme'),
224
      'description' => config('system.theme')->get('admin') ?: 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'))),
225
    ),
226
    'access site reports' => array(
227
      'title' => t('View site reports'),
228
    ),
229
  );
Dries's avatar
   
Dries committed
230
231
}

232
/**
233
 * Implements hook_hook_info().
234
235
236
237
238
 */
function system_hook_info() {
  $hooks['token_info'] = array(
    'group' => 'tokens',
  );
239
240
241
  $hooks['token_info_alter'] = array(
    'group' => 'tokens',
  );
242
243
244
  $hooks['tokens'] = array(
    'group' => 'tokens',
  );
245
246
247
248
  $hooks['tokens_alter'] = array(
    'group' => 'tokens',
  );

249
250
251
  return $hooks;
}

252
/**
253
 * Implements hook_element_info().
254
 */
255
256
257
function system_element_info() {
  // Top level elements.
  $types['form'] = array(
258
259
    '#method' => 'post',
    '#action' => request_uri(),
260
    '#theme_wrappers' => array('form'),
261
  );
262
  $types['page'] = array(
263
264
    '#show_messages' => TRUE,
    '#theme' => 'page',
265
    '#theme_wrappers' => array('html'),
266
  );
267
  // By default, we don't want Ajax commands being rendered in the context of an
268
269
  // HTML page, so we don't provide defaults for #theme or #theme_wrappers.
  // However, modules can set these properties (for example, to provide an HTML
270
  // debugging page that displays rather than executes Ajax commands).
271
272
273
274
  $types['ajax'] = array(
    '#header' => TRUE,
    '#commands' => array(),
    '#error' => NULL,
275
  );
276
277
  $types['html_tag'] = array(
    '#theme' => 'html_tag',
278
    '#pre_render' => array('drupal_pre_render_conditional_comments'),
279
280
281
    '#attributes' => array(),
    '#value' => NULL,
  );
282
283
284
285
286
287
  $types['styles'] = array(
    '#items' => array(),
    '#pre_render' => array('drupal_pre_render_styles'),
    '#group_callback' => 'drupal_group_css',
    '#aggregate_callback' => 'drupal_aggregate_css',
  );
288
289
290
291
292
293
  $types['scripts'] = array(
    '#items' => array(),
    '#pre_render' => array('drupal_pre_render_scripts'),
    '#group_callback' => 'drupal_group_js',
    '#aggregate_callback' => 'drupal_aggregate_js',
  );
294

295
296
  // Input elements.
  $types['submit'] = array(
297
298
    '#input' => TRUE,
    '#name' => 'op',
299
    '#is_button' => TRUE,
300
    '#executes_submit_callback' => TRUE,
301
    '#limit_validation_errors' => FALSE,
302
    '#process' => array('form_process_button', 'ajax_process_form'),
303
304
    '#pre_render' => array('form_pre_render_button'),
    '#theme_wrappers' => array('input__submit'),
305
  );
306
  $types['button'] = array(
307
308
    '#input' => TRUE,
    '#name' => 'op',
309
    '#is_button' => TRUE,
310
    '#executes_submit_callback' => FALSE,
311
    '#limit_validation_errors' => FALSE,
312
    '#process' => array('form_process_button', 'ajax_process_form'),
313
314
    '#pre_render' => array('form_pre_render_button'),
    '#theme_wrappers' => array('input__button'),
315
  );
316
  $types['image_button'] = array(
317
    '#input' => TRUE,
318
    '#is_button' => TRUE,
319
    '#executes_submit_callback' => TRUE,
320
    '#limit_validation_errors' => FALSE,
321
    '#process' => array('form_process_button', 'ajax_process_form'),
322
323
324
    '#return_value' => TRUE,
    '#has_garbage_value' => TRUE,
    '#src' => NULL,
325
326
    '#pre_render' => array('form_pre_render_image_button'),
    '#theme_wrappers' => array('input__image_button'),
327
  );
328
  $types['textfield'] = array(
329
330
331
332
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
    '#autocomplete_path' => FALSE,
333
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
334
335
    '#pre_render' => array('form_pre_render_textfield'),
    '#theme' => 'input__textfield',
336
    '#theme_wrappers' => array('form_element'),
337
  );
338
339
340
341
342
  $types['tel'] = array(
    '#input' => TRUE,
    '#size' => 30,
    '#maxlength' => 128,
    '#autocomplete_path' => FALSE,
343
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
344
345
    '#pre_render' => array('form_pre_render_tel'),
    '#theme' => 'input__tel',
346
347
    '#theme_wrappers' => array('form_element'),
  );
348
349
350
  $types['email'] = array(
    '#input' => TRUE,
    '#size' => 60,
351
352
    // user.module is not loaded in case of early bootstrap errors.
    '#maxlength' => defined('EMAIL_MAX_LENGTH') ? EMAIL_MAX_LENGTH : 255,
353
    '#autocomplete_path' => FALSE,
354
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
355
    '#element_validate' => array('form_validate_email'),
356
357
    '#pre_render' => array('form_pre_render_email'),
    '#theme' => 'input__email',
358
359
    '#theme_wrappers' => array('form_element'),
  );
360
361
362
363
364
  $types['url'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 255,
    '#autocomplete_path' => FALSE,
365
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
366
    '#element_validate' => array('form_validate_url'),
367
368
    '#pre_render' => array('form_pre_render_url'),
    '#theme' => 'input__url',
369
370
    '#theme_wrappers' => array('form_element'),
  );
371
372
373
374
375
  $types['search'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
    '#autocomplete_path' => FALSE,
376
    '#process' => array('form_process_autocomplete', 'ajax_process_form'),
377
378
    '#pre_render' => array('form_pre_render_search'),
    '#theme' => 'input__search',
379
380
    '#theme_wrappers' => array('form_element'),
  );
381
382
383
384
385
  $types['number'] = array(
    '#input' => TRUE,
    '#step' => 1,
    '#process' => array('ajax_process_form'),
    '#element_validate' => array('form_validate_number'),
386
387
    '#pre_render' => array('form_pre_render_number'),
    '#theme' => 'input__number',
388
389
    '#theme_wrappers' => array('form_element'),
  );
390
391
392
393
394
395
396
  $types['range'] = array(
    '#input' => TRUE,
    '#step' => 1,
    '#min' => 0,
    '#max' => 100,
    '#process' => array('ajax_process_form'),
    '#element_validate' => array('form_validate_number'),
397
398
    '#pre_render' => array('form_pre_render_range'),
    '#theme' => 'input__range',
399
400
    '#theme_wrappers' => array('form_element'),
  );
401
402
403
404
  $types['color'] = array(
    '#input' => TRUE,
    '#process' => array('ajax_process_form'),
    '#element_validate' => array('form_validate_color'),
405
406
    '#pre_render' => array('form_pre_render_color'),
    '#theme' => 'input__color',
407
408
    '#theme_wrappers' => array('form_element'),
  );
409
410
411
412
413
414
415
  $types['machine_name'] = array(
    '#input' => TRUE,
    '#default_value' => NULL,
    '#required' => TRUE,
    '#maxlength' => 64,
    '#size' => 60,
    '#autocomplete_path' => FALSE,
416
    '#process' => array('form_process_machine_name', 'form_process_autocomplete', 'ajax_process_form'),
417
    '#element_validate' => array('form_validate_machine_name'),
418
419
    '#pre_render' => array('form_pre_render_textfield'),
    '#theme' => 'input__textfield',
420
421
    '#theme_wrappers' => array('form_element'),
  );
422
  $types['password'] = array(
423
424
425
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
426
    '#process' => array('ajax_process_form', 'form_process_pattern'),
427
428
    '#pre_render' => array('form_pre_render_password'),
    '#theme' => 'input__password',
429
    '#theme_wrappers' => array('form_element'),
430
  );
431
  $types['password_confirm'] = array(
432
    '#input' => TRUE,
433
    '#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'),
434
    '#theme_wrappers' => array('form_element'),
435
  );
436
  $types['textarea'] = array(
437
438
439
    '#input' => TRUE,
    '#cols' => 60,
    '#rows' => 5,
440
    '#resizable' => 'vertical',
441
    '#process' => array('ajax_process_form'),
442
    '#theme' => 'textarea',
443
    '#theme_wrappers' => array('form_element'),
444
  );
445
  $types['radios'] = array(
446
    '#input' => TRUE,
447
    '#process' => array('form_process_radios'),
448
    '#theme_wrappers' => array('radios'),
449
    '#pre_render' => array('form_pre_render_conditional_form_element'),
450
  );
451
  $types['radio'] = array(
452
453
    '#input' => TRUE,
    '#default_value' => NULL,
454
    '#process' => array('ajax_process_form'),
455
456
    '#pre_render' => array('form_pre_render_radio'),
    '#theme' => 'input__radio',
457
    '#theme_wrappers' => array('form_element'),
458
    '#title_display' => 'after',
459
  );
460
  $types['checkboxes'] = array(
461
    '#input' => TRUE,
462
    '#process' => array('form_process_checkboxes'),
463
    '#pre_render' => array('form_pre_render_conditional_form_element'),
464
    '#theme_wrappers' => array('checkboxes'),
465
  );
466
  $types['checkbox'] = array(
467
468
    '#input' => TRUE,
    '#return_value' => 1,
469
    '#process' => array('form_process_checkbox', 'ajax_process_form'),
470
471
    '#pre_render' => array('form_pre_render_checkbox'),
    '#theme' => 'input__checkbox',
472
    '#theme_wrappers' => array('form_element'),
473
    '#title_display' => 'after',
474
  );
475
  $types['select'] = array(
476
477
    '#input' => TRUE,
    '#multiple' => FALSE,
478
    '#process' => array('form_process_select', 'ajax_process_form'),
479
    '#theme' => 'select',
480
    '#theme_wrappers' => array('form_element'),
481
    '#options' => array(),
482
  );
483
484
485
486
  $types['language_select'] = array(
    '#input' => TRUE,
    '#default_value' => LANGUAGE_NOT_SPECIFIED,
  );
487
  $types['weight'] = array(
488
489
490
    '#input' => TRUE,
    '#delta' => 10,
    '#default_value' => 0,
491
    '#process' => array('form_process_weight', 'ajax_process_form'),
492
  );
493
  $types['date'] = array(
494
    '#input' => TRUE,
495
    '#theme' => 'date',
496
    '#theme_wrappers' => array('form_element'),
497
  );
498
  $types['file'] = array(
499
500
    '#input' => TRUE,
    '#size' => 60,
501
502
    '#pre_render' => array('form_pre_render_file'),
    '#theme' => 'input__file',
503
    '#theme_wrappers' => array('form_element'),
504
  );
505
  $types['tableselect'] = array(
506
507
508
509
510
511
    '#input' => TRUE,
    '#js_select' => TRUE,
    '#multiple' => TRUE,
    '#process' => array('form_process_tableselect'),
    '#options' => array(),
    '#empty' => '',
512
    '#theme' => 'tableselect',
513
  );
514

515
516
  // Form structure.
  $types['item'] = array(
517
518
519
520
521
522
    // Forms that show author fields to both anonymous and authenticated users
    // need to dynamically switch between #type 'textfield' and #type 'item' to
    // automatically take over the authenticated user's information. Therefore,
    // we allow #type 'item' to receive input, which is internally assigned by
    // Form API based on the #default_value or #value properties.
    '#input' => TRUE,
523
    '#markup' => '',
524
    '#theme_wrappers' => array('form_element'),
525
  );
526
  $types['hidden'] = array(
527
    '#input' => TRUE,
528
    '#process' => array('ajax_process_form'),
529
530
531
532
533
534
535
    '#pre_render' => array('form_pre_render_hidden'),
    '#theme' => 'input__hidden',
  );
  $types['token'] = array(
    '#input' => TRUE,
    '#pre_render' => array('form_pre_render_hidden'),
    '#theme' => 'input__hidden',
536
  );
537
  $types['value'] = array(
538
539
    '#input' => TRUE,
  );
540
  $types['markup'] = array(
541
    '#markup' => '',
542
543
  );
  $types['link'] = array(
544
    '#pre_render' => array('drupal_pre_render_link'),
545
  );
546
  $types['fieldset'] = array(
547
    '#value' => NULL,
548
549
    '#process' => array('form_process_group', 'ajax_process_form'),
    '#pre_render' => array('form_pre_render_group'),
550
551
552
    '#theme_wrappers' => array('fieldset'),
  );
  $types['details'] = array(
553
554
    '#collapsed' => FALSE,
    '#value' => NULL,
555
556
    '#process' => array('form_process_group', 'ajax_process_form'),
    '#pre_render' => array('form_pre_render_details', 'form_pre_render_group'),
557
    '#theme_wrappers' => array('details'),
558
  );
559
  $types['vertical_tabs'] = array(
560
561
    '#default_tab' => '',
    '#process' => array('form_process_vertical_tabs'),
562
563
    '#pre_render' => array('form_pre_render_vertical_tabs'),
    '#theme_wrappers' => array('vertical_tabs', 'form_element'),
564
  );
565
566
  $types['dropbutton'] = array(
    '#pre_render' => array('drupal_pre_render_dropbutton'),
567
    '#theme' => 'links__dropbutton',
568
569
570
  );
  $types['operations'] = array(
    '#pre_render' => array('drupal_pre_render_dropbutton'),
571
    '#theme' => 'links__dropbutton__operations',
572
  );
573
574

  $types['container'] = array(
575
576
    '#process' => array('form_process_group', 'form_process_container'),
    '#pre_render' => array('form_pre_render_group'),
577
    '#theme_wrappers' => array('container'),
578
  );
579
  $types['actions'] = array(
580
    '#process' => array('form_pre_render_actions_dropbutton', 'form_process_actions', 'form_process_container'),
581
    '#weight' => 100,
582
    '#theme_wrappers' => array('container'),
583
584
  );

585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
  $types['table'] = array(
    '#header' => array(),
    '#rows' => array(),
    '#empty' => '',
    // Properties for tableselect support.
    '#input' => TRUE,
    '#tree' => TRUE,
    '#tableselect' => FALSE,
    '#multiple' => TRUE,
    '#js_select' => TRUE,
    '#value_callback' => 'form_type_table_value',
    '#process' => array('form_process_table'),
    '#element_validate' => array('form_validate_table'),
    // Properties for tabledrag support.
    // The value is a list of arrays that are passed to drupal_add_tabledrag().
    // drupal_pre_render_table() prepends the HTML ID of the table to each set
    // of arguments.
    // @see drupal_add_tabledrag()
    '#tabledrag' => array(),
    // Render properties.
    '#pre_render' => array('drupal_pre_render_table'),
    '#theme' => 'table',
  );

609
  return $types;
610
611
}

Dries's avatar
   
Dries committed
612
/**
613
 * Implements hook_menu().
Dries's avatar
   
Dries committed
614
 */
615
616
function system_menu() {
  $items['system/files'] = array(
617
    'title' => 'File download',
618
    'page callback' => 'file_download',
619
620
621
622
623
624
625
626
    'page arguments' => array('private'),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['system/temporary'] = array(
    'title' => 'Temporary files',
    'page callback' => 'file_download',
    'page arguments' => array('temporary'),
627
    'access callback' => TRUE,
628
629
    'type' => MENU_CALLBACK,
  );
630
  $items['system/ajax'] = array(
631
    'title' => 'AHAH callback',
632
    'page callback' => 'ajax_form_callback',
633
    'access callback' => TRUE,
634
    'theme callback' => 'ajax_base_page_theme',
635
    'type' => MENU_CALLBACK,
636
    'file path' => 'core/includes',
637
    'file' => 'form.inc',
638
  );
639
640
641
642
643
  $items['system/timezone'] = array(
    'title' => 'Time zone',
    'page callback' => 'system_timezone',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
644
    'file' => 'system.admin.inc',
645
  );
646
  $items['admin'] = array(
647
    'title' => 'Administration',
648
    'access arguments' => array('access administration pages'),
649
    'page callback' => 'system_admin_menu_block_page',
650
    'weight' => 9,
651
    'menu_name' => 'admin',
652
    'file' => 'system.admin.inc',
653
654
  );
  $items['admin/compact'] = array(
655
    'title' => 'Compact mode',
656
    'page callback' => 'system_admin_compact_page',
657
    'access arguments' => array('access administration pages'),
658
    'type' => MENU_CALLBACK,
659
    'file' => 'system.admin.inc',
660
  );
661
662
  $items['admin/tasks'] = array(
    'title' => 'Tasks',
663
    'type' => MENU_DEFAULT_LOCAL_TASK,
664
    'weight' => -20,
665
  );
666
667
668
  $items['admin/index'] = array(
    'title' => 'Index',
    'page callback' => 'system_admin_index',
669
    'access arguments' => array('access administration pages'),
670
    'type' => MENU_LOCAL_TASK,
671
    'weight' => -18,
672
    'file' => 'system.admin.inc',
673
  );
674

675
  // Menu items that are basically just menu blocks.
676
677
  $items['admin/structure'] = array(
    'title' => 'Structure',
678
    'description' => 'Administer blocks, content types, menus, etc.',
679
    'position' => 'right',
680
    'weight' => -8,
681
    'page callback' => 'system_admin_menu_block_page',
682
    'access arguments' => array('access administration pages'),
683
    'file' => 'system.admin.inc',
684
  );
685
686
687
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
688
    'description' => 'Select and configure your themes.',
689
    'page callback' => 'system_themes_page',
690
    'access arguments' => array('administer themes'),
691
    'position' => 'left',
692
    'weight' => -6,
693
    'file' => 'system.admin.inc',
694
  );
695
  $items['admin/appearance/list'] = array(
696
    'title' => 'List',
697
    'description' => 'Select and configure your theme',
698
    'type' => MENU_DEFAULT_LOCAL_TASK,
699
    'file' => 'system.admin.inc',
700
  );
701
702
703
  $items['admin/appearance/enable'] = array(
    'title' => 'Enable theme',
    'page callback' => 'system_theme_enable',
704
    'access arguments' => array('administer themes'),
705
706
707
708
709
710
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
  $items['admin/appearance/disable'] = array(
    'title' => 'Disable theme',
    'page callback' => 'system_theme_disable',
711
    'access arguments' => array('administer themes'),
712
713
714
715
716
717
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
  $items['admin/appearance/default'] = array(
    'title' => 'Set default theme',
    'page callback' => 'system_theme_default',
718
    'access arguments' => array('administer themes'),
719
720
721
    'type' => MENU_CALLBACK,
    'file' => 'system.admin.inc',
  );
722
  $items['admin/appearance/settings'] = array(
723
    'title' => 'Settings',
724
    'description' => 'Configure default and theme specific settings.',
725
    'page callback' => 'drupal_get_form',
726
    'page arguments' => array('system_theme_settings'),
727
    'access arguments' => array('administer themes'),
728
    'type' => MENU_LOCAL_TASK,
729
    'file' => 'system.admin.inc',
730
    'weight' => 100,
731
  );
732
  // Theme configuration subtabs.
733
  $items['admin/appearance/settings/global'] = array(
734
    'title' => 'Global settings',
735
736
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
Dries's avatar
   
Dries committed
737

738
  foreach (list_themes() as $key => $theme) {
739
    $items['admin/appearance/settings/' . $theme->name] = array(
740
741
742
743
      'title' => $theme->info['name'],
      'page arguments' => array('system_theme_settings', $theme->name),
      'type' => MENU_LOCAL_TASK,
      'access callback' => '_system_themes_access',
744
      'access arguments' => array($key),
745
      'file' => 'system.admin.inc',
746