brilliant_gallery_config.inc in Brilliant Gallery 7.2
File
brilliant_gallery_config.inc
View source
<?php
function brilliant_gallery_admin($form, &$form_state) {
$form['brilliant_gallery_folder'] = array(
'#type' => 'textfield',
'#title' => t('Root gallery folder'),
'#default_value' => variable_get('brilliant_gallery_folder', ''),
'#size' => 77,
'#maxlength' => 333,
'#description' => t("Enter the name of the main folder in which you plan to store all your future gallery folders.\n This base folder must be located under your default file system folder (see your file system path in /admin/settings/file-system/settings).\n If this main folder does not exist under the file system folder, create it first. Do not use trailing slashes.\n Enter, for example, <i>albums</i>."),
);
return system_settings_form($form);
}
function brilliant_gallery_admin_validate($form, &$form_state) {
$brilliant_gallery_folder = $form_state['values']['brilliant_gallery_folder'];
$dir = 'public://' . $brilliant_gallery_folder;
if ($brilliant_gallery_folder == "") {
form_set_error('brilliant_gallery_folder', 'Please define a root album folder you (will) have in the files/ folder of this site.');
}
else {
if (substr($brilliant_gallery_folder, 0, 1) == "/" or substr($brilliant_gallery_folder, -1, 1) == "/" or substr($brilliant_gallery_folder, 0, 1) == " " or substr($brilliant_gallery_folder, -1, 1) == " ") {
form_set_error('brilliant_gallery_folder', 'The path should not start or end with spaces or slashes.');
}
else {
if (!file_exists($dir) or !is_dir($dir)) {
if (!mkdir($dir)) {
form_set_error('brilliant_gallery_folder', 'Directory ' . $brilliant_gallery_folder . ' does not exist in ' . 'public://' . ' and it was not possible to create it automatically.');
}
}
}
}
}