You are here

function swftools_admin_boolean_settings in SWF Tools 6.3

Converts 1/0 to true/false, or vice versa.

The settings form stores 1/0 for checkboxes, but flash wants to use true/false in its configuration string. This function will convert the appropriate options in the settings between the two.

Parameters

array $settings: An array of embedding configuration configuration parameters.

int $mode: SWFTOOLS_ADMIN_STORE: convert 1/0 to true/false SWFTOOLS_ADMIN_RETRIEVE: convert true/false to 1/0

Return value

nothing The array is passed by reference.

2 calls to swftools_admin_boolean_settings()
swftools_admin_embed_form in includes/swftools.admin.inc
Form definition for embedding settings.
swftools_admin_embed_submit in includes/swftools.admin.inc
Custom form handler to encode checkboxes to true/false.

File

includes/swftools.admin.inc, line 706
Configuration settings for SWF Tools.

Code

function swftools_admin_boolean_settings(&$settings, $mode) {

  // Encode the following parameters to yes/no
  $encode = array(
    'play',
    'menu',
    'loop',
    'allowfullscreen',
    'swliveconnect',
  );

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

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