You are here

function filebrowser_admin_settings in Filebrowser 6

Same name and namespace in other branches
  1. 5 filebrowser.module \filebrowser_admin_settings()
  2. 6.2 filebrowser.admin.inc \filebrowser_admin_settings()
1 string reference to 'filebrowser_admin_settings'
filebrowser_menu in ./filebrowser.module

File

./filebrowser.module, line 117

Code

function filebrowser_admin_settings() {
  $form = array();
  $form['listings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Directory listings'),
  );

  // Insert listings table markup
  $qry = db_query('SELECT path, location, can_explore FROM {filebrowser}');
  $paths = array();
  while ($o = db_fetch_object($qry)) {
    $form['paths'][$o->path] = array(
      '#type' => 'value',
      '#value' => $o->path,
    );
    $form['locations'][$o->path] = array(
      '#type' => 'value',
      '#value' => $o->location,
    );
    $form['can_explore'][$o->path] = array(
      '#type' => 'value',
      '#value' => (bool) (int) $o->can_explore,
    );
    $paths[$o->path] = '';
  }

  // Only display existing listing information if we have some
  if (!empty($paths)) {
    $form['listing_checks'] = array(
      '#type' => 'checkboxes',
      '#options' => $paths,
    );
    $form['listings']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Update directory listings'),
      '#weight' => 10,
      '#submit' => array(
        'filebrowser_admin_settings_submit_update',
      ),
    );
  }
  else {
    $form['listings']['listing_status'] = array(
      '#type' => 'markup',
      '#value' => '<p>' . t('No listings exist.') . '</p>',
    );
  }
  $form['new_listing'] = array(
    '#type' => 'fieldset',
    '#title' => t('Add listing'),
  );

  // Insert options to enter a new listing
  $form['new_listing']['path'] = array(
    '#type' => 'textfield',
    '#title' => t('Drupal path'),
    '#description' => t('Path that users can view this directory listing at.'),
    '#required' => true,
  );
  $form['new_listing']['location'] = array(
    '#type' => 'textfield',
    '#title' => t('File system directory'),
    '#description' => t('File system path to a directory.'),
    '#required' => true,
  );
  $form['new_listing']['can_explore'] = array(
    '#type' => 'checkbox',
    '#title' => t('Do you want to allow exploring subdirectories?'),
  );
  $form['new_listing']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add listing'),
    '#validate' => array(
      'filebrowser_admin_settings_validate_add',
    ),
    '#submit' => array(
      'filebrowser_admin_settings_submit_add',
    ),
  );
  $form['#after_build'] = array(
    'filebrowser_strip_requirements',
  );
  return $form;
}