Same name and namespace in other branches
  1. 4.7.x modules/system.module \system_view_general()

File

modules/system.module, line 196
Configuration system that lets administrators modify the workings of the site.

Code

function system_view_general() {
  global $conf;

  // General settings:
  $group = form_textfield(t('Name'), 'site_name', variable_get('site_name', 'drupal'), 70, 70, t('The name of this web site.'));
  $group .= form_textfield(t('E-mail address'), 'site_mail', variable_get('site_mail', ini_get('sendmail_from')), 70, 128, t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.'));
  $group .= form_textfield(t('Slogan'), 'site_slogan', variable_get('site_slogan', ''), 70, 128, t('The slogan of this website. Some themes display a slogan when available.'));
  $group .= form_textarea(t('Mission'), 'site_mission', variable_get('site_mission', ''), 70, 5, t('Your site\'s mission statement or focus.'));
  $group .= form_textarea(t('Footer message'), 'site_footer', variable_get('site_footer', ''), 70, 5, t('This text will be displayed at the bottom of each page.  Useful for adding a copyright notice to your pages.'));
  $group .= form_textfield(t('Anonymous user'), 'anonymous', variable_get('anonymous', 'Anonymous'), 70, 70, t('The name used to indicate anonymous users.'));
  $group .= form_textfield(t('Default front page'), 'site_frontpage', variable_get('site_frontpage', 'node'), 70, 70, t('The home page displays content from this relative URL.  If you are not using clean URLs, specify the part after "?q=".  If unsure, specify "node".'));

  // We check for clean URL support using an image on the client side.
  $group .= form_radios(t('Clean URLs'), 'clean_url', variable_get('clean_url', 0), array(
    t('Disabled'),
    t('Enabled'),
  ), t('This option makes Drupal emit clean URLs (i.e. without <code>?q=</code> in the URL). You\'ll need <code>ModRewrite</code> support for this to work. See the <code>.htaccess</code> file in Drupal\'s top-level directory for more information.'));
  variable_set('clean_url_ok', 0);
  global $base_url;

  // We will use a random URL so there is no way a proxy or a browser could cache the "no such image" answer.
  $group .= '<img style="position: relative; left: -1000em;" src="' . $base_url . '/system/test/' . user_password(20) . '.png" alt="" />';
  $output = form_group(t('General settings'), $group);

  // Error handling:
  $period = drupal_map_assoc(array(
    3600,
    10800,
    21600,
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
  ), 'format_interval');
  $period['1000000000'] = t('Never');
  $group = form_textfield(t('Default 403 (access denied) page'), 'site_403', variable_get('site_403', ''), 70, 70, t('This page is displayed when the requested document is denied to the current user.  If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
  $group .= form_textfield(t('Default 404 (not found) page'), 'site_404', variable_get('site_404', ''), 70, 70, t('This page is displayed when no other content matches the requested document.  If you are not using clean URLs, specify the part after "?q=". If unsure, specify nothing.'));
  $group .= form_select(t('Error reporting'), 'error_level', variable_get('error_level', 1), array(
    t('Write errors to the log'),
    t('Write errors to the log and to the screen'),
  ), t('Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen.'));
  $group .= form_select(t('Discard log entries older than'), 'watchdog_clear', variable_get('watchdog_clear', 604800), $period, t('The time log entries should be kept.  Older entries will be automatically discarded.  Requires crontab.'));
  $output .= form_group(t('Error handling'), $group);

  // Caching:
  $group = form_radios(t('Cache support'), 'cache', variable_get('cache', 0), array(
    t('Disabled'),
    t('Enabled'),
  ), t('Enable or disable the caching of rendered pages.  When caching is enabled, Drupal will flush the cache when required to make sure updates take effect immediately.  Check the <a href="%documentation">cache documentation</a> for information on Drupal\'s cache system.', array(
    '%documentation' => url('admin/help/system#cache', NULL, NULL, 'cache'),
  )));
  $output .= form_group(t('Cache settings'), $group);

  // File system:
  $directory_path = variable_get('file_directory_path', 'files');
  file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path');
  $directory_temp = variable_get('file_directory_temp', FILE_DIRECTORY_TEMP);
  file_check_directory($directory_temp, FILE_CREATE_DIRECTORY, 'file_directory_temp');
  $group = form_textfield(t('File system path'), 'file_directory_path', $directory_path, 70, 255, t('A file system path where the files will be stored. This directory has to exist and be writable by Drupal. If the download method is set to public this directory has to be relative to Drupal installation directory, and be accessible over the web. When download method is set to private this directory should not be accessible over the web. Changing this location after the site has been in use will cause problems so only change this setting on an existing site if you know what you are doing.'));
  $group .= form_textfield(t('Temporary directory'), 'file_directory_temp', $directory_temp, 70, 255, t('Location where uploaded files will be kept during previews. Relative paths will be resolved relative to the file system path.'));
  $group .= form_radios(t('Download method'), 'file_downloads', variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), array(
    FILE_DOWNLOADS_PUBLIC => t('Public - files are available using http directly.'),
    FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.'),
  ), t('If you want any sort of access control on the downloading of files, this needs to be set to <em>private</em>. You can change this at any time, however all download URLs will change and there may be unexpected problems so it is not recommended.'));
  $output .= form_group(t('File system settings'), $group);

  // Image handling:
  $group = '';
  $toolkits_available = image_get_available_toolkits();
  if (count($toolkits_available) > 1) {
    $group .= form_radios(t('Select an image processing toolkit'), 'image_toolkit', variable_get('image_toolkit', image_get_toolkit()), $toolkits_available);
  }
  $group .= image_toolkit_invoke('settings');
  if ($group) {
    $output .= form_group(t('Image handling'), $group);
  }

  // Date settings:
  $zones = _system_zonelist();

  // Date settings: possible date formats
  $dateshort = array(
    'Y-m-d H:i',
    'm/d/Y - H:i',
    'd/m/Y - H:i',
    'Y/m/d - H:i',
    'm/d/Y - g:ia',
    'd/m/Y - g:ia',
    'Y/m/d - g:ia',
    'M j Y - H:i',
    'j M Y - H:i',
    'Y M j - H:i',
    'M j Y - g:ia',
    'j M Y - g:ia',
    'Y M j - g:ia',
  );
  $datemedium = array(
    'D, Y-m-d H:i',
    'D, m/d/Y - H:i',
    'D, d/m/Y - H:i',
    'D, Y/m/d - H:i',
    'F j, Y - H:i',
    'j F, Y - H:i',
    'Y, F j - H:i',
    'D, m/d/Y - g:ia',
    'D, d/m/Y - g:ia',
    'D, Y/m/d - g:ia',
    'F j, Y - g:ia',
    'j F, Y - g:ia',
    'Y, F j - g:ia',
  );
  $datelong = array(
    'l, F j, Y - H:i',
    'l, j F, Y - H:i',
    'l, Y,  F j - H:i',
    'l, F j, Y - g:ia',
    'l, j F, Y - g:ia',
    'l, Y,  F j - g:ia',
  );

  // Date settings: construct choices for user
  foreach ($dateshort as $f) {
    $dateshortchoices[$f] = format_date(time(), 'custom', $f);
  }
  foreach ($datemedium as $f) {
    $datemediumchoices[$f] = format_date(time(), 'custom', $f);
  }
  foreach ($datelong as $f) {
    $datelongchoices[$f] = format_date(time(), 'custom', $f);
  }
  $group = form_select(t('Default time zone'), 'date_default_timezone', variable_get('date_default_timezone', 0), $zones, t('Select the default site time zone.'));
  $group .= form_radios(t('Configurable time zones'), 'configurable_timezones', variable_get('configurable_timezones', 1), array(
    t('Disabled'),
    t('Enabled'),
  ), t('Enable or disable user-configurable time zones.  When enabled, users can set their own time zone and dates will be updated accordingly.'));
  $group .= form_select(t('Short date format'), 'date_format_short', variable_get('date_format_short', $dateshort[0]), $dateshortchoices, t('The short format of date display.'));
  $group .= form_select(t('Medium date format'), 'date_format_medium', variable_get('date_format_medium', $datemedium[0]), $datemediumchoices, t('The medium sized date display.'));
  $group .= form_select(t('Long date format'), 'date_format_long', variable_get('date_format_long', $datelong[0]), $datelongchoices, t('Longer date format used for detailed display.'));
  $group .= form_select(t('First day of week'), 'date_first_day', variable_get('date_first_day', 0), array(
    0 => t('Sunday'),
    1 => t('Monday'),
    2 => t('Tuesday'),
    3 => t('Wednesday'),
    4 => t('Thursday'),
    5 => t('Friday'),
    6 => t('Saturday'),
  ), t('The first day of the week for calendar views.'));
  $output .= form_group(t('Date settings'), $group);
  return $output;
}