You are here

function domain_theme_file_upload in Domain Access 7.2

Same name and namespace in other branches
  1. 7.3 domain_theme/domain_theme.admin.inc \domain_theme_file_upload()

Helper function for handling logo uploads.

We have disabled the normal function because we do not want our form results saved to the {variables} table.

Parameters

$values: An array of form values, passed by reference.

See also

system_theme_settings_submit()

1 call to domain_theme_file_upload()
domain_theme_settings_submit in domain_theme/domain_theme.admin.inc
Process domain_theme_settings form submissions.

File

domain_theme/domain_theme.admin.inc, line 373
Include file to handle theme configration screen

Code

function domain_theme_file_upload(&$values) {

  // 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 ($file = $values['logo_upload']) {
    unset($values['logo_upload']);
    $filename = file_unmanaged_copy($file->uri);
    $values['default_logo'] = 0;
    $values['logo_path'] = $filename;
    $values['toggle_logo'] = 1;
  }
  if ($file = $values['favicon_upload']) {
    unset($values['favicon_upload']);
    $filename = file_unmanaged_copy($file->uri);
    $values['default_favicon'] = 0;
    $values['favicon_path'] = $filename;
    $values['toggle_favicon'] = 1;
  }

  // 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($values['logo_path'])) {
    $values['logo_path'] = _system_theme_settings_validate_path($values['logo_path']);
  }
  if (!empty($values['favicon_path'])) {
    $values['favicon_path'] = _system_theme_settings_validate_path($values['favicon_path']);
  }
  if (empty($values['default_favicon']) && !empty($values['favicon_path'])) {
    $values['favicon_mimetype'] = file_get_mimetype($values['favicon_path']);
  }
}