system.module 108 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\Language\Language;
11
use Drupal\Core\Utility\ModuleInfo;
12
use Drupal\menu_link\MenuLinkInterface;
13
use Drupal\user\UserInterface;
14
use Symfony\Component\HttpFoundation\JsonResponse;
15
use Symfony\Component\HttpFoundation\RedirectResponse;
16
use Symfony\Component\HttpFoundation\Response;
17
use Symfony\Component\HttpFoundation\Request;
18
19
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Exception\RequestException;
20

21
22
23
/**
 * Maximum age of temporary files in seconds.
 */
24
const DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600;
25

26
27
28
/**
 * New users will be set to the default time zone at registration.
 */
29
const DRUPAL_USER_TIMEZONE_DEFAULT = 0;
30
31
32
33

/**
 * New users will get an empty time zone at registration.
 */
34
const DRUPAL_USER_TIMEZONE_EMPTY = 1;
35
36
37
38

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

41
42
43
 /**
 * Disabled option on forms and settings
 */
44
const DRUPAL_DISABLED = 0;
45
46
47
48

/**
 * Optional option on forms and settings
 */
49
const DRUPAL_OPTIONAL = 1;
50
51
52
53

/**
 * Required option on forms and settings
 */
54
const DRUPAL_REQUIRED = 2;
55

56
/**
57
 * Return only visible regions.
58
59
 *
 * @see system_region_list()
60
 */
61
const REGIONS_VISIBLE = 'visible';
62
63

/**
64
 * Return all regions.
65
66
 *
 * @see system_region_list()
67
 */
68
const REGIONS_ALL = 'all';
69

70
71
72
73
74
75
76
77
78
79
80
81
/**
 * Defines the max length for an email address
 *
 * The maximum length of an e-mail address is 254 characters. RFC 3696
 * specifies a total length of 320 characters, but mentions that
 * addresses longer than 256 characters are not normally useful. Erratum
 * 1690 was then released which corrected this value to 254 characters.
 * @see http://tools.ietf.org/html/rfc3696#section-3
 * @see http://www.rfc-editor.org/errata_search.php?rfc=3696&eid=1690
 */
const EMAIL_MAX_LENGTH = 254;

Dries's avatar
   
Dries committed
82
/**
83
 * Implements hook_help().
Dries's avatar
   
Dries committed
84
 */
85
function system_help($path, $arg) {
86
87
  global $base_url;

88
  switch ($path) {
89
    case 'admin/help#system':
90
91
      $output = '';
      $output .= '<h3>' . t('About') . '</h3>';
92
      $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>';
93
94
95
      $output .= '<h3>' . t('Uses') . '</h3>';
      $output .= '<dl>';
      $output .= '<dt>' . t('Managing modules') . '</dt>';
96
      $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>';
97
98
99
100
101
      $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>';
102
      $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>';
103
      $output .= '<dt>' . t('Configuring basic site settings') . '</dt>';
104
      $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>';
105
      $output .= '</dl>';
106
      return $output;
107
    case 'admin/index':
108
      return '<p>' . t('This page shows you all available administration tasks for each module.') . '</p>';
109
    case 'admin/appearance':
110
      $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>';
111
      return $output;
112
    case 'admin/appearance/settings/' . $arg[3]:
113
114
115
      $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>';
116
    case 'admin/appearance/settings':
117
      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>';
118
    case 'admin/modules':
119
      $output = '<p>' . t('Download additional <a href="@modules">contributed modules</a> to extend Drupal\'s functionality.', array('@modules' => 'http://drupal.org/project/modules')) . '</p>';
120
      if (\Drupal::moduleHandler()->moduleExists('update')) {
121
        if (update_manager_access()) {
122
          $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>';
123
124
        }
        else {
125
          $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>';
126
127
128
        }
      }
      else {
129
        $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>';
130
      }
131
      return $output;
132
    case 'admin/modules/uninstall':
133
      return '<p>' . t('The uninstall process removes all data related to a module.') . '</p>';
134
    case 'admin/structure/block/manage':
135
      if ($arg[4] == 'system' && $arg[5] == 'powered-by') {
136
        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>';
137
      }
138
      break;
139
    case 'admin/config/development/maintenance':
140
      if (\Drupal::currentUser()->id() == 1) {
141
        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>';
142
      }
143
      break;
144
    case 'admin/reports/status':
145
      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>';
146
  }
Dries's avatar
   
Dries committed
147
148
}

