You are here

function om_tools_admin_advanced in OM Tools 8.2

Same name and namespace in other branches
  1. 6.2 inc/om_tools.admin.inc \om_tools_admin_advanced()
  2. 7.2 inc/om_tools.admin.inc \om_tools_admin_advanced()

Admin Form - Advanced Editing OM Tools API 2.0

1 string reference to 'om_tools_admin_advanced'
om_tools_menu in ./om_tools.module
Implementation of hook_menu().

File

inc/om_tools.admin.inc, line 118
OM Tools Admin Configuration

Code

function om_tools_admin_advanced($form, &$form_state, $module = NULL, $title = NULL) {
  drupal_set_title(t('%title Advanced Editing', array(
    '%title' => $title,
  )), PASS_THROUGH);
  $current_values = variable_get($module, '');

  //dsm($current_values);

  // OM Tools backup container
  $backup_values = variable_get($module . '_backup', '');
  $display_values = '';
  om_tools_display_values_get($display_values, $current_values, $backup_values, $module);
  $form = array();
  $form['om_tools_admin_advanced'] = array(
    '#type' => 'fieldset',
    '#title' => t('%title variable content', array(
      '%title' => $title,
    )),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#tree' => TRUE,
    '#description' => 'Edit all settings without the hassle of collapsing forms. Use this only if you really know what you\'re doing. You can always Backup/Restore your settings.',
  );
  $form['om_tools_admin_advanced']['admin_advanced'] = array(
    '#type' => 'textarea',
    '#title' => t(''),
    '#rows' => 30,
    '#default_value' => $display_values,
  );
  $form['om_tools_admin_advanced']['admin_advanced_module'] = array(
    '#type' => 'hidden',
    '#default_value' => $module,
  );

  // button save will not show on empty values
  if (!empty($current_values)) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save'),
    );
  }

  // buton backup will only show if backup empty and current values in not empty
  if (empty($backup_values) && !empty($current_values)) {
    $form['backup'] = array(
      '#type' => 'submit',
      '#value' => t('Backup'),
    );
  }

  // button update backup will shown if both backup and current values are not empty
  if (!empty($backup_values) && !empty($current_values)) {
    $form['backup_update'] = array(
      '#type' => 'submit',
      '#value' => t('Update Backup'),
    );
  }

  // button restore will show if backup is not empty
  if (!empty($backup_values)) {
    $form['restore'] = array(
      '#type' => 'submit',
      '#value' => t('Restore'),
    );
  }

  // button delete will show if both backup and current values are not empty
  if (!empty($backup_values) && !empty($current_values)) {
    $form['delete'] = array(
      '#type' => 'submit',
      '#value' => t('Delete'),
    );
  }

  // current settings
  $om_settings_current = om_file_directory_path() . '/' . $module . '_current.gz';

  // backup settings
  $om_settings_backup = om_file_directory_path() . '/' . $module . '_backup.gz';
  if (!empty($current_values) && file_exists($om_settings_current) || !empty($backup_values) && file_exists($om_settings_backup)) {
    $om_downloads = '';

    // gs file - current settings
    if (!empty($current_values) && file_exists($om_settings_current)) {
      $om_downloads .= '<li>' . t(l('Download Current Settings', $om_settings_current)) . ' - modified: ' . date("F d Y H:i:s.", filemtime($om_settings_current)) . '</li>';
    }

    // gs file - backup settings
    if (!empty($backup_values) && file_exists($om_settings_backup)) {
      $om_downloads .= '<li>' . t(l('Download Backup Settings', $om_settings_backup)) . ' - modified: ' . date("F d Y H:i:s.", filemtime($om_settings_backup)) . '</li>';
    }
    $form['downloads'] = array(
      '#type' => 'markup',
      '#prefix' => '<div class="om-downloads"><ul>' . $om_downloads . '</ul></div>',
    );
  }
  return $form;
}