/[drupal]/contributions/themes/adt_webapplication/theme-settings.php
ViewVC logotype

Contents of /contributions/themes/adt_webapplication/theme-settings.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Jan 24 21:04:18 2008 UTC (22 months ago) by peach
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-php
Initial Release for Drupal 5.0
1 <?php
2 // An example themes/garland/theme-settings.php file.
3
4 /**
5 * Implementation of THEMEHOOK_settings() function.
6 *
7 * @param $saved_settings
8 * array An array of saved settings for this theme.
9 * @return
10 * array A form array.
11 */
12 function phptemplate_settings($saved_settings) {
13 /*
14 * The default values for the theme variables. Make sure $defaults exactly
15 * matches the $defaults in the template.php file.
16 */
17 $defaults = array(
18 'cto_fixedfluid' => 'px',
19 'cto_layout_width' => 900,
20 'cto_main_width' => '60',
21 'cto_subheader' => 0,
22 'cto_navbar' => 0,
23 'cto_font' => '',
24 'cto_iepngfix' => 1,
25 );
26
27 // Merge the saved variables and their default values
28 $settings = array_merge($defaults, $saved_settings);
29
30 // Create the form widgets using Forms API
31 $form['layout'] = array(
32 '#title' => t('Layout Options'),
33 '#type' => 'fieldset',
34 );
35
36 $form['layout']['cto_fixedfluid'] = array(
37 '#type' => 'select',
38 '#title' => t('Fixed or Fluid width'),
39 '#default_value' => $settings['cto_fixedfluid'],
40 '#options' => array(
41 'px' => t('Fixed width (in pixels)'),
42 '%' => t('Fluid width (as percentage of viewport width)'),
43 ),
44 );
45
46 $form['layout']['cto_layout_width'] = array(
47 '#type' => 'textfield',
48 '#title' => t('Layout Width'),
49 '#default_value' => $settings['cto_layout_width'],
50 '#size' => 4,
51 '#maxlength' => 4,
52 '#description' => t('If you chose "relative" in the previous option fill in the percentage, do not append % sign. If you chose fixed width, fill in the number of pixels you want to layout to span.')
53 );
54
55 $form['layout']['cto_main_width'] = array(
56 '#type' => 'textfield',
57 '#title' => t('Main Width'),
58 '#default_value' => $settings['cto_main_width'],
59 '#size' => 3,
60 '#maxlength' => 3,
61 '#description' => t('Main content area width as percentage of layout width. The sidebar(s) will automatically assume the leftover width. For example, if you fill in 60, your content area will take up 60% of the available width, and if you have one sidebar (2 sidebars) it will take up approximately 40% (20%) of the available width.'),
62 '#validate' => array('is_percentage_between' => array('cto_main_width', 0,100)),
63 );
64
65 $form['layout']['cto_subheader'] = array(
66 '#type' => 'checkbox',
67 '#title' => t('Omit Subheader'),
68 '#default_value' => $settings['cto_subheader'],
69 );
70
71 $form['layout']['cto_navbar'] = array(
72 '#type' => 'checkbox',
73 '#title' => t('Omit Nav bar (contains secondary links menu)'),
74 '#default_value' => $settings['cto_navbar'],
75 );
76
77 $form['cto_font'] = array(
78 '#type' => 'select',
79 '#title' => t('Font Family'),
80 '#default_value' => $settings['cto_font'],
81 '#options' => array(
82 'Arial, Verdana, sans-serif' => t('Arial, Verdana, sans-serif (Default)'),
83 'Verdana, Arial, sans-serif' => t('Verdana, Arial, sans-serif'),
84 'Courier New, Courier, monospace' => t('Courier New, Courier, monospace'),
85 'Tahoma, Verdana, Arial, Helvetica, sans-serif' => t('Tahoma, Verdana, Arial, Helvetica, sans-serif'),
86 'Trebucher MS,Trebuchet, Verdana, Arial, Helvetica, sans-serif' => t('Trebucher MS,Trebuchet, Verdana, Arial, Helvetica, sans-serif'),
87 'Times New Roman, Times, serif' => t('Times New Roman, Times, serif'),
88 'Georgia, Times New Roman, Times, serif' => t('Georgia, Times New Roman, Times, serif'),
89 ),
90 );
91
92 $form['cto_iepngfix'] = array(
93 '#type' => 'checkbox',
94 '#title' => t('Use IE PNG Fix'),
95 '#default_value' => $settings['cto_iepngfix'],
96 );
97
98 function is_percentage_between ($formelement, $fieldname, $min=NULL, $max=NULL) {
99 $thevalue = $formelement['#value'];
100 if (is_numeric($thevalue)) {
101 $thevalue = $thevalue + 0;
102 } else {
103 form_set_error($fieldname, t('Percentage must be an integer. Please omit % sign.'));
104 }
105 if (!is_int($thevalue)) {
106 form_set_error($fieldname, t('Percentage must be an integer. Please omit % sign.'));
107 } else {
108 if (isset($min) && ($thevalue < $min)) {
109 form_set_error($fieldname, t("Percentage must be at least $min."));
110 }
111 if (isset($max) && ($thevalue > $max)) {
112 form_set_error($fieldname, t("Percentage must be no higher than $max."));
113 }
114 }
115 }
116 function cto_integer ($formelement, $fieldname) {
117 $thevalue = $formelement['#value'];
118 if (is_numeric($thevalue)) {
119 $thevalue = $thevalue + 0;
120 } else {
121 form_set_error($fieldname, t('width must be an integer.'));
122 }
123 if (!is_int($thevalue)) {
124 form_set_error($fieldname, t('width must be an integer.'));
125 }
126 }
127
128 // Return the additional form widgets
129 return $form;
130 }
131 ?>

  ViewVC Help
Powered by ViewVC 1.1.2