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

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

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


Revision 1.5 - (show annotations) (download) (as text)
Mon May 4 21:34:31 2009 UTC (6 months, 3 weeks ago) by jmburnz
Branch: MAIN
CVS Tags: DRUPAL-6--3-2, DRUPAL-6--3-1, HEAD
Changes since 1.4: +1 -8 lines
File MIME type: text/x-php
updates for 31, new color schemes, minor page tpl edit, remove theme settings for
 overlabel, fix css
1 <?php // $Id: theme-settings.php,v 1.4 2008/12/07 17:03:57 jmburnz Exp $
2 /**
3 * @file
4 * theme-settings.php
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 * The default values for the theme variables. Make sure $defaults exactly
16 * matches the $defaults in the template.php file.
17 */
18 $defaults = array(
19 'pixture_width' => '85%',
20 'pixture_superfish' => 0,
21 'pixture_searchlabel' => 0,
22 );
23
24 // Reset to default value if the user specified setting is invalid
25 $saved_width = $saved_settings['pixture_width'];
26 $saved_settings['pixture_width'] = _validate_page_width($saved_width);
27
28 // Merge the saved variables and their default values
29 $settings = array_merge($defaults, $saved_settings);
30
31 // Create the form widgets using Forms API
32 $form['pixture_width'] = array(
33 '#type' => 'textfield',
34 '#title' => t('Page width'),
35 '#default_value' => $settings['pixture_width'],
36 '#size' => 12,
37 '#maxlength' => 8,
38 '#description' => t('Specify the page width in percent ratio (50-100%) for liquid layout, or in px (800-1600px) for fixed width layout. If an invalid value is specified, the default value (85%) is used instead. You can leave this field blank to use the default value. You need to add either % or px after the number.'),
39 );
40
41 $form['pixture_superfish'] = array(
42 '#type' => 'checkbox',
43 '#title' => t('Enable Superfish Drop Menus'),
44 '#default_value' => $settings['pixture_superfish'],
45 '#description' => t('Check this setting to enable support for Superfish drop menus. NOTE: In order for the drop menu to show you MUST uncheck Primary links in the "Toggle display" settings. See the README for full instructions.'),
46 );
47
48 // Return the additional form widgets
49 return $form;
50 }
51
52 /**
53 * *************************************************************************
54 * NOTE: With Drupal 6.x, I can not call pixture_validate_page_width()
55 * functions in the template.php somehow. So I created a copy of
56 * the function below and use it instead.
57 * ***************************************************************************
58 */
59 /*
60 * Check the page width theme settings and reset to default
61 * if the value is null, or invalid value is specified
62 */
63 function _validate_page_width($width) {
64 global $theme_key;
65
66 /*
67 * The default values for the theme variables. Make sure $defaults exactly
68 * matches the $defaults in the theme-settings.php file.
69 */
70 $defaults = array( // <-- change this array
71 'pixture_width' => '85%',
72 );
73
74 // check if it is liquid (%) or fixed width (px)
75 if (preg_match("/(\d+)\s*%/", $width, $match)) {
76 $liquid = 1;
77 $num = intval($match[0]);
78 if (50 <= $num && $num <= 100) {
79 return $num ."%"; // OK!
80 }
81 }
82 else if (preg_match("/(\d+)\s*px/", $width, $match)) {
83 $fixed = 1;
84 $num = intval($match[0]);
85 if (800 <= $num && $num < 1600) {
86 return $num ."px"; // OK
87 }
88 }
89
90 // reset to default value
91 variable_set(
92 str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
93 array_merge($defaults, theme_get_settings($theme_key))
94 );
95 // Force refresh of Drupal internals
96 theme_get_setting('', TRUE);
97
98 return $defaults['pixture_width'];
99 }

  ViewVC Help
Powered by ViewVC 1.1.2