system.module 110 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

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

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

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

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

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

250 251 252
  return $hooks;
}

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

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

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

  $types['container'] = array(
570 571
    '#process' => array('form_process_group', 'form_process_container'),
    '#pre_render' => array('form_pre_render_group'),
572
    '#theme_wrappers' => array('container'),
573
  );
574
  $types['actions'] = array(
575
    '#process' => array('form_pre_render_actions_dropbutton', 'form_process_actions', 'form_process_container'),
576
    '#weight' => 100,
577
    '#theme_wrappers' => array('container'),
578 579
  );

580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603
  $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',
  );

604
  return $types;
605 606
}

Dries's avatar
 
Dries committed
607
/**
608
 * Implements hook_menu().
Dries's avatar
 
Dries committed
609
 */
610
function system_menu() {
611
  $items['system/ajax'] = array(
612
    'title' => 'AHAH callback',
613
    'route_name' => 'system.ajax',
614
    'theme callback' => 'ajax_base_page_theme',
615 616 617
    'type' => MENU_CALLBACK,
  );
  $items['admin'] = array(
618
    'title' => 'Administration',
619
    'route_name' => 'system.admin',
620
    'weight' => 9,
621
    'menu_name' => 'admin',
622
  );
623 624
  $items['admin/tasks'] = array(
    'title' => 'Tasks',
625
    'type' => MENU_DEFAULT_LOCAL_TASK,
626
    'weight' => -20,
627
  );
628 629
  $items['admin/index'] = array(
    'title' => 'Index',
630
    'route_name' => 'system.admin_index',
631
    'type' => MENU_LOCAL_TASK,
632
    'weight' => -18,
633
  );
634

635
  // Menu items that are basically just menu blocks.
636 637
  $items['admin/structure'] = array(
    'title' => 'Structure',
638
    'description' => 'Administer blocks, content types, menus, etc.',
639
    'position' => 'right',
640
    'weight' => -8,
641
    'route_name' => 'system.admin_structure',
642
  );
643 644 645
  // Appearance.
  $items['admin/appearance'] = array(
    'title' => 'Appearance',
646
    'description' => 'Select and configure your themes.',
647
    'route_name' => 'system.themes_page',
648
    'position' => 'left',
649
    'weight' => -6,
650
  );
651
  $items['admin/appearance/list'] = array(
652
    'title' => 'List',
653
    'description' => 'Select and configure your theme',
654
    'type' => MENU_DEFAULT_LOCAL_TASK,
655
    'file' => 'system.admin.inc',
656
  );
657
  $items['admin/appearance/settings'] = array(
658
    'title' => 'Settings',
659
    'description' => 'Configure default and theme specific settings.',
660
    'route_name' => 'system.theme_settings',
661
    'type' => MENU_LOCAL_TASK,
662
    'weight' => 100,
663
  );
664
  // Theme configuration local tasks.
665
  $items['admin/appearance/settings/global'] = array(
666
    'title' => 'Global settings',
667 668
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
Dries's avatar
 
Dries committed
669

670 671 672 673
  foreach (list_themes(TRUE) as $theme) {
    if (!empty($theme->status)) {
      $items['admin/appearance/settings/' . $theme->name] = array(
        'title' => $theme->info['name'],
674
        'route_name' => 'system.theme_settings_' . $theme->name,
675 676 677
        'type' => MENU_LOCAL_TASK,
      );
    }
Dries's avatar
 
Dries committed
678
  }
drumm's avatar
drumm committed
679

680
  // Modules.
681
  $items['admin/modules'] = array(
682 683
    'title' => 'Extend',
    'description' => 'Add and enable modules to extend site functionality.',
684
    'route_name' => 'system.modules_list',
685
    'weight' => -2,
686
  );
687
  $items['admin/modules/list'] = array(
688
    'title' => 'List',
689 690
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
691
  $items['admin/modules/list/confirm'] = array(
692
    'title' => 'List',
693
    'route_name' => 'system.modules_list_confirm',
694
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
695
  );
696
  $items['admin/modules/uninstall'] = array(
697
    'title' => 'Uninstall',
698
    'route_name' => 'system.modules_uninstall',
699
    'type' => MENU_LOCAL_TASK,
700
    'weight' => 20,