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

Diff of /contributions/themes/pixture/theme-settings.php

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

revision 1.1, Wed Apr 23 04:18:42 2008 UTC revision 1.1.2.1, Thu Apr 24 05:22:25 2008 UTC
# Line 18  function phptemplate_settings($saved_set Line 18  function phptemplate_settings($saved_set
18    
19    // Reset to default value if the user specified setting is invalid    // Reset to default value if the user specified setting is invalid
20    $saved_width = $saved_settings['pixture_width'];    $saved_width = $saved_settings['pixture_width'];
21    $saved_settings['pixture_width'] = pixture_validate_page_width($saved_width);    $saved_settings['pixture_width'] = _validate_page_width($saved_width);
22    
23    // Merge the saved variables and their default values    // Merge the saved variables and their default values
24    $settings = array_merge($defaults, $saved_settings);    $settings = array_merge($defaults, $saved_settings);
# Line 36  function phptemplate_settings($saved_set Line 36  function phptemplate_settings($saved_set
36    // Return the additional form widgets    // Return the additional form widgets
37    return $form;    return $form;
38  }  }
39    
40    /*
41    * Check the page width theme settings and reset to default
42    * if the value is null, or invalid value is specified
43    */
44    function _validate_page_width($width)
45    {
46      global $theme_key;
47    
48      /*
49      * The default values for the theme variables. Make sure $defaults exactly
50      * matches the $defaults in the theme-settings.php file.
51      */
52      $defaults = array(             // <-- change this array
53        'pixture_width' => '85%',
54      );
55    
56      // check if it is liquid (%) or fixed width (px)
57      if(preg_match("/(\d+)\s*%/", $width, $match)) {
58        $liquid = 1;
59        $num = intval($match[0]);
60        if(50 <= $num && $num <= 100) {
61          return $num . "%";  // OK!
62        }
63      }
64      else if(preg_match("/(\d+)\s*px/", $width, $match)) {
65        $fixed = 1;
66        $num = intval($match[0]);
67        if(800 <= $num && $num < 1600) {
68          return $num . "px"; // OK
69        }
70      }
71    
72      // reset to default value
73      variable_set(
74        str_replace('/', '_', 'theme_'. $theme_key .'_settings'),
75        array_merge($defaults, theme_get_settings($theme_key))
76      );
77      // Force refresh of Drupal internals
78      theme_get_setting('', TRUE);
79    
80      return $defaults['pixture_width'];
81    }
82  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.2