system.module 100 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\user\UserInterface;
13
use Symfony\Component\HttpFoundation\JsonResponse;
14
use Symfony\Component\HttpFoundation\RedirectResponse;
15
use Symfony\Component\HttpFoundation\Response;
16 17
use Guzzle\Http\Exception\BadResponseException;
use Guzzle\Http\Exception\RequestException;
18

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

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

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

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

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

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

/**
 * Required option on forms and settings
 */
52
const DRUPAL_REQUIRED = 2;
53

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

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

68 69 70 71 72 73 74 75 76 77 78 79
/**
 * 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
80
/**
81
 * Implements hook_help().
Dries's avatar
 
Dries committed
82
 */
83
function system_help($path, $arg) {
84 85
  global $base_url;

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

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

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

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

255 256 257
  return $hooks;
}

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

296 297
  // Input elements.
  $types['submit'] = array(
298 299
    '#input' => TRUE,
    '#name' => 'op',
300
    '#is_button' => TRUE,
301
    '#executes_submit_callback' => TRUE,
302
    '#limit_validation_errors' => FALSE,
303
    '#process' => array('form_process_button', 'ajax_process_form'),
304 305
    '#pre_render' => array('form_pre_render_button'),
    '#theme_wrappers' => array('input__submit'),
306
  );
307
  $types['button'] = array(
308 309
    '#input' => TRUE,
    '#name' => 'op',
310
    '#is_button' => TRUE,
311
    '#executes_submit_callback' => FALSE,
312
    '#limit_validation_errors' => FALSE,
313
    '#process' => array('form_process_button', 'ajax_process_form'),
314 315
    '#pre_render' => array('form_pre_render_button'),
    '#theme_wrappers' => array('input__button'),
316
  );
317
  $types['image_button'] = array(
318
    '#input' => TRUE,
319
    '#is_button' => TRUE,
320
    '#executes_submit_callback' => TRUE,
321
    '#limit_validation_errors' => FALSE,
322
    '#process' => array('form_process_button', 'ajax_process_form'),
323 324 325
    '#return_value' => TRUE,
    '#has_garbage_value' => TRUE,
    '#src' => NULL,
326 327
    '#pre_render' => array('form_pre_render_image_button'),
    '#theme_wrappers' => array('input__image_button'),
328
  );
329
  $types['textfield'] = array(
330 331 332
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
333
    '#autocomplete_route_name' => FALSE,
334
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
335 336
    '#pre_render' => array('form_pre_render_textfield'),
    '#theme' => 'input__textfield',
337
    '#theme_wrappers' => array('form_element'),
338
  );
339 340 341 342
  $types['tel'] = array(
    '#input' => TRUE,
    '#size' => 30,
    '#maxlength' => 128,
343
    '#autocomplete_route_name' => FALSE,
344
    '#process' => array('form_process_autocomplete', 'ajax_process_form', 'form_process_pattern'),
345 346
    '#pre_render' => array('form_pre_render_tel'),
    '#theme' => 'input__tel',
347 348
    '#theme_wrappers' => array('form_element'),
  );
349 350 351
  $types['email'] = array(
    '#input' => TRUE,
    '#size' => 60,
352
    '#maxlength' => EMAIL_MAX_LENGTH,
353
    '#autocomplete_route_name' => 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
  $types['url'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 255,
364
    '#autocomplete_route_name' => 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
  $types['search'] = array(
    '#input' => TRUE,
    '#size' => 60,
    '#maxlength' => 128,
375
    '#autocomplete_route_name' => 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
  $types['machine_name'] = array(
    '#input' => TRUE,
    '#default_value' => NULL,
    '#required' => TRUE,
    '#maxlength' => 64,
    '#size' => 60,
415
    '#autocomplete_route_name' => 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
  $types['language_select'] = array(
    '#input' => TRUE,
485
    '#default_value' => Language::LANGCODE_NOT_SPECIFIED,
486
  );
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
    '#input' => TRUE,
500 501
    '#multiple' => FALSE,
    '#process' => array('form_process_file'),
502
    '#size' => 60,
503 504
    '#pre_render' => array('form_pre_render_file'),
    '#theme' => 'input__file',
505
    '#theme_wrappers' => array('form_element'),
506
  );
507
  $types['tableselect'] = array(
508 509 510 511 512 513
    '#input' => TRUE,
    '#js_select' => TRUE,
    '#multiple' => TRUE,
    '#process' => array('form_process_tableselect'),
    '#options' => array(),
    '#empty' => '',
514
    '#theme' => 'tableselect',
515
  );
516

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

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

584 585 586 587 588 589 590 591 592 593 594 595 596 597
  $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.
598 599 600 601
    // 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()
602 603 604 605 606 607
    '#tabledrag' => array(),
    // Render properties.
    '#pre_render' => array('drupal_pre_render_table'),
    '#theme' => 'table',
  );

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

615
  return $types;
616 617
}

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

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

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

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

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

  // Service settings.
683 684 685
  $items['admin/config/services'] = array(
    'title' => 'Web services',
    'description' => 'Tools related to web services.',
686 687
    'position' => 'right',
    'weight' => 0,
688
    'route_name' => 'system.admin_config_services',
689
  );
690 691 692
  $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.',
693
    'route_name' => 'system.rss_feeds_settings',
694
  );
695 696 697 698 699

  // Development settings.
  $items['admin/config/development'] = array(
    'title' => 'Development',
    'description' => 'Development tools.',
700 701
    'position' => 'right',
    'weight' => -10,
702
    'route_name' => 'system.admin_config_development',
703 704 705 706
  );
  $items['admin/config/development/maintenance'] = array(
    'title' => 'Maintenance mode',
    'description' => 'Take the site offline for maintenance or bring it back online.',
707
    'route_name' => 'system.site_maintenance_mode',
708
    'weight' => -10,
709 710 711 712
  );
  $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.',
713
    'route_name' => 'system.performance_settings',
714
    'weight' => -20,
715
  );
716
  $items['admin/config/development/logging'] = array(
717 718
    '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.",
719
    'route_name' => 'system.logging_settings',
720
    'weight' => -15,
721
  );
722 723

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

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

  // System settings.
759 760 761 762
  $items['admin/config/system'] = array(
    'title' => 'System',
    'description' => 'General system related configuration.',
    'position' => 'right',
763
    'weight' => -20,
764
    'route_name' => 'system.admin_config_system',
765 766
  );
  $items['admin/config/system/site-information'] = array(
767
    'title' => 'Site information',
768
    'description' => 'Change site name, e-mail address, slogan, default front page and error pages.',
769
    'route_name' => 'system.site_information_settings',
770
    'weight' => -20,
771
  );
772
  $items['admin/config/system/cron'] = array(
773 774
    'title' => 'Cron',
    'description' => 'Manage automatic site maintenance tasks.',
775
    'route_name' => 'system.cron_settings',
776 777
    'weight' => 20,
  );
778
  // Additional categories
779 780 781 782
  $items['admin/config/user-interface'] = array(
    'title' => 'User interface',
    'description' => 'Tools that enhance the user interface.',
    'position' => 'right',
783
    'route_name' => 'system.admin_config_ui',
784
    'weight' => -15,
785
  );
webchick's avatar