149
/**
150
 * Implements hook_theme().
151
 */
152
function system_theme() {
153
  return array_merge(drupal_common_theme(), array(
154
    'system_themes_page' => array(
155
156
157
158
      'variables' => array(
        'theme_groups' => NULL,
        'theme_group_titles' => NULL,
      ),
159
      'file' => 'system.admin.inc',
160
    ),
161
    'system_config_form' => array(
162
      'render element' => 'form',
163
164
    ),
    'confirm_form' => array(
165
      'render element' => 'form',
166
    ),
167
    'system_modules_details' => array(
168
      'render element' => 'form',
169
      'file' => 'system.admin.inc',
170
    ),
171
    'system_modules_incompatible' => array(
172
      'variables' => array('message' => NULL),
173
      'file' => 'system.admin.inc',
174
    ),
175
    'system_modules_uninstall' => array(
176
      'render element' => 'form',
177
      'file' => 'system.admin.inc',
178
179
    ),
    'status_report' => array(
180
      'variables' => array('requirements' => NULL),
181
      'file' => 'system.admin.inc',
182
      'template' => 'status-report',
183
184
    ),
    'admin_page' => array(
185
      'variables' => array('blocks' => NULL),
186
      'file' => 'system.admin.inc',
187
188
    ),
    'admin_block' => array(
189
      'variables' => array('block' => NULL),
190
      'file' => 'system.admin.inc',
191
192
    ),
    'admin_block_content' => array(
193
      'variables' => array('content' => NULL),
194
      'file' => 'system.admin.inc',
195
    ),
196
    'system_admin_index' => array(
197
      'variables' => array('menu_items' => NULL),
198
      'file' => 'system.admin.inc',
199
    ),
200
201
    'system_compact_link' => array(
      'variables' => array(),
202
    ),
203
204
  ));
}
205

Dries's avatar
   
Dries committed
206
/**
207
 * Implements hook_permission().
Dries's avatar
   
Dries committed
208
 */
209
function system_permission() {
210
  return array(
211
212
213
    'administer modules' => array(
      'title' => t('Administer modules'),
    ),
214
215
    'administer site configuration' => array(
      'title' => t('Administer site configuration'),
216
      'restrict access' => TRUE,
217
    ),
218
219
220
    'administer themes' => array(
      'title' => t('Administer themes'),
    ),
221
    'administer software updates' => array(
222
223
      'title' => t('Administer software updates'),
      'restrict access' => TRUE,
224
    ),
225
    'access administration pages' => array(
226
      'title' => t('Use the administration pages and help'),
227
    ),
228
    'access site in maintenance mode' => array(
229
      'title' => t('Use the site in maintenance mode'),
230
    ),
231
232
    'view the administration theme' => array(
      'title' => t('View the administration theme'),
233
      'description' => 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'))),
234
    ),
235
    'access site reports' => array(
236
      'title' => t('View site reports'),
237
    ),
238
  );
Dries's avatar
   
Dries committed
239
240
}

241
/**
242
 * Implements hook_hook_info().
243
244
245
246
247
 */
function system_hook_info() {
  $hooks['token_info'] = array(
    'group' => 'tokens',
  );
248
249
250
  $hooks['token_info_alter'] = array(
    'group' => 'tokens',
  );
251
252
253
  $hooks['tokens'] = array(
    'group' => 'tokens',
  );
254
255
256
257
  $hooks['tokens_alter'] = array(
    'group' => 'tokens',
  );

258
259
260
  return $hooks;
}

261
/**
262
 * Implements hook_element_info().
263
 */
