You are here

function _amazons3_explode_list in AmazonS3 7.2

Explode newlines in our admin form into arrays to save.

Parameters

array $form: The form being displayed.

array &$form_state: The current state of the form.

1 string reference to '_amazons3_explode_list'
amazons3_admin in ./amazons3.admin.inc
Form API callback for the configuration form.

File

./amazons3.admin.inc, line 180

Code

function _amazons3_explode_list($form, &$form_state) {
  $keys = array(
    'amazons3_presigned_urls',
    'amazons3_rrs',
    'amazons3_saveas',
    'amazons3_torrents',
  );
  $values =& $form_state['values'];
  foreach ($keys as $form_key) {
    $values[$form_key] = explode("\n", $values[$form_key]);
    $values[$form_key] = array_map('trim', $values[$form_key]);
    $values[$form_key] = array_filter($values[$form_key], 'strlen');
  }

  // Presigned URLs are special in that they are pipe-separated lines.
  $presigned_config = array();
  foreach ($values['amazons3_presigned_urls'] as $presigned_line) {
    list($timeout, $pattern) = explode("|", $presigned_line);
    $presigned_config[] = array(
      'timeout' => $timeout,
      'pattern' => $pattern,
    );
  }
  $values['amazons3_presigned_urls'] = $presigned_config;
}