Project

General

Profile

Download (2.04 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/**
3
 * see http://drupal.org/node/177868
4
 */
5
/**
6
* Implementation of THEMEHOOK_settings() function.
7
*
8
* @param $saved_settings
9
*   array An array of saved settings for this theme.
10
* @return
11
*   array A form array.
12
*/
13
function phptemplate_settings($saved_settings) {
14

    
15
	$key = sub_theme();
16

    
17
	$defaults = array(
18
	    'default_banner_right' => 1,
19
	    'banner_right_path' => '',
20
	);
21

    
22
  $settings = array_merge($defaults, $saved_settings);
23

    
24
  // Check for a new uploaded logo, and use that instead.
25
  if ($file = file_check_upload('banner_right_upload')) {
26
    if ($info = image_get_info($file->filepath)) {
27
      $parts = pathinfo($file->filename);
28
      $filename = ($key) ? str_replace('/', '_', $key) .'_banner_right.'. $parts['extension'] : '_banner_right.'. $parts['extension'];
29

    
30
      if ($file = file_save_upload('banner_right_upload', $filename, 1)) {
31
        $_POST['default_banner_right'] = 0;
32
        $_POST['banner_right_path'] = $file->filepath;
33
        $form["#after_build"][] = "banner_right_after_build";
34
      }
35
    }
36
    else {
37
      form_set_error('file_upload', t('Only JPEG, PNG and GIF images are allowed to be used as logos.'));
38
    }
39
  }
40

    
41
  if (true || $file) {
42
		$form['default_banner_right'] = array(
43
	      '#type' => 'checkbox',
44
	      '#title' => t('Use the right default header image'),
45
	      '#default_value' => $settings['default_banner_right'],
46
	      '#tree' => FALSE,
47
	      '#description' => t('Check here if you want the theme to use the right header image supplied with it.')
48
		 );
49

    
50
		$form['banner_right_path'] = array(
51
		  '#type' => 'textfield',
52
		  '#title' => t('Right banner image path'),
53
		  '#default_value' => $settings['banner_right_path'],
54
		  '#maxlength' => 255
55
		  );
56

    
57
		$form['banner_right_upload'] = array(
58
		  '#type' => 'file',
59
		  '#title' => t('Upload new right banner image'),
60
		  );
61
  }
62

    
63
  return $form;
64
}
65

    
66

    
67
function banner_right_after_build(&$form, &$form_values) {
68
  $form["#post"]["banner_right_path"] = $_POST['banner_right_path'];
69
  return $form;
70
}
71

    
72

    
(13-13/13)