264
265
266
function system_element_info() {
  // Top level elements.
  $types['form'] = array(
267
268
    '#method' => 'post',
    '#action' => request_uri(),
269
    '#theme_wrappers' => array('form'),
270
  );
271
  $types['page'] = array(
272
273
274
    '#show_messages' => TRUE,
    '#theme' => 'page',
  );
275
  // By default, we don't want Ajax commands being rendered in the context of an
276
277
  // 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
278
  // debugging page that displays rather than executes Ajax commands).
279
280
281
282
  $types['ajax'] = array(
    '#header' => TRUE,
    '#commands' => array(),
    '#error' => NULL,
283
  );
284
  $types['html_tag'] = array(
285
    '#pre_render' => array('drupal_pre_render_conditional_comments', 'drupal_pre_render_html_tag'),
286
287
288
    '#attributes' => array(),
    '#value' => NULL,
  );
289
290
291
292
  $types['styles'] = array(
    '#items' => array(),
    '#pre_render' => array('drupal_pre_render_styles'),
  );
293
294
295
296
  $types['scripts'] = array(
    '#items' => array(),
    '#pre_render' => array('drupal_pre_render_scripts'),
  );
297

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

519
520
  // Form structure.
  $types['item'] = array(
521
522
523
524
525
526
    // 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,
527
    '#markup' => '',
528
    '#theme_wrappers' => array('form_element'),
529
  );
530
  $types['hidden'] = array(
531
    '#input' => TRUE,
532
    '#process' => array('ajax_process_form'),
533
534
535
536
537
538
539
    '#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',
540
  );
541
  $types['value'] = array(
542
543
    '#input' => TRUE,
  );
544
  $types['link'] = array(
545
    '#pre_render' => array('drupal_pre_render_link'),
546
  );
547
  $types['fieldset'] = array(
548
    '#value' => NULL,
549
550
    '#process' => array('form_process_group', 'ajax_process_form'),
    '#pre_render' => array('form_pre_render_group'),
551
552
553
    '#theme_wrappers' => array('fieldset'),
  );
  $types['details'] = array(
554
    '#collapsed' => FALSE,
555
    '#value' => NULL,
556
557
    '#process' => array('form_process_group', 'ajax_process_form'),
    '#pre_render' => array('form_pre_render_details', 'form_pre_render_group'),
558
    '#theme_wrappers' => array('details'),
559
  );
560
  $types['vertical_tabs'] = array(
561
562
    '#default_tab' => '',
    '#process' => array('form_process_vertical_tabs'),
563
564
    '#pre_render' => array('form_pre_render_vertical_tabs'),
    '#theme_wrappers' => array('vertical_tabs', 'form_element'),
565
  );
566
567
  $types['dropbutton'] = array(
    '#pre_render' => array('drupal_pre_render_dropbutton'),
568
    '#theme' => 'links__dropbutton',
569
570
571
  );
  $types['operations'] = array(
    '#pre_render' => array('drupal_pre_render_dropbutton'),
572
    '#theme' => 'links__dropbutton__operations',
573
  );
574
575

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

586
587
588
589
590
591
592
593
594
595
596
597
598
599
  $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.
600
601
602
603
    // The value is a list of arrays that are passed to
    // drupal_attach_tabledrag(). drupal_pre_render_table() prepends the HTML ID
    // of the table to each set of options.
    // @see drupal_attach_tabledrag()
604
605
606
607
608
609
    '#tabledrag' => array(),
    // Render properties.
    '#pre_render' => array('drupal_pre_render_table'),
    '#theme' => 'table',
  );

610
611
612
613
614
615
616
  // Other elements.
  $types['render_cache_placeholder'] = array(
    '#callback' => '',
    '#context' => array(),
    '#pre_render' => array('drupal_pre_render_render_cache_placeholder'),
  );

617
  return $types;
618
619
}

Dries's avatar
   
Dries committed
620
/**
621
 * Implements hook_menu().
Dries's avatar
   
Dries committed
622
 */
623
624
function system_menu() {
  $items['admin'] = array(
625
    'title' => 'Administration',
626
    'route_name' => 'system.admin',
627
    'weight' => 9,
628
    'menu_name' => 'admin',
629
  );
630

631
  // Menu items that are basically just menu blocks.
632
633
  $items['admin/structure'] = array(
    'title' => 'Structure',
634
    'description' => 'Administer blocks, content types, menus, etc.',
635
    'position' => 'right',
636
    'weight' => -8,
637
    'route_name' => 'system.admin_structure',
638
  );
639
640
641
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
642
    'description' => 'Select and configure your themes.',
643
    'route_name' => 'system.themes_page',
644
    'position' => 'left',
645
    'weight' => -6,
646
  );
