Project

General

Profile

Download (2.31 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * @file
4
 * Theme setting callbacks for the garland-cichorieae theme.
5
 *
6
 * @see http://drupal.org/node/177868
7
 */
8

    
9
/**
10
 * Add additional settings for the theme.
11
 *
12
 * @todo might need to be replaced by
13
 * phptemplate_form_system_theme_settings_alter
14
 *
15
 * @param array $saved_settings
16
 *   An array of saved settings for this theme.
17
 *
18
 * @return array
19
 *   A form array.
20
 */
21
function phptemplate_settings($saved_settings) {
22

    
23
    $key = sub_theme();
24

    
25
    $defaults = array(
26
      'default_banner_right' => 1,
27
      'banner_right_path' => '',
28
    );
29

    
30
  $settings = array_merge($defaults, $saved_settings);
31

    
32
  // Check for a new uploaded logo, and use that instead.
33
  if ($file = file_check_upload('banner_right_upload')) {
34
    if ($info = image_get_info($file->filepath)) {
35
      $parts = pathinfo($file->filename);
36
      $filename = ($key) ? str_replace('/', '_', $key) . '_banner_right.' . $parts['extension'] : '_banner_right.' . $parts['extension'];
37

    
38
      if ($file = file_save_upload('banner_right_upload', $filename, 1)) {
39
        $_POST['default_banner_right'] = 0;
40
        $_POST['banner_right_path'] = $file->filepath;
41
        $form["#after_build"][] = "banner_right_after_build";
42
      }
43
    }
44
    else {
45
      form_set_error('file_upload', t(
46
        'Only JPEG, PNG and GIF images are allowed to be used as logos.'
47
      ));
48
    }
49
  }
50

    
51
  if (true || $file) {
52
        $form['default_banner_right'] = array(
53
          '#type' => 'checkbox',
54
          '#title' => t('Use the right default header image'),
55
          '#default_value' => $settings['default_banner_right'],
56
          '#tree' => FALSE,
57
          '#description' => t(
58
             'Check here if you want the theme to use the
59
             right header image supplied with it.'),
60
        );
61

    
62
        $form['banner_right_path'] = array(
63
          '#type' => 'textfield',
64
          '#title' => t('Right banner image path'),
65
          '#default_value' => $settings['banner_right_path'],
66
          '#maxlength' => 255,
67
        );
68

    
69
        $form['banner_right_upload'] = array(
70
          '#type' => 'file',
71
          '#title' => t('Upload new right banner image'),
72
        );
73
  }
74

    
75
  return $form;
76
}
77

    
78
/**
79
 * @todo document this function.
80
 */
81
function banner_right_after_build(&$form, &$form_values) {
82
  $form["#post"]["banner_right_path"] = $_POST['banner_right_path'];
83
  return $form;
84
}
(13-13/13)