You are here

function mobile_tools_themes_configuration_form in Mobile Tools 7.2

Same name and namespace in other branches
  1. 5 mobile_tools.module \mobile_tools_themes_configuration_form()
  2. 6.3 mobile_tools.admin.inc \mobile_tools_themes_configuration_form()
  3. 6 mobile_tools.admin.inc \mobile_tools_themes_configuration_form()
  4. 6.2 mobile_tools.admin.inc \mobile_tools_themes_configuration_form()

Configuration form for configuring the mobile context in the theming system

1 string reference to 'mobile_tools_themes_configuration_form'
mobile_tools_menu in ./mobile_tools.module
Implements hook_menu().

File

./mobile_tools.admin.inc, line 173
Adminstrative pages for Mobile Tools

Code

function mobile_tools_themes_configuration_form() {
  $themes = mobile_tools_list_theme_names();
  $prefix = '';
  $warning = '';
  if (count($themes) == 0) {
    $warning = '<div class="message error">You must enable themes in order to use theme switching</div>';
  }
  $form['mobile_tools_theme_configuration'] = array(
    '#type' => 'fieldset',
    '#title' => 'Theming configuration',
    '#collapsible' => TRUE,
    '#description' => t('You can assign a variation of your current theme to all mobile users . this allows you to configure your theme
    specific for mobile users. See !url for more information on this configuration. In order to use this functionality
    you will have to manually create a second *.info file in your theme directory.', array(
      '!url' => l('help', 'help'),
    )),
    '#suffix' => t('If enabled, !configure the settings of your mobile theme and manage the !blocks layout', array(
      '!configure' => l('configure', 'admin/appearance/list'),
      '!blocks' => l('blocks', 'admin/structure/block'),
    )) . '<br>',
    '#prefix' => $warning,
  );
  $form['mobile_tools_theme_configuration']['mobile_tools_theme_switch'] = array(
    '#type' => 'radios',
    '#title' => t('When do you want to switch themes'),
    '#default_value' => variable_get('mobile_tools_theme_switch', 'mobile-tools-no-switch'),
    '#options' => array(
      'mobile-tools-no-switch' => 'No theme switch',
      'mobile-tools-mobile-url' => 'Switch theme based on the URL',
    ),
    '#description' => 'Choose one of these methods. To change theme based on device, ensure device redirection is enabled. *Note these settings will be replaced by the new device groups options.',
  );
  if (count($themes) > 0) {
    $form['mobile_tools_theme_configuration']['mobile_tools_theme_name'] = array(
      '#type' => 'select',
      '#title' => 'Mobile theme',
      '#default_value' => variable_get("mobile_tools_theme_name", FALSE),
      '#options' => $themes,
      '#description' => t('Select your default mobile theme. You can specify a different theme for different devices.'),
    );
    $form['mobile_tools_theme_configuration']['mobile_tools_additional_config'] = array(
      '#type' => 'fieldset',
      '#title' => t('Additional mobile specific theming configuration'),
    );
    $form['mobile_tools_theme_configuration']['mobile_tools_additional_config']['mobile_tools_hide_address_bar'] = array(
      '#type' => 'checkbox',
      '#title' => t('Automatically hide address bar in mobile theme (uses javascript and only work on javascript enabled devices)'),
      '#default_value' => variable_get('mobile_tools_hide_address_bar', 1),
      '#description' => t('Enabling this injects some line of javascript to hide the address bar when the page is loaded'),
    );
    $form['mobile_tools_theme_configuration']['mobile_tools_additional_config']['mobile_tools_add_header'] = array(
      '#type' => 'checkbox',
      '#title' => t('Add Mobile Tools header'),
      '#default_value' => variable_get('mobile_tools_add_header', 1),
      '#description' => t('Add mobile specific headers into the header tag. This includes viewport, HandheldFriendly, ... See theme/mobile-tools-header.tpl.php'),
    );

    // for each group, checkbox and dropdown
    // Mobile
    $mobile_groups = module_invoke(variable_get('mobile_tools_device_detection', 'mobile_tools'), 'device_groups');
    $mobile_detection_module = variable_get('mobile_tools_device_detection', 'mobile_tools');
    foreach ($mobile_groups as $group => $group_title) {
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group] = array(
        '#type' => 'fieldset',
        '#title' => $group_title,
        '#collapsible' => TRUE,
      );
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group][$mobile_detection_module . '_' . $group . '_enable'] = array(
        '#type' => 'checkbox',
        '#title' => t('Enable filter for this device group'),
        '#default_value' => variable_get($mobile_detection_module . '_' . $group . '_enable', ''),
        '#description' => t('Choose a theme for this device group'),
      );
      $form['mobile_tools_theme_configuration'][$mobile_detection_module . '_' . $group][$mobile_detection_module . '_' . $group . '_theme'] = array(
        '#type' => 'select',
        '#title' => 'Mobile theme',
        '#default_value' => variable_get($mobile_detection_module . '_' . $group . '_theme', FALSE),
        '#options' => $themes,
        '#description' => t('Select your mobile theme. See <a href="">help</a> for information on the name'),
      );
    }
  }
  return system_settings_form($form);
}