| 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); |
| 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 |
?> |
?> |