You are here

function swftools_wpaudio_admin_boolean_settings in SWF Tools 6.3

Convert 1/0 to yes/no, or vice versa.

The settings form stores 1/0 for checkboxes, but WordPress audio player uses yes/no in its configuration string. This function will convert the appropriate options in the settings between the two.

Parameters

array $settings: An array of WordPress audio player configuration parameters.

int $mode: Use one of the following constants:

Return value

nothing The array is passed by reference.

2 calls to swftools_wpaudio_admin_boolean_settings()
swftools_wpaudio_admin_form_submit in wpaudio/swftools_wpaudio.admin.inc
Custom form handler to encode checkboxes to yes/no responses and process color settings.
swftools_wpaudio_profile_form in wpaudio/swftools_wpaudio.admin.inc
Returns a form definition for use by the profile system.

File

wpaudio/swftools_wpaudio.admin.inc, line 53
Configuration settings for WordPress audio player.

Code

function swftools_wpaudio_admin_boolean_settings(&$settings, $mode) {

  // Encode the following parameters to yes/no
  $encode = array(
    'autostart',
    'loop',
    'animation',
    'remaining',
    'noinfo',
    'encode',
    'checkpolicy',
    'rtl',
    'transparentpagebg',
  );

  // Build the map to either encode or decode
  $map = array(
    SWFTOOLS_ADMIN_RETRIEVE => array(
      'yes' => 1,
      'no' => 0,
    ),
    SWFTOOLS_ADMIN_STORE => array(
      0 => 'no',
      1 => 'yes',
    ),
  );

  // Iterate over these settings encoding them, skipping settings that are not present
  foreach ($encode as $parameter) {
    if (isset($settings[$parameter])) {
      $settings[$parameter] = $map[$mode][$settings[$parameter]];
    }
  }
}