1.20.x system.admin.inc system_site_information_settings_submit($form, &$form_state)

Form submission handler for system_site_information_settings().

File

modules/system/system.admin.inc, line 1498
Admin page callbacks for the System module.

Code

function system_site_information_settings_submit($form, &$form_state) {
  // If the user uploaded a new logo or favicon, save it to a permanent location
  // and use it in place of the default theme-provided file.
  if (!empty($form_state['values']['site_logo_upload'])) {
    $file = $form_state['values']['site_logo_upload'];
    unset($form_state['values']['site_logo_upload']);
    $filename = file_unmanaged_copy($file->uri);
    $form_state['values']['site_logo_theme'] = 0;
    $form_state['values']['site_logo_path'] = $filename;
  }

  if ($form_state['values']['site_logo_path']) {
    $form_state['values']['site_logo_attributes'] = array();
    $dimensions = @getimagesize($form_state['values']['site_logo_path']);
    if (!empty($dimensions)) {
      $form_state['values']['site_logo_attributes']['width'] = $dimensions[0];
      $form_state['values']['site_logo_attributes']['height'] = $dimensions[1];
    }
  }
  else {
    $form_state['values']['site_logo_attributes'] = array(
      'width' => "",
      'height' => "",
    );
  }

  if (!empty($form_state['values']['site_favicon_upload'])) {
    $file = $form_state['values']['site_favicon_upload'];
    unset($form_state['values']['site_favicon_upload']);
    $filename = file_unmanaged_copy($file->uri);
    $form_state['values']['site_favicon_theme'] = 0;
    $form_state['values']['site_favicon_path'] = $filename;
  }

  // If the user entered a path relative to the system files directory for
  // a logo or favicon, store a public:// URI so the theme system can handle it.
  if (!empty($form_state['values']['site_logo_path'])) {
    $form_state['values']['site_logo_path'] = _system_site_information_settings_validate_path($form_state['values']['site_logo_path']);
  }
  if (!empty($form_state['values']['site_favicon_path'])) {
    $form_state['values']['site_favicon_path'] = _system_site_information_settings_validate_path($form_state['values']['site_favicon_path']);
  }

  if (empty($form_state['values']['site_favicon_theme']) && !empty($form_state['values']['site_favicon_path'])) {
    $form_state['values']['site_favicon_mimetype'] = file_get_mimetype($form_state['values']['site_favicon_path']);
  }
  else {
    $form_state['values']['site_favicon_mimetype'] = '';
  }

  config('system.core')
    ->set('site_logo_attributes', $form_state['values']['site_logo_attributes'])
    ->set('site_favicon_theme', $form_state['values']['site_favicon_theme'])
    ->set('site_favicon_path', $form_state['values']['site_favicon_path'])
    ->set('site_favicon_mimetype', $form_state['values']['site_favicon_mimetype'])
    ->save();
}