You are here

function demo_admin_settings in Demonstration site (Sandbox / Snapshot) 5

Same name and namespace in other branches
  1. 6 demo.admin.inc \demo_admin_settings()
  2. 7 demo.admin.inc \demo_admin_settings()
1 string reference to 'demo_admin_settings'
demo_menu in ./demo.module
Implementation of hook_menu().

File

./demo.admin.inc, line 13
Demonstration Site administrative pages

Code

function demo_admin_settings() {
  global $base_url;
  $form['status'] = array(
    '#type' => 'fieldset',
    '#title' => t('Status'),
    '#collapsible' => FALSE,
  );
  if (variable_get('demo_reset_last', 0)) {
    $reset_date = format_date(variable_get('demo_reset_last', 0));
  }
  else {
    $reset_date = t('Never');
  }
  $form['status'][] = array(
    '#value' => t('<p><strong>Last reset:</strong> !date</p>', array(
      '!date' => $reset_date,
    )),
  );
  $form['status'][] = array(
    '#value' => t('<p><strong>Default snapshot:</strong> !snapshot</p>', array(
      '!snapshot' => variable_get('demo_dump_cron', t('None')),
    )),
  );
  $fileconfig = demo_get_fileconfig();
  $form['dump'] = array(
    '#type' => 'fieldset',
    '#title' => t('Dump settings'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('demo_reset_interval', 0) ? FALSE : TRUE,
  );
  $period = drupal_map_assoc(array(
    0,
    1800,
    3600,
    7200,
    10800,
    14400,
    18000,
    21600,
    32400,
    43200,
    86400,
    172800,
    259200,
    604800,
    1209600,
    2419200,
    4838400,
    9676800,
  ), 'format_interval');
  $period[0] = t('disabled');
  $form['dump']['interval'] = array(
    '#type' => 'select',
    '#title' => t('Automatically reset site every'),
    '#default_value' => variable_get('demo_reset_interval', 0),
    '#options' => $period,
    '#description' => t('Select how often this demonstration site is automatically reset. Ensure that you have chosen a snapshot for cron runs in <a href="!manage">Manage snapshots</a> first. <strong>Note:</strong> This requires cron to run at least within this interval.', array(
      '!manage' => url('admin/build/demo/manage'),
    )),
  );
  $form['dump']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Dump path'),
    '#default_value' => $fileconfig['path'],
    '#size' => 30,
    '#description' => t('Enter a writable directory where dump files of this demonstration site are stored, f.e. %files. The name of this site (e.g. %confpath) is automatically appended to this directory.<br /><br /><strong>Note: For security reasons you should store site dumps outside of the document root of your webspace!</strong>', array(
      '%files' => file_directory_path() . '/demo',
      '%confpath' => $fileconfig['site'],
    )),
  );
  $form[] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
  );
  return $form;
}