You are here

function mmenu_convert_settings in Mobile sliding menu 7.3

Same name and namespace in other branches
  1. 7 mmenu.module \mmenu_convert_settings()
  2. 7.2 mmenu.module \mmenu_convert_settings()

Converts value from PHP to JSON format.

Parameters

string $type: The type of the settings such as options or configurations.

array $values: An associative array that contains the mmenu settings.

Return value

array A converted mmenu settings array.

1 call to mmenu_convert_settings()
mmenu_admin_settings_form_submit in ./mmenu.admin.inc
Form submission handler for mmenu_admin_settings_form().

File

./mmenu.module, line 1377
Primarily Drupal hooks and global API functions to manipulate mmenus.

Code

function mmenu_convert_settings($type = 'options', array $values = array()) {
  foreach ($values as $k => $value) {
    switch ($k) {
      case 'offCanvas':
        if ($type == 'options' && isset($value['enabled']) && $value['enabled'] == 'false') {
          $value = 'false';
        }
        break;
      default:
        break;
    }
    if (is_array($value)) {
      $values[$k] = mmenu_convert_settings($type, $value);
    }
    if ($value == 'true') {
      $values[$k] = TRUE;
    }
    elseif ($value == 'false') {
      $values[$k] = FALSE;
    }
    elseif (is_numeric($value)) {
      $values[$k] = (double) $value;
    }
  }
  return $values;
}