drumm's avatar
drumm committed
647

648
  // Modules.
649
  $items['admin/modules'] = array(
650
651
    'title' => 'Extend',
    'description' => 'Add and enable modules to extend site functionality.',
652
    'route_name' => 'system.modules_list',
653
    'weight' => -2,
654
  );
655

656
  // Configuration.
657
658
  $items['admin/config'] = array(
    'title' => 'Configuration',
659
    'description' => 'Administer settings.',
660
    'route_name' => 'system.admin_config',
661
662
  );

663
  // Media settings.
664
  $items['admin/config/media'] = array(
665
666
667
    'title' => 'Media',
    'description' => 'Media tools.',
    'position' => 'left',
668
    'weight' => -10,
669
    'route_name' => 'system.admin_config_media',
670
671
  );
  $items['admin/config/media/file-system'] = array(
672
    'title' => 'File system',
673
    'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
674
    'route_name' => 'system.file_system_settings',
675
    'weight' => -10,
676
  );
677
  $items['admin/config/media/image-toolkit'] = array(
678
679
    'title' => 'Image toolkit',
    'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
680
    'route_name' => 'system.image_toolkit_settings',
681
    'weight' => 20,
682
  );
683
684

  // Service settings.
685
686
687
  $items['admin/config/services'] = array(
    'title' => 'Web services',
    'description' => 'Tools related to web services.',
688
689
    'position' => 'right',
    'weight' => 0,
690
    'route_name' => 'system.admin_config_services',
691
  );
692
693
694
  $items['admin/config/services/rss-publishing'] = array(
    'title' => 'RSS publishing',
    'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
695
    'route_name' => 'system.rss_feeds_settings',
696
  );
697
698
699
700
701

  // Development settings.
  $items['admin/config/development'] = array(
    'title' => 'Development',
    'description' => 'Development tools.',
702
703
    'position' => 'right',
    'weight' => -10,
704
    'route_name' => 'system.admin_config_development',
705
706
707
708
  );
  $items['admin/config/development/maintenance'] = array(
    'title' => 'Maintenance mode',
    'description' => 'Take the site offline for maintenance or bring it back online.',
709
    'route_name' => 'system.site_maintenance_mode',
710
    'weight' => -10,
711
712
713
714
  );
  $items['admin/config/development/performance'] = array(
    'title' => 'Performance',
    'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
715
    'route_name' => 'system.performance_settings',
716
    'weight' => -20,
717
  );
718
  $items['admin/config/development/logging'] = array(
719
720
    'title' => 'Logging and errors',
    'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
721
    'route_name' => 'system.logging_settings',
722
    'weight' => -15,
723
  );
724
725

  // Regional and date settings.
726
  $items['admin/config/regional'] = array(
727
728
729
    'title' => 'Regional and language',
    'description' => 'Regional settings, localization and translation.',
    'position' => 'left',
730
    'weight' => -5,
731
    'route_name' => 'system.admin_config_regional',
732
733
734
  );
  $items['admin/config/regional/settings'] = array(
    'title' => 'Regional settings',
735
    'description' => "Settings for the site's default time zone and country.",
736
    'route_name' => 'system.regional_settings',
737
    'weight' => -20,
738
  );
739
  $items['admin/config/regional/date-time'] = array(
740
    'title' => 'Date and time formats',
741
    'description' => 'Configure display format strings for date and time.',
742
    'route_name' => 'system.date_format_list',
743
    'weight' => -5,
744
  );
745
  $items['admin/config/regional/date-time/formats/manage/%'] = array(
746
747
    'title' => 'Edit date format',
    'description' => 'Allow users to edit a configured date format.',
748
    'route_name' => 'system.date_format_edit',
749
  );
750
751

  // Search settings.
752
753
754
  $items['admin/config/search'] = array(
    'title' => 'Search and metadata',
    'description' => 'Local site search, metadata and SEO.',
755
756
    'position' => 'left',
    'weight' => -10,
757
    'route_name' => 'system.admin_config_search',
758
  );
759
760

  // System settings.
761
762
763
764
  $items['admin/config/system'] = array(
    'title' => 'System',
    'description' => 'General system related configuration.',
    'position' => 'right',