<?php
//    $Id$

/**
 *    @file    guidebook-admin.inc
 *    @desc    administrative functions for the guidebook module
 */

/**
 *    guidebook admin settings form
 */

function guidebook_admin()    {
    
$form['guidebook_gmaps_api'] = array(
        
'#type'                =>    'textfield',
        
'#title'            =>    t('Your google maps API key'),
        
'#default_value'    =>    variable_get('guidebook_gmaps_api'''),
        
'#description'        =>    t('Insert your google maps API key. Signup is available <a href="http://code.google.com/apis/maps/signup.html" target="_blank">here</a>.'),
    );
    
$form['guidebook_thumbnail_size']    =    array(
        
'#type'                =>    'textfield',
        
'#size'                =>    7,
        
'#title'            =>    t('Thumbnail size'),
        
'#default_value'    =>    variable_get('guidebook_thumbnail_size''200x200'),
        
'#description'        =>    t('Default size of thumbnails generated (width x height). Changing this value will not alter existing thumbnails.'),
    );
    return 
system_settings_form($form);
}

/**
 *    validation of admin settings
 */

function guidebook_admin_validate(&$form$form_state)    {
    
$key    =    $form_state['values']['guidebook_gmaps_api'];
    
$size    =    _get_image_size($form_state['values']['guidebook_thumbnail_size']);
    if (!
$key)    {
        
form_set_error('guidebook_gmaps_api't('Google maps will not work without an API key') );
    }
    if (
$size['width'] > 999 or $size['height'] > 999 or $size['width'] < 75 or $size['height'] < 75)    {
        
form_set_error('guidebook_thumbnail_size't('Your thumbnails must be in the form ###x### (width x height). The maximum size is 999, and the minimum is 75 (measured in pixels).'));
    }
}