You are here

brilliant_gallery_config.inc in Brilliant Gallery 7.2

File

brilliant_gallery_config.inc
View source
<?php

/**
 * @todo Please document this function.
 */
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>."),
  );

  /*
  $form['brilliant_gallery_cache_duration'] = array(
    '#type' => 'textfield',
    '#title' => t('Time to cache file information in database'),
    '#default_value' => variable_get('brilliant_gallery_cache_duration', '86400'),
    '#size' => 5,
    '#maxlength' => 5,
    '#description' => t("Information about physical files is kept in database to speed up execution. Here you can set how long time they should be cached, in seconds - e.g. 3600, 86400, etc."),
  );
  */
  return system_settings_form($form);
}

/**
 * Validating some configuration options.
 */
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 the dir does not exist, attempt to create it or throw an error.
        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.');
        }
      }
    }
  }
}

Functions

Namesort descending Description
brilliant_gallery_admin @todo Please document this function.
brilliant_gallery_admin_validate Validating some configuration options.