You are here

function mobile_codes_settings_form in Mobile Codes 6.2

Same name and namespace in other branches
  1. 5 mobile_codes.admin.inc \mobile_codes_settings_form()
  2. 6 mobile_codes.admin.inc \mobile_codes_settings_form()
  3. 7.2 mobile_codes.admin.inc \mobile_codes_settings_form()
1 string reference to 'mobile_codes_settings_form'
mobile_codes_mobile_codes_menu_alter in ./mobile_codes.module
Implements hook_mobile_codes_menu_alter().

File

includes/mobile_codes.admin.inc, line 9

Code

function mobile_codes_settings_form(&$form_state) {
  $form = array(
    '#tree' => TRUE,
  );
  $defaults = variable_get('mobile_codes_settings', array(
    'url' => array(
      'alias' => 'alias',
    ),
  ));
  $settings = array();
  drupal_alter('mobile_codes_settings', $settings);
  foreach ($settings as $type => $setting) {
    $form['settings'][$type] = array(
      '#type' => 'fieldset',
      '#title' => t('!type settings', array(
        '!type' => drupal_strtoupper($type),
      )),
    );
    $order = array();
    if (is_array($settings[$type]) && count($settings[$type]) > 0) {
      foreach ($settings[$type] as $setting => $values) {
        $weight = isset($values['weight']) ? $values['weight'] : 0;
        $order[$weight] = isset($order[$weight]) ? $order[$weight] : array();
        $order[$weight][] = $setting;
      }
      ksort($order);
      foreach ($order as $order_settings) {
        sort($order_settings);
        foreach ($order_settings as $setting) {
          $form['settings'][$type][$setting] = array(
            '#type' => 'checkbox',
            '#title' => $settings[$type][$setting]['label'],
            '#description' => $settings[$type][$setting]['description'],
            '#default_value' => isset($defaults[$type][$setting]) ? $defaults[$type][$setting] : FALSE,
          );
        }
      }
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save settings'),
  );
  return $form;
}