You are here

function dynamic_background_build_settings_form in Dynamic Background 7.2

Menu callback, which builds the administration UI.

For a given extension based on the parameters passed to the function.

_state

Parameters

array $form:

string $module: The name of the module that the form should be build form.

boolean $upload: Add upload image options to the administration form.

Return value

array $form

1 string reference to 'dynamic_background_build_settings_form'
dynamic_background_menu in ./dynamic_background.module
Implements hook_menu().

File

./dynamic_background.module, line 118
This module enables administrators to upload images used as background on the site. The selected background image link is exposed as either $background in the page.tpl file or as /background.css.

Code

function dynamic_background_build_settings_form($form, $form_state, $module, $upload = TRUE) {
  $form = array(
    '#tree' => TRUE,
  );

  // Call the extension/modules that implements hook_settings_form(), which
  // gives the extension a possibility to change the form.
  // @todo: move to after the form.
  $function = $module . '_settings_form';
  if (function_exists($function)) {
    $form += $function();
  }

  // Build upload options form.
  if ($upload) {

    // Load the defaults.
    $defaults = variable_get($module, array());
    $form[$module]['upload'] = array(
      '#type' => 'fieldset',
      '#title' => t('User supplied images'),
      '#description' => t('You can allow users to upload their own images. To enable this go to <a href="@link">permissions page</a>.', array(
        '@link' => '/admin/people/permissions',
      )),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
    );
    $form[$module]['upload']['no_of_images'] = array(
      '#type' => 'select',
      '#title' => t('Number of images'),
      '#description' => t('The number of images each user should be allowed to upload, setting it to "0" will disable it.'),
      '#options' => range(0, 20),
      '#default_value' => isset($defaults['upload']['no_of_images']) ? intval($defaults['upload']['no_of_images']) : '1',
    );
  }

  // Builds the CSS behaviour part of the settings form.
  $form_key = $module . '_css';
  $defaults = variable_get($form_key, array());
  $form[$form_key] = array(
    '#type' => 'fieldset',
    '#title' => t('CSS behaviour'),
    '#collapsed' => FALSE,
    '#collapsible' => TRUE,
    '#tree' => TRUE,
  );
  $form[$form_key]['selector'] = array(
    '#type' => 'textfield',
    '#title' => t('CSS selector'),
    '#description' => t('The CSS selector string to target with the background image e.g. body #container.'),
    '#required' => TRUE,
    '#default_value' => isset($defaults['selector']) ? $defaults['selector'] : '',
  );
  $form[$form_key]['css'] = array(
    '#type' => 'textarea',
    '#title' => t('CSS'),
    '#description' => t('The CSS to insert with the background image e.g background-size: cover;.'),
    '#default_value' => isset($defaults['css']) ? $defaults['css'] : '',
  );
  return system_settings_form($form);
}