Exemplo n.º 1
0
/**
 * Implements hook_setings_submit().
 */
function nuboot_radix_settings_submit($form, &$form_state)
{
    $settings = array();
    // If the user entered a path relative to the system files directory for
    // for the hero unit, store a public:// URI so the theme system can handle it.
    if (!empty($values['hero_path'])) {
        $values['hero_path'] = _system_theme_settings_validate_path($values['hero_path']);
    }
    // Get the previous value.
    $previous = $form['hero']['hero_path']['#default_value'];
    if ($previous !== 'profiles/dkan/themes/contrib/nuboot_radix/assets/images/hero.jpg') {
        $previous = 'public://' . $previous;
    } else {
        $previous = FALSE;
    }
    if ($file = file_save_upload('hero_upload')) {
        $parts = pathinfo($file->filename);
        $destination = 'public://' . $parts['basename'];
        $file->status = FILE_STATUS_PERMANENT;
        if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) {
            $_POST['hero_path'] = $form_state['values']['hero_path'] = $destination;
            // If new file has a different name than the old one, delete the old.
            if ($previous && $destination != $previous) {
                drupal_unlink($previous);
            }
        }
    } else {
        // Avoid error when the form is submitted without specifying a new image.
        $_POST['hero_path'] = $form_state['values']['hero_path'] = $previous;
    }
}
function asu_webspark_bootstrap_settings_validate($form, &$form_state)
{
    // Handle file uploads.
    $validators = array('file_validate_is_image' => array());
    // Check for a new uploaded logo.
    $file = file_save_upload('picture_upload', $validators);
    if (isset($file)) {
        // File upload was attempted.
        if ($file) {
            // Put the temporary file in form_values so we can save it on submit.
            $form_state['values']['picture_upload'] = $file;
        } else {
            // File upload failed.
            form_set_error('logo_picture', t('The logo could not be uploaded.'));
        }
    }
    if ($form_state['values']['picture_path']) {
        $path = _system_theme_settings_validate_path($form_state['values']['picture_path']);
        if (!$path) {
            form_set_error('picture_path', t('The custom logo path is invalid.'));
        }
    }
}
Exemplo n.º 3
0
/**
 * Custom Submit Hook
 */
function locke_theme_settings_submit($form, &$form_state)
{
    $values = $form_state['values'];
    // If the user uploaded a new seal, save it to a permanent location
    // and use it in place of the default theme-provided file.
    if ($file = $values['seal_upload']) {
        unset($values['seal_upload']);
        $filename = file_unmanaged_copy($file->uri);
        $values['default_seal'] = 0;
        $values['seal_path'] = $filename;
        $values['toggle_seal'] = 1;
    }
    // If the user entered a path relative to the system files directory for
    // a seal, store a public:// URI so the theme system can handle it.
    if (!empty($values['seal_path'])) {
        $values['seal_path'] = _system_theme_settings_validate_path($values['seal_path']);
    }
    // Save the values to $form_state
    if (!empty($values['seal_path'])) {
        $form_state['values']['seal_path'] = $values['seal_path'];
    }
    if (!empty($values['toggle_seal'])) {
        $form_state['values']['toggle_seal'] = $values['toggle_seal'];
    }
    $form_state['values']['default_seal'] = $values['default_seal'];
}
Exemplo n.º 4
0
/**
 * Process form submission 
 * 
 * @param type $form
 * @param type $form_state
 */
function uw_boundless_theme_settings_submit($form, &$form_state)
{
    $values =& $form_state['values'];
    // If the user uploaded a new hero-image for the front page, save it to a permanent location
    // and use it in place of the default theme-provided file.
    if ($file_hero_front = $values['hero_image_front_upload']) {
        unset($values['hero_image_front_upload']);
        $filename = $file_hero_front->uri;
        $values['hero_image_front_default'] = 0;
        $values['hero_image_front_upload'] = $filename;
        $values['toggle_header'] = 1;
    }
    // If the user entered a path relative to the system files directory for
    // a header image, store a public:// URI so the theme system can handle it.
    if (!empty($values['uw_boundless_hero_image_front_path'])) {
        $values['uw_boundless_hero_image_front_path'] = _system_theme_settings_validate_path($values['uw_boundless_hero_image_front_path']);
    }
    // If the user uploaded a new header, save it to a permanent location
    // and use it in place of the default theme-provided file.
    if ($file_hero = $values['hero_image_upload']) {
        unset($values['hero_image_upload']);
        $filename = $file_hero->uri;
        $values['hero_image_default'] = 0;
        $values['hero_image_upload'] = $filename;
        $values['toggle_header'] = 1;
    }
    // If the user entered a path relative to the system files directory for
    // a header image, store a public:// URI so the theme system can handle it.
    if (!empty($values['uw_boundless_hero_image_path'])) {
        $values['uw_boundless_hero_image_path'] = _system_theme_settings_validate_path($values['uw_boundless_hero_image_path']);
    }
}
Exemplo n.º 5
0
function singular_theme_settings_submit($form, &$form_state) {
  $values = $form_state['values'];

  // If the user uploaded a new background, save it to a permanent location
  // and use it in place of the default theme-provided file.
  if ($file = $values['background_upload']) {
    unset($values['background_upload']);
    $filename = file_unmanaged_copy($file->uri);
    $values['background_path'] = $filename;
  }

  // If the user entered a path relative to the system files directory for
  // a background image, store a public:// URI so the theme system can handle it.
  if (!empty($values['background_path'])) {
    $form_state['values']['background_path'] = _system_theme_settings_validate_path($values['background_path']);
  }
}