system.module 136 KB
Newer Older
1 2
<?php

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

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

14 15 16
/**
 * Maximum age of temporary files in seconds.
 */
17
const DRUPAL_MAXIMUM_TEMP_FILE_AGE = 21600;
18

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

/**
 * New users will get an empty time zone at registration.
 */
27
const DRUPAL_USER_TIMEZONE_EMPTY = 1;
28 29 30 31

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

34 35 36
 /**
 * Disabled option on forms and settings
 */
37
const DRUPAL_DISABLED = 0;
38 39 40 41

/**
 * Optional option on forms and settings
 */
42
const DRUPAL_OPTIONAL = 1;
43 44 45 46

/**
 * Required option on forms and settings
 */
47
const DRUPAL_REQUIRED = 2;
48

49
/**
50
 * Return only visible regions.
51 52
 *
 * @see system_region_list()
53
 */
54
const REGIONS_VISIBLE = 'visible';
55 56

/**
57
 * Return all regions.
58 59
 *
 * @see system_region_list()
60
 */
61
const REGIONS_ALL = 'all';
62

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

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

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

Dries's avatar
Dries committed
194
/**
195
 * Implements hook_permission().
Dries's avatar
Dries committed
196
 */
197
function system_permission() {
198
  return array(
199 200 201
    'administer modules' => array(
      'title' => t('Administer modules'),
    ),
202 203
    'administer site configuration' => array(
      'title' => t('Administer site configuration'),
204
      'restrict access' => TRUE,
205
    ),
206 207 208
    'administer themes' => array(
      'title' => t('Administer themes'),
    ),
209
    'administer software updates' => array(
210 211
      'title' => t('Administer software updates'),
      'restrict access' => TRUE,
212
    ),
213
    'access administration pages' => array(
214
      'title' => t('Use the administration pages and help'),
215
    ),
216
    'access site in maintenance mode' => array(
217
      'title' => t('Use the site in maintenance mode'),
218
    ),
219 220
    'view the administration theme' => array(
      'title' => t('View the administration theme'),
221
      'description' => config('system.theme')->get('admin') ?: t('This is only used when the site is configured to use a separate administration theme on the <a href="@appearance-url">Appearance</a> page.', array('@appearance-url' => url('admin/appearance'))),
222
    ),
223
    'access site reports' => array(
224
      'title' => t('View site reports'),
225
    ),
226
  );
Dries's avatar
Dries committed
227 228
}

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

246 247 248
  return $hooks;
}

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

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

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

608
  return $types;
609 610
}

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

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

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

750
  // Modules.
751
  $items['admin/modules'] = array(
752 753
    'title' => 'Extend',
    'description' => 'Add and enable modules to extend site functionality.',
754 755
    'page callback' => 'drupal_get_form',
    'page arguments' => array('system_modules'),
756
    'access arguments' => array('administer modules'),
757
    'file' => 'system.admin.inc',
758
    'weight' => -2,
759
  );
760
  $items['admin/modules/list'] = array(
761
    'title' => 'List',
762 763
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
764
  $items['admin/modules/list/confirm'] = array(
765
    'title' => 'List',
766
    'access arguments' => array('administer modules'),
767
    'type' => MENU_VISIBLE_IN_BREADCRUMB,
768
  );