/[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.2.1, Thu Apr 24 05:22:25 2008 UTC revision 1.1.2.2, Sun Apr 27 23:44:45 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'] = _validate_page_width($saved_width);    $saved_settings['pixture_width'] = pixture_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  }  }
   
 /*  
 * Check the page width theme settings and reset to default  
 * if the value is null, or invalid value is specified  
 */  
 function _validate_page_width($width)  
 {  
   global $theme_key;  
   
   /*  
   * The default values for the theme variables. Make sure $defaults exactly  
   * matches the $defaults in the theme-settings.php file.  
   */  
   $defaults = array(             // <-- change this array  
     'pixture_width' => '85%',  
   );  
   
   // check if it is liquid (%) or fixed width (px)  
   if(preg_match("/(\d+)\s*%/", $width, $match)) {  
     $liquid = 1;  
     $num = intval($match[0]);  
     if(50 <= $num && $num <= 100) {  
       return $num . "%";  // OK!  
     }  
   }  
   else if(preg_match("/(\d+)\s*px/", $width, $match)) {  
     $fixed = 1;  
     $num = intval($match[0]);  
     if(800 <= $num && $num < 1600) {  
       return $num . "px"; // OK  
     }  
   }  
   
   // reset to default value  
   variable_set(  
     str_replace('/', '_', 'theme_'. $theme_key .'_settings'),  
     array_merge($defaults, theme_get_settings($theme_key))  
   );  
   // Force refresh of Drupal internals  
   theme_get_setting('', TRUE);  
   
   return $defaults['pixture_width'];  
 }  
39  ?>  ?>

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

  ViewVC Help
Powered by ViewVC 1.1.2