flickrgallery.admin.inc in FlickrGallery 7
Same filename and directory in other branches
Administration page callbacks
File
flickrgallery.admin.incView source
<?php
/**
* @file
* Administration page callbacks
*/
/**
* Administration settings form
*/
function flickrgallery_settings_form() {
$form = array();
drupal_set_title(t('Flickr Gallery Settings'));
$options = array(
's' => t('small square 75x75'),
't' => t('thumbnail, 100 on longest side'),
'm' => t('small, 240 on longest side'),
'z' => t('medium 640, 640 on longest side'),
'b' => t('large, 1024 on longest side'),
);
$sizes = array(
"square" => t('small square 75x75'),
"thumbnail" => t('thumbnail, 100 on longest side'),
"small" => t('small, 240 on longest side'),
"medium_640" => t('medium 640, 640 on longest side'),
"large" => t('large, 1024 on longest side'),
);
$form['flickrgallery_userID'] = array(
'#type' => 'textfield',
'#title' => t('User ID'),
'#description' => t('Fill in the user ID or e-mail of the Flickr account.') . ' ' . l(t('Find your User ID'), 'http://idgettr.com/'),
'#default_value' => variable_get('flickrgallery_userID', NULL),
);
$form['flickrgallery_privacy_filter'] = array(
'#type' => 'select',
'#title' => t('Privacy Filter'),
'#description' => t('Return photos only matching a certain privacy level. This only applies when making an authenticated call to view a photoset you own.'),
'#options' => array(
1 => t('public photos'),
2 => t('private photos visible to friends'),
3 => t('private photos visible to family'),
4 => t('private photos visible to friends & family'),
5 => t('completely private photos'),
),
'#default_value' => variable_get('flickrgallery_privacy_filter', 1),
);
$pager = array(
10 => 10,
25 => 25,
50 => 50,
75 => 75,
100 => 100,
);
$form['flickrgallery_title'] = array(
'#type' => 'textfield',
'#title' => t('Title sets page'),
'#description' => t('Provide a title for the sets page.'),
'#default_value' => variable_get('flickrgallery_title', NULL),
);
$form['flickrgallery_description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#description' => t('Provide a description for the sets page.'),
'#default_value' => variable_get('flickrgallery_description', NULL),
);
$form['flickrgallery_lightbox_type'] = array(
'#type' => 'textfield',
'#title' => t('Lightbox type'),
'#description' => t('Fill in what type of Lightbox you would like to use. Examples: lightbox, shadowbox, colorbox, ...<br />This field will be used as the link rel tag and class name. (You need to download these modules separately)'),
'#default_value' => variable_get('flickrgallery_lightbox_type', 'lightbox2'),
);
$form['flickrgallery_albums'] = array(
'#type' => 'select',
'#title' => t('Display sets images size.'),
'#description' => t('Select the size for the sets images'),
'#default_value' => variable_get('flickrgallery_albums', 's'),
'#options' => $options,
);
$form['flickrgallery_thumb'] = array(
'#type' => 'select',
'#title' => t('Display thumbnails on a set page'),
'#description' => t('Select the size for the thumbnails on a set page.'),
'#default_value' => variable_get('flickrgallery_thumb', 'square'),
'#options' => $sizes,
);
$form['flickrgallery_large'] = array(
'#type' => 'select',
'#title' => t('Display large images from a set'),
'#description' => t('Select the size for the larger images'),
'#default_value' => variable_get('flickrgallery_large', 'b'),
'#options' => $sizes,
);
$form['flickrgallery_path'] = array(
'#type' => 'textfield',
'#title' => t('Path for the Gallery'),
'#description' => t('You can set a custom path for your gallery, by default this is /flickr'),
'#default_value' => variable_get('flickrgallery_path', 'flickr'),
);
$form['flickrgallery_pager'] = array(
'#type' => 'fieldset',
'#title' => t('Pagers'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['flickrgallery_pager']['flickrgallery_sets_pager'] = array(
'#type' => 'checkbox',
'#title' => t('Use a pager for the sets page'),
'#description' => t('You can set a pager on the sets page if you have lot\'s of sets on your account'),
'#default_value' => variable_get('flickrgallery_sets_pager', NULL),
);
$form['flickrgallery_pager']['flickrgallery_pager_val'] = array(
'#type' => 'select',
'#title' => t('Number of sets'),
'#description' => t('Set the number of sets to display on a page'),
'#default_value' => variable_get('flickrgallery_pager_val', 50),
'#options' => $pager,
'#states' => array(
'invisible' => array(
'input[name="flickrgallery_sets_pager"]' => array(
'checked' => FALSE,
),
),
),
);
$form['flickrgallery_performance'] = array(
'#type' => 'fieldset',
'#title' => t('Extra options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['flickrgallery_performance']['flickrgallery_override'] = array(
'#type' => 'checkbox',
'#title' => t('Add more information to the images (You need to override the template files)'),
'#description' => t('Select this option is you want to override the template files and have more information about the images available. Not recommended because this will lead to slower performance.'),
'#default_value' => variable_get('flickrgallery_override', FALSE),
);
$form['flickrgallery_help'] = array(
'#markup' => '<div>' . t('When all settings are filled in correctly, you can visit your') . ' ' . l(t('Flickr Gallery'), 'flickr') . '</div>',
);
$form['#validate'][] = 'flickrgallery_settings_form_validate';
$form['#submit'][] = 'flickrgallery_settings_form_submit';
return system_settings_form($form);
}
/**
* Administration settings form validator
*/
function flickrgallery_settings_form_validate($form, &$form_state) {
module_load_include('module', 'flickrapi');
if ($nsid = flickrapi_get_user_nsid($form_state['values']['flickrgallery_userID'])) {
$form_state['values']['flickrgallery_userID'] = $nsid;
}
else {
form_set_error('flickrgallery_userID', t('Not a valid Flickr UserID.'));
}
}
/**
* Custom submit function for the settings form
*/
function flickrgallery_settings_form_submit($form, &$form_state) {
// Check if path is provided, if so rebuild the menu
if ($form_state['values']['flickrgallery_path'] != $form['flickrgallery_path']['#default_value']) {
variable_set('flickrgallery_path', $form_state['values']['flickrgallery_path']);
if (menu_rebuild()) {
drupal_set_message(t('Menu has been rebuild'));
}
}
}
Functions
Name![]() |
Description |
---|---|
flickrgallery_settings_form | Administration settings form |
flickrgallery_settings_form_submit | Custom submit function for the settings form |
flickrgallery_settings_form_validate | Administration settings form validator |